"""simple docstring"""
import json
import pathlib
import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision, slow
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
      import torch

if is_vision_available():
      from PIL import Image

      from transformers import DetaImageProcessor




class        __snake_case	(					unittest.TestCase    ):



      def __init__(						self   ,      lowercase   ,      lowercase=7   ,      lowercase=3   ,      lowercase=30   ,      lowercase=4_00   ,      lowercase=True   ,      lowercase=None   ,      lowercase=True   ,      lowercase=[0.5, 0.5, 0.5]   ,      lowercase=[0.5, 0.5, 0.5]   ,      lowercase=True   ,      lowercase=1 / 2_55   ,      lowercase=True   ,      )     ->      Any:





        '''simple docstring'''





        a__:					Optional[Any]      							=     size if size is not None else {"shortest_edge": 18, "longest_edge": 13_33}
        a__:					str      							=     parent
        a__:					Optional[int]      							=     batch_size
        a__:					Union[str, Any]      							=     num_channels
        a__:					str      							=     min_resolution
        a__:					str      							=     max_resolution
        a__:					Optional[int]      							=     do_resize
        a__:					Dict      							=     size
        a__:					str      							=     do_normalize
        a__:					int      							=     image_mean
        a__:					Any      							=     image_std
        a__:					str      							=     do_rescale
        a__:					str      							=     rescale_factor
        a__:					int      							=     do_pad



      def   lowerCamelCase_       (						self)     ->      Tuple:





        '''simple docstring'''





        return {
            "do_resize": self.do_resize,
            "size": self.size,
            "do_normalize": self.do_normalize,
            "image_mean": self.image_mean,
            "image_std": self.image_std,
            "do_rescale": self.do_rescale,
            "rescale_factor": self.rescale_factor,
            "do_pad": self.do_pad,
        }



      def   lowerCamelCase_       (						self   ,      lowercase   ,      lowercase=False)     ->      Any:





        '''simple docstring'''





        if not batched:
          a__:					Union[str, Any]      							=     image_inputs[0]
          if isinstance(lowerCAmelCase__   ,      Image.Image):
            a__:					Optional[Any]      							=     image.size
          else:
            a__:					Tuple      							=     image.shape[1], image.shape[2]
          if w < h:
            a__:					str      							=     int(self.size['shortest_edge'] * h / w)
            a__:					Dict      							=     self.size["shortest_edge"]
          elif w > h:
            a__:					Optional[int]      							=     self.size["shortest_edge"]
            a__:					Optional[Any]      							=     int(self.size['shortest_edge'] * w / h)
          else:
            a__:					int      							=     self.size["shortest_edge"]
            a__:					Optional[Any]      							=     self.size["shortest_edge"]

        else:
          a__:					List[str]      							=     []
          for image in image_inputs:
            a__:					Optional[int]      							=     self.get_expected_values([image])
            expected_values.append((expected_height, expected_width))
          a__:					List[Any]      							=     max(lowerCAmelCase__   ,      key=lambda lowercase: item[0])[0]
          a__:					Tuple      							=     max(lowerCAmelCase__   ,      key=lambda lowercase: item[1])[1]

        return expected_height, expected_width







