



import inspect
import unittest

from transformers import MobileNetVaConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import MobileNetVaForImageClassification, MobileNetVaForSemanticSegmentation, MobileNetVaModel
    from transformers.models.mobilenet_va.modeling_mobilenet_va import MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
    from PIL import Image

    from transformers import MobileNetVaImageProcessor



class     lowerCAmelCase_		(  a__							):
       def  snake_case_	(      self	)					->		List[str]:
          UpperCamelCase   :  List[Any]						     =     self.config_class(**self.inputs_dict	)
          self.parent.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,      'tf_padding'	)	)
          self.parent.assertTrue(hasattr(SCREAMING_SNAKE_CASE_,      'depth_multiplier'	)	)






class     lowerCAmelCase_		:
       def __init__(      self,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_=13,      SCREAMING_SNAKE_CASE_=3,      SCREAMING_SNAKE_CASE_=32,      SCREAMING_SNAKE_CASE_=0.25,      SCREAMING_SNAKE_CASE_=8,      SCREAMING_SNAKE_CASE_=8,      SCREAMING_SNAKE_CASE_=6,      SCREAMING_SNAKE_CASE_=32,      SCREAMING_SNAKE_CASE_=True,      SCREAMING_SNAKE_CASE_=True,      SCREAMING_SNAKE_CASE_=True,      SCREAMING_SNAKE_CASE_="relu6",      SCREAMING_SNAKE_CASE_=1280,      SCREAMING_SNAKE_CASE_=0.1,      SCREAMING_SNAKE_CASE_=0.02,      SCREAMING_SNAKE_CASE_=True,      SCREAMING_SNAKE_CASE_=True,      SCREAMING_SNAKE_CASE_=10,      SCREAMING_SNAKE_CASE_=None,      )					->		List[Any]:
          UpperCamelCase   :  str						     =     parent
          UpperCamelCase   :  str						     =     batch_size
          UpperCamelCase   :  List[str]						     =     num_channels
          UpperCamelCase   :  Any						     =     image_size
          UpperCamelCase   :  Union[str, Any]						     =     depth_multiplier
          UpperCamelCase   :  Optional[int]						     =     depth_divisible_by
          UpperCamelCase   :  Dict						     =     min_depth
          UpperCamelCase   :  Dict						     =     expand_ratio
          UpperCamelCase   :  Optional[Any]						     =     tf_padding
          UpperCamelCase   :  str						     =     output_stride
          UpperCamelCase   :  Union[str, Any]						     =     first_layer_is_expansion
          UpperCamelCase   :  Optional[Any]						     =     finegrained_output
          UpperCamelCase   :  Optional[int]						     =     hidden_act
          UpperCamelCase   :  Tuple						     =     last_hidden_size if finegrained_output else int(last_hidden_size * depth_multiplier	)
          UpperCamelCase   :  Dict						     =     classifier_dropout_prob
          UpperCamelCase   :  Tuple						     =     use_labels
          UpperCamelCase   :  Optional[int]						     =     is_training
          UpperCamelCase   :  List[Any]						     =     num_labels
          UpperCamelCase   :  Union[str, Any]						     =     initializer_range
          UpperCamelCase   :  int						     =     scope
       def  snake_case_	(      self	)					->		Any:
          UpperCamelCase   :  Any						     =     floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]	)

          UpperCamelCase   :  Optional[int]						     =     None
          UpperCamelCase   :  List[Any]						     =     None
          if self.use_labels:
             UpperCamelCase   :  Dict						     =     ids_tensor([self.batch_size],      self.num_labels	)
             UpperCamelCase   :  List[str]						     =     ids_tensor([self.batch_size, self.image_size, self.image_size],      self.num_labels	)

          UpperCamelCase   :  str						     =     self.get_config()

          return config, pixel_values, labels, pixel_labels
       def  snake_case_	(      self	)					->		List[str]:
          return MobileNetVaConfig(
              num_channels=self.num_channels,      image_size=self.image_size,      depth_multiplier=self.depth_multiplier,      depth_divisible_by=self.depth_divisible_by,      min_depth=self.min_depth,      expand_ratio=self.expand_ratio,      output_stride=self.output_stride,      first_layer_is_expansion=self.first_layer_is_expansion,      finegrained_output=self.finegrained_output,      hidden_act=self.hidden_act,      tf_padding=self.tf_padding,      classifier_dropout_prob=self.classifier_dropout_prob,      initializer_range=self.initializer_range,      )
       def  snake_case_	(      self,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_	)					->		Optional[int]:
          UpperCamelCase   :  Tuple						     =     MobileNetVaModel(config=SCREAMING_SNAKE_CASE_	)
          model.to(SCREAMING_SNAKE_CASE_	)
          model.eval()
          UpperCamelCase   :  Optional[int]						     =     model(SCREAMING_SNAKE_CASE_	)
          self.parent.assertEqual(
              result.last_hidden_state.shape,      (
                  self.batch_size,
                  self.last_hidden_size,
                  self.image_size // self.output_stride,
                  self.image_size // self.output_stride,
              ),      )
          self.parent.assertEqual(
              result.pooler_output.shape,      (self.batch_size, self.last_hidden_size),      )
       def  snake_case_	(      self,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_	)					->		List[Any]:
          UpperCamelCase   :  List[Any]						     =     self.num_labels
          UpperCamelCase   :  Any						     =     MobileNetVaForImageClassification(SCREAMING_SNAKE_CASE_	)
          model.to(SCREAMING_SNAKE_CASE_	)
          model.eval()
          UpperCamelCase   :  List[Any]						     =     model(SCREAMING_SNAKE_CASE_,      labels=SCREAMING_SNAKE_CASE_	)
          self.parent.assertEqual(result.logits.shape,      (self.batch_size, self.num_labels)	)
       def  snake_case_	(      self,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_	)					->		Dict:
          UpperCamelCase   :  Optional[Any]						     =     self.num_labels
          UpperCamelCase   :  Optional[int]						     =     MobileNetVaForSemanticSegmentation(SCREAMING_SNAKE_CASE_	)
          model.to(SCREAMING_SNAKE_CASE_	)
          model.eval()
          UpperCamelCase   :  Union[str, Any]						     =     model(SCREAMING_SNAKE_CASE_	)
          self.parent.assertEqual(
              result.logits.shape,      (
                  self.batch_size,
                  self.num_labels,
                  self.image_size // self.output_stride,
                  self.image_size // self.output_stride,
              ),      )
          UpperCamelCase   :  List[Any]						     =     model(SCREAMING_SNAKE_CASE_,      labels=SCREAMING_SNAKE_CASE_	)
          self.parent.assertEqual(
              result.logits.shape,      (
                  self.batch_size,
                  self.num_labels,
                  self.image_size // self.output_stride,
                  self.image_size // self.output_stride,
              ),      )






       def  snake_case_	(      self	)					->		Optional[Any]:
          UpperCamelCase   :  Optional[Any]						     =     self.prepare_config_and_inputs()
          UpperCamelCase     ,					UpperCamelCase     ,					UpperCamelCase     ,					UpperCamelCase   :  str						     =     config_and_inputs
          UpperCamelCase   :  Tuple						     =     {'pixel_values': pixel_values}
          return config, inputs_dict






