

"""simple docstring"""






import inspect

import jax
import jax.lax as lax
import jax.numpy as jnp

from ..utils import add_start_docstrings
from ..utils.logging import get_logger


_lowerCAmelCase						=		get_logger(__name__)


_lowerCAmelCase						=		r"""
    Args:
        input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary.

            Indices can be obtained using [`PreTrainedTokenizer`]. See [`PreTrainedTokenizer.encode`] and
            [`PreTrainedTokenizer.__call__`] for details.

            [What are input IDs?](../glossary#input-ids)
        scores (`jnp.ndarray` of shape `(batch_size, config.vocab_size)`):
            Prediction scores of a language modeling head. These can be logits for each vocabulary when not using beam
            search or log softmax for each vocabulary token when using beam search
        kwargs (`Dict[str, Any]`, *optional*):
            Additional logits processor specific kwargs.

    Return:
        `jnp.ndarray` of shape `(batch_size, config.vocab_size)`: The processed prediction scores.

"""







class 	__UpperCamelCase    :

  @add_start_docstrings(_A      )
  def __call__(		self    ,_A    ,_A      ):
      '''simple docstring'''

      raise NotImplementedError(
          F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""      )







class 	__UpperCamelCase    :

  @add_start_docstrings(_A      )
  def __call__(		self    ,_A    ,_A      ):
      '''simple docstring'''

      raise NotImplementedError(
          F"""{self.__class__} is an abstract class. Only classes inheriting this class can be called."""      )







