'''simple docstring'''




import gc
import random
import unittest

import numpy as np
import torch
from PIL import Image
from transformers import XLMRobertaTokenizerFast

from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel
from diffusers.pipelines.kandinsky.text_encoder import MCLIPConfig, MultilingualCLIP
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..test_pipelines_common import PipelineTesterMixin, assert_mean_pixel_difference


enable_full_determinism()

class 	lowerCamelCase_	(snake_case__							, unittest.TestCase    ):
      '''simple docstring'''

      __UpperCamelCase:  int						=						KandinskyImgaImgPipeline
      __UpperCamelCase:  Optional[int]						=						["prompt", "image_embeds", "negative_image_embeds", "image"]
      __UpperCamelCase:  Optional[Any]						=						[
          "prompt",
          "negative_prompt",
          "image_embeds",
          "negative_image_embeds",
          "image",
      ]
      __UpperCamelCase:  int						=						[
          "generator",
          "height",
          "width",
          "strength",
          "guidance_scale",
          "negative_prompt",
          "num_inference_steps",
          "return_dict",
          "guidance_scale",
          "num_images_per_prompt",
          "output_type",
          "return_dict",
      ]
      __UpperCamelCase:  Tuple						=						False




      @property
      def      _A	(       self						:				Optional[Any]       ):
             return 32




      @property
      def      _A	(       self						:				Dict       ):
             return 32




      @property
      def      _A	(       self						:				List[str]       ):
             return self.time_input_dim




      @property
      def      _A	(       self						:				str       ):
             return self.time_input_dim * 4




      @property
      def      _A	(       self						:				Dict       ):
             return 100




      @property
      def      _A	(       self						:				Optional[Any]       ):
             _UpperCAmelCase     :  Optional[int]							      =    XLMRobertaTokenizerFast.from_pretrained("YiYiXu/tiny-random-mclip-base"       )
             return tokenizer




      @property
      def      _A	(       self						:				List[Any]       ):
             torch.manual_seed(0       )
             _UpperCAmelCase     :  Any							      =    MCLIPConfig(
                 numDims=self.cross_attention_dim						,					transformerDimensions=self.text_embedder_hidden_size						,					hidden_size=self.text_embedder_hidden_size						,					intermediate_size=37						,					num_attention_heads=4						,					num_hidden_layers=5						,					vocab_size=1005						,					)

             _UpperCAmelCase     :  Optional[int]							      =    MultilingualCLIP(A       )
             _UpperCAmelCase     :  Dict							      =    text_encoder.eval()

             return text_encoder




      @property
      def      _A	(       self						:				Dict       ):
             torch.manual_seed(0       )

             _UpperCAmelCase     :  str							      =    {
                 "in_channels": 4,
                 # Out channels is double in channels because predicts mean and variance
                 "out_channels": 8,
                 "addition_embed_type": "text_image",
                 "down_block_types": ("ResnetDownsampleBlock2D", "SimpleCrossAttnDownBlock2D"),
                 "up_block_types": ("SimpleCrossAttnUpBlock2D", "ResnetUpsampleBlock2D"),
                 "mid_block_type": "UNetMidBlock2DSimpleCrossAttn",
                 "block_out_channels": (self.block_out_channels_a, self.block_out_channels_a * 2),
                 "layers_per_block": 1,
                 "encoder_hid_dim": self.text_embedder_hidden_size,
                 "encoder_hid_dim_type": "text_image_proj",
                 "cross_attention_dim": self.cross_attention_dim,
                 "attention_head_dim": 4,
                 "resnet_time_scale_shift": "scale_shift",
                 "class_embed_type": None,
             }

             _UpperCAmelCase     :  str							      =    UNetaDConditionModel(**A       )
             return model




      @property
      def      _A	(       self						:				str       ):
             return {
                 "block_out_channels": [32, 64],
                 "down_block_types": ["DownEncoderBlock2D", "AttnDownEncoderBlock2D"],
                 "in_channels": 3,
                 "latent_channels": 4,
                 "layers_per_block": 1,
                 "norm_num_groups": 8,
                 "norm_type": "spatial",
                 "num_vq_embeddings": 12,
                 "out_channels": 3,
                 "up_block_types": [
                     "AttnUpDecoderBlock2D",
                     "UpDecoderBlock2D",
                 ],
                 "vq_embed_dim": 4,
             }




      @property
      def      _A	(       self						:				int       ):
             torch.manual_seed(0       )
             _UpperCAmelCase     :  str							      =    VQModel(**self.dummy_movq_kwargs       )
             return model




      def      _A	(       self						:				Union[str, Any]       ):
             _UpperCAmelCase     :  Optional[Any]							      =    self.dummy_text_encoder
             _UpperCAmelCase     :  str							      =    self.dummy_tokenizer
             _UpperCAmelCase     :  int							      =    self.dummy_unet
             _UpperCAmelCase     :  List[str]							      =    self.dummy_movq

             _UpperCAmelCase     :  int							      =    {
                 "num_train_timesteps": 1000,
                 "beta_schedule": "linear",
                 "beta_start": 0.00_085,
                 "beta_end": 0.012,
                 "clip_sample": False,
                 "set_alpha_to_one": False,
                 "steps_offset": 0,
                 "prediction_type": "epsilon",
                 "thresholding": False,
             }

             _UpperCAmelCase     :  List[Any]							      =    DDIMScheduler(**A       )

             _UpperCAmelCase     :  List[Any]							      =    {
                 "text_encoder": text_encoder,
                 "tokenizer": tokenizer,
                 "unet": unet,
                 "scheduler": scheduler,
                 "movq": movq,
             }

             return components




      def      _A	(       self						:				Dict						,					A						:				Any						,					A						:				Dict=0       ):
             _UpperCAmelCase     :  Dict							      =    floats_tensor((1, self.cross_attention_dim)						,					rng=random.Random(A       )       ).to(A       )
             _UpperCAmelCase     :  int							      =    floats_tensor((1, self.cross_attention_dim)						,					rng=random.Random(seed + 1       )       ).to(A       )
             # create init_image
             _UpperCAmelCase     :  int							      =    floats_tensor((1, 3, 64, 64)						,					rng=random.Random(A       )       ).to(A       )
             _UpperCAmelCase     :  Union[str, Any]							      =    image.cpu().permute(0						,					2						,					3						,					1       )[0]
             _UpperCAmelCase     :  Union[str, Any]							      =    Image.fromarray(np.uinta(A       )       ).convert("RGB"       ).resize((256, 256)       )

             if str(A       ).startswith("mps"       ):
                    _UpperCAmelCase     :  str							      =    torch.manual_seed(A       )
             else:
                    _UpperCAmelCase     :  Dict							      =    torch.Generator(device=A       ).manual_seed(A       )
             _UpperCAmelCase     :  Union[str, Any]							      =    {
                 "prompt": "horse",
                 "image": init_image,
                 "image_embeds": image_embeds,
                 "negative_image_embeds": negative_image_embeds,
                 "generator": generator,
                 "height": 64,
                 "width": 64,
                 "num_inference_steps": 10,
                 "guidance_scale": 7.0,
                 "strength": 0.2,
                 "output_type": "np",
             }
             return inputs





      def      _A	(       self						:				List[Any]       ):
             _UpperCAmelCase     :  str							      =    "cpu"

             _UpperCAmelCase     :  Tuple							      =    self.get_dummy_components()

             _UpperCAmelCase     :  Optional[Any]							      =    self.pipeline_class(**A       )
             _UpperCAmelCase     :  Dict							      =    pipe.to(A       )

             pipe.set_progress_bar_config(disable=A       )

             _UpperCAmelCase     :  Optional[Any]							      =    pipe(**self.get_dummy_inputs(A       )       )
             _UpperCAmelCase     :  Union[str, Any]							      =    output.images

             _UpperCAmelCase     :  str							      =    pipe(
                 **self.get_dummy_inputs(A       )						,					return_dict=A						,					)[0]

             _UpperCAmelCase     :  Optional[Any]							      =    image[0, -3:, -3:, -1]
             _UpperCAmelCase     :  Optional[Any]							      =    image_from_tuple[0, -3:, -3:, -1]

             assert image.shape == (1, 64, 64, 3)

             _UpperCAmelCase     :  int							      =    np.array(
                 [0.61_474_943, 0.6_073_539, 0.43_308_544, 0.5_928_269, 0.47_493_595, 0.46_755_973, 0.4_613_838, 0.45_368_797, 0.50_119_233]       )
             assert (
                 np.abs(image_slice.flatten() - expected_slice       ).max() < 1E-2
             ), F""" expected_slice {expected_slice}, but got {image_slice.flatten()}"""
             assert (
                 np.abs(image_from_tuple_slice.flatten() - expected_slice       ).max() < 1E-2
             ), F""" expected_slice {expected_slice}, but got {image_from_tuple_slice.flatten()}"""