@require_torch
class     lowerCAmelCase_		(  a__	,   a__	,   unittest.TestCase							):
       UpperCAmelCase__    : Dict       					=  (
           (MobileNetVaModel, MobileNetVaForImageClassification, MobileNetVaForSemanticSegmentation)
           if is_torch_available()
           else ()
       )
       UpperCAmelCase__    : int       					=  (
           {
               "feature-extraction": MobileNetVaModel,
               "image-classification": MobileNetVaForImageClassification,
               "image-segmentation": MobileNetVaForSemanticSegmentation,
           }
           if is_torch_available()
           else {}
       )

       UpperCAmelCase__    : Dict       					=  False
       UpperCAmelCase__    : Union[str, Any]       					=  False
       UpperCAmelCase__    : Union[str, Any]       					=  False
       UpperCAmelCase__    : Dict       					=  False
       def  snake_case_	(      self	)					->		Optional[int]:
          UpperCamelCase   :  List[Any]						     =     MobileNetVaModelTester(self	)
          UpperCamelCase   :  str						     =     MobileNetVaConfigTester(self,      config_class=SCREAMING_SNAKE_CASE_,      has_text_modality=SCREAMING_SNAKE_CASE_	)
       def  snake_case_	(      self	)					->		List[Any]:
          self.config_tester.run_common_tests()
       @unittest.skip(reason='MobileNetV2 does not use inputs_embeds'	)
       def  snake_case_	(      self	)					->		Tuple:
          pass
       @unittest.skip(reason='MobileNetV2 does not support input and output embeddings'	)
       def  snake_case_	(      self	)					->		List[Any]:
          pass
       @unittest.skip(reason='MobileNetV2 does not output attentions'	)
       def  snake_case_	(      self	)					->		List[Any]:
          pass
       def  snake_case_	(      self	)					->		int:
          UpperCamelCase     ,					UpperCamelCase   :  Tuple						     =     self.model_tester.prepare_config_and_inputs_for_common()

          for model_class in self.all_model_classes:
             UpperCamelCase   :  Union[str, Any]						     =     model_class(SCREAMING_SNAKE_CASE_	)
             UpperCamelCase   :  Union[str, Any]						     =     inspect.signature(model.forward	)
             # signature.parameters is an OrderedDict => so arg_names order is deterministic
             UpperCamelCase   :  Any						     =     [*signature.parameters.keys()]

             UpperCamelCase   :  Union[str, Any]						     =     ['pixel_values']
             self.assertListEqual(arg_names[:1],      SCREAMING_SNAKE_CASE_	)
       def  snake_case_	(      self	)					->		Union[str, Any]:
          UpperCamelCase   :  Union[str, Any]						     =     self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE_	)
       def  snake_case_	(      self	)					->		Union[str, Any]:
          def check_hidden_states_output(SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_	):
             UpperCamelCase   :  int						     =     model_class(SCREAMING_SNAKE_CASE_	)
             model.to(SCREAMING_SNAKE_CASE_	)
             model.eval()

             with torch.no_grad():
                UpperCamelCase   :  Optional[int]						     =     model(**self._prepare_for_class(SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_	)	)

             UpperCamelCase   :  List[Any]						     =     outputs.hidden_states

             UpperCamelCase   :  List[str]						     =     16
             self.assertEqual(len(SCREAMING_SNAKE_CASE_	),      SCREAMING_SNAKE_CASE_	)

          UpperCamelCase     ,					UpperCamelCase   :  Tuple						     =     self.model_tester.prepare_config_and_inputs_for_common()

          for model_class in self.all_model_classes:
             UpperCamelCase   :  List[str]						     =     True
             check_hidden_states_output(SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_	)

             # check that output_hidden_states also work using config
             del inputs_dict["output_hidden_states"]
             UpperCamelCase   :  List[str]						     =     True

             check_hidden_states_output(SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_	)
       def  snake_case_	(      self	)					->		Optional[int]:
          UpperCamelCase   :  List[Any]						     =     self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_image_classification(*SCREAMING_SNAKE_CASE_	)
       def  snake_case_	(      self	)					->		int:
          UpperCamelCase   :  Any						     =     self.model_tester.prepare_config_and_inputs()
          self.model_tester.create_and_check_for_semantic_segmentation(*SCREAMING_SNAKE_CASE_	)






       @slow
       def  snake_case_	(      self	)					->		List[str]:
          for model_name in MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             UpperCamelCase   :  Optional[Any]						     =     MobileNetVaModel.from_pretrained(SCREAMING_SNAKE_CASE_	)
             self.assertIsNotNone(SCREAMING_SNAKE_CASE_	)






