






import logging
import math
from functools import partial
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union

import torch

from .tensor_utils import tensor_tree_map, tree_map


def __A    (      __lowerCAmelCase	)->  List[Tuple[int, ...]]:





						"""simple docstring"""



						_UpperCAmelCase									=			[]
						if isinstance(__lowerCAmelCase ,		__lowerCAmelCase	):
												for v in tree.values():
																		shapes.extend(_fetch_dims(__lowerCAmelCase	)	)
						elif isinstance(__lowerCAmelCase ,		(list, tuple)	):
												for t in tree:
																		shapes.extend(_fetch_dims(__lowerCAmelCase	)	)
						elif isinstance(__lowerCAmelCase ,		torch.Tensor	):
												shapes.append(tree.shape	)
						else:
												raise ValueError('Not supported'	)

						return shapes


@torch.jit.ignore
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase	)->  Tuple[int, ...]:





						"""simple docstring"""



						_UpperCAmelCase									=			[]
						for d in reversed(__lowerCAmelCase	):
												idx.append(flat_idx % d	)
												_UpperCAmelCase									=			flat_idx // d

						return tuple(reversed(__lowerCAmelCase	)	)


@torch.jit.ignore
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase = None ,		__lowerCAmelCase = None ,		)->  List[Tuple[slice, ...]]:





						"""simple docstring"""



						def reduce_edge_list(__lowerCAmelCase	) -> None:
												_UpperCAmelCase									=			True
												for i in range(len(__lowerCAmelCase	)	):
																		_UpperCAmelCase									=			-1 * (i + 1)
																		l[reversed_idx] &= tally
																		_UpperCAmelCase									=			l[reversed_idx]

						if start_edges is None:
												_UpperCAmelCase									=			[s == 0 for s in start]
												reduce_edge_list(__lowerCAmelCase	)
						if end_edges is None:
												_UpperCAmelCase									=			[e == (d - 1) for e, d in zip(__lowerCAmelCase ,		__lowerCAmelCase	)]
												reduce_edge_list(__lowerCAmelCase	)

						# Base cases. Either start/end are empty and we're done, or the final,
						# one-dimensional tensor can be simply sliced
						if len(__lowerCAmelCase	) == 0:
												return [()]
						elif len(__lowerCAmelCase	) == 1:
												return [(slice(start[0] ,		end[0] + 1	),)]

						_UpperCAmelCase									=			[]
						_UpperCAmelCase									=			[]

						# Dimensions common to start and end can be selected directly
						for s, e in zip(__lowerCAmelCase ,		__lowerCAmelCase	):
												if s == e:
																		path_list.append(slice(__lowerCAmelCase ,		s + 1	)	)
												else:
																		break

						_UpperCAmelCase									=			tuple(__lowerCAmelCase	)
						_UpperCAmelCase									=			len(__lowerCAmelCase	)

						# start == end, and we're done
						if divergence_idx == len(__lowerCAmelCase	):
												return [path]

						def upper() -> Tuple[Tuple[slice, ...], ...]:
												assert start_edges is not None
												assert end_edges is not None

												_UpperCAmelCase									=			start[divergence_idx]
												return tuple(
												    path + (slice(__lowerCAmelCase ,		sdi + 1	),) + s
												    for s in _get_minimal_slice_set(
												        start[divergence_idx + 1 :] ,		[d - 1 for d in dims[divergence_idx + 1 :]] ,		dims[divergence_idx + 1 :] ,		start_edges=start_edges[divergence_idx + 1 :] ,		end_edges=[True for _ in end_edges[divergence_idx + 1 :]] ,		)	)

						def lower() -> Tuple[Tuple[slice, ...], ...]:
												assert start_edges is not None
												assert end_edges is not None

												_UpperCAmelCase									=			end[divergence_idx]
												return tuple(
												    path + (slice(__lowerCAmelCase ,		edi + 1	),) + s
												    for s in _get_minimal_slice_set(
												        [0 for _ in start[divergence_idx + 1 :]] ,		end[divergence_idx + 1 :] ,		dims[divergence_idx + 1 :] ,		start_edges=[True for _ in start_edges[divergence_idx + 1 :]] ,		end_edges=end_edges[divergence_idx + 1 :] ,		)	)

						# If both start and end are at the edges of the subtree rooted at
						# divergence_idx, we can just select the whole subtree at once
						if start_edges[divergence_idx] and end_edges[divergence_idx]:
												slices.append(path + (slice(start[divergence_idx] ,		end[divergence_idx] + 1	),)	)
						# If just start is at the edge, we can grab almost all of the subtree,
						# treating only the ragged bottom edge as an edge case
						elif start_edges[divergence_idx]:
												slices.append(path + (slice(start[divergence_idx] ,		end[divergence_idx]	),)	)
												slices.extend(lower()	)
						# Analogous to the previous case, but the top is ragged this time
						elif end_edges[divergence_idx]:
												slices.extend(upper()	)
												slices.append(path + (slice(start[divergence_idx] + 1 ,		end[divergence_idx] + 1	),)	)
						# If both sides of the range are ragged, we need to handle both sides
						# separately. If there's contiguous meat in between them, we can index it
						# in one big chunk
						else:
												slices.extend(upper()	)
												_UpperCAmelCase									=			end[divergence_idx] - start[divergence_idx]
												if middle_ground > 1:
																		slices.append(path + (slice(start[divergence_idx] + 1 ,		end[divergence_idx]	),)	)
												slices.extend(lower()	)

						return slices