@require_torch
@require_vision
class        __snake_case	(					a__	,				unittest.TestCase    ):
      a__				=		DetaImageProcessor if is_vision_available() else None



      def   lowerCamelCase_       (						self)     ->      int:





        '''simple docstring'''





        a__:					Any      							=     DetaImageProcessingTester(self)



      @property
      def   lowerCamelCase_       (						self)     ->      Union[str, Any]:





        '''simple docstring'''





        return self.image_processor_tester.prepare_image_processor_dict()



      def   lowerCamelCase_       (						self)     ->      str:





        '''simple docstring'''





        a__:					Union[str, Any]      							=     self.image_processing_class(**self.image_processor_dict)
        self.assertTrue(hasattr(lowerCAmelCase__   ,      'image_mean'))
        self.assertTrue(hasattr(lowerCAmelCase__   ,      'image_std'))
        self.assertTrue(hasattr(lowerCAmelCase__   ,      'do_normalize'))
        self.assertTrue(hasattr(lowerCAmelCase__   ,      'do_resize'))
        self.assertTrue(hasattr(lowerCAmelCase__   ,      'do_rescale'))
        self.assertTrue(hasattr(lowerCAmelCase__   ,      'do_pad'))
        self.assertTrue(hasattr(lowerCAmelCase__   ,      'size'))



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





        '''simple docstring'''





        a__:					Optional[int]      							=     self.image_processing_class.from_dict(self.image_processor_dict)
        self.assertEqual(image_processor.size   ,      {'shortest_edge': 18, 'longest_edge': 13_33})
        self.assertEqual(image_processor.do_pad   ,      lowerCAmelCase__)



      def   lowerCamelCase_       (						self)     ->      str:





        '''simple docstring'''





        pass



      def   lowerCamelCase_       (						self)     ->      Any:





        '''simple docstring'''





        a__:					Optional[int]      							=     self.image_processing_class(**self.image_processor_dict)
        # create random PIL images
        a__:					Union[str, Any]      							=     prepare_image_inputs(self.image_processor_tester   ,      equal_resolution=lowerCAmelCase__)
        for image in image_inputs:
          self.assertIsInstance(lowerCAmelCase__   ,      Image.Image)

        # Test not batched input
        a__:					str      							=     image_processing(image_inputs[0]   ,      return_tensors='pt').pixel_values

        a__:					Dict      							=     self.image_processor_tester.get_expected_values(lowerCAmelCase__)

        self.assertEqual(
            encoded_images.shape   ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,      )

        # Test batched
        a__:					Any      							=     self.image_processor_tester.get_expected_values(lowerCAmelCase__   ,      batched=lowerCAmelCase__)

        a__:					Tuple      							=     image_processing(lowerCAmelCase__   ,      return_tensors='pt').pixel_values
        self.assertEqual(
            encoded_images.shape   ,      (
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )   ,      )



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





        '''simple docstring'''





        a__:					Dict      							=     self.image_processing_class(**self.image_processor_dict)
        # create random numpy tensors
        a__:					Tuple      							=     prepare_image_inputs(self.image_processor_tester   ,      equal_resolution=lowerCAmelCase__   ,      numpify=lowerCAmelCase__)
        for image in image_inputs:
          self.assertIsInstance(lowerCAmelCase__   ,      np.ndarray)

        # Test not batched input
        a__:					Dict      							=     image_processing(image_inputs[0]   ,      return_tensors='pt').pixel_values

        a__:					List[str]      							=     self.image_processor_tester.get_expected_values(lowerCAmelCase__)

        self.assertEqual(
            encoded_images.shape   ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,      )

        # Test batched
        a__:					Tuple      							=     image_processing(lowerCAmelCase__   ,      return_tensors='pt').pixel_values

        a__:					Optional[Any]      							=     self.image_processor_tester.get_expected_values(lowerCAmelCase__   ,      batched=lowerCAmelCase__)

        self.assertEqual(
            encoded_images.shape   ,      (
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )   ,      )



      def   lowerCamelCase_       (						self)     ->      int:





        '''simple docstring'''





        a__:					Optional[int]      							=     self.image_processing_class(**self.image_processor_dict)
        # create random PyTorch tensors
        a__:					List[str]      							=     prepare_image_inputs(self.image_processor_tester   ,      equal_resolution=lowerCAmelCase__   ,      torchify=lowerCAmelCase__)
        for image in image_inputs:
          self.assertIsInstance(lowerCAmelCase__   ,      torch.Tensor)

        # Test not batched input
        a__:					Any      							=     image_processing(image_inputs[0]   ,      return_tensors='pt').pixel_values

        a__:					Any      							=     self.image_processor_tester.get_expected_values(lowerCAmelCase__)

        self.assertEqual(
            encoded_images.shape   ,      (1, self.image_processor_tester.num_channels, expected_height, expected_width)   ,      )

        # Test batched
        a__:					str      							=     image_processing(lowerCAmelCase__   ,      return_tensors='pt').pixel_values

        a__:					Any      							=     self.image_processor_tester.get_expected_values(lowerCAmelCase__   ,      batched=lowerCAmelCase__)

        self.assertEqual(
            encoded_images.shape   ,      (
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                expected_height,
                expected_width,
            )   ,      )



      @slow
      def   lowerCamelCase_       (						self)     ->      str:





        '''simple docstring'''





        a__:					Any      							=     Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png')
        with open('./tests/fixtures/tests_samples/COCO/coco_annotations.txt'   ,      'r') as f:
          a__:					int      							=     json.loads(f.read())

        a__:					List[str]      							=     {"image_id": 3_97_69, "annotations": target}

        # encode them
        a__:					Dict      							=     DetaImageProcessor()
        a__:					Optional[Any]      							=     image_processing(images=lowerCAmelCase__   ,      annotations=lowerCAmelCase__   ,      return_tensors='pt')

        # verify pixel values
        a__:					Dict      							=     torch.Size([1, 3, 8_00, 10_66])
        self.assertEqual(encoding['pixel_values'].shape   ,      lowerCAmelCase__)

        a__:					Any      							=     torch.tensor([0.2796, 0.3138, 0.3481])
        self.assertTrue(torch.allclose(encoding['pixel_values'][0, 0, 0, :3]   ,      lowerCAmelCase__   ,      atol=1e-4))

        # verify area
        a__:					Tuple      							=     torch.tensor([58_87.96_00, 1_12_50.20_61, 48_93_53.84_38, 83_71_22.75_00, 14_79_67.51_56, 16_57_32.34_38])
        self.assertTrue(torch.allclose(encoding['labels'][0]['area']   ,      lowerCAmelCase__))
        # verify boxes
        a__:					Optional[int]      							=     torch.Size([6, 4])
        self.assertEqual(encoding['labels'][0]['boxes'].shape   ,      lowerCAmelCase__)
        a__:					List[Any]      							=     torch.tensor([0.5503, 0.2765, 0.0604, 0.2215])
        self.assertTrue(torch.allclose(encoding['labels'][0]['boxes'][0]   ,      lowerCAmelCase__   ,      atol=1e-3))
        # verify image_id
        a__:					Union[str, Any]      							=     torch.tensor([3_97_69])
        self.assertTrue(torch.allclose(encoding['labels'][0]['image_id']   ,      lowerCAmelCase__))
        # verify is_crowd
        a__:					Any      							=     torch.tensor([0, 0, 0, 0, 0, 0])
        self.assertTrue(torch.allclose(encoding['labels'][0]['iscrowd']   ,      lowerCAmelCase__))
        # verify class_labels
        a__:					str      							=     torch.tensor([75, 75, 63, 65, 17, 17])
        self.assertTrue(torch.allclose(encoding['labels'][0]['class_labels']   ,      lowerCAmelCase__))
        # verify orig_size
        a__:					int      							=     torch.tensor([4_80, 6_40])
        self.assertTrue(torch.allclose(encoding['labels'][0]['orig_size']   ,      lowerCAmelCase__))
        # verify size
        a__:					List[str]      							=     torch.tensor([8_00, 10_66])
        self.assertTrue(torch.allclose(encoding['labels'][0]['size']   ,      lowerCAmelCase__))



      @slow
      def   lowerCamelCase_       (						self)     ->      Any:





        '''simple docstring'''





        a__:					Tuple      							=     Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png')
        with open('./tests/fixtures/tests_samples/COCO/coco_panoptic_annotations.txt'   ,      'r') as f:
          a__:					Dict      							=     json.loads(f.read())

        a__:					Optional[int]      							=     {"file_name": "000000039769.png", "image_id": 3_97_69, "segments_info": target}

        a__:					Optional[int]      							=     pathlib.Path('./tests/fixtures/tests_samples/COCO/coco_panoptic')

        # encode them
        a__:					List[Any]      							=     DetaImageProcessor(format='coco_panoptic')
        a__:					Optional[Any]      							=     image_processing(images=lowerCAmelCase__   ,      annotations=lowerCAmelCase__   ,      masks_path=lowerCAmelCase__   ,      return_tensors='pt')

        # verify pixel values
        a__:					Optional[int]      							=     torch.Size([1, 3, 8_00, 10_66])
        self.assertEqual(encoding['pixel_values'].shape   ,      lowerCAmelCase__)

        a__:					Any      							=     torch.tensor([0.2796, 0.3138, 0.3481])
        self.assertTrue(torch.allclose(encoding['pixel_values'][0, 0, 0, :3]   ,      lowerCAmelCase__   ,      atol=1e-4))

        # verify area
        a__:					str      							=     torch.tensor([14_79_79.68_75, 16_55_27.04_69, 48_46_38.59_38, 1_12_92.93_75, 58_79.65_62, 76_34.11_47])
        self.assertTrue(torch.allclose(encoding['labels'][0]['area']   ,      lowerCAmelCase__))
        # verify boxes
        a__:					Tuple      							=     torch.Size([6, 4])
        self.assertEqual(encoding['labels'][0]['boxes'].shape   ,      lowerCAmelCase__)
        a__:					List[str]      							=     torch.tensor([0.2625, 0.5437, 0.4688, 0.8625])
        self.assertTrue(torch.allclose(encoding['labels'][0]['boxes'][0]   ,      lowerCAmelCase__   ,      atol=1e-3))
        # verify image_id
        a__:					Optional[int]      							=     torch.tensor([3_97_69])
        self.assertTrue(torch.allclose(encoding['labels'][0]['image_id']   ,      lowerCAmelCase__))
        # verify is_crowd
        a__:					Tuple      							=     torch.tensor([0, 0, 0, 0, 0, 0])
        self.assertTrue(torch.allclose(encoding['labels'][0]['iscrowd']   ,      lowerCAmelCase__))
        # verify class_labels
        a__:					Tuple      							=     torch.tensor([17, 17, 63, 75, 75, 93])
        self.assertTrue(torch.allclose(encoding['labels'][0]['class_labels']   ,      lowerCAmelCase__))
        # verify masks
        a__:					Union[str, Any]      							=     82_28_73
        self.assertEqual(encoding['labels'][0]['masks'].sum().item()   ,      lowerCAmelCase__)
        # verify orig_size
        a__:					Union[str, Any]      							=     torch.tensor([4_80, 6_40])
        self.assertTrue(torch.allclose(encoding['labels'][0]['orig_size']   ,      lowerCAmelCase__))
        # verify size
        a__:					Optional[Any]      							=     torch.tensor([8_00, 10_66])
        self.assertTrue(torch.allclose(encoding['labels'][0]['size']   ,      lowerCAmelCase__))



