





import argparse
import json
from pathlib import Path

import requests
import torch
from huggingface_hub import cached_download, hf_hub_url
from PIL import Image

from transformers import DeformableDetrConfig, DeformableDetrForObjectDetection, DeformableDetrImageProcessor
from transformers.utils import logging


logging.set_verbosity_info()
a__		    =    logging.get_logger(__name__)





def 							A__   (snake_case      :		Dict							)    ->	Tuple:
					if "backbone.0.body" in orig_key:
										__UpperCamelCase				:  str								=			orig_key.replace("""backbone.0.body"""		,  """backbone.conv_encoder.model"""							)
					if "transformer" in orig_key:
										__UpperCamelCase				:  str								=			orig_key.replace("""transformer."""		,  """"""							)
					if "norm1" in orig_key:
										if "encoder" in orig_key:
															__UpperCamelCase				:  str								=			orig_key.replace("""norm1"""		,  """self_attn_layer_norm"""							)
										else:
															__UpperCamelCase				:  Tuple								=			orig_key.replace("""norm1"""		,  """encoder_attn_layer_norm"""							)
					if "norm2" in orig_key:
										if "encoder" in orig_key:
															__UpperCamelCase				:  Optional[Any]								=			orig_key.replace("""norm2"""		,  """final_layer_norm"""							)
										else:
															__UpperCamelCase				:  List[str]								=			orig_key.replace("""norm2"""		,  """self_attn_layer_norm"""							)
					if "norm3" in orig_key:
										__UpperCamelCase				:  Optional[int]								=			orig_key.replace("""norm3"""		,  """final_layer_norm"""							)
					if "linear1" in orig_key:
										__UpperCamelCase				:  Tuple								=			orig_key.replace("""linear1"""		,  """fc1"""							)
					if "linear2" in orig_key:
										__UpperCamelCase				:  List[str]								=			orig_key.replace("""linear2"""		,  """fc2"""							)
					if "query_embed" in orig_key:
										__UpperCamelCase				:  Dict								=			orig_key.replace("""query_embed"""		,  """query_position_embeddings"""							)
					if "cross_attn" in orig_key:
										__UpperCamelCase				:  Tuple								=			orig_key.replace("""cross_attn"""		,  """encoder_attn"""							)

					return orig_key





def 							A__   (snake_case      :		Union[str, Any]							)    ->	Optional[int]:
					# transformer decoder self-attention layers
					for i in range(6							):
										# read in weights + bias of input projection layer of self-attention
										__UpperCamelCase				:  List[Any]								=			state_dict.pop(F'''decoder.layers.{i}.self_attn.in_proj_weight'''							)
										__UpperCamelCase				:  str								=			state_dict.pop(F'''decoder.layers.{i}.self_attn.in_proj_bias'''							)
										# next, add query, keys and values (in that order) to the state dict
										__UpperCamelCase				:  Optional[int]								=			in_proj_weight[:2_56, :]
										__UpperCamelCase				:  List[str]								=			in_proj_bias[:2_56]
										__UpperCamelCase				:  Optional[Any]								=			in_proj_weight[2_56:5_12, :]
										__UpperCamelCase				:  Any								=			in_proj_bias[2_56:5_12]
										__UpperCamelCase				:  Any								=			in_proj_weight[-2_56:, :]
										__UpperCamelCase				:  Optional[Any]								=			in_proj_bias[-2_56:]





def 							A__   ()    ->	List[str]:
					__UpperCamelCase				:  int								=			"""http://images.cocodataset.org/val2017/000000039769.jpg"""
					__UpperCamelCase				:  Tuple								=			Image.open(requests.get(lowercase__		,  stream=lowercase__							).raw							)

					return im