def 		UpperCamelCase     (       )     ->					Dict:
   UpperCamelCase   :  str						     =     Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'     )
   return image



@require_torch
@require_vision
class     lowerCAmelCase_		(  unittest.TestCase							):
       @cached_property
       def  snake_case_	(      self	)					->		int:
          return (
              MobileNetVaImageProcessor.from_pretrained('google/mobilenet_v2_1.0_224'	) if is_vision_available() else None
          )
       @slow
       def  snake_case_	(      self	)					->		List[Any]:
          UpperCamelCase   :  Any						     =     MobileNetVaForImageClassification.from_pretrained('google/mobilenet_v2_1.0_224'	).to(SCREAMING_SNAKE_CASE_	)

          UpperCamelCase   :  Any						     =     self.default_image_processor
          UpperCamelCase   :  Optional[int]						     =     prepare_img()
          UpperCamelCase   :  Union[str, Any]						     =     image_processor(images=SCREAMING_SNAKE_CASE_,      return_tensors='pt'	).to(SCREAMING_SNAKE_CASE_	)

          # forward pass
          with torch.no_grad():
             UpperCamelCase   :  Dict						     =     model(**SCREAMING_SNAKE_CASE_	)

          # verify the logits
          UpperCamelCase   :  List[Any]						     =     torch.Size((1, 1001)	)
          self.assertEqual(outputs.logits.shape,      SCREAMING_SNAKE_CASE_	)

          UpperCamelCase   :  Optional[Any]						     =     torch.tensor([0.24_45, -1.19_93, 0.19_05]	).to(SCREAMING_SNAKE_CASE_	)

          self.assertTrue(torch.allclose(outputs.logits[0, :3],      SCREAMING_SNAKE_CASE_,      atol=1e-4	)	)






       @slow
       def  snake_case_	(      self	)					->		Union[str, Any]:
          UpperCamelCase   :  Tuple						     =     MobileNetVaForSemanticSegmentation.from_pretrained('google/deeplabv3_mobilenet_v2_1.0_513'	)
          UpperCamelCase   :  Tuple						     =     model.to(SCREAMING_SNAKE_CASE_	)

          UpperCamelCase   :  Union[str, Any]						     =     MobileNetVaImageProcessor.from_pretrained('google/deeplabv3_mobilenet_v2_1.0_513'	)

          UpperCamelCase   :  Dict						     =     prepare_img()
          UpperCamelCase   :  Union[str, Any]						     =     image_processor(images=SCREAMING_SNAKE_CASE_,      return_tensors='pt'	).to(SCREAMING_SNAKE_CASE_	)

          # forward pass
          with torch.no_grad():
             UpperCamelCase   :  Dict						     =     model(**SCREAMING_SNAKE_CASE_	)
          UpperCamelCase   :  Union[str, Any]						     =     outputs.logits

          # verify the logits
          UpperCamelCase   :  Tuple						     =     torch.Size((1, 21, 65, 65)	)
          self.assertEqual(logits.shape,      SCREAMING_SNAKE_CASE_	)

          UpperCamelCase   :  Dict						     =     torch.tensor(
              [
                  [[17.57_90, 17.75_81, 18.33_55], [18.32_57, 18.42_30, 18.89_73], [18.61_69, 18.86_50, 19.21_87]],
                  [[-2.15_95, -2.09_77, -2.37_41], [-2.42_26, -2.30_28, -2.68_35], [-2.78_19, -2.59_91, -2.77_06]],
                  [[4.20_58, 4.83_17, 4.76_38], [4.41_36, 5.03_61, 4.93_83], [4.50_28, 4.96_44, 4.87_34]],
              ],      device=SCREAMING_SNAKE_CASE_,      )

          self.assertTrue(torch.allclose(logits[0, :3, :3, :3],      SCREAMING_SNAKE_CASE_,      atol=1e-4	)	)








