import argparse
import json
import logging
import os
import shutil
import sys
import tempfile
import unittest
from unittest import mock

import torch
from accelerate.utils import write_basic_config

from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device
from transformers.utils import is_apex_available


logging.basicConfig(level=logging.DEBUG)

__lowercase							 =					logging.getLogger()



def lowerCamelCase  (   ):
    '''simple docstring'''







    __UpperCamelCase     :List[Any]			  =		argparse.ArgumentParser()
    parser.add_argument('''-f'''	)
    __UpperCamelCase     :Any			  =		parser.parse_args()
    return args.f



def lowerCamelCase  (   SCREAMING_SNAKE_CASE	):
    '''simple docstring'''







    __UpperCamelCase     :Union[str, Any]			  =		{}
    __UpperCamelCase     :str			  =		os.path.join(SCREAMING_SNAKE_CASE  ,			'''all_results.json'''	)
    if os.path.exists(SCREAMING_SNAKE_CASE	):
        with open(SCREAMING_SNAKE_CASE  ,			'''r'''	) as f:
            __UpperCamelCase     :Optional[Any]			  =		json.load(SCREAMING_SNAKE_CASE	)
    else:
        raise ValueError(f"""can't find {path}"""	)
    return results



def lowerCamelCase  (   ):
    '''simple docstring'''







    __UpperCamelCase     :Optional[Any]			  =		torch.cuda.is_available() and torch_device == '''cuda'''
    return is_using_cuda and is_apex_available()


__lowercase							 =					logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)


