


import warnings
from typing import Any, Dict, List, Optional, Union

import numpy as np

from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function
from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
from ...utils import PaddingStrategy, TensorType, logging


__lowerCAmelCase			=							logging.get_logger(__name__)





class   __a      (   __UpperCamelCase				):
 __lowercase			:							Tuple       					=			['input_values', 'attention_mask']
 def __init__(       self    ,			lowerCAmelCase__ = 1    ,			lowerCAmelCase__ = 16_000    ,			lowerCAmelCase__ = 0.0    ,			lowerCAmelCase__ = False    ,			lowerCAmelCase__ = 80    ,			lowerCAmelCase__ = 16    ,			lowerCAmelCase__ = 64    ,			lowerCAmelCase__ = "hann_window"    ,			lowerCAmelCase__ = 1.0    ,			lowerCAmelCase__ = 80    ,			lowerCAmelCase__ = 7_600    ,			lowerCAmelCase__ = 1E-10    ,			lowerCAmelCase__ = 2    ,			lowerCAmelCase__ = True    ,			**lowerCAmelCase__    ,			) ->    List[Any]:




        '''simple docstring'''
        super().__init__(feature_size=lowerCAmelCase__    ,			sampling_rate=lowerCAmelCase__    ,			padding_value=lowerCAmelCase__    ,			**lowerCAmelCase__			)
        lowercase__:       Dict        =       do_normalize
        lowercase__:       Optional[Any]        =       return_attention_mask

        lowercase__:       str        =       num_mel_bins
        lowercase__:       Dict        =       hop_length
        lowercase__:       Dict        =       win_length
        lowercase__:       Optional[int]        =       win_function
        lowercase__:       Any        =       frame_signal_scale
        lowercase__:       Tuple        =       fmin
        lowercase__:       Tuple        =       fmax
        lowercase__:       Dict        =       mel_floor
        lowercase__:       int        =       reduction_factor

        lowercase__:       List[Any]        =       win_length * sampling_rate // 1_000
        lowercase__:       Optional[Any]        =       hop_length * sampling_rate // 1_000
        lowercase__:       Optional[int]        =       optimal_fft_length(self.sample_size			)
        lowercase__:       Optional[Any]        =       (self.n_fft // 2) + 1

        lowercase__:       str        =       window_function(window_length=self.sample_size    ,			name=self.win_function    ,			periodic=lowerCAmelCase__			)

        lowercase__:       Optional[Any]        =       mel_filter_bank(
            num_frequency_bins=self.n_freqs    ,			num_mel_filters=self.num_mel_bins    ,			min_frequency=self.fmin    ,			max_frequency=self.fmax    ,			sampling_rate=self.sampling_rate    ,			norm='slaney'    ,			mel_scale='slaney'    ,			)

        if frame_signal_scale != 1.0:
               warnings.warn(
                   'The argument `frame_signal_scale` is deprecated and will be removed in version 4.30.0 of Transformers'    ,			lowerCAmelCase__    ,			)
        if reduction_factor != 2.0:
               warnings.warn(
                   'The argument `reduction_factor` is deprecated and will be removed in version 4.30.0 of Transformers'    ,			lowerCAmelCase__    ,			)
 @staticmethod
 # Copied from transformers.models.wav2vec2.feature_extraction_wav2vec2.Wav2Vec2FeatureExtractor.zero_mean_unit_var_norm
 def 		SCREAMING_SNAKE_CASE__       (       lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__ = 0.0			) ->    List[np.ndarray]:




        '''simple docstring'''
        if attention_mask is not None:
               lowercase__:       List[str]        =       np.array(lowerCAmelCase__    ,			np.intaa			)
               lowercase__:       Tuple        =       []

               for vector, length in zip(lowerCAmelCase__    ,			attention_mask.sum(-1			)			):
                      lowercase__:       int        =       (vector - vector[:length].mean()) / np.sqrt(vector[:length].var() + 1E-7			)
                      if length < normed_slice.shape[0]:
                             lowercase__:       Tuple        =       padding_value

                      normed_input_values.append(lowerCAmelCase__			)
        else:
               lowercase__:       Union[str, Any]        =       [(x - x.mean()) / np.sqrt(x.var() + 1E-7			) for x in input_values]

        return normed_input_values
 def 		SCREAMING_SNAKE_CASE__       (       self    ,			lowerCAmelCase__    ,			) ->    np.ndarray:




        '''simple docstring'''
        lowercase__:       List[str]        =       spectrogram(
            lowerCAmelCase__    ,			window=self.window    ,			frame_length=self.sample_size    ,			hop_length=self.sample_stride    ,			fft_length=self.n_fft    ,			mel_filters=self.mel_filters    ,			mel_floor=self.mel_floor    ,			log_mel='log10'    ,			)
        return log_mel_spec.T
 def __call__(       self    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = False    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = False    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = None    ,			**lowerCAmelCase__    ,			) ->    BatchFeature:




        '''simple docstring'''
        if audio is None and audio_target is None:
               raise ValueError('You must provide either `audio` or `audio_target` values.'			)

        if sampling_rate is not None:
               if sampling_rate != self.sampling_rate:
                      raise ValueError(
                          F'The model corresponding to this feature extractor: {self} was trained using a sampling rate of'
                          F' {self.sampling_rate}. Please make sure that the provided audio input was sampled with'
                          F' {self.sampling_rate} and not {sampling_rate}.'			)
        else:
               logger.warning(
                   'It is strongly recommended to pass the ``sampling_rate`` argument to this function. '
                   'Failing to do so can result in silent errors that might be hard to debug.'			)

        if audio is not None:
               lowercase__:       Dict        =       self._process_audio(
                   lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			**lowerCAmelCase__    ,			)
        else:
               lowercase__:       str        =       None

        if audio_target is not None:
               lowercase__:       List[str]        =       self._process_audio(
                   lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			**lowerCAmelCase__    ,			)

               if inputs is None:
                      return inputs_target
               else:
                      lowercase__:       int        =       inputs_target['input_values']
                      lowercase__:       List[str]        =       inputs_target.get('attention_mask'			)
                      if decoder_attention_mask is not None:
                             lowercase__:       Optional[int]        =       decoder_attention_mask

        return inputs
 def 		SCREAMING_SNAKE_CASE__       (       self    ,			lowerCAmelCase__    ,			lowerCAmelCase__ = False    ,			lowerCAmelCase__ = False    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = False    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = None    ,			lowerCAmelCase__ = None    ,			**lowerCAmelCase__    ,			) ->    BatchFeature:




        '''simple docstring'''
        lowercase__:       int        =       isinstance(lowerCAmelCase__    ,			np.ndarray			) and len(speech.shape			) > 1
        if is_batched_numpy and len(speech.shape			) > 2:
               raise ValueError(F'Only mono-channel audio is supported for input to {self}'			)
        lowercase__:       Tuple        =       is_batched_numpy or (
            isinstance(lowerCAmelCase__    ,			(list, tuple)			) and (isinstance(speech[0]    ,			(np.ndarray, tuple, list)			))
        )

        if is_batched:
               lowercase__:       Dict        =       [np.asarray(lowerCAmelCase__    ,			dtype=np.floataa			) for speech in speech]
        elif not is_batched and not isinstance(lowerCAmelCase__    ,			np.ndarray			):
               lowercase__:       Optional[Any]        =       np.asarray(lowerCAmelCase__    ,			dtype=np.floataa			)
        elif isinstance(lowerCAmelCase__    ,			np.ndarray			) and speech.dtype is np.dtype(np.floataa			):
               lowercase__:       Optional[Any]        =       speech.astype(np.floataa			)

        # always return batch
        if not is_batched:
               lowercase__:       Optional[int]        =       [speech]

        # needed to make pad() work on spectrogram inputs
        lowercase__:       str        =       self.feature_size

        # convert into correct format for padding
        if is_target:
               lowercase__:       int        =       [self._extract_mel_features(lowerCAmelCase__			) for waveform in speech]
               lowercase__:       Dict        =       BatchFeature({'input_values': features}			)
               lowercase__:       Union[str, Any]        =       self.num_mel_bins
        else:
               lowercase__:       Union[str, Any]        =       BatchFeature({'input_values': speech}			)

        lowercase__:       Dict        =       self.pad(
            lowerCAmelCase__    ,			padding=lowerCAmelCase__    ,			max_length=lowerCAmelCase__    ,			truncation=lowerCAmelCase__    ,			pad_to_multiple_of=lowerCAmelCase__    ,			return_attention_mask=lowerCAmelCase__    ,			**lowerCAmelCase__    ,			)

        lowercase__:       List[str]        =       feature_size_hack

        # convert input values to correct format
        lowercase__:       Union[str, Any]        =       padded_inputs['input_values']
        if not isinstance(input_values[0]    ,			np.ndarray			):
               lowercase__:       List[Any]        =       [np.asarray(lowerCAmelCase__    ,			dtype=np.floataa			) for array in input_values]
        elif (
            not isinstance(lowerCAmelCase__    ,			np.ndarray			)
            and isinstance(input_values[0]    ,			np.ndarray			)
            and input_values[0].dtype is np.dtype(np.floataa			)
        ):
               lowercase__:       Dict        =       [array.astype(np.floataa			) for array in input_values]
        elif isinstance(lowerCAmelCase__    ,			np.ndarray			) and input_values.dtype is np.dtype(np.floataa			):
               lowercase__:       Tuple        =       input_values.astype(np.floataa			)

        # convert attention_mask to correct format
        lowercase__:       Tuple        =       padded_inputs.get('attention_mask'			)
        if attention_mask is not None:
               lowercase__:       str        =       [np.asarray(lowerCAmelCase__    ,			dtype=np.intaa			) for array in attention_mask]

        # zero-mean and unit-variance normalization
        if not is_target and self.do_normalize:
               lowercase__:       Tuple        =       (
                   attention_mask
                   if self._get_padding_strategies(lowerCAmelCase__    ,			max_length=lowerCAmelCase__			) is not PaddingStrategy.DO_NOT_PAD
                   else None
               )
               lowercase__:       str        =       self.zero_mean_unit_var_norm(
                   padded_inputs['input_values']    ,			attention_mask=lowerCAmelCase__    ,			padding_value=self.padding_value			)

        if return_tensors is not None:
               lowercase__:       Union[str, Any]        =       padded_inputs.convert_to_tensors(lowerCAmelCase__			)

        return padded_inputs
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Dict[str, Any]:




        '''simple docstring'''
        lowercase__:       int        =       super().to_dict()

        # Don't serialize these as they are derived from the other properties.
        lowercase__:       str        =       ['window', 'mel_filters', 'sample_size', 'sample_stride', 'n_fft', 'n_freqs']
        for name in names:
               if name in output:
                      del output[name]

        return output






from __future__ import annotations

import inspect
import unittest

import numpy as np

from transformers import DeiTConfig
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 (
     TFDeiTForImageClassification,
     TFDeiTForImageClassificationWithTeacher,
     TFDeiTForMaskedImageModeling,
     TFDeiTModel,
 )
 from transformers.models.deit.modeling_tf_deit import TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
 from PIL import Image

 from transformers import DeiTImageProcessor





class   __a      :
 def __init__(       self    ,			lowerCAmelCase__    ,			lowerCAmelCase__=13    ,			lowerCAmelCase__=30    ,			lowerCAmelCase__=2    ,			lowerCAmelCase__=3    ,			lowerCAmelCase__=True    ,			lowerCAmelCase__=True    ,			lowerCAmelCase__=32    ,			lowerCAmelCase__=2    ,			lowerCAmelCase__=4    ,			lowerCAmelCase__=37    ,			lowerCAmelCase__="gelu"    ,			lowerCAmelCase__=0.1    ,			lowerCAmelCase__=0.1    ,			lowerCAmelCase__=10    ,			lowerCAmelCase__=0.0_2    ,			lowerCAmelCase__=3    ,			lowerCAmelCase__=None    ,			lowerCAmelCase__=2    ,			) ->    List[str]:




        '''simple docstring'''
        lowercase__:       List[str]        =       parent
        lowercase__:       Tuple        =       batch_size
        lowercase__:       Optional[Any]        =       image_size
        lowercase__:       int        =       patch_size
        lowercase__:       Union[str, Any]        =       num_channels
        lowercase__:       Dict        =       is_training
        lowercase__:       Any        =       use_labels
        lowercase__:       Optional[int]        =       hidden_size
        lowercase__:       Tuple        =       num_hidden_layers
        lowercase__:       List[str]        =       num_attention_heads
        lowercase__:       Any        =       intermediate_size
        lowercase__:       Union[str, Any]        =       hidden_act
        lowercase__:       Union[str, Any]        =       hidden_dropout_prob
        lowercase__:       Optional[Any]        =       attention_probs_dropout_prob
        lowercase__:       str        =       type_sequence_label_size
        lowercase__:       List[str]        =       initializer_range
        lowercase__:       Optional[Any]        =       scope
        lowercase__:       Dict        =       encoder_stride

        # in DeiT, the seq length equals the number of patches + 2 (we add 2 for the [CLS] and distilation tokens)
        lowercase__:       List[str]        =       (image_size // patch_size) ** 2
        lowercase__:       Tuple        =       num_patches + 2
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Optional[int]:




        '''simple docstring'''
        lowercase__:       List[Any]        =       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

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

        lowercase__:       List[str]        =       self.get_config()

        return config, pixel_values, labels
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Optional[Any]:




        '''simple docstring'''
        return DeiTConfig(
            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    ,			)
 def 		SCREAMING_SNAKE_CASE__       (       self    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__			) ->    int:




        '''simple docstring'''
        lowercase__:       List[str]        =       TFDeiTModel(config=lowerCAmelCase__			)
        lowercase__:       Any        =       model(lowerCAmelCase__			)
        self.parent.assertEqual(result.last_hidden_state.shape    ,			(self.batch_size, self.seq_length, self.hidden_size)			)
 def 		SCREAMING_SNAKE_CASE__       (       self    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__			) ->    Union[str, Any]:




        '''simple docstring'''
        lowercase__:       Any        =       TFDeiTForMaskedImageModeling(config=lowerCAmelCase__			)
        lowercase__:       int        =       model(lowerCAmelCase__			)
        self.parent.assertEqual(
            result.reconstruction.shape    ,			(self.batch_size, self.num_channels, self.image_size, self.image_size)			)

        # test greyscale images
        lowercase__:       Tuple        =       1
        lowercase__:       Optional[int]        =       TFDeiTForMaskedImageModeling(lowerCAmelCase__			)

        lowercase__:       int        =       floats_tensor([self.batch_size, 1, self.image_size, self.image_size]			)
        lowercase__:       str        =       model(lowerCAmelCase__			)
        self.parent.assertEqual(result.reconstruction.shape    ,			(self.batch_size, 1, self.image_size, self.image_size)			)
 def 		SCREAMING_SNAKE_CASE__       (       self    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__			) ->    List[Any]:




        '''simple docstring'''
        lowercase__:       Any        =       self.type_sequence_label_size
        lowercase__:       Optional[Any]        =       TFDeiTForImageClassification(lowerCAmelCase__			)
        lowercase__:       List[Any]        =       model(lowerCAmelCase__    ,			labels=lowerCAmelCase__			)
        self.parent.assertEqual(result.logits.shape    ,			(self.batch_size, self.type_sequence_label_size)			)

        # test greyscale images
        lowercase__:       Optional[Any]        =       1
        lowercase__:       Union[str, Any]        =       TFDeiTForImageClassification(lowerCAmelCase__			)

        lowercase__:       List[str]        =       floats_tensor([self.batch_size, 1, self.image_size, self.image_size]			)
        lowercase__:       str        =       model(lowerCAmelCase__    ,			labels=lowerCAmelCase__			)
        self.parent.assertEqual(result.logits.shape    ,			(self.batch_size, self.type_sequence_label_size)			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Tuple:




        '''simple docstring'''
        lowercase__:       Dict        =       self.prepare_config_and_inputs()
        lowercase__      ,						lowercase__      ,						lowercase__:       Dict        =       config_and_inputs
        lowercase__:       Optional[Any]        =       {'pixel_values': pixel_values}
        return config, inputs_dict





@require_tf
class   __a      (   __UpperCamelCase	,	__UpperCamelCase	,	unittest.TestCase				):
 __lowercase			:							Union[str, Any]       					=			(
     (
         TFDeiTModel,
         TFDeiTForImageClassification,
         TFDeiTForImageClassificationWithTeacher,
         TFDeiTForMaskedImageModeling,
     )
     if is_tf_available()
     else ()
 )
 __lowercase			:							Union[str, Any]       					=			(
     {
         'feature-extraction': TFDeiTModel,
         'image-classification': (TFDeiTForImageClassification, TFDeiTForImageClassificationWithTeacher),
     }
     if is_tf_available()
     else {}
 )

 __lowercase			:							Union[str, Any]       					=			False
 __lowercase			:							Tuple       					=			False
 __lowercase			:							int       					=			False
 __lowercase			:							Optional[int]       					=			False
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    List[Any]:




        '''simple docstring'''
        lowercase__:       List[Any]        =       TFDeiTModelTester(self			)
        lowercase__:       int        =       ConfigTester(self    ,			config_class=lowerCAmelCase__    ,			has_text_modality=lowerCAmelCase__    ,			hidden_size=37			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    List[str]:




        '''simple docstring'''
        self.config_tester.run_common_tests()
 @unittest.skip(reason='DeiT does not use inputs_embeds'			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    List[str]:




        '''simple docstring'''
        pass
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Dict:




        '''simple docstring'''
        lowercase__      ,						lowercase__:       int        =       self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
               lowercase__:       Tuple        =       model_class(lowerCAmelCase__			)
               self.assertIsInstance(model.get_input_embeddings()    ,			(tf.keras.layers.Layer)			)
               lowercase__:       Union[str, Any]        =       model.get_output_embeddings()
               self.assertTrue(x is None or isinstance(lowerCAmelCase__    ,			tf.keras.layers.Dense			)			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Union[str, Any]:




        '''simple docstring'''
        lowercase__      ,						lowercase__:       Union[str, Any]        =       self.model_tester.prepare_config_and_inputs_for_common()

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

               lowercase__:       Any        =       ['pixel_values']
               self.assertListEqual(arg_names[:1]    ,			lowerCAmelCase__			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Dict:




        '''simple docstring'''
        lowercase__:       Dict        =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*lowerCAmelCase__			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    List[str]:




        '''simple docstring'''
        lowercase__:       Tuple        =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_masked_image_modeling(*lowerCAmelCase__			)
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    int:




        '''simple docstring'''
        lowercase__:       List[Any]        =       self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase__			)
 def 		SCREAMING_SNAKE_CASE__       (       self    ,			lowerCAmelCase__    ,			lowerCAmelCase__    ,			lowerCAmelCase__=False			) ->    List[Any]:




        '''simple docstring'''
        lowercase__:       Union[str, Any]        =       super()._prepare_for_class(lowerCAmelCase__    ,			lowerCAmelCase__    ,			return_labels=lowerCAmelCase__			)

        if return_labels:
               if "labels" in inputs_dict and "labels" not in inspect.signature(model_class.call			).parameters:
                      del inputs_dict["labels"]

        return inputs_dict
 @slow
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Tuple:




        '''simple docstring'''
        for model_name in TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               lowercase__:       Union[str, Any]        =       TFDeiTModel.from_pretrained(lowerCAmelCase__			)
               self.assertIsNotNone(lowerCAmelCase__			)





def        snake_case_					(  )  ->    Tuple:
       lowercase__:       Any        =       Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'					)
       return image





@require_tf
@require_vision
class   __a      (   unittest.TestCase				):
 @cached_property
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Tuple:




        '''simple docstring'''
        return (
            DeiTImageProcessor.from_pretrained('facebook/deit-base-distilled-patch16-224'			)
            if is_vision_available()
            else None
        )
 @slow
 def 		SCREAMING_SNAKE_CASE__       (       self			) ->    Dict:




        '''simple docstring'''
        lowercase__:       str        =       TFDeiTForImageClassificationWithTeacher.from_pretrained('facebook/deit-base-distilled-patch16-224'			)

        lowercase__:       str        =       self.default_image_processor
        lowercase__:       Dict        =       prepare_img()
        lowercase__:       Optional[int]        =       image_processor(images=lowerCAmelCase__    ,			return_tensors='tf'			)

        # forward pass
        lowercase__:       int        =       model(**lowerCAmelCase__			)

        # verify the logits
        lowercase__:       Tuple        =       tf.TensorShape((1, 1_000)			)
        self.assertEqual(outputs.logits.shape    ,			lowerCAmelCase__			)

        lowercase__:       List[Any]        =       tf.constant([-1.0_2_6_6, 0.1_9_1_2, -1.2_8_6_1]			)

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


