





'''simple docstring'''





import json
import re
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import numpy as np

from ...utils import is_tf_available, is_torch_available, logging


if TYPE_CHECKING:
  if is_torch_available():
    import torch
  if is_tf_available():
    import tensorflow as tf

from tokenizers import pre_tokenizers

from ...tokenization_utils_base import BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_codegen import CodeGenTokenizer


UpperCAmelCase_  							=				logging.get_logger(__name__)

UpperCAmelCase_  							=				{'vocab_file': 'vocab.json', 'merges_file': 'merges.txt', 'tokenizer_file': 'tokenizer.json'}

UpperCAmelCase_  							=				{
    'vocab_file': {
        'Salesforce/codegen-350M-mono': 'https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/vocab.json',
    },
    'merges_file': {
        'Salesforce/codegen-350M-mono': 'https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/merges.txt',
    },
    'tokenizer_file': {
        'Salesforce/codegen-350M-mono': (
            'https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/tokenizer.json'
        ),
    },
}

UpperCAmelCase_  							=				{
    'Salesforce/codegen-350M-mono': 2048,
}






class 					lowercase__ (			__lowerCamelCase       ):

   '''simple docstring'''


   a		:							Union[str, Any]     	=	VOCAB_FILES_NAMES
   a		:							List[str]     	=	PRETRAINED_VOCAB_FILES_MAP
   a		:							Optional[int]     	=	PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   a		:							List[Any]     	=	["input_ids", "attention_mask"]
   a		:							Any     	=	CodeGenTokenizer




   def __init__(					self,	__magic_name__=None,	__magic_name__=None,	__magic_name__=None,	__magic_name__="<|endoftext|>",	__magic_name__="<|endoftext|>",	__magic_name__="<|endoftext|>",	__magic_name__=False,	**__magic_name__,	)				->   Optional[int]:






       """simple docstring"""
       super().__init__(
           __magic_name__,	__magic_name__,	tokenizer_file=__magic_name__,	unk_token=__magic_name__,	bos_token=__magic_name__,	eos_token=__magic_name__,	add_prefix_space=__magic_name__,	**__magic_name__,	)

       if kwargs.pop('''add_bos_token''',	__magic_name__							):
           UpperCamelCase__							:       List[Any]      =   kwargs.pop('''name_or_path''',	''''''							)
           raise ValueError(
               '''Currenty GPT2\'s fast tokenizer does NOT support adding a BOS token.'''
               '''Instead you should use GPT2\'s slow tokenizer class `CodeGenTokenizer` as follows: \n'''
               f"`CodeGenTokenizer.from_pretrained('{model_id}')`\nor\n"
               f"`AutoTokenizer.from_pretrained('{model_id}', use_fast=False)`\n"
               '''This issue will be fixed soon, see: https://github.com/huggingface/tokenizers/pull/1005.'''
               ''' so that the fast tokenizer works correctly.'''							)

       UpperCamelCase__							:       Dict      =   json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()							)
       if pre_tok_state.get('''add_prefix_space''',	__magic_name__							) != add_prefix_space:
           UpperCamelCase__							:       List[str]      =   getattr(__magic_name__,	pre_tok_state.pop('''type'''							)							)
           UpperCamelCase__							:       int      =   add_prefix_space
           UpperCamelCase__							:       List[str]      =   pre_tok_class(**__magic_name__							)

       UpperCamelCase__							:       List[Any]      =   add_prefix_space




   def    UpperCamelCase__						(					self,	*__magic_name__,	**__magic_name__							)				->   BatchEncoding:






       """simple docstring"""
       UpperCamelCase__							:       List[Any]      =   kwargs.get('''is_split_into_words''',	__magic_name__							)
       assert self.add_prefix_space or not is_split_into_words, (
           f"You need to instantiate {self.__class__.__name__} with add_prefix_space=True "
           "to use it with pretokenized inputs."
       )

       return super()._batch_encode_plus(*__magic_name__,	**__magic_name__							)




   def    UpperCamelCase__						(					self,	*__magic_name__,	**__magic_name__							)				->   BatchEncoding:






       """simple docstring"""
       UpperCamelCase__							:       Dict      =   kwargs.get('''is_split_into_words''',	__magic_name__							)

       assert self.add_prefix_space or not is_split_into_words, (
           f"You need to instantiate {self.__class__.__name__} with add_prefix_space=True "
           "to use it with pretokenized inputs."
       )

       return super()._encode_plus(*__magic_name__,	**__magic_name__							)




   def    UpperCamelCase__						(					self,	__magic_name__,	__magic_name__ = None							)				->   Tuple[str]:






       """simple docstring"""
       UpperCamelCase__							:       List[Any]      =   self._tokenizer.model.save(__magic_name__,	name=__magic_name__							)
       return tuple(__magic_name__							)




   def    UpperCamelCase__						(					self,	__magic_name__,	__magic_name__ = False,	__magic_name__ = None,	__magic_name__ = None,	**__magic_name__,	)				->   str:






       """simple docstring"""
       UpperCamelCase__							:       Dict      =   super().decode(
           token_ids=__magic_name__,	skip_special_tokens=__magic_name__,	clean_up_tokenization_spaces=__magic_name__,	**__magic_name__,	)

       if truncate_before_pattern is not None and len(__magic_name__							) > 0:
           UpperCamelCase__							:       str      =   self.truncate(__magic_name__,	__magic_name__							)

       return decoded_text




   def    UpperCamelCase__						(					self,	__magic_name__,	__magic_name__							)				->   List[str]:






       """simple docstring"""
       def find_re(__magic_name__,	__magic_name__,	__magic_name__							):
           UpperCamelCase__							:       Dict      =   pattern.search(__magic_name__,	__magic_name__							)
           return m.start() if m else -1

       UpperCamelCase__							:       Union[str, Any]      =   [re.compile(__magic_name__,	re.MULTILINE							) for pattern in truncate_before_pattern]

       UpperCamelCase__							:       List[Any]      =   list(re.finditer('''^print''',	__magic_name__,	re.MULTILINE							)							)

       if len(__magic_name__							) > 1:
           UpperCamelCase__							:       Tuple      =   completion[: prints[1].start()]

       UpperCamelCase__							:       Optional[int]      =   list(re.finditer('''^def''',	__magic_name__,	re.MULTILINE							)							)

       if len(__magic_name__							) > 1:
           UpperCamelCase__							:       Optional[Any]      =   completion[: defs[1].start()]

       UpperCamelCase__							:       str      =   0

       UpperCamelCase__							:       Tuple      =   [
           pos for pos in [find_re(__magic_name__,	__magic_name__,	__magic_name__							) for terminal in terminals] if pos != -1
       ]

       if len(__magic_name__							) > 0:
           return completion[: min(__magic_name__							)]
       else:
           return completion








