
import timeit
from typing import Callable, Optional

from ..configuration_utils import PretrainedConfig
from ..models.auto.modeling_auto import MODEL_MAPPING, MODEL_WITH_LM_HEAD_MAPPING
from ..utils import is_pyanvml_available, is_torch_available, logging
from .benchmark_utils import (
    Benchmark,
    Memory,
    MemorySummary,
    measure_peak_memory_cpu,
    start_memory_tracing,
    stop_memory_tracing,
)


if is_torch_available():
					import torch

					from .benchmark_args import PyTorchBenchmarkArguments


if is_pyanvml_available():
					import pyanvml.pyanvml as nvml


SCREAMING_SNAKE_CASE__     :    str      							=					logging.get_logger(__name__)

class      lowerCAmelCase__  (			__lowercase    ):
		a__ :		PyTorchBenchmarkArguments
		a__ :		PretrainedConfig
		a__ :		str   						=	"PyTorch"






		@property
		def 				__A (	self	:							Union[str, Any]						)  ->							Optional[Any]:
						return torch.__version__






		def 				__A (	self	:							Tuple							,    SCREAMING_SNAKE_CASE__	:							str							,    SCREAMING_SNAKE_CASE__	:							int							,    SCREAMING_SNAKE_CASE__	:							int						)  ->							float:
						__lowerCamelCase					      =			self._prepare_inference_func(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)
						return self._measure_speed(_inference						)






		def 				__A (	self	:							List[Any]							,    SCREAMING_SNAKE_CASE__	:							str							,    SCREAMING_SNAKE_CASE__	:							int							,    SCREAMING_SNAKE_CASE__	:							int						)  ->							[Memory, Optional[MemorySummary]]:
						__lowerCamelCase					      =			self._prepare_inference_func(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)
						return self._measure_memory(_inference						)






		def 				__A (	self	:							Optional[int]							,    SCREAMING_SNAKE_CASE__	:							str							,    SCREAMING_SNAKE_CASE__	:							int							,    SCREAMING_SNAKE_CASE__	:							int						)  ->							float:
						__lowerCamelCase					      =			self._prepare_train_func(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)
						return self._measure_speed(_train						)






		def 				__A (	self	:							List[str]							,    SCREAMING_SNAKE_CASE__	:							str							,    SCREAMING_SNAKE_CASE__	:							int							,    SCREAMING_SNAKE_CASE__	:							int						)  ->							[Memory, Optional[MemorySummary]]:
						__lowerCamelCase					      =			self._prepare_train_func(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)
						return self._measure_memory(_train						)






		def 				__A (	self	:							Dict							,    SCREAMING_SNAKE_CASE__	:							str							,    SCREAMING_SNAKE_CASE__	:							int							,    SCREAMING_SNAKE_CASE__	:							int						)  ->							Callable[[], None]:
						__lowerCamelCase					      =			self.config_dict[model_name]

						if self.args.torchscript:
										__lowerCamelCase					      =			True

						__lowerCamelCase					      =			(
						    hasattr(SCREAMING_SNAKE_CASE__							,    '''architectures'''						)
						    and isinstance(config.architectures							,    SCREAMING_SNAKE_CASE__						)
						    and len(config.architectures						) > 0
						)
						if not self.args.only_pretrain_model and has_model_class_in_config:
										try:
														__lowerCamelCase					      =			config.architectures[0]
														__lowerCamelCase					      =			__import__('''transformers'''							,    fromlist=[model_class]						)
														__lowerCamelCase					      =			getattr(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)
														__lowerCamelCase					      =			model_cls(SCREAMING_SNAKE_CASE__						)
										except ImportError:
														raise ImportError(
														    f'''{model_class} does not exist. If you just want to test the pretrained model, you might want to'''
														    ''' set `--only_pretrain_model` or `args.only_pretrain_model=True`.'''						)
						else:
										__lowerCamelCase					      =			MODEL_MAPPING[config.__class__](SCREAMING_SNAKE_CASE__						)

						model.eval()
						model.to(self.args.device						)

						# encoder-decoder has vocab size saved differently
						__lowerCamelCase					      =			config.vocab_size if hasattr(SCREAMING_SNAKE_CASE__							,    '''vocab_size'''						) else config.encoder.vocab_size
						__lowerCamelCase					      =			torch.randint(SCREAMING_SNAKE_CASE__							,    (batch_size, sequence_length)							,    dtype=torch.long							,    device=self.args.device						)

						if self.args.fpaa:
										logger.info('''Running training in Mixed Precision...'''						)
										if not self.args.is_gpu:
														raise ValueError('''Mixed precision is possible only for GPU.'''						)
										# amp seems to have memory leaks so that memory usage
										# is measured using .half() for now https://github.com/NVIDIA/apex/issues/439
										model.half()

						if self.args.torchscript:
										with torch.no_grad():
														__lowerCamelCase					      =			torch.jit.trace(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)
						else:
										__lowerCamelCase					      =			model

						def encoder_decoder_forward():
										with torch.no_grad():
														__lowerCamelCase					      =			inference_model(SCREAMING_SNAKE_CASE__							,    decoder_input_ids=SCREAMING_SNAKE_CASE__						)
										return outputs

						def encoder_forward():
										with torch.no_grad():
														__lowerCamelCase					      =			inference_model(SCREAMING_SNAKE_CASE__						)
										return outputs

						__lowerCamelCase					      =			encoder_decoder_forward if config.is_encoder_decoder else encoder_forward
						return _forward






		def 				__A (	self	:							Tuple							,    SCREAMING_SNAKE_CASE__	:							str							,    SCREAMING_SNAKE_CASE__	:							int							,    SCREAMING_SNAKE_CASE__	:							int						)  ->							Callable[[], None]:
						__lowerCamelCase					      =			self.config_dict[model_name]

						__lowerCamelCase					      =			(
						    hasattr(SCREAMING_SNAKE_CASE__							,    '''architectures'''						)
						    and isinstance(config.architectures							,    SCREAMING_SNAKE_CASE__						)
						    and len(config.architectures						) > 0
						)
						if not self.args.only_pretrain_model and has_model_class_in_config:
										try:
														__lowerCamelCase					      =			config.architectures[0]
														__lowerCamelCase					      =			__import__('''transformers'''							,    fromlist=[model_class]						)
														__lowerCamelCase					      =			getattr(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)
														__lowerCamelCase					      =			model_cls(SCREAMING_SNAKE_CASE__						)
										except ImportError:
														raise ImportError(
														    f'''{model_class} does not exist. If you just want to test the pretrained model, you might want to'''
														    ''' set `--only_pretrain_model` or `args.only_pretrain_model=True`.'''						)
						else:
										__lowerCamelCase					      =			MODEL_WITH_LM_HEAD_MAPPING[config.__class__](SCREAMING_SNAKE_CASE__						)

						if self.args.torchscript:
										raise NotImplementedError('''Training for torchscript is currently not implemented'''						)
						else:
										__lowerCamelCase					      =			model

						model.train()
						model.to(self.args.device						)

						# encoder-decoder has vocab size saved differently
						__lowerCamelCase					      =			config.vocab_size if hasattr(SCREAMING_SNAKE_CASE__							,    '''vocab_size'''						) else config.encoder.vocab_size
						__lowerCamelCase					      =			torch.randint(SCREAMING_SNAKE_CASE__							,    (batch_size, sequence_length)							,    dtype=torch.long							,    device=self.args.device						)

						if self.args.fpaa:
										logger.info('''Running training in Mixed Precision...'''						)
										if not self.args.is_gpu:
														raise ValueError('''Mixed precision is possible only for GPU.'''						)

										# amp seems to have memory leaks so that memory usage
										# is measured using .half() for now https://github.com/NVIDIA/apex/issues/439
										model.half()

						def compute_loss_and_backprob_encoder():
										__lowerCamelCase					      =			train_model(SCREAMING_SNAKE_CASE__							,    labels=SCREAMING_SNAKE_CASE__						)[0]
										loss.backward()
										return loss

						def compute_loss_and_backprob_encoder_decoder():
										__lowerCamelCase					      =			train_model(SCREAMING_SNAKE_CASE__							,    decoder_input_ids=SCREAMING_SNAKE_CASE__							,    labels=SCREAMING_SNAKE_CASE__						)[0]
										loss.backward()
										return loss

						__lowerCamelCase					      =			(
						    compute_loss_and_backprob_encoder_decoder
						    if config.is_encoder_decoder
						    else compute_loss_and_backprob_encoder
						)
						return _train






		def 				__A (	self	:							Dict							,    SCREAMING_SNAKE_CASE__	:							List[Any]						)  ->							float:
						try:
										if self.args.is_tpu or self.args.torchscript:
														# run additional 10 times to stabilize compilation for tpu and torchscript
														logger.info('''Do inference on TPU or torchscript. Running model 5 times to stabilize compilation'''						)
														timeit.repeat(
														    SCREAMING_SNAKE_CASE__							,    repeat=1							,    number=5							,    )

										# as written in https://docs.python.org/2/library/timeit.html#timeit.Timer.repeat, min should be taken rather than the average
										__lowerCamelCase					      =			timeit.repeat(
										    SCREAMING_SNAKE_CASE__							,    repeat=self.args.repeat							,    number=10							,    )

										if self.args.is_tpu and self.args.torch_xla_tpu_print_metrics:
														import torch_xla.debug.metrics as met

														self.print_fn(met.metrics_report()						)

										return min(SCREAMING_SNAKE_CASE__						) / 10.0
						except RuntimeError as e:
										self.print_fn(f'''Doesn\'t fit on GPU. {e}'''						)
										return "N/A"







		def 				__A (	self	:							Optional[Any]							,    SCREAMING_SNAKE_CASE__	:							Callable[[], None]						)  ->							[Memory, MemorySummary]:
						try:
										if self.args.trace_memory_line_by_line:
														__lowerCamelCase					      =			start_memory_tracing('''transformers'''						)

										if self.args.is_tpu:
														# tpu
														raise NotImplementedError(
														    '''Memory Benchmarking is currently not implemented for TPU. Please disable memory benchmarking with'''
														    ''' `--no-memory` or `args.memory=False`'''						)
										elif self.args.is_gpu:
														if not is_pyanvml_available():
																		logger.warning(
																		    '''py3nvml not installed, we won\'t log GPU memory usage. '''
																		    '''Install py3nvml (pip install py3nvml) to log information about GPU.'''						)
																		__lowerCamelCase					      =			'''N/A'''
														else:
																		logger.info(
																		    '''Measuring total GPU usage on GPU device. Make sure to not have additional processes running'''
																		    ''' on the same GPU.'''						)
																		# init nvml
																		nvml.nvmlInit()
																		func()
																		__lowerCamelCase					      =			nvml.nvmlDeviceGetHandleByIndex(self.args.device_idx						)
																		__lowerCamelCase					      =			nvml.nvmlDeviceGetMemoryInfo(SCREAMING_SNAKE_CASE__						)
																		__lowerCamelCase					      =			meminfo.used
																		__lowerCamelCase					      =			Memory(SCREAMING_SNAKE_CASE__						)
																		# shutdown nvml
																		nvml.nvmlShutdown()
										else:
														# cpu
														__lowerCamelCase					      =			measure_peak_memory_cpu(SCREAMING_SNAKE_CASE__						)
														__lowerCamelCase					      =			Memory(SCREAMING_SNAKE_CASE__						) if isinstance(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						) else memory_bytes

										if self.args.trace_memory_line_by_line:
														__lowerCamelCase					      =			stop_memory_tracing(SCREAMING_SNAKE_CASE__						)
										else:
														__lowerCamelCase					      =			None

										return memory, summary
						except RuntimeError as e:
										self.print_fn(f'''Doesn\'t fit on GPU. {e}'''						)
										return "N/A", None