class 	__UpperCamelCase    (    a__						):

  @add_start_docstrings(_A      )
  def __call__(		self    ,_A    ,_A    ,_A    ,**_A      ):
      '''simple docstring'''

      for processor in self:
          _lowerCAmelCase       :   List[Any]  =    inspect.signature(processor.__call__      ).parameters
          if len(_A      ) > 3:
              if not all(arg in kwargs for arg in list(function_args.keys()      )[2:]      ):
                  raise ValueError(
                      F"""Make sure that all the required parameters: {list(function_args.keys()      )} for """
                      F"""{processor.__class__} are passed to the logits processor."""      )
              _lowerCAmelCase       :   Tuple  =    processor(_A    ,_A    ,_A    ,**_A      )
          else:
              _lowerCAmelCase       :   Optional[int]  =    processor(_A    ,_A    ,_A      )
      return scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A      ):
      '''simple docstring'''

      if not isinstance(_A    ,_A      ) or not (temperature > 0):
          raise ValueError(F"""`temperature` has to be a strictly positive float, but is {temperature}"""      )

      _lowerCAmelCase       :   List[Any]  =    temperature







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   int  =    scores / self.temperature
      return scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A    ,_A = -float('Inf'      )    ,_A = 1      ):
      '''simple docstring'''

      if not isinstance(_A    ,_A      ) or (top_p < 0 or top_p > 1.0):
          raise ValueError(F"""`top_p` has to be a float > 0 and < 1, but is {top_p}"""      )
      if not isinstance(_A    ,_A      ) or (min_tokens_to_keep < 1):
          raise ValueError(F"""`min_tokens_to_keep` has to be a positive integer, but is {min_tokens_to_keep}"""      )

      _lowerCAmelCase       :   List[Any]  =    top_p
      _lowerCAmelCase       :   str  =    filter_value
      _lowerCAmelCase       :   Union[str, Any]  =    min_tokens_to_keep







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Union[str, Any]  =    lax.top_k(_A    ,scores.shape[-1]      )

      _lowerCAmelCase       :   Union[str, Any]  =    jnp.full_like(_A    ,self.filter_value      )
      _lowerCAmelCase       :   Optional[int]  =    jax.nn.softmax(_A    ,axis=-1      ).cumsum(axis=-1      )
      _lowerCAmelCase       :   Optional[int]  =    cumulative_probs < self.top_p

      # include the token that is higher than top_p as well
      _lowerCAmelCase       :   Optional[Any]  =    jnp.roll(_A    ,1      )
      score_mask |= score_mask.at[:, 0].set(_A      )

      # min tokens to keep
      _lowerCAmelCase       :   List[str]  =    score_mask.at[:, : self.min_tokens_to_keep].set(_A      )

      _lowerCAmelCase       :   List[str]  =    jnp.where(_A    ,_A    ,_A      )
      _lowerCAmelCase       :   Tuple  =    jax.lax.sort_key_val(_A    ,_A      )[-1]

      return next_scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A    ,_A = -float('Inf'      )    ,_A = 1      ):
      '''simple docstring'''

      if not isinstance(_A    ,_A      ) or top_k <= 0:
          raise ValueError(F"""`top_k` has to be a strictly positive integer, but is {top_k}"""      )

      _lowerCAmelCase       :   Dict  =    max(_A    ,_A      )
      _lowerCAmelCase       :   Dict  =    filter_value







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Tuple  =    scores.shape
      _lowerCAmelCase       :   Union[str, Any]  =    jnp.full(batch_size * vocab_size    ,self.filter_value      )

      _lowerCAmelCase       :   str  =    min(self.top_k    ,scores.shape[-1]      )  # Safety check
      _lowerCAmelCase       :   int  =    lax.top_k(_A    ,_A      )
      _lowerCAmelCase       :   Union[str, Any]  =    jnp.broadcast_to((jnp.arange(_A      ) * vocab_size)[:, None]    ,(batch_size, topk)      ).flatten()
      _lowerCAmelCase       :   Optional[int]  =    topk_scores.flatten()
      _lowerCAmelCase       :   Optional[int]  =    topk_indices.flatten() + shift

      _lowerCAmelCase       :   List[Any]  =    next_scores_flat.at[topk_indices_flat].set(_A      )
      _lowerCAmelCase       :   Union[str, Any]  =    next_scores_flat.reshape(_A    ,_A      )
      return next_scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Any  =    bos_token_id







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   List[str]  =    jnp.full(scores.shape    ,-float('inf'      )      )

      _lowerCAmelCase       :   Any  =    1 - jnp.bool_(cur_len - 1      )

      _lowerCAmelCase       :   Optional[Any]  =    jnp.where(_A    ,new_scores.at[:, self.bos_token_id].set(0      )    ,_A      )

      return scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Optional[Any]  =    max_length
      _lowerCAmelCase       :   Dict  =    eos_token_id







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Any  =    jnp.full(scores.shape    ,-float('inf'      )      )

      _lowerCAmelCase       :   Optional[int]  =    1 - jnp.bool_(cur_len - self.max_length + 1      )

      _lowerCAmelCase       :   Any  =    jnp.where(_A    ,new_scores.at[:, self.eos_token_id].set(0      )    ,_A      )

      return scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A    ,_A      ):
      '''simple docstring'''

      if not isinstance(_A    ,_A      ) or min_length < 0:
          raise ValueError(F"""`min_length` has to be a positive integer, but is {min_length}"""      )

      if not isinstance(_A    ,_A      ) or eos_token_id < 0:
          raise ValueError(F"""`eos_token_id` has to be a positive integer, but is {eos_token_id}"""      )

      _lowerCAmelCase       :   Union[str, Any]  =    min_length
      _lowerCAmelCase       :   Dict  =    eos_token_id







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Union[str, Any]  =    1 - jnp.clip(cur_len - self.min_length    ,0    ,1      )

      _lowerCAmelCase       :   int  =    jnp.where(_A    ,scores.at[:, self.eos_token_id].set(-float('inf'      )      )    ,_A      )

      return scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Any  =    list(_A      )
      _lowerCAmelCase       :   str  =    begin_index







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Optional[Any]  =    1 - jnp.bool_(cur_len - self.begin_index      )

      _lowerCAmelCase       :   List[Any]  =    jnp.where(_A    ,scores.at[:, self.begin_suppress_tokens].set(-float('inf'      )      )    ,_A      )

      return scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   List[Any]  =    list(_A      )







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   str  =    scores.at[..., self.suppress_tokens].set(-float('inf'      )      )

      return scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Optional[Any]  =    dict(_A      )
      # Converts the dictionary of format {index: token} containing the tokens to be forced to an array, where the
      # index of the array corresponds to the index of the token to be forced, for XLA compatibility.
      # Indexes without forced tokens will have a negative value.
      _lowerCAmelCase       :   int  =    jnp.ones((max(force_token_map.keys()      ) + 1)    ,dtype=jnp.intaa      ) * -1
      for index, token in force_token_map.items():
          if token is not None:
              _lowerCAmelCase       :   Optional[int]  =    force_token_array.at[index].set(_A      )
      _lowerCAmelCase       :   str  =    jnp.intaa(_A      )







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      def _force_token(_A      ):
          _lowerCAmelCase       :   List[str]  =    scores.shape[0]
          _lowerCAmelCase       :   Tuple  =    self.force_token_array[generation_idx]

          _lowerCAmelCase       :   int  =    jnp.ones_like(_A    ,dtype=scores.dtype      ) * -float('inf'      )
          _lowerCAmelCase       :   List[Any]  =    jnp.zeros((batch_size, 1)    ,dtype=scores.dtype      )
          _lowerCAmelCase       :   Optional[Any]  =    lax.dynamic_update_slice(_A    ,_A    ,(0, current_token)      )
          return new_scores

      _lowerCAmelCase       :   Optional[int]  =    lax.cond(
          cur_len >= self.force_token_array.shape[0]    ,lambda: scores    ,lambda: lax.cond(
              self.force_token_array[cur_len] >= 0    ,lambda: _force_token(_A      )    ,lambda: scores    ,)    ,)
      return scores