import inspect
import unittest
from typing import List

import numpy as np

from transformers import EfficientFormerConfig
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 (
      TFEfficientFormerForImageClassification,
      TFEfficientFormerForImageClassificationWithTeacher,
      TFEfficientFormerModel,
  )
  from transformers.models.efficientformer.modeling_tf_efficientformer import (
      TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
  )


if is_vision_available():
  from PIL import Image

  from transformers import EfficientFormerImageProcessor






class 					lowercase__ :

   '''simple docstring'''


   def __init__(					self,	__magic_name__,	__magic_name__ = 13,	__magic_name__ = 64,	__magic_name__ = 2,	__magic_name__ = 3,	__magic_name__ = 3,	__magic_name__ = True,	__magic_name__ = True,	__magic_name__ = 128,	__magic_name__=[16, 32, 64, 128],	__magic_name__ = 7,	__magic_name__ = 4,	__magic_name__ = 37,	__magic_name__ = "gelu",	__magic_name__ = 0.1,	__magic_name__ = 0.1,	__magic_name__ = 10,	__magic_name__ = 0.02,	__magic_name__ = 2,	__magic_name__ = 1,	__magic_name__ = 128,	__magic_name__ = [2, 2, 2, 2],	__magic_name__ = 2,	__magic_name__ = 2,	)				->   List[str]:






       """simple docstring"""
       UpperCamelCase__							:       List[str]      =   parent
       UpperCamelCase__							:       Optional[int]      =   batch_size
       UpperCamelCase__							:       Optional[Any]      =   image_size
       UpperCamelCase__							:       Optional[int]      =   patch_size
       UpperCamelCase__							:       Any      =   num_channels
       UpperCamelCase__							:       int      =   is_training
       UpperCamelCase__							:       str      =   use_labels
       UpperCamelCase__							:       Optional[Any]      =   hidden_size
       UpperCamelCase__							:       Tuple      =   num_hidden_layers
       UpperCamelCase__							:       str      =   num_attention_heads
       UpperCamelCase__							:       Any      =   intermediate_size
       UpperCamelCase__							:       int      =   hidden_act
       UpperCamelCase__							:       Dict      =   hidden_dropout_prob
       UpperCamelCase__							:       str      =   attention_probs_dropout_prob
       UpperCamelCase__							:       Tuple      =   type_sequence_label_size
       UpperCamelCase__							:       Optional[Any]      =   initializer_range
       UpperCamelCase__							:       Optional[int]      =   encoder_stride
       UpperCamelCase__							:       Any      =   num_attention_outputs
       UpperCamelCase__							:       Dict      =   embed_dim
       UpperCamelCase__							:       str      =   embed_dim + 1
       UpperCamelCase__							:       int      =   resolution
       UpperCamelCase__							:       List[str]      =   depths
       UpperCamelCase__							:       str      =   hidden_sizes
       UpperCamelCase__							:       Tuple      =   dim
       UpperCamelCase__							:       Optional[int]      =   mlp_expansion_ratio




   def    UpperCamelCase__						(					self							)				->   Union[str, Any]:






       """simple docstring"""
       UpperCamelCase__							:       Union[str, Any]      =   floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]							)

       UpperCamelCase__							:       Dict      =   None
       if self.use_labels:
           UpperCamelCase__							:       Optional[Any]      =   ids_tensor([self.batch_size],	self.type_sequence_label_size							)

       UpperCamelCase__							:       int      =   self.get_config()

       return config, pixel_values, labels




   def    UpperCamelCase__						(					self							)				->   str:






       """simple docstring"""
       return EfficientFormerConfig(
           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=__magic_name__,	initializer_range=self.initializer_range,	encoder_stride=self.encoder_stride,	resolution=self.resolution,	depths=self.depths,	hidden_sizes=self.hidden_sizes,	dim=self.dim,	mlp_expansion_ratio=self.mlp_expansion_ratio,	)




   def    UpperCamelCase__						(					self,	__magic_name__,	__magic_name__,	__magic_name__							)				->   Any:






       """simple docstring"""
       UpperCamelCase__							:       Dict      =   TFEfficientFormerModel(config=__magic_name__							)
       UpperCamelCase__							:       str      =   model(__magic_name__,	training=__magic_name__							)
       self.parent.assertEqual(result.last_hidden_state.shape,	(self.batch_size, self.seq_length, self.hidden_size)							)




   def    UpperCamelCase__						(					self,	__magic_name__,	__magic_name__,	__magic_name__							)				->   Optional[int]:






       """simple docstring"""
       UpperCamelCase__							:       Optional[int]      =   self.type_sequence_label_size
       UpperCamelCase__							:       Dict      =   TFEfficientFormerForImageClassification(__magic_name__							)
       UpperCamelCase__							:       Any      =   model(__magic_name__,	labels=__magic_name__,	training=__magic_name__							)
       self.parent.assertEqual(result.logits.shape,	(self.batch_size, self.type_sequence_label_size)							)

       # test greyscale images
       UpperCamelCase__							:       Optional[Any]      =   1
       UpperCamelCase__							:       List[str]      =   TFEfficientFormerForImageClassification(__magic_name__							)

       UpperCamelCase__							:       List[Any]      =   floats_tensor([self.batch_size, 1, self.image_size, self.image_size]							)
       UpperCamelCase__							:       Union[str, Any]      =   model(__magic_name__,	labels=__magic_name__							)
       self.parent.assertEqual(result.logits.shape,	(self.batch_size, self.type_sequence_label_size)							)




   def    UpperCamelCase__						(					self							)				->   Optional[Any]:






       """simple docstring"""
       UpperCamelCase__							:       List[str]      =   self.prepare_config_and_inputs()
       UpperCamelCase__     ,UpperCamelCase__     ,UpperCamelCase__							:       Dict      =   config_and_inputs
       UpperCamelCase__							:       Any      =   {'''pixel_values''': pixel_values}
       return config, inputs_dict






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

   '''simple docstring'''


   a		:							int     	=	(
       (
           TFEfficientFormerModel,
           TFEfficientFormerForImageClassificationWithTeacher,
           TFEfficientFormerForImageClassification,
       )
       if is_tf_available()
       else ()
   )
   a		:							Union[str, Any]     	=	(
       {
           "feature-extraction": TFEfficientFormerModel,
           "image-classification": (
               TFEfficientFormerForImageClassification,
               TFEfficientFormerForImageClassificationWithTeacher,
           ),
       }
       if is_tf_available()
       else {}
   )

   a		:							Any     	=	False

   a		:							Tuple     	=	False
   a		:							Any     	=	False
   a		:							int     	=	False
   a		:							Tuple     	=	False




   def    UpperCamelCase__						(					self							)				->   List[str]:






       """simple docstring"""
       UpperCamelCase__							:       Optional[Any]      =   TFEfficientFormerModelTester(self							)
       UpperCamelCase__							:       int      =   ConfigTester(
           self,	config_class=__magic_name__,	has_text_modality=__magic_name__,	hidden_size=37							)




   def    UpperCamelCase__						(					self							)				->   str:






       """simple docstring"""
       self.config_tester.run_common_tests()




   @unittest.skip(reason='''EfficientFormer does not use inputs_embeds'''							)
   def    UpperCamelCase__						(					self							)				->   Any:






       """simple docstring"""
       pass




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






       """simple docstring"""
       pass




   def    UpperCamelCase__						(					self							)				->   int:






       """simple docstring"""
       UpperCamelCase__     ,UpperCamelCase__							:       Any      =   self.model_tester.prepare_config_and_inputs_for_common()

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

           UpperCamelCase__							:       int      =   ['''pixel_values''']
           self.assertListEqual(arg_names[:1],	__magic_name__							)




   def    UpperCamelCase__						(					self							)				->   str:






       """simple docstring"""
       def check_hidden_states_output(__magic_name__,	__magic_name__,	__magic_name__							):
           UpperCamelCase__							:       Union[str, Any]      =   model_class(__magic_name__							)

           UpperCamelCase__							:       str      =   model(**self._prepare_for_class(__magic_name__,	__magic_name__							),	training=__magic_name__							)
           UpperCamelCase__							:       Tuple      =   outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

           UpperCamelCase__							:       Optional[int]      =   getattr(
               self.model_tester,	'''expected_num_hidden_layers''',	self.model_tester.num_hidden_layers + 1							)
           self.assertEqual(len(__magic_name__							),	__magic_name__							)

           if hasattr(self.model_tester,	'''encoder_seq_length'''							):
               UpperCamelCase__							:       Dict      =   self.model_tester.encoder_seq_length
               if hasattr(self.model_tester,	'''chunk_length'''							) and self.model_tester.chunk_length > 1:
                   UpperCamelCase__							:       Tuple      =   seq_length * self.model_tester.chunk_length
           else:
               UpperCamelCase__							:       Optional[Any]      =   self.model_tester.seq_length

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

           if config.is_encoder_decoder:
               UpperCamelCase__							:       List[str]      =   outputs.decoder_hidden_states

               self.asseretIsInstance(__magic_name__,	(list, tuple)							)
               self.assertEqual(len(__magic_name__							),	__magic_name__							)
               UpperCamelCase__							:       str      =   getattr(self.model_tester,	'''seq_length''',	__magic_name__							)
               UpperCamelCase__							:       Optional[Any]      =   getattr(self.model_tester,	'''decoder_seq_length''',	__magic_name__							)

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

       UpperCamelCase__     ,UpperCamelCase__							:       str      =   self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
           UpperCamelCase__							:       List[str]      =   True
           check_hidden_states_output(__magic_name__,	__magic_name__,	__magic_name__							)

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

           check_hidden_states_output(__magic_name__,	__magic_name__,	__magic_name__							)




   def    UpperCamelCase__						(					self,	__magic_name__,	__magic_name__,	__magic_name__=False							)				->   Any:






       """simple docstring"""
       UpperCamelCase__							:       List[str]      =   super()._prepare_for_class(__magic_name__,	__magic_name__,	return_labels=__magic_name__							)

       if return_labels:
           if model_class.__name__ == "TFEfficientFormerForImageClassificationWithTeacher":
               del inputs_dict["labels"]

       return inputs_dict




   def    UpperCamelCase__						(					self							)				->   Optional[Any]:






       """simple docstring"""
       UpperCamelCase__							:       List[str]      =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*__magic_name__							)




   @unittest.skip(reason='''EfficientFormer does not implement masked image modeling yet'''							)
   def    UpperCamelCase__						(					self							)				->   Union[str, Any]:






       """simple docstring"""
       UpperCamelCase__							:       Optional[int]      =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_image_modeling(*__magic_name__							)




   def    UpperCamelCase__						(					self							)				->   Optional[Any]:






       """simple docstring"""
       UpperCamelCase__							:       List[Any]      =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*__magic_name__							)




   @slow
   def    UpperCamelCase__						(					self							)				->   Optional[int]:






       """simple docstring"""
       for model_name in TF_EFFICIENTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           UpperCamelCase__							:       Dict      =   TFEfficientFormerModel.from_pretrained(__magic_name__							)
           self.assertIsNotNone(__magic_name__							)




   def    UpperCamelCase__						(					self							)				->   Tuple:






       """simple docstring"""
       UpperCamelCase__     ,UpperCamelCase__							:       str      =   self.model_tester.prepare_config_and_inputs_for_common()
       UpperCamelCase__							:       Dict      =   True

       UpperCamelCase__							:       Optional[Any]      =   getattr(self.model_tester,	'''seq_length''',	__magic_name__							)
       UpperCamelCase__							:       Any      =   getattr(self.model_tester,	'''encoder_seq_length''',	__magic_name__							)
       UpperCamelCase__							:       Tuple      =   getattr(self.model_tester,	'''key_length''',	__magic_name__							)
       UpperCamelCase__							:       Union[str, Any]      =   getattr(self.model_tester,	'''chunk_length''',	__magic_name__							)

       if chunk_length is not None and hasattr(self.model_tester,	'''num_hashes'''							):
           UpperCamelCase__							:       Dict      =   encoder_seq_length * self.model_tester.num_hashes

       for model_class in self.all_model_classes:
           UpperCamelCase__							:       Dict      =   True
           UpperCamelCase__							:       Optional[int]      =   False
           UpperCamelCase__							:       Any      =   True
           UpperCamelCase__							:       str      =   model_class(__magic_name__							)

           UpperCamelCase__							:       Optional[int]      =   model(**self._prepare_for_class(__magic_name__,	__magic_name__							),	training=__magic_name__							)
           UpperCamelCase__							:       List[str]      =   outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions
           self.assertEqual(len(__magic_name__							),	self.model_tester.num_attention_outputs							)

           # check that output_attentions also work using config
           del inputs_dict["output_attentions"]
           UpperCamelCase__							:       Optional[int]      =   True
           UpperCamelCase__							:       int      =   model_class(__magic_name__							)
           UpperCamelCase__							:       str      =   model(**self._prepare_for_class(__magic_name__,	__magic_name__							),	training=__magic_name__							)

           UpperCamelCase__							:       List[str]      =   outputs.encoder_attentions if config.is_encoder_decoder else outputs.attentions
           self.assertEqual(len(__magic_name__							),	self.model_tester.num_attention_outputs							)

           if chunk_length is not None:
               self.assertListEqual(
                   list(attentions[0].shape[-4:]							),	[self.model_tester.num_attention_heads, encoder_seq_length, chunk_length, encoder_key_length],	)
           else:
               self.assertListEqual(
                   list(attentions[0].shape[-3:]							),	[self.model_tester.num_attention_heads, encoder_seq_length, encoder_key_length],	)




   def    UpperCamelCase__						(					self							)				->   Dict:






       """simple docstring"""
       # We use a simplified version of this test for EfficientFormer because it requires training=False
       # and Keras refuses to let us force that during functional construction
       UpperCamelCase__     ,UpperCamelCase__							:       str      =   self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
           # Prepare our model
           UpperCamelCase__							:       str      =   model_class(__magic_name__							)
           # These are maximally general inputs for the model, with multiple None dimensions
           # Hopefully this will catch any conditionals that fail for flexible shapes
           UpperCamelCase__							:       Tuple      =   {
               key: tf.keras.Input(shape=val.shape[1:],	dtype=val.dtype,	name=__magic_name__							)
               for key, val in model.input_signature.items()
               if key in model.dummy_inputs
           }
           UpperCamelCase__							:       str      =   model(__magic_name__							)
           self.assertTrue(outputs_dict is not None							)