class 	lowerCamelCase_     (   UpperCAmelCase_ ):






    '''simple docstring'''






    @classmethod
    def 			UpperCamelCase__   (	cls)       ->	int:
        # Write Accelerate config, will pick up on CPU, GPU, and multi-GPU
        __UpperCamelCase     :List[Any]			  =		tempfile.mkdtemp()
        __UpperCamelCase     :List[Any]			  =		os.path.join(cls.tmpdir , '''default_config.yml''')
        write_basic_config(save_location=cls.configPath)
        __UpperCamelCase     :int			  =		['''accelerate''', '''launch''', '''--config_file''', cls.configPath]







    @classmethod
    def 			UpperCamelCase__   (	cls)       ->	Union[str, Any]:
        shutil.rmtree(cls.tmpdir)







    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	Union[str, Any]:
        __UpperCamelCase     :List[str]			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :Any			  =		f"""
            {self.examples_dir}/pytorch/text-classification/run_glue_no_trainer.py
            --model_name_or_path distilbert-base-uncased
            --output_dir {tmp_dir}
            --train_file ./tests/fixtures/tests_samples/MRPC/train.csv
            --validation_file ./tests/fixtures/tests_samples/MRPC/dev.csv
            --per_device_train_batch_size=2
            --per_device_eval_batch_size=1
            --learning_rate=1e-4
            --seed=42
            --checkpointing_steps epoch
            --with_tracking
        """.split()

        if is_cuda_and_apex_available():
            testargs.append('''--fp16''')

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Optional[Any]			  =		get_results(__lowercase)
        self.assertGreaterEqual(result['''eval_accuracy'''] , 0.75)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''epoch_0''')))
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''glue_no_trainer''')))







    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	int:
        __UpperCamelCase     :Any			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :List[str]			  =		f"""
            {self.examples_dir}/pytorch/language-modeling/run_clm_no_trainer.py
            --model_name_or_path distilgpt2
            --train_file ./tests/fixtures/sample_text.txt
            --validation_file ./tests/fixtures/sample_text.txt
            --block_size 128
            --per_device_train_batch_size 5
            --per_device_eval_batch_size 5
            --num_train_epochs 2
            --output_dir {tmp_dir}
            --checkpointing_steps epoch
            --with_tracking
        """.split()

        if torch.cuda.device_count() > 1:
            # Skipping because there are not enough batches to train the model + would need a drop_last to work.
            return

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Dict			  =		get_results(__lowercase)
        self.assertLess(result['''perplexity'''] , 100)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''epoch_0''')))
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''clm_no_trainer''')))







    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	Any:
        __UpperCamelCase     :List[Any]			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :List[Any]			  =		f"""
            {self.examples_dir}/pytorch/language-modeling/run_mlm_no_trainer.py
            --model_name_or_path distilroberta-base
            --train_file ./tests/fixtures/sample_text.txt
            --validation_file ./tests/fixtures/sample_text.txt
            --output_dir {tmp_dir}
            --num_train_epochs=1
            --checkpointing_steps epoch
            --with_tracking
        """.split()

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Union[str, Any]			  =		get_results(__lowercase)
        self.assertLess(result['''perplexity'''] , 42)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''epoch_0''')))
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''mlm_no_trainer''')))







    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	Tuple:
        # with so little data distributed training needs more epochs to get the score on par with 0/1 gpu
        __UpperCamelCase     :Union[str, Any]			  =		7 if get_gpu_count() > 1 else 2

        __UpperCamelCase     :List[Any]			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :List[Any]			  =		f"""
            {self.examples_dir}/pytorch/token-classification/run_ner_no_trainer.py
            --model_name_or_path bert-base-uncased
            --train_file tests/fixtures/tests_samples/conll/sample.json
            --validation_file tests/fixtures/tests_samples/conll/sample.json
            --output_dir {tmp_dir}
            --learning_rate=2e-4
            --per_device_train_batch_size=2
            --per_device_eval_batch_size=2
            --num_train_epochs={epochs}
            --seed 7
            --checkpointing_steps epoch
            --with_tracking
        """.split()

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Optional[Any]			  =		get_results(__lowercase)
        self.assertGreaterEqual(result['''eval_accuracy'''] , 0.75)
        self.assertLess(result['''train_loss'''] , 0.5)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''epoch_0''')))
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''ner_no_trainer''')))







    @unittest.skip(reason='''Fix me @muellerzr''')
    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	Union[str, Any]:
        __UpperCamelCase     :Union[str, Any]			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :int			  =		f"""
            {self.examples_dir}/pytorch/question-answering/run_qa_no_trainer.py
            --model_name_or_path bert-base-uncased
            --version_2_with_negative
            --train_file tests/fixtures/tests_samples/SQUAD/sample.json
            --validation_file tests/fixtures/tests_samples/SQUAD/sample.json
            --output_dir {tmp_dir}
            --seed=42
            --max_train_steps=10
            --num_warmup_steps=2
            --learning_rate=2e-4
            --per_device_train_batch_size=2
            --per_device_eval_batch_size=1
            --checkpointing_steps epoch
            --with_tracking
        """.split()

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Any			  =		get_results(__lowercase)
        # Because we use --version_2_with_negative the testing script uses SQuAD v2 metrics.
        self.assertGreaterEqual(result['''eval_f1'''] , 28)
        self.assertGreaterEqual(result['''eval_exact'''] , 28)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''epoch_0''')))
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''qa_no_trainer''')))







    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	Union[str, Any]:
        __UpperCamelCase     :int			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :int			  =		f"""
            {self.examples_dir}/pytorch/multiple-choice/run_swag_no_trainer.py
            --model_name_or_path bert-base-uncased
            --train_file tests/fixtures/tests_samples/swag/sample.json
            --validation_file tests/fixtures/tests_samples/swag/sample.json
            --output_dir {tmp_dir}
            --max_train_steps=20
            --num_warmup_steps=2
            --learning_rate=2e-4
            --per_device_train_batch_size=2
            --per_device_eval_batch_size=1
            --with_tracking
        """.split()

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Dict			  =		get_results(__lowercase)
        self.assertGreaterEqual(result['''eval_accuracy'''] , 0.8)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''swag_no_trainer''')))







    @slow
    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	str:
        __UpperCamelCase     :str			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :Dict			  =		f"""
            {self.examples_dir}/pytorch/summarization/run_summarization_no_trainer.py
            --model_name_or_path t5-small
            --train_file tests/fixtures/tests_samples/xsum/sample.json
            --validation_file tests/fixtures/tests_samples/xsum/sample.json
            --output_dir {tmp_dir}
            --max_train_steps=50
            --num_warmup_steps=8
            --learning_rate=2e-4
            --per_device_train_batch_size=2
            --per_device_eval_batch_size=1
            --checkpointing_steps epoch
            --with_tracking
        """.split()

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Tuple			  =		get_results(__lowercase)
        self.assertGreaterEqual(result['''eval_rouge1'''] , 10)
        self.assertGreaterEqual(result['''eval_rouge2'''] , 2)
        self.assertGreaterEqual(result['''eval_rougeL'''] , 7)
        self.assertGreaterEqual(result['''eval_rougeLsum'''] , 7)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''epoch_0''')))
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''summarization_no_trainer''')))







    @slow
    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	str:
        __UpperCamelCase     :Optional[int]			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :Dict			  =		f"""
            {self.examples_dir}/pytorch/translation/run_translation_no_trainer.py
            --model_name_or_path sshleifer/student_marian_en_ro_6_1
            --source_lang en
            --target_lang ro
            --train_file tests/fixtures/tests_samples/wmt16/sample.json
            --validation_file tests/fixtures/tests_samples/wmt16/sample.json
            --output_dir {tmp_dir}
            --max_train_steps=50
            --num_warmup_steps=8
            --num_beams=6
            --learning_rate=3e-3
            --per_device_train_batch_size=2
            --per_device_eval_batch_size=1
            --source_lang en_XX
            --target_lang ro_RO
            --checkpointing_steps epoch
            --with_tracking
        """.split()

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Optional[int]			  =		get_results(__lowercase)
        self.assertGreaterEqual(result['''eval_bleu'''] , 30)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''epoch_0''')))
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''translation_no_trainer''')))







    @slow
    def 			UpperCamelCase__   (	self)       ->	Tuple:
        __UpperCamelCase     :Tuple			  =		logging.StreamHandler(sys.stdout)
        logger.addHandler(__lowercase)

        __UpperCamelCase     :int			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :Any			  =		f"""
            {self.examples_dir}/pytorch/semantic-segmentation/run_semantic_segmentation_no_trainer.py
            --dataset_name huggingface/semantic-segmentation-test-sample
            --output_dir {tmp_dir}
            --max_train_steps=10
            --num_warmup_steps=2
            --learning_rate=2e-4
            --per_device_train_batch_size=2
            --per_device_eval_batch_size=1
            --checkpointing_steps epoch
        """.split()

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :List[str]			  =		get_results(__lowercase)
        self.assertGreaterEqual(result['''eval_overall_accuracy'''] , 0.10)







    @mock.patch.dict(os.environ , {'''WANDB_MODE''': '''offline'''})
    def 			UpperCamelCase__   (	self)       ->	Optional[int]:
        __UpperCamelCase     :Union[str, Any]			  =		self.get_auto_remove_tmp_dir()
        __UpperCamelCase     :Optional[Any]			  =		f"""
            {self.examples_dir}/pytorch/image-classification/run_image_classification_no_trainer.py
            --model_name_or_path google/vit-base-patch16-224-in21k
            --dataset_name hf-internal-testing/cats_vs_dogs_sample
            --learning_rate 1e-4
            --per_device_train_batch_size 2
            --per_device_eval_batch_size 1
            --max_train_steps 2
            --train_val_split 0.1
            --seed 42
            --output_dir {tmp_dir}
            --with_tracking
            --checkpointing_steps 1
        """.split()

        if is_cuda_and_apex_available():
            testargs.append('''--fp16''')

        run_command(self._launch_args + testargs)
        __UpperCamelCase     :Optional[Any]			  =		get_results(__lowercase)
        # The base model scores a 25%
        self.assertGreaterEqual(result['''eval_accuracy'''] , 0.6)
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''step_1''')))
        self.assertTrue(os.path.exists(os.path.join(__lowercase , '''image_classification_no_trainer''')))






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



    """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    ,			):
       lowercase__:   Optional[Any]					=      parent
       lowercase__:   Union[str, Any]					=      batch_size
       lowercase__:   int					=      image_size
       lowercase__:   Optional[Any]					=      num_channels
       lowercase__:   Optional[int]					=      embeddings_size
       lowercase__:   Dict					=      hidden_sizes
       lowercase__:   Union[str, Any]					=      depths
       lowercase__:   str					=      is_training
       lowercase__:   Optional[int]					=      use_labels
       lowercase__:   List[str]					=      hidden_act
       lowercase__:   Dict					=      num_labels
       lowercase__:   Any					=      scope
       lowercase__:   Optional[Any]					=      len(_UpperCAmelCase							)






    def _snake_case			(   self							):
       lowercase__:   Union[str, Any]					=      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]							)

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

       lowercase__:   Optional[int]					=      self.get_config()

       return config, pixel_values, labels






    def _snake_case			(   self							):
       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 _snake_case			(   self    ,			_UpperCAmelCase    ,			_UpperCAmelCase    ,			_UpperCAmelCase							):
       lowercase__:   Optional[Any]					=      TFResNetModel(config=_UpperCAmelCase							)
       lowercase__:   Dict					=      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 _snake_case			(   self    ,			_UpperCAmelCase    ,			_UpperCAmelCase    ,			_UpperCAmelCase							):
       lowercase__:   str					=      self.num_labels
       lowercase__:   int					=      TFResNetForImageClassification(_UpperCAmelCase							)
       lowercase__:   Optional[Any]					=      model(_UpperCAmelCase    ,			labels=_UpperCAmelCase							)
       self.parent.assertEqual(result.logits.shape    ,			(self.batch_size, self.num_labels)							)






    def _snake_case			(   self							):
       lowercase__:   int					=      self.prepare_config_and_inputs()
       lowercase__, lowercase__, lowercase__:   Optional[Any]					=      config_and_inputs
       lowercase__:   Union[str, Any]					=      {'''pixel_values''': pixel_values}
       return config, inputs_dict



@require_tf
class     UpperCAmelCase						(_UpperCAmelCase    ,_UpperCAmelCase    ,unittest.TestCase  ):



    """simple docstring"""

    _UpperCAmelCase	:Any						    = (TFResNetModel, TFResNetForImageClassification) if is_tf_available() else ()
    _UpperCAmelCase	:List[str]						    = (
        {"feature-extraction": TFResNetModel, "image-classification": TFResNetForImageClassification}
        if is_tf_available()
        else {}
    )

    _UpperCAmelCase	:Any						    = False
    _UpperCAmelCase	:List[str]						    = False
    _UpperCAmelCase	:Optional[Any]						    = False
    _UpperCAmelCase	:Tuple						    = False
    _UpperCAmelCase	:List[Any]						    = False






    def _snake_case			(   self							):
       lowercase__:   Union[str, Any]					=      TFResNetModelTester(self							)
       lowercase__:   Optional[int]					=      ConfigTester(self    ,			config_class=_UpperCAmelCase    ,			has_text_modality=_UpperCAmelCase							)






    def _snake_case			(   self							):
       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 _snake_case			(   self							):
       return






    @unittest.skip(reason='''ResNet does not use inputs_embeds'''							)
    def _snake_case			(   self							):
       pass






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






    def _snake_case			(   self							):
       lowercase__, lowercase__:   int					=      self.model_tester.prepare_config_and_inputs_for_common()

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

          lowercase__:   Optional[Any]					=      ['''pixel_values''']
          self.assertListEqual(arg_names[:1]    ,			_UpperCAmelCase							)






    def _snake_case			(   self							):
       lowercase__:   Any					=      self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*_UpperCAmelCase							)






    def _snake_case			(   self							):
       def check_hidden_states_output(_UpperCAmelCase    ,			_UpperCAmelCase    ,			_UpperCAmelCase							):
          lowercase__:   Union[str, Any]					=      model_class(_UpperCAmelCase							)
          lowercase__:   List[Any]					=      model(**self._prepare_for_class(_UpperCAmelCase    ,			_UpperCAmelCase							)							)

          lowercase__:   Union[str, Any]					=      outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

          lowercase__:   Tuple					=      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]    ,			)

       lowercase__, lowercase__:   Optional[Any]					=      self.model_tester.prepare_config_and_inputs_for_common()
       lowercase__:   Union[str, Any]					=      ['''basic''', '''bottleneck''']
       for model_class in self.all_model_classes:
          for layer_type in layers_type:
             lowercase__:   Tuple					=      layer_type
             lowercase__:   Any					=      True
             check_hidden_states_output(_UpperCAmelCase    ,			_UpperCAmelCase    ,			_UpperCAmelCase							)

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

             check_hidden_states_output(_UpperCAmelCase    ,			_UpperCAmelCase    ,			_UpperCAmelCase							)






    def _snake_case			(   self							):
       lowercase__:   Optional[int]					=      self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*_UpperCAmelCase							)






    @slow
    def _snake_case			(   self							):
       for model_name in TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
          lowercase__:   Dict					=      TFResNetModel.from_pretrained(_UpperCAmelCase							)
          self.assertIsNotNone(_UpperCAmelCase							)



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




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



    """simple docstring"""

    @cached_property
    def _snake_case			(   self							):
       return (
           AutoImageProcessor.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]							)
           if is_vision_available()
           else None
       )






    @slow
    def _snake_case			(   self							):
       lowercase__:   Tuple					=      TFResNetForImageClassification.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]							)

       lowercase__:   Any					=      self.default_image_processor
       lowercase__:   List[Any]					=      prepare_img()
       lowercase__:   List[Any]					=      image_processor(images=_UpperCAmelCase    ,			return_tensors='''tf'''							)

       # forward pass
       lowercase__:   Dict					=      model(**_UpperCAmelCase							)

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

       lowercase__:   Dict					=      tf.constant([-11.1_069, -9.7_877, -8.3_777]							)

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