






import unittest

from transformers import (
    MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
    TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING,
    Pipeline,
    ZeroShotClassificationPipeline,
    pipeline,
)
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow

from .test_pipelines_common import ANY


# These 2 model types require different inputs than those of the usual text models.
A_       :Dict       =						{'LayoutLMv2Config', 'LayoutLMv3Config'}




@is_pipeline_test
class 				__A     (			unittest.TestCase ):





				"""simple docstring"""







				UpperCamelCase__ :      str			 =MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
				UpperCamelCase__ :      Dict			 =TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING

				if model_mapping is not None:
								UpperCamelCase__ :      List[str]			 ={config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
				if tf_model_mapping is not None:
								UpperCamelCase__ :      Union[str, Any]			 ={
								    config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
								}


				def       __lowercase							( self							,  lowerCamelCase__							,  lowerCamelCase__							,  lowerCamelCase__    ):




									"""simple docstring"""

									__UpperCamelCase      :					Optional[int]       		=ZeroShotClassificationPipeline(
									    model=lowerCamelCase__							,  tokenizer=lowerCamelCase__							,  candidate_labels=['polics', 'health']    )
									return classifier, ["Who are you voting for in 2020?", "My stomach hurts."]


				def       __lowercase							( self							,  lowerCamelCase__							,  lowerCamelCase__    ):




									"""simple docstring"""

									__UpperCamelCase      :					Tuple       		=classifier('Who are you voting for in 2020?'							,  candidate_labels='politics'    )
									self.assertEqual(lowerCamelCase__							,  {'sequence': ANY(lowerCamelCase__    ), 'labels': [ANY(lowerCamelCase__    )], 'scores': [ANY(lowerCamelCase__    )]}    )

									# No kwarg
									__UpperCamelCase      :					Tuple       		=classifier('Who are you voting for in 2020?'							,  ['politics']    )
									self.assertEqual(lowerCamelCase__							,  {'sequence': ANY(lowerCamelCase__    ), 'labels': [ANY(lowerCamelCase__    )], 'scores': [ANY(lowerCamelCase__    )]}    )

									__UpperCamelCase      :					str       		=classifier('Who are you voting for in 2020?'							,  candidate_labels=['politics']    )
									self.assertEqual(lowerCamelCase__							,  {'sequence': ANY(lowerCamelCase__    ), 'labels': [ANY(lowerCamelCase__    )], 'scores': [ANY(lowerCamelCase__    )]}    )

									__UpperCamelCase      :					Any       		=classifier('Who are you voting for in 2020?'							,  candidate_labels='politics, public health'    )
									self.assertEqual(
									    lowerCamelCase__							,  {'sequence': ANY(lowerCamelCase__    ), 'labels': [ANY(lowerCamelCase__    ), ANY(lowerCamelCase__    )], 'scores': [ANY(lowerCamelCase__    ), ANY(lowerCamelCase__    )]}    )
									self.assertAlmostEqual(sum(nested_simplify(outputs['scores']    )    )							,  1.0    )

									__UpperCamelCase      :					int       		=classifier('Who are you voting for in 2020?'							,  candidate_labels=['politics', 'public health']    )
									self.assertEqual(
									    lowerCamelCase__							,  {'sequence': ANY(lowerCamelCase__    ), 'labels': [ANY(lowerCamelCase__    ), ANY(lowerCamelCase__    )], 'scores': [ANY(lowerCamelCase__    ), ANY(lowerCamelCase__    )]}    )
									self.assertAlmostEqual(sum(nested_simplify(outputs['scores']    )    )							,  1.0    )

									__UpperCamelCase      :					Union[str, Any]       		=classifier(
									    'Who are you voting for in 2020?'							,  candidate_labels='politics'							,  hypothesis_template='This text is about {}'    )
									self.assertEqual(lowerCamelCase__							,  {'sequence': ANY(lowerCamelCase__    ), 'labels': [ANY(lowerCamelCase__    )], 'scores': [ANY(lowerCamelCase__    )]}    )

									# https://github.com/huggingface/transformers/issues/13846
									__UpperCamelCase      :					str       		=classifier(['I am happy']							,  ['positive', 'negative']    )
									self.assertEqual(
									    lowerCamelCase__							,  [
									        {'sequence': ANY(lowerCamelCase__    ), 'labels': [ANY(lowerCamelCase__    ), ANY(lowerCamelCase__    )], 'scores': [ANY(lowerCamelCase__    ), ANY(lowerCamelCase__    )]}
									        for i in range(1    )
									    ]							,  )
									__UpperCamelCase      :					Dict       		=classifier(['I am happy', 'I am sad']							,  ['positive', 'negative']    )
									self.assertEqual(
									    lowerCamelCase__							,  [
									        {'sequence': ANY(lowerCamelCase__    ), 'labels': [ANY(lowerCamelCase__    ), ANY(lowerCamelCase__    )], 'scores': [ANY(lowerCamelCase__    ), ANY(lowerCamelCase__    )]}
									        for i in range(2    )
									    ]							,  )

									with self.assertRaises(lowerCamelCase__    ):
														classifier(''							,  candidate_labels='politics'    )

									with self.assertRaises(lowerCamelCase__    ):
														classifier(lowerCamelCase__							,  candidate_labels='politics'    )

									with self.assertRaises(lowerCamelCase__    ):
														classifier('Who are you voting for in 2020?'							,  candidate_labels=''    )

									with self.assertRaises(lowerCamelCase__    ):
														classifier('Who are you voting for in 2020?'							,  candidate_labels=lowerCamelCase__    )

									with self.assertRaises(lowerCamelCase__    ):
														classifier(
														    'Who are you voting for in 2020?'							,  candidate_labels='politics'							,  hypothesis_template='Not formatting template'							,  )

									with self.assertRaises(lowerCamelCase__    ):
														classifier(
														    'Who are you voting for in 2020?'							,  candidate_labels='politics'							,  hypothesis_template=lowerCamelCase__							,  )

									self.run_entailment_id(lowerCamelCase__    )


				def       __lowercase							( self							,  lowerCamelCase__    ):




									"""simple docstring"""

									__UpperCamelCase      :					Dict       		=zero_shot_classifier.model.config
									__UpperCamelCase      :					List[str]       		=config.labelaid
									__UpperCamelCase      :					List[Any]       		=zero_shot_classifier.entailment_id

									__UpperCamelCase      :					Tuple       		={'LABEL_0': 0, 'LABEL_1': 1, 'LABEL_2': 2}
									self.assertEqual(zero_shot_classifier.entailment_id							,  -1    )

									__UpperCamelCase      :					Union[str, Any]       		={'entailment': 0, 'neutral': 1, 'contradiction': 2}
									self.assertEqual(zero_shot_classifier.entailment_id							,  0    )

									__UpperCamelCase      :					int       		={'ENTAIL': 0, 'NON-ENTAIL': 1}
									self.assertEqual(zero_shot_classifier.entailment_id							,  0    )

									__UpperCamelCase      :					Tuple       		={'ENTAIL': 2, 'NEUTRAL': 1, 'CONTR': 0}
									self.assertEqual(zero_shot_classifier.entailment_id							,  2    )

									__UpperCamelCase      :					List[Any]       		=original_labelaid
									self.assertEqual(lowerCamelCase__							,  zero_shot_classifier.entailment_id    )


				@require_torch
				def       __lowercase							( self    ):




									"""simple docstring"""

									__UpperCamelCase      :					Optional[int]       		=pipeline(
									    'zero-shot-classification'							,  model='sshleifer/tiny-distilbert-base-cased-distilled-squad'							,  framework='pt'							,  )
									# There was a regression in 4.10 for this
									# Adding a test so we don't make the mistake again.
									# https://github.com/huggingface/transformers/issues/13381#issuecomment-912343499
									zero_shot_classifier(
									    'Who are you voting for in 2020?' * 100							,  candidate_labels=['politics', 'public health', 'science']    )


				@require_torch
				def       __lowercase							( self    ):




									"""simple docstring"""

									__UpperCamelCase      :					str       		=pipeline(
									    'zero-shot-classification'							,  model='sshleifer/tiny-distilbert-base-cased-distilled-squad'							,  framework='pt'							,  )
									__UpperCamelCase      :					Optional[int]       		=zero_shot_classifier(
									    'Who are you voting for in 2020?'							,  candidate_labels=['politics', 'public health', 'science']    )

									self.assertEqual(
									    nested_simplify(lowerCamelCase__    )							,  {
									        'sequence': 'Who are you voting for in 2020?',
									        'labels': ['science', 'public health', 'politics'],
									        'scores': [0.333, 0.333, 0.333],
									    }							,  )


				@require_tf
				def       __lowercase							( self    ):




									"""simple docstring"""

									__UpperCamelCase      :					Dict       		=pipeline(
									    'zero-shot-classification'							,  model='sshleifer/tiny-distilbert-base-cased-distilled-squad'							,  framework='tf'							,  )
									__UpperCamelCase      :					str       		=zero_shot_classifier(
									    'Who are you voting for in 2020?'							,  candidate_labels=['politics', 'public health', 'science']    )

									self.assertEqual(
									    nested_simplify(lowerCamelCase__    )							,  {
									        'sequence': 'Who are you voting for in 2020?',
									        'labels': ['science', 'public health', 'politics'],
									        'scores': [0.333, 0.333, 0.333],
									    }							,  )


				@slow
				@require_torch
				def       __lowercase							( self    ):




									"""simple docstring"""

									__UpperCamelCase      :					Optional[Any]       		=pipeline('zero-shot-classification'							,  model='roberta-large-mnli'							,  framework='pt'    )
									__UpperCamelCase      :					List[Any]       		=zero_shot_classifier(
									    'Who are you voting for in 2020?'							,  candidate_labels=['politics', 'public health', 'science']    )

									self.assertEqual(
									    nested_simplify(lowerCamelCase__    )							,  {
									        'sequence': 'Who are you voting for in 2020?',
									        'labels': ['politics', 'public health', 'science'],
									        'scores': [0.976, 0.015, 0.009],
									    }							,  )
									__UpperCamelCase      :					Optional[Any]       		=zero_shot_classifier(
									    'The dominant sequence transduction models are based on complex recurrent or convolutional neural networks'
									    ' in an encoder-decoder configuration. The best performing models also connect the encoder and decoder'
									    ' through an attention mechanism. We propose a new simple network architecture, the Transformer, based'
									    ' solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two'
									    ' machine translation tasks show these models to be superior in quality while being more parallelizable'
									    ' and requiring significantly less time to train. Our model achieves 28.4 BLEU on the WMT 2014'
									    ' English-to-German translation task, improving over the existing best results, including ensembles by'
									    ' over 2 BLEU. On the WMT 2014 English-to-French translation task, our model establishes a new'
									    ' single-model state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small'
									    ' fraction of the training costs of the best models from the literature. We show that the Transformer'
									    ' generalizes well to other tasks by applying it successfully to English constituency parsing both with'
									    ' large and limited training data.'							,  candidate_labels=['machine learning', 'statistics', 'translation', 'vision']							,  multi_label=lowerCamelCase__							,  )
									self.assertEqual(
									    nested_simplify(lowerCamelCase__    )							,  {
									        'sequence': (
									            'The dominant sequence transduction models are based on complex recurrent or convolutional neural'
									            ' networks in an encoder-decoder configuration. The best performing models also connect the'
									            ' encoder and decoder through an attention mechanism. We propose a new simple network'
									            ' architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence'
									            ' and convolutions entirely. Experiments on two machine translation tasks show these models to be'
									            ' superior in quality while being more parallelizable and requiring significantly less time to'
									            ' train. Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task,'
									            ' improving over the existing best results, including ensembles by over 2 BLEU. On the WMT 2014'
									            ' English-to-French translation task, our model establishes a new single-model state-of-the-art'
									            ' BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training'
									            ' costs of the best models from the literature. We show that the Transformer generalizes well to'
									            ' other tasks by applying it successfully to English constituency parsing both with large and'
									            ' limited training data.'
									        ),
									        'labels': ['translation', 'machine learning', 'vision', 'statistics'],
									        'scores': [0.817, 0.713, 0.018, 0.018],
									    }							,  )







				@slow
				@require_tf
				def       __lowercase							( self    ):




									"""simple docstring"""

									__UpperCamelCase      :					int       		=pipeline('zero-shot-classification'							,  model='roberta-large-mnli'							,  framework='tf'    )
									__UpperCamelCase      :					Union[str, Any]       		=zero_shot_classifier(
									    'Who are you voting for in 2020?'							,  candidate_labels=['politics', 'public health', 'science']    )

									self.assertEqual(
									    nested_simplify(lowerCamelCase__    )							,  {
									        'sequence': 'Who are you voting for in 2020?',
									        'labels': ['politics', 'public health', 'science'],
									        'scores': [0.976, 0.015, 0.009],
									    }							,  )
									__UpperCamelCase      :					str       		=zero_shot_classifier(
									    'The dominant sequence transduction models are based on complex recurrent or convolutional neural networks'
									    ' in an encoder-decoder configuration. The best performing models also connect the encoder and decoder'
									    ' through an attention mechanism. We propose a new simple network architecture, the Transformer, based'
									    ' solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two'
									    ' machine translation tasks show these models to be superior in quality while being more parallelizable'
									    ' and requiring significantly less time to train. Our model achieves 28.4 BLEU on the WMT 2014'
									    ' English-to-German translation task, improving over the existing best results, including ensembles by'
									    ' over 2 BLEU. On the WMT 2014 English-to-French translation task, our model establishes a new'
									    ' single-model state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small'
									    ' fraction of the training costs of the best models from the literature. We show that the Transformer'
									    ' generalizes well to other tasks by applying it successfully to English constituency parsing both with'
									    ' large and limited training data.'							,  candidate_labels=['machine learning', 'statistics', 'translation', 'vision']							,  multi_label=lowerCamelCase__							,  )
									self.assertEqual(
									    nested_simplify(lowerCamelCase__    )							,  {
									        'sequence': (
									            'The dominant sequence transduction models are based on complex recurrent or convolutional neural'
									            ' networks in an encoder-decoder configuration. The best performing models also connect the'
									            ' encoder and decoder through an attention mechanism. We propose a new simple network'
									            ' architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence'
									            ' and convolutions entirely. Experiments on two machine translation tasks show these models to be'
									            ' superior in quality while being more parallelizable and requiring significantly less time to'
									            ' train. Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task,'
									            ' improving over the existing best results, including ensembles by over 2 BLEU. On the WMT 2014'
									            ' English-to-French translation task, our model establishes a new single-model state-of-the-art'
									            ' BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training'
									            ' costs of the best models from the literature. We show that the Transformer generalizes well to'
									            ' other tasks by applying it successfully to English constituency parsing both with large and'
									            ' limited training data.'
									        ),
									        'labels': ['translation', 'machine learning', 'vision', 'statistics'],
									        'scores': [0.817, 0.713, 0.018, 0.018],
									    }							,  )





'''simple docstring'''

import gc
import random
import unittest

import numpy as np
import torch
from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel

from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline
from diffusers.pipelines.shap_e import ShapERenderer
from diffusers.utils import floats_tensor, load_image, 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						(lowercase_  ,     unittest.TestCase     ):





      '''simple docstring'''






      lowerCAmelCase__					:     Dict  					=							ShapEImgaImgPipeline
      lowerCAmelCase__					:     List[str]  					=							["""image"""]
      lowerCAmelCase__					:     Any  					=							["""image"""]
      lowerCAmelCase__					:     Any  					=							[
          """num_images_per_prompt""",
          """num_inference_steps""",
          """generator""",
          """latents""",
          """guidance_scale""",
          """frame_size""",
          """output_type""",
          """return_dict""",
      ]
      lowerCAmelCase__					:     Tuple  					=							False



      @property
      def       UpperCamelCase__		(self    :    List[Any] ):

             '''simple docstring'''







             return 32



      @property
      def       UpperCamelCase__		(self    :    str ):

             '''simple docstring'''







             return 32



      @property
      def       UpperCamelCase__		(self    :    Union[str, Any] ):

             '''simple docstring'''







             return self.time_input_dim * 4



      @property
      def       UpperCamelCase__		(self    :    int ):

             '''simple docstring'''







             return 8



      @property
      def       UpperCamelCase__		(self    :    Any ):

             '''simple docstring'''







             torch.manual_seed(0 )
             lowercase__      			= CLIPVisionConfig(
                 hidden_size=self.text_embedder_hidden_size   ,						image_size=64   ,						projection_dim=self.text_embedder_hidden_size   ,						intermediate_size=37   ,						num_attention_heads=4   ,						num_channels=3   ,						num_hidden_layers=5   ,						patch_size=1   ,						)

             lowercase__      			= CLIPVisionModel(UpperCamelCase )
             return model



      @property
      def       UpperCamelCase__		(self    :    List[Any] ):

             '''simple docstring'''







             lowercase__      			= CLIPImageProcessor(
                 crop_size=224   ,						do_center_crop=UpperCamelCase   ,						do_normalize=UpperCamelCase   ,						do_resize=UpperCamelCase   ,						image_mean=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]   ,						image_std=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]   ,						resample=3   ,						size=224   ,						)

             return image_processor



      @property
      def       UpperCamelCase__		(self    :    str ):

             '''simple docstring'''







             torch.manual_seed(0 )

             lowercase__      			= {
                 '''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''',
                 '''embedding_proj_norm_type''': '''layer''',
                 '''encoder_hid_proj_type''': None,
                 '''added_emb_type''': None,
             }

             lowercase__      			= PriorTransformer(**UpperCamelCase )
             return model



      @property
      def       UpperCamelCase__		(self    :    int ):

             '''simple docstring'''







             torch.manual_seed(0 )

             lowercase__      			= {
                 '''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,
                 ),
             }
             lowercase__      			= ShapERenderer(**UpperCamelCase )
             return model



      def       UpperCamelCase__		(self    :    Union[str, Any] ):

             '''simple docstring'''







             lowercase__      			= self.dummy_prior
             lowercase__      			= self.dummy_image_encoder
             lowercase__      			= self.dummy_image_processor
             lowercase__      			= self.dummy_renderer

             lowercase__      			= HeunDiscreteScheduler(
                 beta_schedule='''exp'''   ,						num_train_timesteps=1024   ,						prediction_type='''sample'''   ,						use_karras_sigmas=UpperCamelCase   ,						clip_sample=UpperCamelCase   ,						clip_sample_range=1.0   ,						)
             lowercase__      			= {
                 '''prior''': prior,
                 '''image_encoder''': image_encoder,
                 '''image_processor''': image_processor,
                 '''renderer''': renderer,
                 '''scheduler''': scheduler,
             }

             return components



      def       UpperCamelCase__		(self    :    Optional[int]   ,						UpperCamelCase    :    Optional[int]   ,						UpperCamelCase    :    str=0 ):

             '''simple docstring'''







             lowercase__      			= floats_tensor((1, 3, 64, 64)   ,						rng=random.Random(UpperCamelCase ) ).to(UpperCamelCase )

             if str(UpperCamelCase ).startswith('''mps''' ):
                    lowercase__      			= torch.manual_seed(UpperCamelCase )
             else:
                    lowercase__      			= torch.Generator(device=UpperCamelCase ).manual_seed(UpperCamelCase )
             lowercase__      			= {
                 '''image''': input_image,
                 '''generator''': generator,
                 '''num_inference_steps''': 1,
                 '''frame_size''': 32,
                 '''output_type''': '''np''',
             }
             return inputs



      def       UpperCamelCase__		(self    :    Tuple ):

             '''simple docstring'''







             lowercase__      			= '''cpu'''

             lowercase__      			= self.get_dummy_components()

             lowercase__      			= self.pipeline_class(**UpperCamelCase )
             lowercase__      			= pipe.to(UpperCamelCase )

             pipe.set_progress_bar_config(disable=UpperCamelCase )

             lowercase__      			= pipe(**self.get_dummy_inputs(UpperCamelCase ) )
             lowercase__      			= output.images[0]
             lowercase__      			= image[0, -3:, -3:, -1]

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

             lowercase__      			= 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       UpperCamelCase__		(self    :    Optional[Any] ):

             '''simple docstring'''







             self._test_inference_batch_consistent(batch_sizes=[1, 2] )



      def       UpperCamelCase__		(self    :    int ):

             '''simple docstring'''







             lowercase__      			= torch_device == '''cpu'''
             lowercase__      			= True
             self._test_inference_batch_single_identical(
                 batch_size=2   ,						test_max_difference=UpperCamelCase   ,						relax_max_difference=UpperCamelCase   ,						)






      def       UpperCamelCase__		(self    :    int ):

             '''simple docstring'''







             lowercase__      			= self.get_dummy_components()
             lowercase__      			= self.pipeline_class(**UpperCamelCase )
             lowercase__      			= pipe.to(UpperCamelCase )
             pipe.set_progress_bar_config(disable=UpperCamelCase )

             lowercase__      			= 1
             lowercase__      			= 2

             lowercase__      			= self.get_dummy_inputs(UpperCamelCase )

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

             lowercase__      			= pipe(**UpperCamelCase   ,						num_images_per_prompt=UpperCamelCase )[0]

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






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





      '''simple docstring'''






      def       UpperCamelCase__		(self    :    Optional[Any] ):

             '''simple docstring'''







             super().tearDown()
             gc.collect()
             torch.cuda.empty_cache()






      def       UpperCamelCase__		(self    :    Union[str, Any] ):

             '''simple docstring'''







             lowercase__      			= load_image(
                 '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main''' '''/shap_e/corgi.png''' )
             lowercase__      			= load_numpy(
                 '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
                 '''/shap_e/test_shap_e_img2img_out.npy''' )
             lowercase__      			= ShapEImgaImgPipeline.from_pretrained('''openai/shap-e-img2img''' )
             lowercase__      			= pipe.to(UpperCamelCase )
             pipe.set_progress_bar_config(disable=UpperCamelCase )

             lowercase__      			= torch.Generator(device=UpperCamelCase ).manual_seed(0 )

             lowercase__      			= pipe(
                 UpperCamelCase   ,						generator=UpperCamelCase   ,						guidance_scale=3.0   ,						num_inference_steps=64   ,						frame_size=64   ,						output_type='''np'''   ,						).images[0]

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

             assert_mean_pixel_difference(UpperCamelCase   ,						UpperCamelCase )