@torch.no_grad()
def 							A__   (snake_case      :		Tuple		,  snake_case      :		List[Any]		,  snake_case      :		List[str]		,  snake_case      :		Optional[Any]		,  snake_case      :		Tuple		,  snake_case      :		int		,  snake_case      :		int		,  )    ->	int:
					__UpperCamelCase				:  Dict								=			DeformableDetrConfig()
					# set config attributes
					if single_scale:
										__UpperCamelCase				:  Optional[Any]								=			1
					__UpperCamelCase				:  Any								=			dilation
					__UpperCamelCase				:  List[str]								=			with_box_refine
					__UpperCamelCase				:  Optional[int]								=			two_stage
					# set labels
					__UpperCamelCase				:  int								=			91
					__UpperCamelCase				:  Optional[Any]								=			"""huggingface/label-files"""
					__UpperCamelCase				:  Tuple								=			"""coco-detection-id2label.json"""
					__UpperCamelCase				:  Union[str, Any]								=			json.load(open(cached_download(hf_hub_url(lowercase__		,  lowercase__		,  repo_type="""dataset"""							)							)		,  """r"""							)							)
					__UpperCamelCase				:  int								=			{int(lowercase__							): v for k, v in idalabel.items()}
					__UpperCamelCase				:  int								=			idalabel
					__UpperCamelCase				:  Dict								=			{v: k for k, v in idalabel.items()}

					# load image processor
					__UpperCamelCase				:  Optional[Any]								=			DeformableDetrImageProcessor(format="""coco_detection"""							)

					# prepare image
					__UpperCamelCase				:  Optional[Any]								=			prepare_img()
					__UpperCamelCase				:  int								=			image_processor(images=lowercase__		,  return_tensors="""pt"""							)
					__UpperCamelCase				:  int								=			encoding["""pixel_values"""]

					logger.info("""Converting model..."""							)

					# load original state dict
					__UpperCamelCase				:  Any								=			torch.load(lowercase__		,  map_location="""cpu"""							)["""model"""]
					# rename keys
					for key in state_dict.copy().keys():
										__UpperCamelCase				:  Union[str, Any]								=			state_dict.pop(lowercase__							)
										__UpperCamelCase				:  Optional[int]								=			val
					# query, key and value matrices need special treatment
					read_in_q_k_v(lowercase__							)
					# important: we need to prepend a prefix to each of the base model keys as the head models use different attributes for them
					__UpperCamelCase				:  Optional[Any]								=			"""model."""
					for key in state_dict.copy().keys():
										if not key.startswith("""class_embed"""							) and not key.startswith("""bbox_embed"""							):
															__UpperCamelCase				:  List[str]								=			state_dict.pop(lowercase__							)
															__UpperCamelCase				:  Union[str, Any]								=			val
    # finally, create HuggingFace model and load state dict
					__UpperCamelCase				:  Optional[int]								=			DeformableDetrForObjectDetection(lowercase__							)
					model.load_state_dict(lowercase__							)
					model.eval()

					__UpperCamelCase				:  Dict								=			"""cuda""" if torch.cuda.is_available() else """cpu"""
					model.to(lowercase__							)
					# verify our conversion
					__UpperCamelCase				:  Any								=			model(pixel_values.to(lowercase__							)							)

					__UpperCamelCase				:  Union[str, Any]								=			torch.tensor(
					    [[-9.6645, -4.3449, -5.8705], [-9.7035, -3.8504, -5.0724], [-10.56_34, -5.3379, -7.5116]]							)
					__UpperCamelCase				:  Union[str, Any]								=			torch.tensor([[0.8693, 0.2289, 0.2492], [0.3150, 0.5489, 0.5845], [0.5563, 0.7580, 0.8518]]							)

					if single_scale:
										__UpperCamelCase				:  Optional[int]								=			torch.tensor(
										    [[-9.9051, -4.2541, -6.4852], [-9.6947, -4.0854, -6.8033], [-10.06_65, -5.8470, -7.7003]]							)
										__UpperCamelCase				:  Tuple								=			torch.tensor([[0.7292, 0.4991, 0.5532], [0.7959, 0.2426, 0.4236], [0.7582, 0.3518, 0.4451]]							)

					if single_scale and dilation:
										__UpperCamelCase				:  Dict								=			torch.tensor(
										    [[-8.9652, -4.1074, -5.6635], [-9.0596, -4.9447, -6.6075], [-10.11_78, -4.5275, -6.2671]]							)
										__UpperCamelCase				:  Tuple								=			torch.tensor([[0.7665, 0.4130, 0.4769], [0.8364, 0.1841, 0.3391], [0.6261, 0.3895, 0.7978]]							)

					if with_box_refine:
										__UpperCamelCase				:  Any								=			torch.tensor(
										    [[-8.8895, -5.4187, -6.8153], [-8.4706, -6.1668, -7.6184], [-9.0042, -5.5359, -6.9141]]							)
										__UpperCamelCase				:  Dict								=			torch.tensor([[0.7828, 0.2208, 0.4323], [0.0892, 0.5996, 0.1319], [0.5524, 0.6389, 0.8914]]							)

					if with_box_refine and two_stage:
										__UpperCamelCase				:  List[str]								=			torch.tensor(
										    [[-6.7108, -4.3213, -6.3777], [-8.9014, -6.1799, -6.7240], [-6.9315, -4.4735, -6.2298]]							)
										__UpperCamelCase				:  List[str]								=			torch.tensor([[0.2583, 0.5499, 0.4683], [0.7652, 0.9068, 0.4882], [0.5490, 0.2763, 0.0564]]							)

					print("""Logits:"""		,  outputs.logits[0, :3, :3]							)

					assert torch.allclose(outputs.logits[0, :3, :3]		,  expected_logits.to(lowercase__							)		,  atol=1e-4							)
					assert torch.allclose(outputs.pred_boxes[0, :3, :3]		,  expected_boxes.to(lowercase__							)		,  atol=1e-4							)

					print("""Everything ok!"""							)

					# Save model and image processor
					logger.info(F'''Saving PyTorch model and image processor to {pytorch_dump_folder_path}...'''							)
					Path(lowercase__							).mkdir(exist_ok=lowercase__							)
					model.save_pretrained(lowercase__							)
					image_processor.save_pretrained(lowercase__							)

					# Push to hub
					if push_to_hub:
										__UpperCamelCase				:  Any								=			"""deformable-detr"""
										model_name += "-single-scale" if single_scale else ""
										model_name += "-dc5" if dilation else ""
										model_name += "-with-box-refine" if with_box_refine else ""
										model_name += "-two-stage" if two_stage else ""
										print("""Pushing model to hub..."""							)
										model.push_to_hub(repo_path_or_name=lowercase__		,  organization="""nielsr"""		,  commit_message="""Add model"""							)


