






from typing import List, Optional, Tuple, Union

import PIL
import torch
from torchvision import transforms

from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput
from diffusers.schedulers import DDIMScheduler
from diffusers.utils import randn_tensor


__UpperCamelCase      :      Dict     						=						transforms.Compose(
    [
        transforms.Resize((256, 256)),
        transforms.ToTensor(),
        transforms.Normalize([0.5], [0.5]),
    ]
)





def 				snake_case  (     lowerCamelCase					):




	'''simple docstring'''







	if isinstance(lowerCamelCase				,  torch.Tensor					):
		return image
	elif isinstance(lowerCamelCase				,  PIL.Image.Image					):
		__lowercase             =  [image]

	__lowercase             =  [trans(img.convert("""RGB"""					)					) for img in image]
	__lowercase             =  torch.stack(lowerCamelCase					)
	return image




class        __UpperCamelCase    (     _lowerCAmelCase   ):







	def __init__(  self      :							Dict       ,				_lowerCAmelCase      :							str       ,				_lowerCAmelCase      :							Optional[Any]			)		-> Dict:
		"""simple docstring"""







		super().__init__()

		# make sure scheduler can always be converted to DDIM
		__lowercase             =  DDIMScheduler.from_config(scheduler.config			)

		self.register_modules(unet=_lowerCAmelCase       ,				scheduler=_lowerCAmelCase			)







	def  _a   (  self      :							Union[str, Any]       ,				_lowerCAmelCase      :							List[Any]			)		-> List[str]:
		"""simple docstring"""







		if strength < 0 or strength > 1:
			raise ValueError(F'The value of strength should in [0.0, 1.0] but is {strength}'			)







	def  _a   (  self      :							str       ,				_lowerCAmelCase      :							Any       ,				_lowerCAmelCase      :							List[str]       ,				_lowerCAmelCase      :							Optional[Any]			)		-> str:
		"""simple docstring"""







		__lowercase             =  min(int(num_inference_steps * strength			)       ,				_lowerCAmelCase			)

		__lowercase             =  max(num_inference_steps - init_timestep       ,				0			)
		__lowercase             =  self.scheduler.timesteps[t_start:]

		return timesteps, num_inference_steps - t_start







	def  _a   (  self      :							int       ,				_lowerCAmelCase      :							str       ,				_lowerCAmelCase      :							Optional[Any]       ,				_lowerCAmelCase      :							str       ,				_lowerCAmelCase      :							Union[str, Any]       ,				_lowerCAmelCase      :							str       ,				_lowerCAmelCase      :							List[Any]=None			)		-> Optional[int]:
		"""simple docstring"""







		if not isinstance(_lowerCAmelCase       ,				(torch.Tensor, PIL.Image.Image, list)			):
			raise ValueError(
			    F'`image` has to be of type `torch.Tensor`, `PIL.Image.Image` or list but is {type(_lowerCAmelCase			)}'			)

		__lowercase             =  image.to(device=_lowerCAmelCase       ,				dtype=_lowerCAmelCase			)

		if isinstance(_lowerCAmelCase       ,				_lowerCAmelCase			) and len(_lowerCAmelCase			) != batch_size:
			raise ValueError(
			    F'You have passed a list of generators of length {len(_lowerCAmelCase			)}, but requested an effective batch'
			    F' size of {batch_size}. Make sure the batch size matches the length of the generators.'			)

		__lowercase             =  init_latents.shape
		__lowercase             =  randn_tensor(_lowerCAmelCase       ,				generator=_lowerCAmelCase       ,				device=_lowerCAmelCase       ,				dtype=_lowerCAmelCase			)

		# get latents
		print("""add noise to latents at timestep"""       ,				_lowerCAmelCase			)
		__lowercase             =  self.scheduler.add_noise(_lowerCAmelCase       ,				_lowerCAmelCase       ,				_lowerCAmelCase			)
		__lowercase             =  init_latents

		return latents







	@torch.no_grad()
	def __call__(  self      :							Any       ,				_lowerCAmelCase      :							Union[torch.FloatTensor, PIL.Image.Image] = None       ,				_lowerCAmelCase      :							float = 0.8       ,				_lowerCAmelCase      :							int = 1       ,				_lowerCAmelCase      :							Optional[Union[torch.Generator, List[torch.Generator]]] = None       ,				_lowerCAmelCase      :							float = 0.0       ,				_lowerCAmelCase      :							int = 50       ,				_lowerCAmelCase      :							Optional[bool] = None       ,				_lowerCAmelCase      :							Optional[str] = "pil"       ,				_lowerCAmelCase      :							bool = True       ,				)		-> Union[ImagePipelineOutput, Tuple]:
		"""simple docstring"""







		self.check_inputs(_lowerCAmelCase			)

		# 2. Preprocess image
		__lowercase             =  preprocess(_lowerCAmelCase			)

		# 3. set timesteps
		self.scheduler.set_timesteps(_lowerCAmelCase       ,				device=self.device			)
		__lowercase       ,						__lowercase             =  self.get_timesteps(_lowerCAmelCase       ,				_lowerCAmelCase       ,				self.device			)
		__lowercase             =  timesteps[:1].repeat(_lowerCAmelCase			)

		# 4. Prepare latent variables
		__lowercase             =  self.prepare_latents(_lowerCAmelCase       ,				_lowerCAmelCase       ,				_lowerCAmelCase       ,				self.unet.dtype       ,				self.device       ,				_lowerCAmelCase			)
		__lowercase             =  latents

		# 5. Denoising loop
		for t in self.progress_bar(_lowerCAmelCase			):
			# 1. predict noise model_output
			__lowercase             =  self.unet(_lowerCAmelCase       ,				_lowerCAmelCase			).sample

			# 2. predict previous mean of image x_t-1 and add variance depending on eta
			# eta corresponds to η in paper and should be between [0, 1]
			# do x_t -> x_t-1
			__lowercase             =  self.scheduler.step(
			    _lowerCAmelCase       ,				_lowerCAmelCase       ,				_lowerCAmelCase       ,				eta=_lowerCAmelCase       ,				use_clipped_model_output=_lowerCAmelCase       ,				generator=_lowerCAmelCase       ,				).prev_sample

		__lowercase             =  (image / 2 + 0.5).clamp(0       ,				1			)
		__lowercase             =  image.cpu().permute(0       ,				2       ,				3       ,				1			).numpy()
		if output_type == "pil":
			__lowercase             =  self.numpy_to_pil(_lowerCAmelCase			)

		if not return_dict:
			return (image, latent_timestep.item())

		return ImagePipelineOutput(images=_lowerCAmelCase			)