import gc
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer

from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline
from diffusers.pipelines.shap_e import ShapERenderer
from diffusers.utils import load_numpy, slow
from diffusers.utils.testing_utils import require_torch_gpu, torch_device

from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference



class     lowerCAmelCase_		(  a__	,   unittest.TestCase							):
       UpperCAmelCase__    : Union[str, Any]       					=  ShapEPipeline
       UpperCAmelCase__    : List[Any]       					=  ["prompt"]
       UpperCAmelCase__    : List[str]       					=  ["prompt"]
       UpperCAmelCase__    : int       					=  [
           "num_images_per_prompt",
           "num_inference_steps",
           "generator",
           "latents",
           "guidance_scale",
           "frame_size",
           "output_type",
           "return_dict",
       ]
       UpperCAmelCase__    : Union[str, Any]       					=  False
       @property
       def  snake_case_	(      self	)					->		Union[str, Any]:
          return 32
       @property
       def  snake_case_	(      self	)					->		List[str]:
          return 32
       @property
       def  snake_case_	(      self	)					->		int:
          return self.time_input_dim * 4
       @property
       def  snake_case_	(      self	)					->		Optional[int]:
          return 8
       @property
       def  snake_case_	(      self	)					->		str:
          UpperCamelCase   :  Union[str, Any]						     =     CLIPTokenizer.from_pretrained('hf-internal-testing/tiny-random-clip'	)
          return tokenizer
       @property
       def  snake_case_	(      self	)					->		Optional[Any]:
          torch.manual_seed(0	)
          UpperCamelCase   :  Dict						     =     CLIPTextConfig(
              bos_token_id=0,      eos_token_id=2,      hidden_size=self.text_embedder_hidden_size,      projection_dim=self.text_embedder_hidden_size,      intermediate_size=37,      layer_norm_eps=1e-05,      num_attention_heads=4,      num_hidden_layers=5,      pad_token_id=1,      vocab_size=1000,      )
          return CLIPTextModelWithProjection(SCREAMING_SNAKE_CASE_	)
       @property
       def  snake_case_	(      self	)					->		Dict:
          torch.manual_seed(0	)

          UpperCamelCase   :  int						     =     {
              'num_attention_heads': 2,
              'attention_head_dim': 16,
              'embedding_dim': self.time_input_dim,
              'num_embeddings': 32,
              'embedding_proj_dim': self.text_embedder_hidden_size,
              'time_embed_dim': self.time_embed_dim,
              'num_layers': 1,
              'clip_embed_dim': self.time_input_dim * 2,
              'additional_embeddings': 0,
              'time_embed_act_fn': 'gelu',
              'norm_in_type': 'layer',
              'encoder_hid_proj_type': None,
              'added_emb_type': None,
          }

          UpperCamelCase   :  Any						     =     PriorTransformer(**SCREAMING_SNAKE_CASE_	)
          return model
       @property
       def  snake_case_	(      self	)					->		Tuple:
          torch.manual_seed(0	)

          UpperCamelCase   :  Any						     =     {
              'param_shapes': (
                  (self.renderer_dim, 93),
                  (self.renderer_dim, 8),
                  (self.renderer_dim, 8),
                  (self.renderer_dim, 8),
              ),
              'd_latent': self.time_input_dim,
              'd_hidden': self.renderer_dim,
              'n_output': 12,
              'background': (
                  0.1,
                  0.1,
                  0.1,
              ),
          }
          UpperCamelCase   :  Dict						     =     ShapERenderer(**SCREAMING_SNAKE_CASE_	)
          return model
       def  snake_case_	(      self	)					->		Tuple:
          UpperCamelCase   :  List[Any]						     =     self.dummy_prior
          UpperCamelCase   :  int						     =     self.dummy_text_encoder
          UpperCamelCase   :  Dict						     =     self.dummy_tokenizer
          UpperCamelCase   :  List[str]						     =     self.dummy_renderer

          UpperCamelCase   :  str						     =     HeunDiscreteScheduler(
              beta_schedule='exp',      num_train_timesteps=1024,      prediction_type='sample',      use_karras_sigmas=SCREAMING_SNAKE_CASE_,      clip_sample=SCREAMING_SNAKE_CASE_,      clip_sample_range=1.0,      )
          UpperCamelCase   :  List[str]						     =     {
              'prior': prior,
              'text_encoder': text_encoder,
              'tokenizer': tokenizer,
              'renderer': renderer,
              'scheduler': scheduler,
          }

          return components
       def  snake_case_	(      self,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_=0	)					->		Any:
          if str(SCREAMING_SNAKE_CASE_	).startswith('mps'	):
             UpperCamelCase   :  Optional[int]						     =     torch.manual_seed(SCREAMING_SNAKE_CASE_	)
          else:
             UpperCamelCase   :  Any						     =     torch.Generator(device=SCREAMING_SNAKE_CASE_	).manual_seed(SCREAMING_SNAKE_CASE_	)
          UpperCamelCase   :  str						     =     {
              'prompt': 'horse',
              'generator': generator,
              'num_inference_steps': 1,
              'frame_size': 32,
              'output_type': 'np',
          }
          return inputs
       def  snake_case_	(      self	)					->		int:
          UpperCamelCase   :  str						     =     'cpu'

          UpperCamelCase   :  Optional[int]						     =     self.get_dummy_components()

          UpperCamelCase   :  int						     =     self.pipeline_class(**SCREAMING_SNAKE_CASE_	)
          UpperCamelCase   :  Optional[Any]						     =     pipe.to(SCREAMING_SNAKE_CASE_	)

          pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE_	)

          UpperCamelCase   :  str						     =     pipe(**self.get_dummy_inputs(SCREAMING_SNAKE_CASE_	)	)
          UpperCamelCase   :  Optional[int]						     =     output.images[0]
          UpperCamelCase   :  Union[str, Any]						     =     image[0, -3:, -3:, -1]

          assert image.shape == (20, 32, 32, 3)

          UpperCamelCase   :  List[str]						     =     np.array(
              [
                  0.00_03_92_16,
                  0.00_03_92_16,
                  0.00_03_92_16,
                  0.00_03_92_16,
                  0.00_03_92_16,
                  0.00_03_92_16,
                  0.00_03_92_16,
                  0.00_03_92_16,
                  0.00_03_92_16,
              ]	)

          assert np.abs(image_slice.flatten() - expected_slice	).max() < 1e-2
       def  snake_case_	(      self	)					->		int:
          # NOTE: Larger batch sizes cause this test to timeout, only test on smaller batches
          self._test_inference_batch_consistent(batch_sizes=[1, 2]	)
       def  snake_case_	(      self	)					->		str:
          UpperCamelCase   :  str						     =     torch_device == 'cpu'
          UpperCamelCase   :  Optional[int]						     =     True

          self._test_inference_batch_single_identical(
              batch_size=2,      test_max_difference=SCREAMING_SNAKE_CASE_,      relax_max_difference=SCREAMING_SNAKE_CASE_,      )






       def  snake_case_	(      self	)					->		List[Any]:
          UpperCamelCase   :  List[Any]						     =     self.get_dummy_components()
          UpperCamelCase   :  str						     =     self.pipeline_class(**SCREAMING_SNAKE_CASE_	)
          UpperCamelCase   :  Optional[int]						     =     pipe.to(SCREAMING_SNAKE_CASE_	)
          pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE_	)

          UpperCamelCase   :  Optional[Any]						     =     1
          UpperCamelCase   :  Union[str, Any]						     =     2

          UpperCamelCase   :  Union[str, Any]						     =     self.get_dummy_inputs(SCREAMING_SNAKE_CASE_	)

          for key in inputs.keys():
             if key in self.batch_params:
                UpperCamelCase   :  List[Any]						     =     batch_size * [inputs[key]]

          UpperCamelCase   :  int						     =     pipe(**SCREAMING_SNAKE_CASE_,      num_images_per_prompt=SCREAMING_SNAKE_CASE_	)[0]

          assert images.shape[0] == batch_size * num_images_per_prompt






@slow
@require_torch_gpu
class     lowerCAmelCase_		(  unittest.TestCase							):
       def  snake_case_	(      self	)					->		str:
          # clean up the VRAM after each test
          super().tearDown()
          gc.collect()
          torch.cuda.empty_cache()






       def  snake_case_	(      self	)					->		Tuple:
          UpperCamelCase   :  Optional[int]						     =     load_numpy(
              'https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'
              '/shap_e/test_shap_e_np_out.npy'	)
          UpperCamelCase   :  Optional[int]						     =     ShapEPipeline.from_pretrained('openai/shap-e'	)
          UpperCamelCase   :  Optional[int]						     =     pipe.to(SCREAMING_SNAKE_CASE_	)
          pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE_	)

          UpperCamelCase   :  str						     =     torch.Generator(device=SCREAMING_SNAKE_CASE_	).manual_seed(0	)

          UpperCamelCase   :  Dict						     =     pipe(
              'a shark',      generator=SCREAMING_SNAKE_CASE_,      guidance_scale=15.0,      num_inference_steps=64,      frame_size=64,      output_type='np',      ).images[0]

          assert images.shape == (20, 64, 64, 3)

          assert_mean_pixel_difference(SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_	)



