
'''simple docstring'''






import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionTextToImagePipeline
from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device


UpperCAmelCase_       :   int   =       False

class  UpperCAmelCase__						(       unittest.TestCase ):
    pass


@nightly
@require_torch_gpu
class  UpperCAmelCase__						(       unittest.TestCase ):



    def   lowerCamelCase_  (	self      :       Tuple     ):
          # clean up the VRAM after each test
          super().tearDown()
          gc.collect()
          torch.cuda.empty_cache()



    def   lowerCamelCase_  (	self      :       List[Any]     ):
          _lowerCamelCase				:   str								=   VersatileDiffusionTextToImagePipeline.from_pretrained("shi-labs/versatile-diffusion"     )
          # remove text_unet
          pipe.remove_unused_weights()
          pipe.to(_lowerCamelCase     )
          pipe.set_progress_bar_config(disable=_lowerCamelCase     )

          _lowerCamelCase				:   int								=   "A painting of a squirrel eating a burger "
          _lowerCamelCase				:   Any								=   torch.manual_seed(0     )
          _lowerCamelCase				:   Dict								=   pipe(
              prompt=_lowerCamelCase,generator=_lowerCamelCase,guidance_scale=7.5,num_inference_steps=2,output_type="numpy"     ).images

          with tempfile.TemporaryDirectory() as tmpdirname:
                pipe.save_pretrained(_lowerCamelCase     )
                _lowerCamelCase				:   int								=   VersatileDiffusionTextToImagePipeline.from_pretrained(_lowerCamelCase     )
          pipe.to(_lowerCamelCase     )
          pipe.set_progress_bar_config(disable=_lowerCamelCase     )

          _lowerCamelCase				:   Optional[Any]								=   generator.manual_seed(0     )
          _lowerCamelCase				:   List[str]								=   pipe(
              prompt=_lowerCamelCase,generator=_lowerCamelCase,guidance_scale=7.5,num_inference_steps=2,output_type="numpy"     ).images

          assert np.abs(image - new_image     ).sum() < 1e-5, "Models don't have the same forward pass"



    def   lowerCamelCase_  (	self      :       str     ):
          _lowerCamelCase				:   Any								=   VersatileDiffusionTextToImagePipeline.from_pretrained(
              "shi-labs/versatile-diffusion",torch_dtype=torch.floataa     )
          pipe.to(_lowerCamelCase     )
          pipe.set_progress_bar_config(disable=_lowerCamelCase     )

          _lowerCamelCase				:   Optional[Any]								=   "A painting of a squirrel eating a burger "
          _lowerCamelCase				:   Tuple								=   torch.manual_seed(0     )
          _lowerCamelCase				:   str								=   pipe(
              prompt=_lowerCamelCase,generator=_lowerCamelCase,guidance_scale=7.5,num_inference_steps=5_0,output_type="numpy"     ).images

          _lowerCamelCase				:   List[str]								=   image[0, 2_5_3:2_5_6, 2_5_3:2_5_6, -1]

          assert image.shape == (1, 5_1_2, 5_1_2, 3)
          _lowerCamelCase				:   Dict								=   np.array([0.3367, 0.3169, 0.2656, 0.3870, 0.4790, 0.3796, 0.4009, 0.4878, 0.4778]     )

          assert np.abs(image_slice.flatten() - expected_slice     ).max() < 1e-2

'''simple docstring'''






from math import sqrt







def 		A_       (	_lowerCAmelCase   :    int = 1000000							):



      """simple docstring"""




      _lowerCamelCase				:   int								=   0
      _lowerCamelCase				:   int								=   0
      _lowerCamelCase				:   int

      while num_cuboids <= limit:
            max_cuboid_size += 1
            for sum_shortest_sides in range(2				,	2 * max_cuboid_size + 1							):
                  if sqrt(sum_shortest_sides**2 + max_cuboid_size**2							).is_integer():
                        num_cuboids += (
                            min(_lowerCAmelCase				,	sum_shortest_sides // 2							)
                            - max(1				,	sum_shortest_sides - max_cuboid_size							)
                            + 1
                        )

      return max_cuboid_size


if __name__ == "__main__":
 print(f'''{solution() = }''')