import inspect
import unittest
from typing import List

import numpy as np

from transformers import EfficientFormerConfig
from transformers.testing_utils import require_tf, require_vision, slow
from transformers.utils import cached_property, is_tf_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
						import tensorflow as tf

						from transformers import (
						    TFEfficientFormerForImageClassification,
						    TFEfficientFormerForImageClassificationWithTeacher,
						    TFEfficientFormerModel,
						)
						from transformers.models.efficientformer.modeling_tf_efficientformer import (
						    TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
						)


if is_vision_available():
						from PIL import Image

						from transformers import EfficientFormerImageProcessor


class        __UpperCamelCase    :







	def __init__(  self      :							int       ,				_lowerCAmelCase      :							Tuple       ,				_lowerCAmelCase      :							int = 13       ,				_lowerCAmelCase      :							int = 64       ,				_lowerCAmelCase      :							int = 2       ,				_lowerCAmelCase      :							int = 3       ,				_lowerCAmelCase      :							int = 3       ,				_lowerCAmelCase      :							bool = True       ,				_lowerCAmelCase      :							bool = True       ,				_lowerCAmelCase      :							int = 128       ,				_lowerCAmelCase      :							Optional[int]=[16, 32, 64, 128]       ,				_lowerCAmelCase      :							int = 7       ,				_lowerCAmelCase      :							int = 4       ,				_lowerCAmelCase      :							int = 37       ,				_lowerCAmelCase      :							str = "gelu"       ,				_lowerCAmelCase      :							float = 0.1       ,				_lowerCAmelCase      :							float = 0.1       ,				_lowerCAmelCase      :							int = 10       ,				_lowerCAmelCase      :							float = 0.02       ,				_lowerCAmelCase      :							int = 2       ,				_lowerCAmelCase      :							int = 1       ,				_lowerCAmelCase      :							int = 128       ,				_lowerCAmelCase      :							List[int] = [2, 2, 2, 2]       ,				_lowerCAmelCase      :							int = 2       ,				_lowerCAmelCase      :							int = 2       ,				)		-> Tuple:
		"""simple docstring"""







		__lowercase             =  parent
		__lowercase             =  batch_size
		__lowercase             =  image_size
		__lowercase             =  patch_size
		__lowercase             =  num_channels
		__lowercase             =  is_training
		__lowercase             =  use_labels
		__lowercase             =  hidden_size
		__lowercase             =  num_hidden_layers
		__lowercase             =  num_attention_heads
		__lowercase             =  intermediate_size
		__lowercase             =  hidden_act
		__lowercase             =  hidden_dropout_prob
		__lowercase             =  attention_probs_dropout_prob
		__lowercase             =  type_sequence_label_size
		__lowercase             =  initializer_range
		__lowercase             =  encoder_stride
		__lowercase             =  num_attention_outputs
		__lowercase             =  embed_dim
		__lowercase             =  embed_dim + 1
		__lowercase             =  resolution
		__lowercase             =  depths
		__lowercase             =  hidden_sizes
		__lowercase             =  dim
		__lowercase             =  mlp_expansion_ratio







	def  _a   (  self      :							List[Any]			)		-> Optional[int]:
		"""simple docstring"""







		__lowercase             =  floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

		__lowercase             =  None
		if self.use_labels:
			__lowercase             =  ids_tensor([self.batch_size]       ,				self.type_sequence_label_size			)

		__lowercase             =  self.get_config()

		return config, pixel_values, labels







	def  _a   (  self      :							Optional[Any]			)		-> str:
		"""simple docstring"""







		return EfficientFormerConfig(
		    image_size=self.image_size       ,				patch_size=self.patch_size       ,				num_channels=self.num_channels       ,				hidden_size=self.hidden_size       ,				num_hidden_layers=self.num_hidden_layers       ,				num_attention_heads=self.num_attention_heads       ,				intermediate_size=self.intermediate_size       ,				hidden_act=self.hidden_act       ,				hidden_dropout_prob=self.hidden_dropout_prob       ,				attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,				is_decoder=_lowerCAmelCase       ,				initializer_range=self.initializer_range       ,				encoder_stride=self.encoder_stride       ,				resolution=self.resolution       ,				depths=self.depths       ,				hidden_sizes=self.hidden_sizes       ,				dim=self.dim       ,				mlp_expansion_ratio=self.mlp_expansion_ratio       ,				)







	def  _a   (  self      :							Union[str, Any]       ,				_lowerCAmelCase      :							Dict       ,				_lowerCAmelCase      :							List[str]       ,				_lowerCAmelCase      :							Optional[int]			)		-> Optional[int]:
		"""simple docstring"""







		__lowercase             =  TFEfficientFormerModel(config=_lowerCAmelCase			)
		__lowercase             =  model(_lowerCAmelCase       ,				training=_lowerCAmelCase			)
		self.parent.assertEqual(result.last_hidden_state.shape       ,				(self.batch_size, self.seq_length, self.hidden_size)			)







	def  _a   (  self      :							Union[str, Any]       ,				_lowerCAmelCase      :							Dict       ,				_lowerCAmelCase      :							Dict       ,				_lowerCAmelCase      :							Dict			)		-> Optional[Any]:
		"""simple docstring"""







		__lowercase             =  self.type_sequence_label_size
		__lowercase             =  TFEfficientFormerForImageClassification(_lowerCAmelCase			)
		__lowercase             =  model(_lowerCAmelCase       ,				labels=_lowerCAmelCase       ,				training=_lowerCAmelCase			)
		self.parent.assertEqual(result.logits.shape       ,				(self.batch_size, self.type_sequence_label_size)			)

		# test greyscale images
		__lowercase             =  1
		__lowercase             =  TFEfficientFormerForImageClassification(_lowerCAmelCase			)

		__lowercase             =  floats_tensor([self.batch_size, 1, self.image_size, self.image_size]			)
		__lowercase             =  model(_lowerCAmelCase       ,				labels=_lowerCAmelCase			)
		self.parent.assertEqual(result.logits.shape       ,				(self.batch_size, self.type_sequence_label_size)			)







	def  _a   (  self      :							Optional[Any]			)		-> Any:
		"""simple docstring"""







		__lowercase             =  self.prepare_config_and_inputs()
		__lowercase       ,						__lowercase       ,						__lowercase             =  config_and_inputs
		__lowercase             =  {"""pixel_values""": pixel_values}
		return config, inputs_dict