"""simple docstring"""
import inspect
import unittest

from transformers import RegNetConfig
from transformers.file_utils import cached_property, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
 import torch
 from torch import nn

 from transformers import RegNetForImageClassification, RegNetModel
 from transformers.models.regnet.modeling_regnet import REGNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
 from PIL import Image

 from transformers import AutoImageProcessor




class        __snake_case	:



      def __init__(						self   ,      lowercase   ,      lowercase=3   ,      lowercase=32   ,      lowercase=3   ,      lowercase=10   ,      lowercase=[10, 20, 30, 40]   ,      lowercase=[1, 1, 2, 1]   ,      lowercase=True   ,      lowercase=True   ,      lowercase="relu"   ,      lowercase=3   ,      lowercase=None   ,      )     ->      Any:





        '''simple docstring'''





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



      def   lowerCamelCase_       (						self)     ->      int:





        '''simple docstring'''





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

        a__:					str      							=     None
        if self.use_labels:
          a__:					Dict      							=     ids_tensor([self.batch_size]   ,      self.num_labels)

        a__:					int      							=     self.get_config()

        return config, pixel_values, labels



      def   lowerCamelCase_       (						self)     ->      Optional[int]:





        '''simple docstring'''





        return RegNetConfig(
            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   ,      )



      def   lowerCamelCase_       (						self   ,      lowercase   ,      lowercase   ,      lowercase)     ->      Any:





        '''simple docstring'''





        a__:					Dict      							=     RegNetModel(config=lowercase)
        model.to(lowercase)
        model.eval()
        a__:					List[str]      							=     model(lowercase)
        # 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   ,      lowercase   ,      lowercase   ,      lowercase)     ->      List[Any]:





        '''simple docstring'''





        a__:					Tuple      							=     self.num_labels
        a__:					Tuple      							=     RegNetForImageClassification(lowercase)
        model.to(lowercase)
        model.eval()
        a__:					Any      							=     model(lowercase   ,      labels=lowercase)
        self.parent.assertEqual(result.logits.shape   ,      (self.batch_size, self.num_labels))



      def   lowerCamelCase_       (						self)     ->      str:





        '''simple docstring'''





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