@slow
@require_torch_gpu
class 	lowerCamelCase_	(unittest.TestCase    ):
      '''simple docstring'''

      def      _A	(       self						:				Union[str, Any]       ):
             # clean up the VRAM after each test
             super().tearDown()
             gc.collect()
             torch.cuda.empty_cache()





      def      _A	(       self						:				Optional[int]       ):
             _UpperCAmelCase     :  Any							      =    load_numpy(
                 "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
                 "/kandinsky/kandinsky_img2img_frog.npy"       )

             _UpperCAmelCase     :  int							      =    load_image(
                 "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main" "/kandinsky/cat.png"       )
             _UpperCAmelCase     :  Optional[Any]							      =    "A red cartoon frog, 4k"

             _UpperCAmelCase     :  Any							      =    KandinskyPriorPipeline.from_pretrained(
                 "kandinsky-community/kandinsky-2-1-prior"						,					torch_dtype=torch.floataa       )
             pipe_prior.to(A       )

             _UpperCAmelCase     :  List[str]							      =    KandinskyImgaImgPipeline.from_pretrained(
                 "kandinsky-community/kandinsky-2-1"						,					torch_dtype=torch.floataa       )
             _UpperCAmelCase     :  List[Any]							      =    pipeline.to(A       )

             pipeline.set_progress_bar_config(disable=A       )

             _UpperCAmelCase     :  int							      =    torch.Generator(device="cpu"       ).manual_seed(0       )
             _UpperCAmelCase      ,  _UpperCAmelCase     :  Any							      =    pipe_prior(
                 A						,					generator=A						,					num_inference_steps=5						,					negative_prompt=""						,					).to_tuple()

             _UpperCAmelCase     :  int							      =    pipeline(
                 A						,					image=A						,					image_embeds=A						,					negative_image_embeds=A						,					generator=A						,					num_inference_steps=100						,					height=768						,					width=768						,					strength=0.2						,					output_type="np"						,					)

             _UpperCAmelCase     :  List[Any]							      =    output.images[0]

             assert image.shape == (768, 768, 3)

             assert_mean_pixel_difference(A						,					A       )