@torch.jit.ignore
def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase	)->  torch.Tensor:





						"""simple docstring"""



						_UpperCAmelCase									=			t.shape[:no_batch_dims]
						_UpperCAmelCase									=			list(_flat_idx_to_idx(__lowerCAmelCase ,		__lowerCAmelCase	)	)
						# _get_minimal_slice_set is inclusive
						_UpperCAmelCase									=			list(_flat_idx_to_idx(flat_end - 1 ,		__lowerCAmelCase	)	)

						# Get an ordered list of slices to perform
						_UpperCAmelCase									=			_get_minimal_slice_set(
						    __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		)

						_UpperCAmelCase									=			[t[s] for s in slices]

						return torch.cat([s.view((-1,) + t.shape[no_batch_dims:]	) for s in sliced_tensors]	)


def __A    (      __lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase ,		__lowerCAmelCase = False ,		__lowerCAmelCase = None ,		__lowerCAmelCase = False ,		)->  Any:





						"""simple docstring"""



						if not (len(__lowerCAmelCase	) > 0):
												raise ValueError('Must provide at least one input'	)

						_UpperCAmelCase									=			[shape[:no_batch_dims] for shape in _fetch_dims(__lowerCAmelCase	)]
						_UpperCAmelCase									=			tuple([max(__lowerCAmelCase	) for s in zip(*__lowerCAmelCase	)]	)

						def _prep_inputs(__lowerCAmelCase	) -> torch.Tensor:
												if not low_mem:
																		if not sum(t.shape[:no_batch_dims]	) == no_batch_dims:
																								_UpperCAmelCase									=			t.expand(orig_batch_dims + t.shape[no_batch_dims:]	)
																		_UpperCAmelCase									=			t.reshape(-1 ,		*t.shape[no_batch_dims:]	)
												else:
																		_UpperCAmelCase									=			t.expand(orig_batch_dims + t.shape[no_batch_dims:]	)
												return t

						_UpperCAmelCase									=			tensor_tree_map(_prep_inputs ,		__lowerCAmelCase	)
						_UpperCAmelCase									=			None
						if _out is not None:
												_UpperCAmelCase									=			tensor_tree_map(lambda __lowerCAmelCase	: t.view([-1] + list(t.shape[no_batch_dims:]	)	) ,		_out	)

						_UpperCAmelCase									=			1
						for d in orig_batch_dims:
												flat_batch_dim *= d

						_UpperCAmelCase									=			flat_batch_dim // chunk_size + (flat_batch_dim % chunk_size != 0)

						def _select_chunk(__lowerCAmelCase	) -> torch.Tensor:
												return t[i : i + chunk_size] if t.shape[0] != 1 else t

						_UpperCAmelCase									=			0
						_UpperCAmelCase									=			prepped_outputs
						for _ in range(__lowerCAmelCase	):
												# Chunk the input
												if not low_mem:
																		_UpperCAmelCase									=			_select_chunk
												else:
																		_UpperCAmelCase									=			partial(
																		    _chunk_slice ,		flat_start=__lowerCAmelCase ,		flat_end=min(__lowerCAmelCase ,		i + chunk_size	) ,		no_batch_dims=len(__lowerCAmelCase	) ,		)

												_UpperCAmelCase									=			tensor_tree_map(__lowerCAmelCase ,		__lowerCAmelCase	)

												# Run the layer on the chunk
												_UpperCAmelCase									=			layer(**__lowerCAmelCase	)

												# Allocate space for the output
												if out is None:
																		_UpperCAmelCase									=			tensor_tree_map(lambda __lowerCAmelCase	: t.new_zeros((flat_batch_dim,) + t.shape[1:]	) ,		__lowerCAmelCase	)

												# Put the chunk in its pre-allocated space
												if isinstance(__lowerCAmelCase ,		__lowerCAmelCase	):

																		def assign(__lowerCAmelCase ,		__lowerCAmelCase	) -> None:
																								for k, v in da.items():
																														if isinstance(__lowerCAmelCase ,		__lowerCAmelCase	):
																																				assign(__lowerCAmelCase ,		da[k]	)
																														else:
																																				if _add_into_out:
																																										v[i : i + chunk_size] += da[k]
																																				else:
																																										_UpperCAmelCase									=			da[k]

																		assign(__lowerCAmelCase ,		__lowerCAmelCase	)
												elif isinstance(__lowerCAmelCase ,		__lowerCAmelCase	):
																		for xa, xa in zip(__lowerCAmelCase ,		__lowerCAmelCase	):
																								if _add_into_out:
																														xa[i : i + chunk_size] += xa
																								else:
																														_UpperCAmelCase									=			xa
												elif isinstance(__lowerCAmelCase ,		torch.Tensor	):
																		if _add_into_out:
																								out[i : i + chunk_size] += output_chunk
																		else:
																								_UpperCAmelCase									=			output_chunk
												else:
																		raise ValueError('Not supported'	)

												i += chunk_size

						_UpperCAmelCase									=			tensor_tree_map(lambda __lowerCAmelCase	: t.view(orig_batch_dims + t.shape[1:]	) ,		__lowerCAmelCase	)

						return out





