





import os
import sys
import tempfile
import unittest
import unittest.mock as mock
from pathlib import Path

from huggingface_hub import HfFolder, delete_repo
from huggingface_hub.file_download import http_get
from requests.exceptions import HTTPError

from transformers import (
    AlbertTokenizer,
    AutoTokenizer,
    BertTokenizer,
    BertTokenizerFast,
    GPTaTokenizerFast,
    is_tokenizers_available,
)
from transformers.testing_utils import TOKEN, USER, is_staging_test, require_tokenizers
from transformers.tokenization_utils import Trie


sys.path.append(str(Path(__file__).parent.parent / "utils"))

from test_module.custom_tokenization import CustomTokenizer  # noqa E402


if is_tokenizers_available():
     from test_module.custom_tokenization_fast import CustomTokenizerFast



class      _SCREAMING_SNAKE_CASE		(			unittest.TestCase					):







      '''simple docstring'''

      def 							SCREAMING_SNAKE_CASE_      (self       :     Union[str, Any]) ->Tuple:



        '''simple docstring'''



        lowerCamelCase__:   List[str]    						=mock.Mock()
        lowerCamelCase__:   Union[str, Any]    						=500
        lowerCamelCase__:   Dict    						={}
        lowerCamelCase__:   Dict    						=HTTPError
        lowerCamelCase__:   Union[str, Any]    						={}

        # Download this model to make sure it's in the cache.
        lowerCamelCase__:   str    						=BertTokenizer.from_pretrained("hf-internal-testing/tiny-random-bert")

        # Under the mock environment we get a 500 error when trying to reach the tokenizer.
        with mock.patch("requests.Session.request" ,				return_value=lowerCAmelCase_) as mock_head:
          lowerCamelCase__:   List[Any]    						=BertTokenizer.from_pretrained("hf-internal-testing/tiny-random-bert")
          # This check we did call the fake head request
          mock_head.assert_called()

      @require_tokenizers
      def 							SCREAMING_SNAKE_CASE_      (self       :     Dict) ->str:



        '''simple docstring'''



        lowerCamelCase__:   List[str]    						=mock.Mock()
        lowerCamelCase__:   Any    						=500
        lowerCamelCase__:   List[Any]    						={}
        lowerCamelCase__:   Dict    						=HTTPError
        lowerCamelCase__:   Optional[Any]    						={}

        # Download this model to make sure it's in the cache.
        lowerCamelCase__:   Optional[int]    						=GPTaTokenizerFast.from_pretrained("gpt2")

        # Under the mock environment we get a 500 error when trying to reach the tokenizer.
        with mock.patch("requests.Session.request" ,				return_value=lowerCAmelCase_) as mock_head:
          lowerCamelCase__:   Tuple    						=GPTaTokenizerFast.from_pretrained("gpt2")
          # This check we did call the fake head request
          mock_head.assert_called()

      def 							SCREAMING_SNAKE_CASE_      (self       :     Any) ->Any:



        '''simple docstring'''



        try:
          lowerCamelCase__:   Optional[int]    						=tempfile.mktemp()
          with open(lowerCAmelCase_ ,				"wb") as f:
            http_get("https://huggingface.co/albert-base-v1/resolve/main/spiece.model" ,				lowerCAmelCase_)

          lowerCamelCase__:   Optional[int]    						=AlbertTokenizer.from_pretrained(lowerCAmelCase_)
        finally:
          os.remove(lowerCAmelCase_)

        # Supporting this legacy load introduced a weird bug where the tokenizer would load local files if they are in
        # the current folder and have the right name.
        if os.path.isfile("tokenizer.json"):
          # We skip the test if the user has a `tokenizer.json` in this folder to avoid deleting it.
          return
        try:
          with open("tokenizer.json" ,				"wb") as f:
            http_get("https://huggingface.co/hf-internal-testing/tiny-random-bert/blob/main/tokenizer.json" ,				lowerCAmelCase_)
          lowerCamelCase__:   Union[str, Any]    						=AutoTokenizer.from_pretrained("hf-internal-testing/tiny-random-gpt2")
          # The tiny random BERT has a vocab size of 1024, tiny gpt2 as a vocab size of 1000
          self.assertEqual(tokenizer.vocab_size ,				1_000)
          # Tokenizer should depend on the remote checkpoint, not the local tokenizer.json file.

        finally:
          os.remove("tokenizer.json")







      def 							SCREAMING_SNAKE_CASE_      (self       :     int) ->List[str]:



        '''simple docstring'''



        lowerCamelCase__:   Any    						=AlbertTokenizer.from_pretrained("https://huggingface.co/albert-base-v1/resolve/main/spiece.model")