@require_tf
class        __UpperCamelCase    (     _lowerCAmelCase   ,			_lowerCAmelCase   ,			unittest.TestCase   ):
	__snake_case	:Any   =       (
	    (
	        TFEfficientFormerModel,
	        TFEfficientFormerForImageClassificationWithTeacher,
	        TFEfficientFormerForImageClassification,
	    )
	    if is_tf_available()
	    else ()
	)
	__snake_case	:Any   =       (
	    {
	        'feature-extraction': TFEfficientFormerModel,
	        'image-classification': (
	            TFEfficientFormerForImageClassification,
	            TFEfficientFormerForImageClassificationWithTeacher,
	        ),
	    }
	    if is_tf_available()
	    else {}
	)

	__snake_case	:int   =       False

	__snake_case	:Optional[int]   =       False
	__snake_case	:int   =       False
	__snake_case	:Any   =       False
	__snake_case	:Any   =       False







	def  _a   (  self      :							Tuple			)		-> Tuple:
		"""simple docstring"""







		__lowercase             =  TFEfficientFormerModelTester(self			)
		__lowercase             =  ConfigTester(
		    self       ,				config_class=_lowerCAmelCase       ,				has_text_modality=_lowerCAmelCase       ,				hidden_size=37			)







	def  _a   (  self      :							Optional[int]			)		-> int:
		"""simple docstring"""







		self.config_tester.run_common_tests()







	@unittest.skip(reason="""EfficientFormer does not use inputs_embeds"""			)
	def  _a   (  self      :							Optional[int]			)		-> Any:
		"""simple docstring"""







		pass







	@unittest.skip(reason="""EfficientFormer does not support input and output embeddings"""			)
	def  _a   (  self      :							int			)		-> str:
		"""simple docstring"""







		pass







	def  _a   (  self      :							Union[str, Any]			)		-> List[str]:
		"""simple docstring"""







		__lowercase       ,						__lowercase             =  self.model_tester.prepare_config_and_inputs_for_common()

		for model_class in self.all_model_classes:
			__lowercase             =  model_class(_lowerCAmelCase			)
			__lowercase             =  inspect.signature(model.call			)
			# signature.parameters is an OrderedDict => so arg_names order is deterministic
			__lowercase             =  [*signature.parameters.keys()]

			__lowercase             =  ["""pixel_values"""]
			self.assertListEqual(arg_names[:1]       ,				_lowerCAmelCase			)







	def  _a   (  self      :							Union[str, Any]			)		-> Dict:
		"""simple docstring"""







		def check_hidden_states_output(_lowerCAmelCase      :							int       ,				_lowerCAmelCase      :							Any       ,				_lowerCAmelCase      :							List[Any]			):
			__lowercase             =  model_class(_lowerCAmelCase			)

			__lowercase             =  model(**self._prepare_for_class(_lowerCAmelCase       ,				_lowerCAmelCase			)       ,				training=_lowerCAmelCase			)
			__lowercase             =  outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

			__lowercase             =  getattr(
			    self.model_tester       ,				"""expected_num_hidden_layers"""       ,				self.model_tester.num_hidden_layers + 1			)
			self.assertEqual(len(_lowerCAmelCase			)       ,				_lowerCAmelCase			)

			if hasattr(self.model_tester       ,				"""encoder_seq_length"""			):
				__lowercase             =  self.model_tester.encoder_seq_length
				if hasattr(self.model_tester       ,				"""chunk_length"""			) and self.model_tester.chunk_length > 1:
					__lowercase             =  seq_length * self.model_tester.chunk_length
			else:
				__lowercase             =  self.model_tester.seq_length

			self.assertListEqual(
			    list(hidden_states[-1].shape[-2:]			)       ,				[seq_length, self.model_tester.hidden_size]       ,				)

			if config.is_encoder_decoder:
				__lowercase             =  outputs.decoder_hidden_states

				self.asseretIsInstance(_lowerCAmelCase       ,				(list, tuple)			)
				self.assertEqual(len(_lowerCAmelCase			)       ,				_lowerCAmelCase			)
				__lowercase             =  getattr(self.model_tester       ,				"""seq_length"""       ,				_lowerCAmelCase			)
				__lowercase             =  getattr(self.model_tester       ,				"""decoder_seq_length"""       ,				_lowerCAmelCase			)

				self.assertListEqual(
				    list(hidden_states[-1].shape[-2:]			)       ,				[decoder_seq_length, self.model_tester.hidden_size]       ,				)

		__lowercase       ,						__lowercase             =  self.model_tester.prepare_config_and_inputs_for_common()

		for model_class in self.all_model_classes:
			__lowercase             =  True
			check_hidden_states_output(_lowerCAmelCase       ,				_lowerCAmelCase       ,				_lowerCAmelCase			)

			# check that output_hidden_states also work using config
			del inputs_dict["output_hidden_states"]
			__lowercase             =  True

			check_hidden_states_output(_lowerCAmelCase       ,				_lowerCAmelCase       ,				_lowerCAmelCase			)







	def  _a   (  self      :							Optional[Any]       ,				_lowerCAmelCase      :							Any       ,				_lowerCAmelCase      :							str       ,				_lowerCAmelCase      :							Optional[Any]=False			)		-> Dict:
		"""simple docstring"""







		__lowercase             =  super()._prepare_for_class(_lowerCAmelCase       ,				_lowerCAmelCase       ,				return_labels=_lowerCAmelCase			)

		if return_labels:
			if model_class.__name__ == "TFEfficientFormerForImageClassificationWithTeacher":
				del inputs_dict["labels"]

		return inputs_dict







	def  _a   (  self      :							int			)		-> int:
		"""simple docstring"""







		__lowercase             =  self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_model(*_lowerCAmelCase			)







	@unittest.skip(reason="""EfficientFormer does not implement masked image modeling yet"""			)
	def  _a   (  self      :							Union[str, Any]			)		-> str:
		"""simple docstring"""







		__lowercase             =  self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_for_masked_image_modeling(*_lowerCAmelCase			)







	def  _a   (  self      :							Optional[int]			)		-> Union[str, Any]:
		"""simple docstring"""







		__lowercase             =  self.model_tester.prepare_config_and_inputs()
		self.model_tester.create_and_check_for_image_classification(*_lowerCAmelCase			)







	@slow
	def  _a   (  self      :							List[str]			)		-> List[Any]:
		"""simple docstring"""







		for model_name in TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
			__lowercase             =  TFEfficientFormerModel.from_pretrained(_lowerCAmelCase			)
			self.assertIsNotNone(_lowerCAmelCase			)







	def  _a   (  self      :							Any			)		-> List[str]:
		"""simple docstring"""







		__lowercase       ,						__lowercase             =  self.model_tester.prepare_config_and_inputs_for_common()
		__lowercase             =  True

		__lowercase             =  getattr(self.model_tester       ,				"""seq_length"""       ,				_lowerCAmelCase			)
		__lowercase             =  getattr(self.model_tester       ,				"""encoder_seq_length"""       ,				_lowerCAmelCase			)
		__lowercase             =  getattr(self.model_tester       ,				"""key_length"""       ,				_lowerCAmelCase			)
		__lowercase             =  getattr(self.model_tester       ,				"""chunk_length"""       ,				_lowerCAmelCase			)

		if chunk_length is not None and hasattr(self.model_tester       ,				"""num_hashes"""			):
			__lowercase             =  encoder_seq_length * self.model_tester.num_hashes

		for model_class in self.all_model_classes:
			__lowercase             =  True
			__lowercase             =  False
			__lowercase             =  True
			__lowercase             =  model_class(_lowerCAmelCase			)

			__lowercase             =  model(**self._prepare_for_class(_lowerCAmelCase       ,				_lowerCAmelCase			)       ,				training=_lowerCAmelCase			)
			__lowercase             =  outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions
			self.assertEqual(len(_lowerCAmelCase			)       ,				self.model_tester.num_attention_outputs			)

			# check that output_attentions also work using config
			del inputs_dict["output_attentions"]
			__lowercase             =  True
			__lowercase             =  model_class(_lowerCAmelCase			)
			__lowercase             =  model(**self._prepare_for_class(_lowerCAmelCase       ,				_lowerCAmelCase			)       ,				training=_lowerCAmelCase			)

			__lowercase             =  outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions
			self.assertEqual(len(_lowerCAmelCase			)       ,				self.model_tester.num_attention_outputs			)

			if chunk_length is not None:
				self.assertListEqual(
				    list(attentions[0].shape[-4:]			)       ,				[self.model_tester.num_attention_heads, encoder_seq_length, chunk_length, encoder_key_length]       ,				)
			else:
				self.assertListEqual(
				    list(attentions[0].shape[-3:]			)       ,				[self.model_tester.num_attention_heads, encoder_seq_length, encoder_key_length]       ,				)







	def  _a   (  self      :							Dict			)		-> Optional[int]:
		"""simple docstring"""







		__lowercase       ,						__lowercase             =  self.model_tester.prepare_config_and_inputs_for_common()

		for model_class in self.all_model_classes:
			# Prepare our model
			__lowercase             =  model_class(_lowerCAmelCase			)
			# These are maximally general inputs for the model, with multiple None dimensions
			# Hopefully this will catch any conditionals that fail for flexible shapes
			__lowercase             =  {
			    key: tf.keras.Input(shape=val.shape[1:]       ,				dtype=val.dtype       ,				name=_lowerCAmelCase			)
			    for key, val in model.input_signature.items()
			    if key in model.dummy_inputs
			}
			__lowercase             =  model(_lowerCAmelCase			)
			self.assertTrue(outputs_dict is not None			)