class __lowerCamelCase :





	"""simple docstring"""






	def __init__(							self       ,    UpperCAmelCase = 512       ,    ):
							"""simple docstring"""







							_UpperCAmelCase									=			max_chunk_size
							_UpperCAmelCase									=			None
							_UpperCAmelCase									=			None

	def        UpperCamelCase    (							self       ,    UpperCAmelCase       ,    UpperCAmelCase       ,    UpperCAmelCase    ):
							"""simple docstring"""







							logging.info('Tuning chunk size...'    )

							if min_chunk_size >= self.max_chunk_size:
													return min_chunk_size

							_UpperCAmelCase									=			[2**l for l in range(int(math.log(self.max_chunk_size       ,    2    )    ) + 1    )]
							_UpperCAmelCase									=			[c for c in candidates if c > min_chunk_size]
							_UpperCAmelCase									=			[min_chunk_size] + candidates
							candidates[-1] += 4

							def test_chunk_size(UpperCAmelCase    ) -> bool:
													try:
																			with torch.no_grad():
																									fn(*UpperCAmelCase       ,    chunk_size=UpperCAmelCase    )
																			return True
													except RuntimeError:
																			return False

							_UpperCAmelCase									=			0
							_UpperCAmelCase									=			len(UpperCAmelCase    ) - 1
							while i > min_viable_chunk_size_index:
													_UpperCAmelCase									=			test_chunk_size(candidates[i]    )
													if not viable:
																			_UpperCAmelCase									=			(min_viable_chunk_size_index + i) // 2
													else:
																			_UpperCAmelCase									=			i
																			_UpperCAmelCase									=			(i + len(UpperCAmelCase    ) - 1) // 2

							return candidates[min_viable_chunk_size_index]

	def        UpperCamelCase    (							self       ,    UpperCAmelCase       ,    UpperCAmelCase    ):
							"""simple docstring"""







							_UpperCAmelCase									=			True
							for aa, aa in zip(UpperCAmelCase       ,    UpperCAmelCase    ):
													assert type(UpperCAmelCase    ) == type(UpperCAmelCase    )
													if isinstance(UpperCAmelCase       ,    (list, tuple)    ):
																			consistent &= self._compare_arg_caches(UpperCAmelCase       ,    UpperCAmelCase    )
													elif isinstance(UpperCAmelCase       ,    UpperCAmelCase    ):
																			_UpperCAmelCase									=			[v for _, v in sorted(aa.items()       ,    key=lambda UpperCAmelCase    : x[0]    )]
																			_UpperCAmelCase									=			[v for _, v in sorted(aa.items()       ,    key=lambda UpperCAmelCase    : x[0]    )]
																			consistent &= self._compare_arg_caches(UpperCAmelCase       ,    UpperCAmelCase    )
													else:
																			consistent &= aa == aa

							return consistent

	def        UpperCamelCase    (							self       ,    UpperCAmelCase       ,    UpperCAmelCase       ,    UpperCAmelCase       ,    ):
							"""simple docstring"""







							_UpperCAmelCase									=			True
							_UpperCAmelCase									=			tree_map(lambda UpperCAmelCase    : a.shape if isinstance(UpperCAmelCase       ,    torch.Tensor    ) else a       ,    UpperCAmelCase       ,    UpperCAmelCase    )
							if self.cached_arg_data is not None:
													# If args have changed shape/value, we need to re-tune
													assert len(self.cached_arg_data    ) == len(UpperCAmelCase    )
													_UpperCAmelCase									=			self._compare_arg_caches(self.cached_arg_data       ,    UpperCAmelCase    )
							else:
													# Otherwise, we can reuse the precomputed value
													_UpperCAmelCase									=			False

							if not consistent:
													_UpperCAmelCase									=			self._determine_favorable_chunk_size(
													    UpperCAmelCase       ,    UpperCAmelCase       ,    UpperCAmelCase       ,    )
													_UpperCAmelCase									=			arg_data

							assert self.cached_chunk_size is not None

							return self.cached_chunk_size