@is_staging_test
class      _SCREAMING_SNAKE_CASE		(			unittest.TestCase					):







      '''simple docstring'''
      lowercase_	=    ["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]", "bla", "blou"]

      @classmethod
      def 							SCREAMING_SNAKE_CASE_      (cls       :     Dict) ->Optional[Any]:



        '''simple docstring'''



        lowerCamelCase__:   List[str]    						=TOKEN
        HfFolder.save_token(lowerCAmelCase_)

      @classmethod
      def 							SCREAMING_SNAKE_CASE_      (cls       :     Optional[Any]) ->Any:



        '''simple docstring'''



        try:
          delete_repo(token=cls._token ,				repo_id="test-tokenizer")
        except HTTPError:
          pass

        try:
          delete_repo(token=cls._token ,				repo_id="valid_org/test-tokenizer-org")
        except HTTPError:
          pass

        try:
          delete_repo(token=cls._token ,				repo_id="test-dynamic-tokenizer")
        except HTTPError:
          pass

      def 							SCREAMING_SNAKE_CASE_      (self       :     Union[str, Any]) ->Union[str, Any]:



        '''simple docstring'''



        with tempfile.TemporaryDirectory() as tmp_dir:
          lowerCamelCase__:   str    						=os.path.join(lowerCAmelCase_ ,				"vocab.txt")
          with open(lowerCAmelCase_ ,				"w" ,				encoding="utf-8") as vocab_writer:
            vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]))
          lowerCamelCase__:   Union[str, Any]    						=BertTokenizer(lowerCAmelCase_)

        tokenizer.push_to_hub("test-tokenizer" ,				use_auth_token=self._token)
        lowerCamelCase__:   List[str]    						=BertTokenizer.from_pretrained(F"""{USER}/test-tokenizer""")
        self.assertDictEqual(new_tokenizer.vocab ,				tokenizer.vocab)

        # Reset repo
        delete_repo(token=self._token ,				repo_id="test-tokenizer")

        # Push to hub via save_pretrained
        with tempfile.TemporaryDirectory() as tmp_dir:
          tokenizer.save_pretrained(lowerCAmelCase_ ,				repo_id="test-tokenizer" ,				push_to_hub=lowerCAmelCase_ ,				use_auth_token=self._token)

        lowerCamelCase__:   str    						=BertTokenizer.from_pretrained(F"""{USER}/test-tokenizer""")
        self.assertDictEqual(new_tokenizer.vocab ,				tokenizer.vocab)

      def 							SCREAMING_SNAKE_CASE_      (self       :     Optional[int]) ->int:



        '''simple docstring'''



        with tempfile.TemporaryDirectory() as tmp_dir:
          lowerCamelCase__:   List[str]    						=os.path.join(lowerCAmelCase_ ,				"vocab.txt")
          with open(lowerCAmelCase_ ,				"w" ,				encoding="utf-8") as vocab_writer:
            vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]))
          lowerCamelCase__:   List[Any]    						=BertTokenizer(lowerCAmelCase_)

        tokenizer.push_to_hub("valid_org/test-tokenizer-org" ,				use_auth_token=self._token)
        lowerCamelCase__:   Dict    						=BertTokenizer.from_pretrained("valid_org/test-tokenizer-org")
        self.assertDictEqual(new_tokenizer.vocab ,				tokenizer.vocab)

        # Reset repo
        delete_repo(token=self._token ,				repo_id="valid_org/test-tokenizer-org")

        # Push to hub via save_pretrained
        with tempfile.TemporaryDirectory() as tmp_dir:
          tokenizer.save_pretrained(
              lowerCAmelCase_ ,				repo_id="valid_org/test-tokenizer-org" ,				push_to_hub=lowerCAmelCase_ ,				use_auth_token=self._token)

        lowerCamelCase__:   Union[str, Any]    						=BertTokenizer.from_pretrained("valid_org/test-tokenizer-org")
        self.assertDictEqual(new_tokenizer.vocab ,				tokenizer.vocab)







      @require_tokenizers
      def 							SCREAMING_SNAKE_CASE_      (self       :     Any) ->Union[str, Any]:



        '''simple docstring'''



        CustomTokenizer.register_for_auto_class()
        with tempfile.TemporaryDirectory() as tmp_dir:
          lowerCamelCase__:   Any    						=os.path.join(lowerCAmelCase_ ,				"vocab.txt")
          with open(lowerCAmelCase_ ,				"w" ,				encoding="utf-8") as vocab_writer:
            vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]))
          lowerCamelCase__:   List[str]    						=CustomTokenizer(lowerCAmelCase_)

        # No fast custom tokenizer
        tokenizer.push_to_hub("test-dynamic-tokenizer" ,				use_auth_token=self._token)

        lowerCamelCase__:   Tuple    						=AutoTokenizer.from_pretrained(F"""{USER}/test-dynamic-tokenizer""" ,				trust_remote_code=lowerCAmelCase_)
        # Can't make an isinstance check because the new_model.config is from the CustomTokenizer class of a dynamic module
        self.assertEqual(tokenizer.__class__.__name__ ,				"CustomTokenizer")

        # Fast and slow custom tokenizer
        CustomTokenizerFast.register_for_auto_class()
        with tempfile.TemporaryDirectory() as tmp_dir:
          lowerCamelCase__:   Optional[Any]    						=os.path.join(lowerCAmelCase_ ,				"vocab.txt")
          with open(lowerCAmelCase_ ,				"w" ,				encoding="utf-8") as vocab_writer:
            vocab_writer.write("".join([x + "\n" for x in self.vocab_tokens]))

          lowerCamelCase__:   List[str]    						=BertTokenizerFast.from_pretrained(lowerCAmelCase_)
          bert_tokenizer.save_pretrained(lowerCAmelCase_)
          lowerCamelCase__:   int    						=CustomTokenizerFast.from_pretrained(lowerCAmelCase_)

        tokenizer.push_to_hub("test-dynamic-tokenizer" ,				use_auth_token=self._token)

        lowerCamelCase__:   Dict    						=AutoTokenizer.from_pretrained(F"""{USER}/test-dynamic-tokenizer""" ,				trust_remote_code=lowerCAmelCase_)
        # Can't make an isinstance check because the new_model.config is from the FakeConfig class of a dynamic module
        self.assertEqual(tokenizer.__class__.__name__ ,				"CustomTokenizerFast")
        lowerCamelCase__:   str    						=AutoTokenizer.from_pretrained(
            F"""{USER}/test-dynamic-tokenizer""" ,				use_fast=lowerCAmelCase_ ,				trust_remote_code=lowerCAmelCase_)
        # Can't make an isinstance check because the new_model.config is from the FakeConfig class of a dynamic module
        self.assertEqual(tokenizer.__class__.__name__ ,				"CustomTokenizer")