def 	lowerCAmelCase_					(						)   ->			List[str]:
    UpperCamelCase__							:       Any      =   Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''   )
    return image






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

   '''simple docstring'''


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






       """simple docstring"""
       return (
           EfficientFormerImageProcessor.from_pretrained('''snap-research/efficientformer-l1-300'''							)
           if is_vision_available()
           else None
       )




   @slow
   def    UpperCamelCase__						(					self							)				->   Optional[Any]:






       """simple docstring"""
       UpperCamelCase__							:       Optional[Any]      =   TFEfficientFormerForImageClassification.from_pretrained('''snap-research/efficientformer-l1-300'''							)
       UpperCamelCase__							:       Dict      =   self.default_image_processor
       UpperCamelCase__							:       List[str]      =   prepare_img()
       UpperCamelCase__							:       str      =   image_processor(images=__magic_name__,	return_tensors='''tf'''							)
       # forward pass
       UpperCamelCase__							:       Dict      =   model(**__magic_name__,	training=__magic_name__							)
       # verify the logits
       UpperCamelCase__							:       Tuple      =   tf.TensorShape((1, 1000)							)
       self.assertEqual(outputs.logits.shape,	__magic_name__							)
       UpperCamelCase__							:       List[str]      =   tf.constant([-0.0555, 0.4825, -0.0852]							)
       self.assertTrue(np.allclose(outputs.logits[0, :3],	__magic_name__,	atol=1E-4							)							)




   @slow
   def    UpperCamelCase__						(					self							)				->   Union[str, Any]:






       """simple docstring"""
       UpperCamelCase__							:       str      =   TFEfficientFormerForImageClassificationWithTeacher.from_pretrained(
           '''snap-research/efficientformer-l1-300'''							)
       UpperCamelCase__							:       List[str]      =   self.default_image_processor
       UpperCamelCase__							:       Union[str, Any]      =   prepare_img()
       UpperCamelCase__							:       int      =   image_processor(images=__magic_name__,	return_tensors='''tf'''							)
       # forward pass
       UpperCamelCase__							:       Tuple      =   model(**__magic_name__,	training=__magic_name__							)
       # verify the logits
       UpperCamelCase__							:       Tuple      =   tf.TensorShape((1, 1000)							)
       self.assertEqual(outputs.logits.shape,	__magic_name__							)
       UpperCamelCase__							:       Optional[int]      =   tf.constant([-0.1312, 0.4353, -1.0499]							)
       self.assertTrue(np.allclose(outputs.logits[0, :3],	__magic_name__,	atol=1E-4							)							)

