


import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionImageVariationPipeline
from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device


__UpperCamelCase				:  Optional[int]      					=							False





class  lowerCAmelCase__(    unittest.TestCase						):






    '''simple docstring'''





    pass





@slow
@require_torch_gpu
class  lowerCAmelCase__(    unittest.TestCase						):






    '''simple docstring'''





    def 					_lowerCamelCase (	self				:   Tuple	):





       '''simple docstring'''
       UpperCAmelCase_							:      List[str]						=   VersatileDiffusionImageVariationPipeline.from_pretrained('''shi-labs/versatile-diffusion'''	)
       pipe.to(__snake_case	)
       pipe.set_progress_bar_config(disable=__snake_case	)

       UpperCAmelCase_							:      Optional[Any]						=   load_image(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/versatile_diffusion/benz.jpg'''	)
       UpperCAmelCase_							:      Dict						=   torch.manual_seed(0	)
       UpperCAmelCase_							:      Dict						=   pipe(
           image=__snake_case       ,   generator=__snake_case       ,   guidance_scale=7.5       ,   num_inference_steps=50       ,   output_type='''numpy'''       ,   ).images

       UpperCAmelCase_							:      List[str]						=   image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       UpperCAmelCase_							:      int						=   np.array([0.0_441, 0.0_469, 0.0_507, 0.0_575, 0.0_632, 0.0_650, 0.0_865, 0.0_909, 0.0_945]	)

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



from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments
def      snake_case_						( ):
   UpperCAmelCase_							:      str						=   HfArgumentParser(__lowercase       )
   UpperCAmelCase_							:      Optional[Any]						=   parser.parse_args_into_dataclasses()[0]
   UpperCAmelCase_							:      Optional[int]						=   TensorFlowBenchmark(args=__lowercase       )
   try:
      UpperCAmelCase_							:      List[Any]						=   parser.parse_args_into_dataclasses()[0]
   except ValueError as e:
      UpperCAmelCase_							:      List[Any]						=   '''Arg --no_{0} is no longer used, please use --no-{0} instead.'''
      UpperCAmelCase_							:      List[str]						=   ''' '''.join(str(__lowercase       ).split(''' '''       )[:-1]       )
      UpperCAmelCase_							:      Optional[int]						=   ''''''
      UpperCAmelCase_							:      Dict						=   eval(str(__lowercase       ).split(''' '''       )[-1]       )
      UpperCAmelCase_							:      int						=   []
      for arg in depreciated_args:
         # arg[2:] removes '--'
         if arg[2:] in TensorFlowBenchmark.deprecated_args:
            # arg[5:] removes '--no_'
            full_error_msg += arg_error_msg.format(arg[5:]       )
         else:
            wrong_args.append(__lowercase       )
      if len(__lowercase       ) > 0:
         UpperCAmelCase_							:      Tuple						=   full_error_msg + begin_error_msg + str(__lowercase       )
      raise ValueError(__lowercase       )
   benchmark.run()


if __name__ == "__main__":
       main()