"""simple docstring"""
import inspect
import unittest

from transformers import ConvNextVaConfig
from transformers.models.auto import get_values
from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES
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 ConvNextVaBackbone, ConvNextVaForImageClassification, ConvNextVaModel
			from transformers.models.convnextva.modeling_convnextva import CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
			from PIL import Image

			from transformers import AutoImageProcessor



class 			_UpperCAmelCase :






		'''simple docstring'''

		def __init__(self				,       a_				,       a_=13				,       a_=32				,       a_=3				,       a_=4				,       a_=[10, 20, 30, 40]				,       a_=[2, 2, 3, 2]				,       a_=True				,       a_=True				,       a_=37				,       a_="gelu"				,       a_=10				,       a_=0.02				,       a_=["stage2", "stage3", "stage4"]				,       a_=[2, 3, 4]				,       a_=None				,       ):





			'''simple docstring'''

			__snake_case	:						List[str]						=				parent
			__snake_case	:						str						=				batch_size
			__snake_case	:						List[Any]						=				image_size
			__snake_case	:						List[Any]						=				num_channels
			__snake_case	:						str						=				num_stages
			__snake_case	:						Any						=				hidden_sizes
			__snake_case	:						Optional[int]						=				depths
			__snake_case	:						Dict						=				is_training
			__snake_case	:						Tuple						=				use_labels
			__snake_case	:						str						=				intermediate_size
			__snake_case	:						Optional[int]						=				hidden_act
			__snake_case	:						Dict						=				num_labels
			__snake_case	:						Tuple						=				initializer_range
			__snake_case	:						Dict						=				out_features
			__snake_case	:						Optional[int]						=				out_indices
			__snake_case	:						str						=				scope



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						Optional[Any]						=				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

			__snake_case	:						str						=				None
			if self.use_labels:
				__snake_case	:						Any						=				ids_tensor([self.batch_size]				,       self.num_labels					)

			__snake_case	:						Dict						=				self.get_config()

			return config, pixel_values, labels



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			return ConvNextVaConfig(
			    num_channels=self.num_channels				,       hidden_sizes=self.hidden_sizes				,       depths=self.depths				,       num_stages=self.num_stages				,       hidden_act=self.hidden_act				,       is_decoder=a_				,       initializer_range=self.initializer_range				,       out_features=self.out_features				,       out_indices=self.out_indices				,       num_labels=self.num_labels				,       )



		def 				SCREAMING_SNAKE_CASE  (self				,       a_				,       a_				,       a_					):





			'''simple docstring'''

			__snake_case	:						Optional[int]						=				ConvNextVaModel(config=a_					)
			model.to(a_					)
			model.eval()
			__snake_case	:						Any						=				model(a_					)
			# expected last hidden states: B, C, H // 32, W // 32
			self.parent.assertEqual(
			    result.last_hidden_state.shape				,       (self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32)				,       )



		def 				SCREAMING_SNAKE_CASE  (self				,       a_				,       a_				,       a_					):





			'''simple docstring'''

			__snake_case	:						Any						=				ConvNextVaForImageClassification(a_					)
			model.to(a_					)
			model.eval()
			__snake_case	:						Union[str, Any]						=				model(a_				,       labels=a_					)
			self.parent.assertEqual(result.logits.shape				,       (self.batch_size, self.num_labels)					)



		def 				SCREAMING_SNAKE_CASE  (self				,       a_				,       a_				,       a_					):





			'''simple docstring'''

			__snake_case	:						Dict						=				ConvNextVaBackbone(config=a_					)
			model.to(a_					)
			model.eval()
			__snake_case	:						Tuple						=				model(a_					)

			# verify hidden states
			self.parent.assertEqual(len(result.feature_maps					)				,       len(config.out_features					)					)
			self.parent.assertListEqual(list(result.feature_maps[0].shape					)				,       [self.batch_size, self.hidden_sizes[1], 4, 4]					)

			# verify channels
			self.parent.assertEqual(len(model.channels					)				,       len(config.out_features					)					)
			self.parent.assertListEqual(model.channels				,       config.hidden_sizes[1:]					)

			# verify backbone works with out_features=None
			__snake_case	:						str						=				None
			__snake_case	:						Optional[Any]						=				ConvNextVaBackbone(config=a_					)
			model.to(a_					)
			model.eval()
			__snake_case	:						Tuple						=				model(a_					)

			# verify feature maps
			self.parent.assertEqual(len(result.feature_maps					)				,       1					)
			self.parent.assertListEqual(list(result.feature_maps[0].shape					)				,       [self.batch_size, self.hidden_sizes[-1], 1, 1]					)

			# verify channels
			self.parent.assertEqual(len(model.channels					)				,       1					)
			self.parent.assertListEqual(model.channels				,       [config.hidden_sizes[-1]]					)



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						int						=				self.prepare_config_and_inputs()
			__snake_case	,							__snake_case	,							__snake_case	:						Union[str, Any]						=				config_and_inputs
			__snake_case	:						Any						=				{'''pixel_values''': pixel_values}
			return config, inputs_dict



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						int						=				self.prepare_config_and_inputs()
			__snake_case	,							__snake_case	,							__snake_case	:						Union[str, Any]						=				config_and_inputs
			__snake_case	:						Optional[int]						=				{'''pixel_values''': pixel_values, '''labels''': labels}
			return config, inputs_dict