from __future__ import annotations

import inspect
import unittest

import numpy as np

from transformers import ResNetConfig
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 TFResNetForImageClassification, TFResNetModel
		from transformers.models.resnet.modeling_tf_resnet import TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
		from PIL import Image

		from transformers import AutoImageProcessor





class __lowerCamelCase :





	"""simple docstring"""






	def __init__(							self       ,    UpperCAmelCase       ,    UpperCAmelCase=3       ,    UpperCAmelCase=32       ,    UpperCAmelCase=3       ,    UpperCAmelCase=10       ,    UpperCAmelCase=[10, 20, 30, 40]       ,    UpperCAmelCase=[1, 1, 2, 1]       ,    UpperCAmelCase=True       ,    UpperCAmelCase=True       ,    UpperCAmelCase="relu"       ,    UpperCAmelCase=3       ,    UpperCAmelCase=None       ,    ):
							"""simple docstring"""







							_UpperCAmelCase									=			parent
							_UpperCAmelCase									=			batch_size
							_UpperCAmelCase									=			image_size
							_UpperCAmelCase									=			num_channels
							_UpperCAmelCase									=			embeddings_size
							_UpperCAmelCase									=			hidden_sizes
							_UpperCAmelCase									=			depths
							_UpperCAmelCase									=			is_training
							_UpperCAmelCase									=			use_labels
							_UpperCAmelCase									=			hidden_act
							_UpperCAmelCase									=			num_labels
							_UpperCAmelCase									=			scope
							_UpperCAmelCase									=			len(UpperCAmelCase    )

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







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

							_UpperCAmelCase									=			None
							if self.use_labels:
													_UpperCAmelCase									=			ids_tensor([self.batch_size]       ,    self.num_labels    )

							_UpperCAmelCase									=			self.get_config()

							return config, pixel_values, labels

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							return ResNetConfig(
							    num_channels=self.num_channels       ,    embeddings_size=self.embeddings_size       ,    hidden_sizes=self.hidden_sizes       ,    depths=self.depths       ,    hidden_act=self.hidden_act       ,    num_labels=self.num_labels       ,    image_size=self.image_size       ,    )

	def        UpperCamelCase    (							self       ,    UpperCAmelCase       ,    UpperCAmelCase       ,    UpperCAmelCase    ):
							"""simple docstring"""







							_UpperCAmelCase									=			TFResNetModel(config=UpperCAmelCase    )
							_UpperCAmelCase									=			model(UpperCAmelCase    )
							# 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        UpperCamelCase    (							self       ,    UpperCAmelCase       ,    UpperCAmelCase       ,    UpperCAmelCase    ):
							"""simple docstring"""







							_UpperCAmelCase									=			self.num_labels
							_UpperCAmelCase									=			TFResNetForImageClassification(UpperCAmelCase    )
							_UpperCAmelCase									=			model(UpperCAmelCase       ,    labels=UpperCAmelCase    )
							self.parent.assertEqual(result.logits.shape       ,    (self.batch_size, self.num_labels)    )

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							_UpperCAmelCase									=			self.prepare_config_and_inputs()
							_UpperCAmelCase					, _UpperCAmelCase					, _UpperCAmelCase									=			config_and_inputs
							_UpperCAmelCase									=			{'pixel_values': pixel_values}
							return config, inputs_dict