if __name__ == "__main__":
	a__		    =    argparse.ArgumentParser()

	parser.add_argument(
	    '''--checkpoint_path''',
	    type=str,
	    default='''/home/niels/checkpoints/deformable_detr/r50_deformable_detr-checkpoint.pth''',
	    help='''Path to Pytorch checkpoint (.pth file) you\'d like to convert.''',
	)
	parser.add_argument('''--single_scale''', action='''store_true''', help='''Whether to set config.num_features_levels = 1.''')
	parser.add_argument('''--dilation''', action='''store_true''', help='''Whether to set config.dilation=True.''')
	parser.add_argument('''--with_box_refine''', action='''store_true''', help='''Whether to set config.with_box_refine=True.''')
	parser.add_argument('''--two_stage''', action='''store_true''', help='''Whether to set config.two_stage=True.''')
	parser.add_argument(
	    '''--pytorch_dump_folder_path''',
	    default=None,
	    type=str,
	    required=True,
	    help='''Path to the folder to output PyTorch model.''',
	)
	parser.add_argument(
	    '''--push_to_hub''', action='''store_true''', help='''Whether or not to push the converted model to the 🤗 hub.'''
	)
	a__		    =    parser.parse_args()
	convert_deformable_detr_checkpoint(
	    args.checkpoint_path,
	    args.single_scale,
	    args.dilation,
	    args.with_box_refine,
	    args.two_stage,
	    args.pytorch_dump_folder_path,
	    args.push_to_hub,
	)