import inspect
import unittest

import requests

from transformers import MgpstrConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
					import torch
					from torch import nn

					from transformers import MgpstrForSceneTextRecognition


if is_vision_available():
					from PIL import Image

					from transformers import MgpstrProcessor

class      lowerCAmelCase__  :






		def __init__(	self	:							int							,    SCREAMING_SNAKE_CASE__	:							Union[str, Any]							,    SCREAMING_SNAKE_CASE__	:							List[Any]=False							,    SCREAMING_SNAKE_CASE__	:							Optional[int]=13							,    SCREAMING_SNAKE_CASE__	:							Any=(32, 1_28)							,    SCREAMING_SNAKE_CASE__	:							Optional[Any]=4							,    SCREAMING_SNAKE_CASE__	:							List[Any]=3							,    SCREAMING_SNAKE_CASE__	:							Union[str, Any]=27							,    SCREAMING_SNAKE_CASE__	:							Union[str, Any]=38							,    SCREAMING_SNAKE_CASE__	:							Dict=99							,    SCREAMING_SNAKE_CASE__	:							int=99							,    SCREAMING_SNAKE_CASE__	:							Tuple=32							,    SCREAMING_SNAKE_CASE__	:							Any=5							,    SCREAMING_SNAKE_CASE__	:							str=4							,    SCREAMING_SNAKE_CASE__	:							List[str]=4.0							,    SCREAMING_SNAKE_CASE__	:							Optional[Any]=2_57							,    SCREAMING_SNAKE_CASE__	:							Tuple=None							,    )  ->							List[Any]:
						__lowerCamelCase					      =			parent
						__lowerCamelCase					      =			is_training
						__lowerCamelCase					      =			batch_size
						__lowerCamelCase					      =			image_size
						__lowerCamelCase					      =			patch_size
						__lowerCamelCase					      =			num_channels
						__lowerCamelCase					      =			max_token_length
						__lowerCamelCase					      =			num_character_labels
						__lowerCamelCase					      =			num_bpe_labels
						__lowerCamelCase					      =			num_wordpiece_labels
						__lowerCamelCase					      =			hidden_size
						__lowerCamelCase					      =			num_hidden_layers
						__lowerCamelCase					      =			num_attention_heads
						__lowerCamelCase					      =			mlp_ratio
						__lowerCamelCase					      =			patch_embeds_hidden_size
						__lowerCamelCase					      =			output_hidden_states






		def 				__A (	self	:							Any						)  ->							Optional[int]:
						__lowerCamelCase					      =			floats_tensor([self.batch_size, self.num_channels, self.image_size[0], self.image_size[1]]						)
						__lowerCamelCase					      =			self.get_config()
						return config, pixel_values






		def 				__A (	self	:							int						)  ->							Union[str, Any]:
						return MgpstrConfig(
						    image_size=self.image_size							,    patch_size=self.patch_size							,    num_channels=self.num_channels							,    max_token_length=self.max_token_length							,    num_character_labels=self.num_character_labels							,    num_bpe_labels=self.num_bpe_labels							,    num_wordpiece_labels=self.num_wordpiece_labels							,    hidden_size=self.hidden_size							,    num_hidden_layers=self.num_hidden_layers							,    num_attention_heads=self.num_attention_heads							,    mlp_ratio=self.mlp_ratio							,    output_hidden_states=self.output_hidden_states							,    )






		def 				__A (	self	:							List[str]							,    SCREAMING_SNAKE_CASE__	:							List[str]							,    SCREAMING_SNAKE_CASE__	:							Union[str, Any]						)  ->							List[Any]:
						__lowerCamelCase					      =			MgpstrForSceneTextRecognition(SCREAMING_SNAKE_CASE__						)
						model.to(SCREAMING_SNAKE_CASE__						)
						model.eval()
						with torch.no_grad():
										__lowerCamelCase					      =			model(SCREAMING_SNAKE_CASE__						)
						self.parent.assertEqual(
						    generated_ids[0][0].shape							,    (self.batch_size, self.max_token_length, self.num_character_labels)						)







		def 				__A (	self	:							Dict						)  ->							Union[str, Any]:
						__lowerCamelCase					      =			self.prepare_config_and_inputs()
						__lowerCamelCase      ,					__lowerCamelCase					      =			config_and_inputs
						__lowerCamelCase					      =			{'''pixel_values''': pixel_values}
						return config, inputs_dict