@require_tf
class __lowerCamelCase (      snake_case__     ,       snake_case__     ,       unittest.TestCase):





	"""simple docstring"""






	UpperCamelCase__								=      (TFResNetModel, TFResNetForImageClassification) if is_tf_available() else ()
	UpperCamelCase__								=      (
	    {"feature-extraction": TFResNetModel, "image-classification": TFResNetForImageClassification}
	    if is_tf_available()
	    else {}
	)

	UpperCamelCase__								=      False
	UpperCamelCase__								=      False
	UpperCamelCase__								=      False
	UpperCamelCase__								=      False
	UpperCamelCase__								=      False

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							_UpperCAmelCase									=			TFResNetModelTester(self    )
							_UpperCAmelCase									=			ConfigTester(self       ,    config_class=UpperCAmelCase       ,    has_text_modality=UpperCAmelCase    )

	def        UpperCamelCase    (							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        UpperCamelCase    (							self    ):
							"""simple docstring"""







							return

	@unittest.skip(reason='ResNet does not use inputs_embeds'    )
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							pass

	@unittest.skip(reason='ResNet does not support input and output embeddings'    )
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							pass

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							_UpperCAmelCase					, _UpperCAmelCase									=			self.model_tester.prepare_config_and_inputs_for_common()

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

													_UpperCAmelCase									=			['pixel_values']
													self.assertListEqual(arg_names[:1]       ,    UpperCAmelCase    )

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							_UpperCAmelCase									=			self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*UpperCAmelCase    )

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							def check_hidden_states_output(UpperCAmelCase       ,    UpperCAmelCase       ,    UpperCAmelCase    ):
													_UpperCAmelCase									=			model_class(UpperCAmelCase    )
													_UpperCAmelCase									=			model(**self._prepare_for_class(UpperCAmelCase       ,    UpperCAmelCase    )    )

													_UpperCAmelCase									=			outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

													_UpperCAmelCase									=			self.model_tester.num_stages
													self.assertEqual(len(UpperCAmelCase    )       ,    expected_num_stages + 1    )

													# ResNet'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]       ,    )

							_UpperCAmelCase					, _UpperCAmelCase									=			self.model_tester.prepare_config_and_inputs_for_common()
							_UpperCAmelCase									=			['basic', 'bottleneck']
							for model_class in self.all_model_classes:
													for layer_type in layers_type:
																			_UpperCAmelCase									=			layer_type
																			_UpperCAmelCase									=			True
																			check_hidden_states_output(UpperCAmelCase       ,    UpperCAmelCase       ,    UpperCAmelCase    )

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

																			check_hidden_states_output(UpperCAmelCase       ,    UpperCAmelCase       ,    UpperCAmelCase    )

	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							_UpperCAmelCase									=			self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_image_classification(*UpperCAmelCase    )

	@slow
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							for model_name in TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													_UpperCAmelCase									=			TFResNetModel.from_pretrained(UpperCAmelCase    )
													self.assertIsNotNone(UpperCAmelCase    )



def __A    (      )->  Optional[Any]:





						"""simple docstring"""



						_UpperCAmelCase									=			Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'	)
						return image





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





	"""simple docstring"""






	@cached_property
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							return (
							    AutoImageProcessor.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]    )
							    if is_vision_available()
							    else None
							)

	@slow
	def        UpperCamelCase    (							self    ):
							"""simple docstring"""







							_UpperCAmelCase									=			TFResNetForImageClassification.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]    )

							_UpperCAmelCase									=			self.default_image_processor
							_UpperCAmelCase									=			prepare_img()
							_UpperCAmelCase									=			image_processor(images=UpperCAmelCase       ,    return_tensors='tf'    )

							# forward pass
							_UpperCAmelCase									=			model(**UpperCAmelCase    )

							# verify the logits
							_UpperCAmelCase									=			tf.TensorShape((1, 1000)    )
							self.assertEqual(outputs.logits.shape       ,    UpperCAmelCase    )

							_UpperCAmelCase									=			tf.constant([-11.10_69, -9.78_77, -8.37_77]    )

							self.assertTrue(np.allclose(outputs.logits[0, :3].numpy()       ,    UpperCAmelCase       ,    atol=1e-4    )    )