class 	__UpperCamelCase    (    a__						):

  def __init__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   List[Any]  =    generate_config.eos_token_id
      _lowerCAmelCase       :   Union[str, Any]  =    generate_config.no_timestamps_token_id
      _lowerCAmelCase       :   List[str]  =    generate_config.no_timestamps_token_id + 1

      _lowerCAmelCase       :   Optional[Any]  =    decoder_input_length + 1

      if generate_config.is_multilingual:
          # room for language token and task token
          self.begin_index += 2
      if hasattr(_A    ,'max_initial_timestamp_index'      ):
          _lowerCAmelCase       :   Optional[Any]  =    generate_config.max_initial_timestamp_index
      else:
          _lowerCAmelCase       :   Optional[int]  =    model_config.vocab_size
      if self.max_initial_timestamp_index is None:
          _lowerCAmelCase       :   str  =    model_config.vocab_size







  def __call__(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   str  =    scores.at[:, self.no_timestamps_token_id].set(-float('inf'      )      )

      def handle_pairs(_A    ,_A      ):
          _lowerCAmelCase       :   str  =    jnp.where((cur_len - self.begin_index) >= 1    ,_A    ,_A      )
          _lowerCAmelCase       :   Union[str, Any]  =    jnp.where(
              input_ids_k[cur_len - 1] >= self.timestamp_begin    ,True and last_was_timestamp    ,_A    ,)

          _lowerCAmelCase       :   Any  =    jnp.where((cur_len - self.begin_index) < 2    ,_A    ,_A      )
          _lowerCAmelCase       :   int  =    jnp.where(
              input_ids_k[cur_len - 2] >= self.timestamp_begin    ,_A    ,_A    ,)

          return jnp.where(
              _A    ,jnp.where(
                  penultimate_was_timestamp > 0    ,scores_k.at[self.timestamp_begin :].set(-float('inf'      )      )    ,scores_k.at[: self.eos_token_id].set(-float('inf'      )      )    ,)    ,_A    ,)

      _lowerCAmelCase       :   Dict  =    jax.vmap(_A      )(_A    ,_A      )

      _lowerCAmelCase       :   Tuple  =    jnp.where(cur_len == self.begin_index    ,_A    ,_A      )
      _lowerCAmelCase       :   List[str]  =    jnp.where(
          self.max_initial_timestamp_index is not None    ,True and apply_max_initial_timestamp    ,_A    ,)

      _lowerCAmelCase       :   Dict  =    self.timestamp_begin + self.max_initial_timestamp_index

      _lowerCAmelCase       :   Dict  =    jnp.where(
          _A    ,scores.at[:, last_allowed + 1 :].set(-float('inf'      )      )    ,_A    ,)

      # if sum of probability over timestamps is above any other token, sample timestamp
      _lowerCAmelCase       :   Dict  =    jax.nn.log_softmax(_A    ,axis=-1      )

      def handle_cumulative_probs(_A    ,_A      ):
          _lowerCAmelCase       :   Tuple  =    jax.nn.logsumexp(logprobs_k[self.timestamp_begin :]    ,axis=-1      )
          _lowerCAmelCase       :   Tuple  =    jnp.max(logprobs_k[: self.timestamp_begin]      )
          return jnp.where(
              timestamp_logprob > max_text_token_logprob    ,scores_k.at[: self.timestamp_begin].set(-float('inf'      )      )    ,_A    ,)

      _lowerCAmelCase       :   Any  =    jax.vmap(_A      )(_A    ,_A      )

      return scores








"""simple docstring"""






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 	__UpperCamelCase    :

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

      _lowerCAmelCase       :   Union[str, Any]  =    parent
      _lowerCAmelCase       :   int  =    batch_size
      _lowerCAmelCase       :   int  =    image_size
      _lowerCAmelCase       :   List[str]  =    num_channels
      _lowerCAmelCase       :   Optional[int]  =    embeddings_size
      _lowerCAmelCase       :   Optional[int]  =    hidden_sizes
      _lowerCAmelCase       :   str  =    depths
      _lowerCAmelCase       :   str  =    is_training
      _lowerCAmelCase       :   int  =    use_labels
      _lowerCAmelCase       :   Optional[int]  =    hidden_act
      _lowerCAmelCase       :   Optional[int]  =    num_labels
      _lowerCAmelCase       :   Dict  =    scope
      _lowerCAmelCase       :   Union[str, Any]  =    len(_A      )

  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Optional[int]  =    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]      )

      _lowerCAmelCase       :   Optional[Any]  =    None
      if self.use_labels:
          _lowerCAmelCase       :   List[Any]  =    ids_tensor([self.batch_size]    ,self.num_labels      )

      _lowerCAmelCase       :   Union[str, Any]  =    self.get_config()

      return config, pixel_values, labels

  def __lowerCamelCase		(		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 __lowerCamelCase		(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Optional[Any]  =    TFResNetModel(config=_A      )
      _lowerCAmelCase       :   List[str]  =    model(_A      )
      # 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 __lowerCamelCase		(		self    ,_A    ,_A    ,_A      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Any  =    self.num_labels
      _lowerCAmelCase       :   Dict  =    TFResNetForImageClassification(_A      )
      _lowerCAmelCase       :   int  =    model(_A    ,labels=_A      )
      self.parent.assertEqual(result.logits.shape    ,(self.batch_size, self.num_labels)      )







  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Union[str, Any]  =    self.prepare_config_and_inputs()
      _lowerCAmelCase,					_lowerCAmelCase,					_lowerCAmelCase       :   Tuple  =    config_and_inputs
      _lowerCAmelCase       :   Any  =    {'pixel_values': pixel_values}
      return config, inputs_dict







@require_tf
class 	__UpperCamelCase    (    a__							,							a__							,							unittest.TestCase						):
  _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 __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase       :   List[str]  =    TFResNetModelTester(self      )
      _lowerCAmelCase       :   List[str]  =    ConfigTester(self    ,config_class=_A    ,has_text_modality=_A      )

  def __lowerCamelCase		(		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 __lowerCamelCase		(		self      ):
      '''simple docstring'''

      return

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

      pass

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

      pass

  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase,					_lowerCAmelCase       :   Optional[int]  =    self.model_tester.prepare_config_and_inputs_for_common()

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

          _lowerCAmelCase       :   str  =    ['pixel_values']
          self.assertListEqual(arg_names[:1]    ,_A      )

  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Dict  =    self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model(*_A      )

  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      def check_hidden_states_output(_A    ,_A    ,_A      ):
          _lowerCAmelCase       :   int  =    model_class(_A      )
          _lowerCAmelCase       :   int  =    model(**self._prepare_for_class(_A    ,_A      )      )

          _lowerCAmelCase       :   Dict  =    outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

          _lowerCAmelCase       :   int  =    self.model_tester.num_stages
          self.assertEqual(len(_A      )    ,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]    ,)

      _lowerCAmelCase,					_lowerCAmelCase       :   List[str]  =    self.model_tester.prepare_config_and_inputs_for_common()
      _lowerCAmelCase       :   Any  =    ['basic', 'bottleneck']
      for model_class in self.all_model_classes:
          for layer_type in layers_type:
              _lowerCAmelCase       :   Optional[int]  =    layer_type
              _lowerCAmelCase       :   Tuple  =    True
              check_hidden_states_output(_A    ,_A    ,_A      )

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

              check_hidden_states_output(_A    ,_A    ,_A      )

  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase       :   str  =    self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_for_image_classification(*_A      )







  @slow
  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      for model_name in TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
          _lowerCAmelCase       :   Optional[Any]  =    TFResNetModel.from_pretrained(_A      )
          self.assertIsNotNone(_A      )





def 		lowerCamelCase__		(					):

    '''simple docstring'''



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







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

  @cached_property
  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

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







  @slow
  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase       :   str  =    TFResNetForImageClassification.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]      )

      _lowerCAmelCase       :   Tuple  =    self.default_image_processor
      _lowerCAmelCase       :   Optional[Any]  =    prepare_img()
      _lowerCAmelCase       :   int  =    image_processor(images=_A    ,return_tensors='tf'      )

      # forward pass
      _lowerCAmelCase       :   int  =    model(**_A      )

      # verify the logits
      _lowerCAmelCase       :   Optional[Any]  =    tf.TensorShape((1, 1000)      )
      self.assertEqual(outputs.logits.shape    ,_A      )

      _lowerCAmelCase       :   Any  =    tf.constant([-1_1.1_0_6_9, -9.7_8_7_7, -8.3_7_7_7]      )

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