@require_torch
class      lowerCAmelCase__  (			__lowercase						,			__lowercase						,			unittest.TestCase    ):
		a__ :		Dict   						=	(MgpstrForSceneTextRecognition,) if is_torch_available() else ()
		a__ :		Optional[int]   						=	{"""feature-extraction""": MgpstrForSceneTextRecognition} if is_torch_available() else {}
		a__ :		Any   						=	False

		a__ :		List[Any]   						=	False
		a__ :		Any   						=	False
		a__ :		int   						=	False
		a__ :		Tuple   						=	False






		def 				__A (	self	:							Optional[Any]						)  ->							str:
						__lowerCamelCase					      =			MgpstrModelTester(self						)
						__lowerCamelCase					      =			ConfigTester(self							,    config_class=SCREAMING_SNAKE_CASE__							,    has_text_modality=SCREAMING_SNAKE_CASE__						)






		def 				__A (	self	:							List[Any]						)  ->							Tuple:
						self.config_tester.run_common_tests()






		def 				__A (	self	:							List[str]						)  ->							Any:
						__lowerCamelCase					      =			self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*SCREAMING_SNAKE_CASE__						)






		@unittest.skip(reason='''MgpstrModel does not use inputs_embeds'''						)
		def 				__A (	self	:							Optional[int]						)  ->							Dict:
						pass






		def 				__A (	self	:							Tuple						)  ->							Tuple:
						__lowerCamelCase      ,					__lowerCamelCase					      =			self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
										__lowerCamelCase					      =			model_class(SCREAMING_SNAKE_CASE__						)
										self.assertIsInstance(model.get_input_embeddings()							,    (nn.Module)						)
										__lowerCamelCase					      =			model.get_output_embeddings()
										self.assertTrue(x is None or isinstance(SCREAMING_SNAKE_CASE__							,    nn.Linear						)						)






		def 				__A (	self	:							Tuple						)  ->							Optional[Any]:
						__lowerCamelCase      ,					__lowerCamelCase					      =			self.model_tester.prepare_config_and_inputs_for_common()

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

										__lowerCamelCase					      =			['''pixel_values''']
										self.assertListEqual(arg_names[:1]							,    SCREAMING_SNAKE_CASE__						)






		@unittest.skip(reason='''MgpstrModel does not support feedforward chunking'''						)
		def 				__A (	self	:							Optional[Any]						)  ->							str:
						pass






		def 				__A (	self	:							str						)  ->							Tuple:
						__lowerCamelCase      ,					__lowerCamelCase					      =			self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
										if not model_class.supports_gradient_checkpointing:
														continue

										__lowerCamelCase					      =			True
										__lowerCamelCase					      =			model_class(SCREAMING_SNAKE_CASE__						)
										self.assertTrue(model.is_gradient_checkpointing						)






		def 				__A (	self	:							List[str]						)  ->							List[str]:
						def check_hidden_states_output(SCREAMING_SNAKE_CASE__	:							Optional[Any]							,    SCREAMING_SNAKE_CASE__	:							List[Any]							,    SCREAMING_SNAKE_CASE__	:							Union[str, Any]						):
										__lowerCamelCase					      =			model_class(SCREAMING_SNAKE_CASE__						)
										model.to(SCREAMING_SNAKE_CASE__						)
										model.eval()

										with torch.no_grad():
														__lowerCamelCase					      =			model(**self._prepare_for_class(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)						)

										__lowerCamelCase					      =			outputs.hidden_states

										__lowerCamelCase					      =			getattr(
										    self.model_tester							,    '''expected_num_hidden_layers'''							,    self.model_tester.num_hidden_layers + 1						)
										self.assertEqual(len(SCREAMING_SNAKE_CASE__						)							,    SCREAMING_SNAKE_CASE__						)

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

						__lowerCamelCase      ,					__lowerCamelCase					      =			self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
										__lowerCamelCase					      =			True
										check_hidden_states_output(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)

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

										check_hidden_states_output(SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__						)






		def 				__A (	self	:							Tuple						)  ->							int:
						__lowerCamelCase      ,					__lowerCamelCase					      =			self.model_tester.prepare_config_and_inputs_for_common()

						__lowerCamelCase					      =			_config_zero_init(SCREAMING_SNAKE_CASE__						)
						for model_class in self.all_model_classes:
										__lowerCamelCase					      =			model_class(config=SCREAMING_SNAKE_CASE__						)
										for name, param in model.named_parameters():
														if isinstance(SCREAMING_SNAKE_CASE__							,    (nn.Linear, nn.Convad, nn.LayerNorm)						):
																		if param.requires_grad:
																						self.assertIn(
																						    ((param.data.mean() * 1e9).round() / 1e9).item()							,    [0.0, 1.0]							,    msg=f'''Parameter {name} of model {model_class} seems not properly initialized'''							,    )







		@unittest.skip(reason='''Retain_grad is tested in individual model tests'''						)
		def 				__A (	self	:							int						)  ->							Union[str, Any]:
						pass