class      _SCREAMING_SNAKE_CASE		(			unittest.TestCase					):







      '''simple docstring'''

      def 							SCREAMING_SNAKE_CASE_      (self       :     List[str]) ->Optional[int]:



        '''simple docstring'''



        lowerCamelCase__:   List[Any]    						=Trie()
        trie.add("Hello 友達")
        self.assertEqual(trie.data ,				{"H": {"e": {"l": {"l": {"o": {" ": {"友": {"達": {"": 1}}}}}}}}})
        trie.add("Hello")
        trie.data
        self.assertEqual(trie.data ,				{"H": {"e": {"l": {"l": {"o": {"": 1, " ": {"友": {"達": {"": 1}}}}}}}}})

      def 							SCREAMING_SNAKE_CASE_      (self       :     List[Any]) ->List[str]:



        '''simple docstring'''



        lowerCamelCase__:   str    						=Trie()
        self.assertEqual(trie.split("[CLS] This is a extra_id_100") ,				["[CLS] This is a extra_id_100"])
        trie.add("[CLS]")
        trie.add("extra_id_1")
        trie.add("extra_id_100")
        self.assertEqual(trie.split("[CLS] This is a extra_id_100") ,				["[CLS]", " This is a ", "extra_id_100"])

      def 							SCREAMING_SNAKE_CASE_      (self       :     List[str]) ->int:



        '''simple docstring'''



        lowerCamelCase__:   Optional[int]    						=Trie()
        trie.add("A")
        self.assertEqual(trie.split("ABC") ,				["A", "BC"])
        self.assertEqual(trie.split("BCA") ,				["BC", "A"])

      def 							SCREAMING_SNAKE_CASE_      (self       :     Any) ->int:



        '''simple docstring'''



        lowerCamelCase__:   Dict    						=Trie()
        trie.add("TOKEN]")
        trie.add("[SPECIAL_TOKEN]")
        self.assertEqual(trie.split("This is something [SPECIAL_TOKEN]") ,				["This is something ", "[SPECIAL_TOKEN]"])

      def 							SCREAMING_SNAKE_CASE_      (self       :     Union[str, Any]) ->Optional[Any]:



        '''simple docstring'''



        lowerCamelCase__:   Dict    						=Trie()
        trie.add("A")
        trie.add("P")
        trie.add("[SPECIAL_TOKEN]")
        self.assertEqual(trie.split("This is something [SPECIAL_TOKEN]") ,				["This is something ", "[SPECIAL_TOKEN]"])

      def 							SCREAMING_SNAKE_CASE_      (self       :     str) ->str:



        '''simple docstring'''



        lowerCamelCase__:   str    						=Trie()
        trie.add("AB")
        trie.add("B")
        trie.add("C")
        self.assertEqual(trie.split("ABC") ,				["AB", "C"])

      def 							SCREAMING_SNAKE_CASE_      (self       :     List[str]) ->int:



        '''simple docstring'''



        lowerCamelCase__:   Dict    						=Trie()
        trie.add("ABC")
        trie.add("B")
        trie.add("CD")
        self.assertEqual(trie.split("ABCD") ,				["ABC", "D"])







      def 							SCREAMING_SNAKE_CASE_      (self       :     Optional[int]) ->str:



        '''simple docstring'''



        lowerCamelCase__:   int    						=Trie()
        lowerCamelCase__:   str    						=trie.cut_text("ABC" ,				[0, 0, 2, 1, 2, 3])
        self.assertEqual(lowerCAmelCase_ ,				["AB", "C"])








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      _SCREAMING_SNAKE_CASE		(			__SCREAMING_SNAKE_CASE					,							unittest.TestCase					):







 '''simple docstring'''
 lowercase_	=    ShapEImgaImgPipeline
 lowercase_	=    ["image"]
 lowercase_	=    ["image"]
 lowercase_	=    [
     "num_images_per_prompt",
     "num_inference_steps",
     "generator",
     "latents",
     "guidance_scale",
     "frame_size",
     "output_type",
     "return_dict",
 ]
 lowercase_	=    False

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     Any) ->Union[str, Any]:



   '''simple docstring'''



   return 32

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     Optional[Any]) ->str:



   '''simple docstring'''



   return 32

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     Tuple) ->List[Any]:



   '''simple docstring'''



   return self.time_input_dim * 4

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     Any) ->Union[str, Any]:



   '''simple docstring'''



   return 8

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     str) ->str:



   '''simple docstring'''



   torch.manual_seed(0)
   lowerCamelCase__:   List[str]    						=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 ,				)

   lowerCamelCase__:   Union[str, Any]    						=CLIPVisionModel(UpperCAmelCase_)
   return model

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     Optional[Any]) ->Optional[Any]:



   '''simple docstring'''



   lowerCamelCase__:   str    						=CLIPImageProcessor(
       crop_size=224 ,				do_center_crop=UpperCAmelCase_ ,				do_normalize=UpperCAmelCase_ ,				do_resize=UpperCAmelCase_ ,				image_mean=[0.4814_5466, 0.457_8275, 0.4082_1073] ,				image_std=[0.2686_2954, 0.2613_0258, 0.2757_7711] ,				resample=3 ,				size=224 ,				)

   return image_processor

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     Dict) ->Optional[int]:



   '''simple docstring'''



   torch.manual_seed(0)

   lowerCamelCase__:   str    						={
       "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,
   }

   lowerCamelCase__:   Optional[int]    						=PriorTransformer(**UpperCAmelCase_)
   return model

 @property
 def 							SCREAMING_SNAKE_CASE_      (self       :     Tuple) ->Dict:



   '''simple docstring'''



   torch.manual_seed(0)

   lowerCamelCase__:   Tuple    						={
       "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,
       ),
   }
   lowerCamelCase__:   Any    						=ShapERenderer(**UpperCAmelCase_)
   return model

 def 							SCREAMING_SNAKE_CASE_      (self       :     Any) ->Any:



   '''simple docstring'''



   lowerCamelCase__:   Optional[Any]    						=self.dummy_prior
   lowerCamelCase__:   str    						=self.dummy_image_encoder
   lowerCamelCase__:   Any    						=self.dummy_image_processor
   lowerCamelCase__:   Dict    						=self.dummy_renderer

   lowerCamelCase__:   Tuple    						=HeunDiscreteScheduler(
       beta_schedule="exp" ,				num_train_timesteps=1_024 ,				prediction_type="sample" ,				use_karras_sigmas=UpperCAmelCase_ ,				clip_sample=UpperCAmelCase_ ,				clip_sample_range=1.0 ,				)
   lowerCamelCase__:   Tuple    						={
       "prior": prior,
       "image_encoder": image_encoder,
       "image_processor": image_processor,
       "renderer": renderer,
       "scheduler": scheduler,
   }

   return components

 def 							SCREAMING_SNAKE_CASE_      (self       :     Optional[int] ,				UpperCAmelCase_       :     Union[str, Any] ,				UpperCAmelCase_       :     Any=0) ->int:



   '''simple docstring'''



   lowerCamelCase__:   int    						=floats_tensor((1, 3, 64, 64) ,				rng=random.Random(UpperCAmelCase_)).to(UpperCAmelCase_)

   if str(UpperCAmelCase_).startswith("mps"):
     lowerCamelCase__:   List[str]    						=torch.manual_seed(UpperCAmelCase_)
   else:
     lowerCamelCase__:   Any    						=torch.Generator(device=UpperCAmelCase_).manual_seed(UpperCAmelCase_)
   lowerCamelCase__:   Tuple    						={
       "image": input_image,
       "generator": generator,
       "num_inference_steps": 1,
       "frame_size": 32,
       "output_type": "np",
   }
   return inputs

 def 							SCREAMING_SNAKE_CASE_      (self       :     List[str]) ->List[Any]:



   '''simple docstring'''



   lowerCamelCase__:   List[Any]    						="cpu"

   lowerCamelCase__:   Optional[Any]    						=self.get_dummy_components()

   lowerCamelCase__:   str    						=self.pipeline_class(**UpperCAmelCase_)
   lowerCamelCase__:   Optional[int]    						=pipe.to(UpperCAmelCase_)

   pipe.set_progress_bar_config(disable=UpperCAmelCase_)

   lowerCamelCase__:   str    						=pipe(**self.get_dummy_inputs(UpperCAmelCase_))
   lowerCamelCase__:   int    						=output.images[0]
   lowerCamelCase__:   Optional[int]    						=image[0, -3:, -3:, -1]

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

   lowerCamelCase__:   Any    						=np.array(
       [
           0.0003_9216,
           0.0003_9216,
           0.0003_9216,
           0.0003_9216,
           0.0003_9216,
           0.0003_9216,
           0.0003_9216,
           0.0003_9216,
           0.0003_9216,
       ])

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

 def 							SCREAMING_SNAKE_CASE_      (self       :     List[str]) ->Dict:



   '''simple docstring'''



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

 def 							SCREAMING_SNAKE_CASE_      (self       :     List[Any]) ->Union[str, Any]:



   '''simple docstring'''



   lowerCamelCase__:   str    						=torch_device == "cpu"
   lowerCamelCase__:   str    						=True
   self._test_inference_batch_single_identical(
       batch_size=2 ,				test_max_difference=UpperCAmelCase_ ,				relax_max_difference=UpperCAmelCase_ ,				)







 def 							SCREAMING_SNAKE_CASE_      (self       :     Optional[int]) ->str:



   '''simple docstring'''



   lowerCamelCase__:   Any    						=self.get_dummy_components()
   lowerCamelCase__:   List[str]    						=self.pipeline_class(**UpperCAmelCase_)
   lowerCamelCase__:   Union[str, Any]    						=pipe.to(UpperCAmelCase_)
   pipe.set_progress_bar_config(disable=UpperCAmelCase_)

   lowerCamelCase__:   Union[str, Any]    						=1
   lowerCamelCase__:   List[str]    						=2

   lowerCamelCase__:   int    						=self.get_dummy_inputs(UpperCAmelCase_)

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

   lowerCamelCase__:   List[str]    						=pipe(**UpperCAmelCase_ ,				num_images_per_prompt=UpperCAmelCase_)[0]

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



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







 '''simple docstring'''

 def 							SCREAMING_SNAKE_CASE_      (self       :     str) ->Optional[int]:



   '''simple docstring'''



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







 def 							SCREAMING_SNAKE_CASE_      (self       :     Optional[int]) ->Optional[int]:



   '''simple docstring'''



   lowerCamelCase__:   str    						=load_image(
       "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/shap_e/corgi.png")
   lowerCamelCase__:   Optional[Any]    						=load_numpy(
       "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
       "/shap_e/test_shap_e_img2img_out.npy")
   lowerCamelCase__:   Tuple    						=ShapEImgaImgPipeline.from_pretrained("openai/shap-e-img2img")
   lowerCamelCase__:   str    						=pipe.to(UpperCAmelCase_)
   pipe.set_progress_bar_config(disable=UpperCAmelCase_)

   lowerCamelCase__:   int    						=torch.Generator(device=UpperCAmelCase_).manual_seed(0)

   lowerCamelCase__:   Union[str, Any]    						=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_)