import inspect
import unittest

from transformers import EfficientNetConfig
from transformers.testing_utils import is_pipeline_test, 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 EfficientNetForImageClassification, EfficientNetModel
	from transformers.models.efficientnet.modeling_efficientnet import EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	from PIL import Image

	from transformers import AutoImageProcessor


class       SCREAMING_SNAKE_CASE_							:



	"""simple docstring"""


	def __init__(				self		:	Optional[int]				,    lowerCAmelCase		:	List[Any]				,    lowerCAmelCase		:	int=13				,    lowerCAmelCase		:	Union[str, Any]=32				,    lowerCAmelCase		:	List[Any]=3				,    lowerCAmelCase		:	Tuple=[3, 3, 5]				,    lowerCAmelCase		:	str=[32, 16, 24]				,    lowerCAmelCase		:	Dict=[16, 24, 40]				,    lowerCAmelCase		:	Optional[Any]=[1, 1, 2]				,    lowerCAmelCase		:	int=[1, 1, 2]				,    lowerCAmelCase		:	Any=[1, 6, 6]				,    lowerCAmelCase		:	str=True				,    lowerCAmelCase		:	Tuple=True				,    lowerCAmelCase		:	Dict=37				,    lowerCAmelCase		:	Any="gelu"				,    lowerCAmelCase		:	List[str]=10				,    )  ->					Optional[Any]:







						"""simple docstring"""







						__UpperCamelCase				:  List[Any]								=			parent
						__UpperCamelCase				:  Any								=			batch_size
						__UpperCamelCase				:  List[str]								=			image_size
						__UpperCamelCase				:  int								=			num_channels
						__UpperCamelCase				:  Tuple								=			kernel_sizes
						__UpperCamelCase				:  Union[str, Any]								=			in_channels
						__UpperCamelCase				:  int								=			out_channels
						__UpperCamelCase				:  List[str]								=			strides
						__UpperCamelCase				:  Optional[Any]								=			num_block_repeats
						__UpperCamelCase				:  Tuple								=			expand_ratios
						__UpperCamelCase				:  Optional[int]								=			is_training
						__UpperCamelCase				:  Dict								=			hidden_act
						__UpperCamelCase				:  Optional[int]								=			num_labels
						__UpperCamelCase				:  List[Any]								=			use_labels






	def 				lowerCamelCase__    (				self		:	Optional[Any]  )  ->					Tuple:







						"""simple docstring"""







						__UpperCamelCase				:  Tuple								=			floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]  )

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

						__UpperCamelCase				:  int								=			self.get_config()
						return config, pixel_values, labels






	def 				lowerCamelCase__    (				self		:	Tuple  )  ->					Any:







						"""simple docstring"""







						return EfficientNetConfig(
						    num_channels=self.num_channels				,    kernel_sizes=self.kernel_sizes				,    in_channels=self.in_channels				,    out_channels=self.out_channels				,    strides=self.strides				,    num_block_repeats=self.num_block_repeats				,    expand_ratios=self.expand_ratios				,    hidden_act=self.hidden_act				,    num_labels=self.num_labels				,    )






	def 				lowerCamelCase__    (				self		:	Optional[int]				,    lowerCAmelCase		:	int				,    lowerCAmelCase		:	Tuple				,    lowerCAmelCase		:	Optional[Any]  )  ->					Union[str, Any]:







						"""simple docstring"""







						__UpperCamelCase				:  int								=			EfficientNetModel(config=lowerCAmelCase  )
						model.to(lowerCAmelCase  )
						model.eval()
						__UpperCamelCase				:  Union[str, Any]								=			model(lowerCAmelCase  )
						# expected last hidden states: B, C, H // 4, W // 4
						self.parent.assertEqual(
						    result.last_hidden_state.shape				,    (self.batch_size, config.hidden_dim, self.image_size // 4, self.image_size // 4)				,    )






	def 				lowerCamelCase__    (				self		:	int				,    lowerCAmelCase		:	Union[str, Any]				,    lowerCAmelCase		:	Optional[Any]				,    lowerCAmelCase		:	str  )  ->					Optional[int]:







						"""simple docstring"""







						__UpperCamelCase				:  List[Any]								=			EfficientNetForImageClassification(lowerCAmelCase  )
						model.to(lowerCAmelCase  )
						model.eval()
						__UpperCamelCase				:  Optional[int]								=			model(lowerCAmelCase				,    labels=lowerCAmelCase  )
						self.parent.assertEqual(result.logits.shape				,    (self.batch_size, self.num_labels)  )






	def 				lowerCamelCase__    (				self		:	Optional[Any]  )  ->					Optional[int]:







						"""simple docstring"""







						__UpperCamelCase				:  Optional[int]								=			self.prepare_config_and_inputs()
						__UpperCamelCase			, __UpperCamelCase			, __UpperCamelCase				:  str								=			config_and_inputs
						__UpperCamelCase				:  Optional[Any]								=			{"""pixel_values""": pixel_values}
						return config, inputs_dict






@require_torch
class       SCREAMING_SNAKE_CASE_							(					_UpperCamelCase  ,     _UpperCamelCase  ,     unittest.TestCase      ):



	"""simple docstring"""


	__magic_name__      :					List[Any]			  =		(EfficientNetModel, EfficientNetForImageClassification) if is_torch_available() else ()
	__magic_name__      :					Tuple			  =		(
	    {'feature-extraction': EfficientNetModel, 'image-classification': EfficientNetForImageClassification}
	    if is_torch_available()
	    else {}
	)

	__magic_name__      :					Union[str, Any]			  =		False
	__magic_name__      :					Dict			  =		False
	__magic_name__      :					str			  =		False
	__magic_name__      :					Union[str, Any]			  =		False
	__magic_name__      :					int			  =		False






	def 				lowerCamelCase__    (				self		:	Dict  )  ->					Optional[int]:







						"""simple docstring"""







						__UpperCamelCase				:  List[str]								=			EfficientNetModelTester(self  )
						__UpperCamelCase				:  Optional[Any]								=			ConfigTester(
						    self				,    config_class=lowerCAmelCase				,    has_text_modality=lowerCAmelCase				,    hidden_size=37  )






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







						"""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 				lowerCamelCase__    (				self		:	Optional[Any]  )  ->					Dict:







						"""simple docstring"""







						return






	@unittest.skip(reason="""EfficientNet does not use inputs_embeds"""  )
	def 				lowerCamelCase__    (				self		:	str  )  ->					List[str]:







						"""simple docstring"""







						pass






	@unittest.skip(reason="""EfficientNet does not support input and output embeddings"""  )
	def 				lowerCamelCase__    (				self		:	Optional[Any]  )  ->					Any:







						"""simple docstring"""







						pass






	@unittest.skip(reason="""EfficientNet does not use feedforward chunking"""  )
	def 				lowerCamelCase__    (				self		:	Tuple  )  ->					Optional[int]:







						"""simple docstring"""







						pass






	def 				lowerCamelCase__    (				self		:	Tuple  )  ->					List[str]:







						"""simple docstring"""







						__UpperCamelCase			, __UpperCamelCase				:  Dict								=			self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
											__UpperCamelCase				:  List[str]								=			model_class(lowerCAmelCase  )
											__UpperCamelCase				:  str								=			inspect.signature(model.forward  )
											# signature.parameters is an OrderedDict => so arg_names order is deterministic
											__UpperCamelCase				:  Tuple								=			[*signature.parameters.keys()]

											__UpperCamelCase				:  Union[str, Any]								=			["""pixel_values"""]
											self.assertListEqual(arg_names[:1]				,    lowerCAmelCase  )






	def 				lowerCamelCase__    (				self		:	Any  )  ->					Optional[int]:







						"""simple docstring"""







						__UpperCamelCase				:  Optional[int]								=			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*lowerCAmelCase  )






	def 				lowerCamelCase__    (				self		:	Tuple  )  ->					List[Any]:







						"""simple docstring"""







						def check_hidden_states_output(lowerCAmelCase		:	Optional[Any]				,    lowerCAmelCase		:	str				,    lowerCAmelCase		:	Any  ):
											__UpperCamelCase				:  int								=			model_class(lowerCAmelCase  )
											model.to(lowerCAmelCase  )
											model.eval()

											with torch.no_grad():
																__UpperCamelCase				:  Tuple								=			model(**self._prepare_for_class(lowerCAmelCase				,    lowerCAmelCase  )  )

											__UpperCamelCase				:  Any								=			outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states
											__UpperCamelCase				:  Union[str, Any]								=			sum(config.num_block_repeats  ) * 4
											self.assertEqual(len(lowerCAmelCase  )				,    lowerCAmelCase  )

											# EfficientNet'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 // 2, self.model_tester.image_size // 2]				,    )

						__UpperCamelCase			, __UpperCamelCase				:  Union[str, Any]								=			self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
											__UpperCamelCase				:  Union[str, Any]								=			True
											check_hidden_states_output(lowerCAmelCase				,    lowerCAmelCase				,    lowerCAmelCase  )

											# check that output_hidden_states also work using config
											del inputs_dict["output_hidden_states"]
											__UpperCamelCase				:  Optional[Any]								=			True

											check_hidden_states_output(lowerCAmelCase				,    lowerCAmelCase				,    lowerCAmelCase  )






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







						"""simple docstring"""







						__UpperCamelCase				:  Optional[Any]								=			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase  )






	@unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests."""  )
	def 				lowerCamelCase__    (				self		:	Optional[int]  )  ->					Dict:







						"""simple docstring"""







						pass






	@slow
	def 				lowerCamelCase__    (				self		:	str  )  ->					Any:







						"""simple docstring"""







						for model_name in EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											__UpperCamelCase				:  Union[str, Any]								=			EfficientNetModel.from_pretrained(lowerCAmelCase  )
											self.assertIsNotNone(lowerCAmelCase  )






	@is_pipeline_test
	@require_vision
	@slow
	def 				lowerCamelCase__    (				self		:	List[str]  )  ->					Union[str, Any]:







						"""simple docstring"""







						super().test_pipeline_image_classification()






def 							A__   ()    ->	Union[str, Any]:
					__UpperCamelCase				:  List[str]								=			Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""							)
					return image







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



	"""simple docstring"""


	@cached_property
	def 				lowerCamelCase__    (				self		:	List[str]  )  ->					Union[str, Any]:







						"""simple docstring"""







						return AutoImageProcessor.from_pretrained("""google/efficientnet-b7"""  ) if is_vision_available() else None






	@slow
	def 				lowerCamelCase__    (				self		:	List[str]  )  ->					Dict:







						"""simple docstring"""







						__UpperCamelCase				:  Optional[Any]								=			EfficientNetForImageClassification.from_pretrained("""google/efficientnet-b7"""  ).to(lowerCAmelCase  )

						__UpperCamelCase				:  Any								=			self.default_image_processor
						__UpperCamelCase				:  Any								=			prepare_img()
						__UpperCamelCase				:  Optional[Any]								=			image_processor(images=lowerCAmelCase				,    return_tensors="""pt"""  ).to(lowerCAmelCase  )

						# forward pass
						with torch.no_grad():
											__UpperCamelCase				:  Tuple								=			model(**lowerCAmelCase  )

						# verify the logits
						__UpperCamelCase				:  Optional[int]								=			torch.Size((1, 1000)  )
						self.assertEqual(outputs.logits.shape				,    lowerCAmelCase  )

						__UpperCamelCase				:  int								=			torch.tensor([0.00_01, 0.00_02, 0.00_02]  ).to(lowerCAmelCase  )
						self.assertTrue(torch.allclose(outputs.logits[0, :3]				,    lowerCAmelCase				,    atol=1E-4  )  )