def 				__magic_name__				(     )    ->     Optional[Any]:
				__lowerCamelCase					      =			'''https://i.postimg.cc/ZKwLg2Gw/367-14.png'''
				__lowerCamelCase					      =			Image.open(requests.get(__lowerCAmelCase	,						stream=__lowerCAmelCase							).raw							).convert('''RGB'''							)
				return im







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






		@slow
		def 				__A (	self	:							List[str]						)  ->							Optional[int]:
						__lowerCamelCase					      =			'''alibaba-damo/mgp-str-base'''
						__lowerCamelCase					      =			MgpstrForSceneTextRecognition.from_pretrained(SCREAMING_SNAKE_CASE__						).to(SCREAMING_SNAKE_CASE__						)
						__lowerCamelCase					      =			MgpstrProcessor.from_pretrained(SCREAMING_SNAKE_CASE__						)

						__lowerCamelCase					      =			prepare_img()
						__lowerCamelCase					      =			processor(images=SCREAMING_SNAKE_CASE__							,    return_tensors='''pt'''						).pixel_values.to(SCREAMING_SNAKE_CASE__						)

						# forward pass
						with torch.no_grad():
										__lowerCamelCase					      =			model(SCREAMING_SNAKE_CASE__						)

						# verify the logits
						self.assertEqual(outputs.logits[0].shape							,    torch.Size((1, 27, 38)						)						)

						__lowerCamelCase					      =			processor.batch_decode(outputs.logits						)
						__lowerCamelCase					      =			'''ticket'''

						self.assertEqual(out_strs['''generated_text'''][0]							,    SCREAMING_SNAKE_CASE__						)

						__lowerCamelCase					      =			torch.tensor(
						    [[[-39.5397, -44.4024, -36.1844], [-61.4709, -63.8639, -58.3454], [-74.0225, -68.5494, -71.2164]]]							,    device=SCREAMING_SNAKE_CASE__							,    )

						self.assertTrue(torch.allclose(outputs.logits[0][:, 1:4, 1:4]							,    SCREAMING_SNAKE_CASE__							,    atol=1e-4						)						)