@require_torch
class 			_UpperCAmelCase (							__snake_case,				__snake_case,				unittest.TestCase				):






		'''simple docstring'''

		lowerCamelCase__				=(
		    (
		        ConvNextVaModel,
		        ConvNextVaForImageClassification,
		        ConvNextVaBackbone,
		    )
		    if is_torch_available()
		    else ()
		)
		lowerCamelCase__				=(
		    {'feature-extraction': ConvNextVaModel, 'image-classification': ConvNextVaForImageClassification}
		    if is_torch_available()
		    else {}
		)

		lowerCamelCase__				=False
		lowerCamelCase__				=False
		lowerCamelCase__				=False
		lowerCamelCase__				=False
		lowerCamelCase__				=False



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						Dict						=				ConvNextVaModelTester(self					)
			__snake_case	:						Union[str, Any]						=				ConfigTester(self				,       config_class=a_				,       has_text_modality=a_				,       hidden_size=37					)



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			self.create_and_test_config_common_properties()
			self.config_tester.create_and_test_config_to_json_string()
			self.config_tester.create_and_test_config_to_json_file()
			self.config_tester.create_and_test_config_from_and_save_pretrained()
			self.config_tester.create_and_test_config_with_num_labels()
			self.config_tester.check_config_can_be_init_without_params()
			self.config_tester.check_config_arguments_init()



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			return



		@unittest.skip(reason='''ConvNextV2 does not use inputs_embeds'''					)
		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			pass



		@unittest.skip(reason='''ConvNextV2 does not support input and output embeddings'''					)
		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			pass



		@unittest.skip(reason='''ConvNextV2 does not use feedforward chunking'''					)
		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			pass



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			if not self.model_tester.is_training:
				return

			for model_class in self.all_model_classes:
				__snake_case	,							__snake_case	:						str						=				self.model_tester.prepare_config_and_inputs_with_labels()
				__snake_case	:						int						=				True

				if model_class.__name__ in [
				    *get_values(a_					),
				    *get_values(a_					),
				]:
					continue

				__snake_case	:						Dict						=				model_class(a_					)
				model.to(a_					)
				model.train()
				__snake_case	:						Tuple						=				self._prepare_for_class(a_				,       a_				,       return_labels=a_					)
				__snake_case	:						List[str]						=				model(**a_					).loss
				loss.backward()



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			if not self.model_tester.is_training:
				return

			for model_class in self.all_model_classes:
				__snake_case	,							__snake_case	:						Optional[Any]						=				self.model_tester.prepare_config_and_inputs_with_labels()
				__snake_case	:						Optional[Any]						=				False
				__snake_case	:						Tuple						=				True

				if (
				    model_class.__name__
				    in [*get_values(a_					), *get_values(a_					)]
				    or not model_class.supports_gradient_checkpointing
				):
					continue

				__snake_case	:						Union[str, Any]						=				model_class(a_					)
				model.to(a_					)
				model.gradient_checkpointing_enable()
				model.train()
				__snake_case	:						str						=				self._prepare_for_class(a_				,       a_				,       return_labels=a_					)
				__snake_case	:						Union[str, Any]						=				model(**a_					).loss
				loss.backward()



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	,							__snake_case	:						Optional[Any]						=				self.model_tester.prepare_config_and_inputs_for_common()

			for model_class in self.all_model_classes:
				__snake_case	:						Optional[Any]						=				model_class(a_					)
				__snake_case	:						int						=				inspect.signature(model.forward					)
				# signature.parameters is an OrderedDict => so arg_names order is deterministic
				__snake_case	:						int						=				[*signature.parameters.keys()]

				__snake_case	:						Any						=				['''pixel_values''']
				self.assertListEqual(arg_names[:1]				,       a_					)



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						str						=				self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_model(*a_					)



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			def check_hidden_states_output(a_				,       a_				,       a_					):
				__snake_case	:						Tuple						=				model_class(a_					)
				model.to(a_					)
				model.eval()

				with torch.no_grad():
					__snake_case	:						Union[str, Any]						=				model(**self._prepare_for_class(a_				,       a_					)					)

				__snake_case	:						Union[str, Any]						=				outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

				__snake_case	:						List[Any]						=				self.model_tester.num_stages
				self.assertEqual(len(a_					)				,       expected_num_stages + 1					)

				# ConvNextV2's feature maps are of shape (batch_size, num_channels, height, width)
				self.assertListEqual(
				    list(hidden_states[0].shape[-2:]					)				,       [self.model_tester.image_size // 4, self.model_tester.image_size // 4]				,       )

			__snake_case	,							__snake_case	:						List[Any]						=				self.model_tester.prepare_config_and_inputs_for_common()

			for model_class in self.all_model_classes:
				__snake_case	:						str						=				True
				check_hidden_states_output(a_				,       a_				,       a_					)

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

				check_hidden_states_output(a_				,       a_				,       a_					)



		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						str						=				self.model_tester.prepare_config_and_inputs()
			self.model_tester.create_and_check_for_image_classification(*a_					)



		@slow
		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			for model_name in CONVNEXTV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
				__snake_case	:						str						=				ConvNextVaModel.from_pretrained(a_					)
				self.assertIsNotNone(a_					)






def 		lowercase							(     )     ->Any:
	"""simple docstring"""





	__snake_case	:						List[str]						=				Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''     )
	return image



@require_torch
@require_vision
class 			_UpperCAmelCase (							unittest.TestCase				):






		'''simple docstring'''

		@cached_property
		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			return AutoImageProcessor.from_pretrained('''facebook/convnextv2-tiny-1k-224'''					) if is_vision_available() else None



		@slow
		def 				SCREAMING_SNAKE_CASE  (self					):





			'''simple docstring'''

			__snake_case	:						str						=				ConvNextVaForImageClassification.from_pretrained('''facebook/convnextv2-tiny-1k-224'''					).to(a_					)

			__snake_case	:						Dict						=				self.default_image_processor
			__snake_case	:						Tuple						=				prepare_img()
			__snake_case	:						Tuple						=				preprocessor(images=a_				,       return_tensors='''pt'''					).to(a_					)

			# forward pass
			with torch.no_grad():
				__snake_case	:						Union[str, Any]						=				model(**a_					)

			# verify the logits
			__snake_case	:						Tuple						=				torch.Size((1, 10_00)					)
			self.assertEqual(outputs.logits.shape				,       a_					)

			__snake_case	:						Any						=				torch.tensor([0.9996, 0.1966, -0.4386]					).to(a_					)
			self.assertTrue(torch.allclose(outputs.logits[0, :3]				,       a_				,       atol=1E-4					)					)