def 				snake_case  (     ):




	'''simple docstring'''







	__lowercase             =  Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""					)
	return image




@require_tf
@require_vision
class        __UpperCamelCase    (     unittest.TestCase   ):







	@cached_property
	def  _a   (  self      :							Optional[Any]			)		-> Any:
		"""simple docstring"""







		return (
		    EfficientFormerImageProcessor.from_pretrained("""snap-research/efficientformer-l1-300"""			)
		    if is_vision_available()
		    else None
		)







	@slow
	def  _a   (  self      :							Optional[Any]			)		-> Any:
		"""simple docstring"""







		__lowercase             =  TFEfficientFormerForImageClassification.from_pretrained("""snap-research/efficientformer-l1-300"""			)
		__lowercase             =  self.default_image_processor
		__lowercase             =  prepare_img()
		__lowercase             =  image_processor(images=_lowerCAmelCase       ,				return_tensors="""tf"""			)
		# forward pass
		__lowercase             =  model(**_lowerCAmelCase       ,				training=_lowerCAmelCase			)
		# verify the logits
		__lowercase             =  tf.TensorShape((1, 1000)			)
		self.assertEqual(outputs.logits.shape       ,				_lowerCAmelCase			)
		__lowercase             =  tf.constant([-0.0_555, 0.4_825, -0.0_852]			)
		self.assertTrue(np.allclose(outputs.logits[0, :3]       ,				_lowerCAmelCase       ,				atol=1e-4			)			)







	@slow
	def  _a   (  self      :							Optional[Any]			)		-> Tuple:
		"""simple docstring"""







		__lowercase             =  TFEfficientFormerForImageClassificationWithTeacher.from_pretrained(
		    """snap-research/efficientformer-l1-300"""			)
		__lowercase             =  self.default_image_processor
		__lowercase             =  prepare_img()
		__lowercase             =  image_processor(images=_lowerCAmelCase       ,				return_tensors="""tf"""			)
		# forward pass
		__lowercase             =  model(**_lowerCAmelCase       ,				training=_lowerCAmelCase			)
		# verify the logits
		__lowercase             =  tf.TensorShape((1, 1000)			)
		self.assertEqual(outputs.logits.shape       ,				_lowerCAmelCase			)
		__lowercase             =  tf.constant([-0.1_312, 0.4_353, -1.0_499]			)
		self.assertTrue(np.allclose(outputs.logits[0, :3]       ,				_lowerCAmelCase       ,				atol=1e-4			)			)