@require_torch
class        __snake_case	(					__lowerCAmelCase	,				__lowerCAmelCase	,				unittest.TestCase    ):
      a__				=		(RegNetModel, RegNetForImageClassification) if is_torch_available() else ()
      a__				=		(
          {"""feature-extraction""": RegNetModel, """image-classification""": RegNetForImageClassification}
          if is_torch_available()
          else {}
      )

      a__				=		False
      a__				=		False
      a__				=		False
      a__				=		False



      def   lowerCamelCase_       (						self)     ->      Dict:





        '''simple docstring'''





        a__:					Dict      							=     RegNetModelTester(self)
        a__:					Dict      							=     ConfigTester(self   ,      config_class=lowercase   ,      has_text_modality=lowercase)



      def   lowerCamelCase_       (						self)     ->      Dict:





        '''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)     ->      Optional[Any]:





        '''simple docstring'''





        return



      @unittest.skip(reason='RegNet does not use inputs_embeds')
      def   lowerCamelCase_       (						self)     ->      List[str]:





        '''simple docstring'''





        pass



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





        '''simple docstring'''





        pass



      def   lowerCamelCase_       (						self)     ->      List[Any]:





        '''simple docstring'''





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

        for model_class in self.all_model_classes:
          a__:					int      							=     model_class(lowercase)
          a__:					str      							=     inspect.signature(model.forward)
          # signature.parameters is an OrderedDict => so arg_names order is deterministic
          a__:					int      							=     [*signature.parameters.keys()]

          a__:					List[str]      							=     ['pixel_values']
          self.assertListEqual(arg_names[:1]   ,      lowercase)



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





        '''simple docstring'''





        a__:					Any      							=     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_model(*lowercase)



      def   lowerCamelCase_       (						self)     ->      Dict:





        '''simple docstring'''





        a__							,   a__:					int      							=     self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
          a__:					int      							=     model_class(config=lowercase)
          for name, module in model.named_modules():
            if isinstance(lowercase   ,      (nn.BatchNormad, nn.GroupNorm)):
              self.assertTrue(
                  torch.all(module.weight == 1)   ,      msg=f'Parameter {name} of model {model_class} seems not properly initialized'   ,      )
              self.assertTrue(
                  torch.all(module.bias == 0)   ,      msg=f'Parameter {name} of model {model_class} seems not properly initialized'   ,      )



      def   lowerCamelCase_       (						self)     ->      Optional[int]:





        '''simple docstring'''





        def check_hidden_states_output(lowercase   ,      lowercase   ,      lowercase):
          a__:					int      							=     model_class(lowercase)
          model.to(lowercase)
          model.eval()

          with torch.no_grad():
            a__:					int      							=     model(**self._prepare_for_class(lowercase   ,      lowercase))

          a__:					Any      							=     outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

          a__:					List[str]      							=     self.model_tester.num_stages
          self.assertEqual(len(lowercase)   ,      expected_num_stages + 1)

          # RegNet'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 // 2, self.model_tester.image_size // 2]   ,      )

        a__							,   a__:					Optional[Any]      							=     self.model_tester.prepare_config_and_inputs_for_common()
        a__:					Dict      							=     ['basic', 'bottleneck']
        for model_class in self.all_model_classes:
          for layer_type in layers_type:
            a__:					Dict      							=     layer_type
            a__:					Dict      							=     True
            check_hidden_states_output(lowercase   ,      lowercase   ,      lowercase)

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

            check_hidden_states_output(lowercase   ,      lowercase   ,      lowercase)



      def   lowerCamelCase_       (						self)     ->      List[Any]:





        '''simple docstring'''





        a__:					Optional[Any]      							=     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_for_image_classification(*lowercase)



      @slow
      def   lowerCamelCase_       (						self)     ->      str:





        '''simple docstring'''





        for model_name in REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
          a__:					Tuple      							=     RegNetModel.from_pretrained(lowercase)
          self.assertIsNotNone(lowercase)







def 						__a       (     )     ->Dict:
  a__:					str      							=     Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'       )
  return image




@require_torch
@require_vision
class        __snake_case	(					unittest.TestCase    ):



      @cached_property
      def   lowerCamelCase_       (						self)     ->      Any:





        '''simple docstring'''





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



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





        '''simple docstring'''





        a__:					Tuple      							=     RegNetForImageClassification.from_pretrained(REGNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]).to(lowercase)

        a__:					Tuple      							=     self.default_image_processor
        a__:					str      							=     prepare_img()
        a__:					Optional[int]      							=     image_processor(images=lowercase   ,      return_tensors='pt').to(lowercase)

        # forward pass
        with torch.no_grad():
          a__:					List[Any]      							=     model(**lowercase)

        # verify the logits
        a__:					Tuple      							=     torch.Size((1, 10_00))
        self.assertEqual(outputs.logits.shape   ,      lowercase)

        a__:					Optional[Any]      							=     torch.tensor([-0.4180, -1.5051, -3.4836]).to(lowercase)

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


