





'''simple docstring'''






import inspect
import unittest

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

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 transformers import MobileNetVaForImageClassification, MobileNetVaModel
    from transformers.models.mobilenet_va.modeling_mobilenet_va import MOBILENET_V1_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
    from PIL import Image

    from transformers import MobileNetVaImageProcessor
class 					__snake_case  (					__SCREAMING_SNAKE_CASE							):






   '''simple docstring'''





   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					str    =  self.config_class(**self.inputs_dict       )
    self.parent.assertTrue(hasattr(__SCREAMING_SNAKE_CASE	,		"""tf_padding"""       )       )
    self.parent.assertTrue(hasattr(__SCREAMING_SNAKE_CASE	,		"""depth_multiplier"""       )       )



class 					__snake_case  :






   '''simple docstring'''





   def __init__(							self	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE=1_3	,		__SCREAMING_SNAKE_CASE=3	,		__SCREAMING_SNAKE_CASE=3_2	,		__SCREAMING_SNAKE_CASE=0.25	,		__SCREAMING_SNAKE_CASE=8	,		__SCREAMING_SNAKE_CASE=True	,		__SCREAMING_SNAKE_CASE=1_0_2_4	,		__SCREAMING_SNAKE_CASE=3_2	,		__SCREAMING_SNAKE_CASE="relu6"	,		__SCREAMING_SNAKE_CASE=0.1	,		__SCREAMING_SNAKE_CASE=0.02	,		__SCREAMING_SNAKE_CASE=True	,		__SCREAMING_SNAKE_CASE=True	,		__SCREAMING_SNAKE_CASE=1_0	,		__SCREAMING_SNAKE_CASE=None	,		):
    snake_case__     :					Dict    =  parent
    snake_case__     :					Dict    =  batch_size
    snake_case__     :					int    =  num_channels
    snake_case__     :					Optional[Any]    =  image_size
    snake_case__     :					Optional[Any]    =  depth_multiplier
    snake_case__     :					Tuple    =  min_depth
    snake_case__     :					int    =  tf_padding
    snake_case__     :					List[Any]    =  int(last_hidden_size * depth_multiplier       )
    snake_case__     :					Tuple    =  output_stride
    snake_case__     :					Optional[Any]    =  hidden_act
    snake_case__     :					Optional[int]    =  classifier_dropout_prob
    snake_case__     :					Optional[Any]    =  use_labels
    snake_case__     :					Tuple    =  is_training
    snake_case__     :					Dict    =  num_labels
    snake_case__     :					int    =  initializer_range
    snake_case__     :					Optional[Any]    =  scope

   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					Optional[Any]    =  floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]       )

    snake_case__     :					List[Any]    =  None
    snake_case__     :					List[str]    =  None
    if self.use_labels:
     snake_case__     :					Union[str, Any]    =  ids_tensor([self.batch_size]	,		self.num_labels       )
     snake_case__     :					Optional[Any]    =  ids_tensor([self.batch_size, self.image_size, self.image_size]	,		self.num_labels       )

    snake_case__     :					List[Any]    =  self.get_config()

    return config, pixel_values, labels, pixel_labels

   def 		__UpperCamelCase						(							self       ):
    return MobileNetVaConfig(
        num_channels=self.num_channels	,		image_size=self.image_size	,		depth_multiplier=self.depth_multiplier	,		min_depth=self.min_depth	,		tf_padding=self.tf_padding	,		hidden_act=self.hidden_act	,		classifier_dropout_prob=self.classifier_dropout_prob	,		initializer_range=self.initializer_range	,		)

   def 		__UpperCamelCase						(							self	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       ):
    snake_case__     :					Optional[int]    =  MobileNetVaModel(config=__SCREAMING_SNAKE_CASE       )
    model.to(__SCREAMING_SNAKE_CASE       )
    model.eval()
    snake_case__     :					List[Any]    =  model(__SCREAMING_SNAKE_CASE       )
    self.parent.assertEqual(
        result.last_hidden_state.shape	,		(
            self.batch_size,
            self.last_hidden_size,
            self.image_size // self.output_stride,
            self.image_size // self.output_stride,
        )	,		)

   def 		__UpperCamelCase						(							self	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       ):
    snake_case__     :					str    =  self.num_labels
    snake_case__     :					Tuple    =  MobileNetVaForImageClassification(__SCREAMING_SNAKE_CASE       )
    model.to(__SCREAMING_SNAKE_CASE       )
    model.eval()
    snake_case__     :					Optional[Any]    =  model(__SCREAMING_SNAKE_CASE	,		labels=__SCREAMING_SNAKE_CASE       )
    self.parent.assertEqual(result.logits.shape	,		(self.batch_size, self.num_labels)       )


   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					str    =  self.prepare_config_and_inputs()
    snake_case__  ,							snake_case__  ,							snake_case__  ,							snake_case__     :					Optional[int]    =  config_and_inputs
    snake_case__     :					Optional[int]    =  {"""pixel_values""": pixel_values}
    return config, inputs_dict



@require_torch
class 					__snake_case  (					__SCREAMING_SNAKE_CASE		,				__SCREAMING_SNAKE_CASE		,				unittest.TestCase							):






   '''simple docstring'''





   lowerCamelCase__    							=      (MobileNetVaModel, MobileNetVaForImageClassification) if is_torch_available() else ()
   lowerCamelCase__    							=      (
       {'''feature-extraction''': MobileNetVaModel, '''image-classification''': MobileNetVaForImageClassification}
       if is_torch_available()
       else {}
   )

   lowerCamelCase__    							=      False
   lowerCamelCase__    							=      False
   lowerCamelCase__    							=      False
   lowerCamelCase__    							=      False

   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					List[str]    =  MobileNetVaModelTester(self       )
    snake_case__     :					str    =  MobileNetVaConfigTester(self	,		config_class=__SCREAMING_SNAKE_CASE	,		has_text_modality=__SCREAMING_SNAKE_CASE       )

   def 		__UpperCamelCase						(							self       ):
    self.config_tester.run_common_tests()

   @unittest.skip(reason="""MobileNetV1 does not use inputs_embeds"""       )
   def 		__UpperCamelCase						(							self       ):
    pass

   @unittest.skip(reason="""MobileNetV1 does not support input and output embeddings"""       )
   def 		__UpperCamelCase						(							self       ):
    pass

   @unittest.skip(reason="""MobileNetV1 does not output attentions"""       )
   def 		__UpperCamelCase						(							self       ):
    pass

   def 		__UpperCamelCase						(							self       ):
    snake_case__  ,							snake_case__     :					Tuple    =  self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     snake_case__     :					Optional[int]    =  model_class(__SCREAMING_SNAKE_CASE       )
     snake_case__     :					List[Any]    =  inspect.signature(model.forward       )
     # signature.parameters is an OrderedDict => so arg_names order is deterministic
     snake_case__     :					Dict    =  [*signature.parameters.keys()]

     snake_case__     :					Optional[int]    =  ["""pixel_values"""]
     self.assertListEqual(arg_names[:1]	,		__SCREAMING_SNAKE_CASE       )

   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					Optional[int]    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE       )

   def 		__UpperCamelCase						(							self       ):
    def check_hidden_states_output(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       ):
     snake_case__     :					List[str]    =  model_class(__SCREAMING_SNAKE_CASE       )
     model.to(__SCREAMING_SNAKE_CASE       )
     model.eval()

     with torch.no_grad():
      snake_case__     :					Dict    =  model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )       )

     snake_case__     :					Optional[Any]    =  outputs.hidden_states

     snake_case__     :					int    =  2_6
     self.assertEqual(len(__SCREAMING_SNAKE_CASE       )	,		__SCREAMING_SNAKE_CASE       )

    snake_case__  ,							snake_case__     :					Optional[Any]    =  self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     snake_case__     :					Optional[Any]    =  True
     check_hidden_states_output(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )

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

     check_hidden_states_output(__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE	,		__SCREAMING_SNAKE_CASE       )

   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					Dict    =  self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_image_classification(*__SCREAMING_SNAKE_CASE       )


   @slow
   def 		__UpperCamelCase						(							self       ):
    for model_name in MOBILENET_V1_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
     snake_case__     :					Dict    =  MobileNetVaModel.from_pretrained(__SCREAMING_SNAKE_CASE       )
     self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )



def        UpperCamelCase__		(						)				->			List[str]:
 '''simple docstring'''






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





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






   '''simple docstring'''





   @cached_property
   def 		__UpperCamelCase						(							self       ):
    return (
        MobileNetVaImageProcessor.from_pretrained("""google/mobilenet_v1_1.0_224"""       ) if is_vision_available() else None
    )


   @slow
   def 		__UpperCamelCase						(							self       ):
    snake_case__     :					int    =  MobileNetVaForImageClassification.from_pretrained("""google/mobilenet_v1_1.0_224"""       ).to(__SCREAMING_SNAKE_CASE       )

    snake_case__     :					Any    =  self.default_image_processor
    snake_case__     :					List[str]    =  prepare_img()
    snake_case__     :					Optional[Any]    =  image_processor(images=__SCREAMING_SNAKE_CASE	,		return_tensors="""pt"""       ).to(__SCREAMING_SNAKE_CASE       )

    # forward pass
    with torch.no_grad():
     snake_case__     :					Optional[Any]    =  model(**__SCREAMING_SNAKE_CASE       )

    # verify the logits
    snake_case__     :					List[Any]    =  torch.Size((1, 1_0_0_1)       )
    self.assertEqual(outputs.logits.shape	,		__SCREAMING_SNAKE_CASE       )

    snake_case__     :					List[Any]    =  torch.tensor([-4.1739, -1.1233, 3.1205]       ).to(__SCREAMING_SNAKE_CASE       )

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









"""simple docstring"""







import inspect
import unittest

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

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 transformers import MobileNetVaForImageClassification, MobileNetVaForSemanticSegmentation, MobileNetVaModel
	from transformers.models.mobilenet_va.modeling_mobilenet_va import MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
	from PIL import Image

	from transformers import MobileNetVaImageProcessor







class 					A_(SCREAMING_SNAKE_CASE_      ):







			"""simple docstring"""



			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Optional[int]	       =    self.config_class(**self.inputs_dict							)
						self.parent.assertTrue(hasattr(A				,   'tf_padding'							)							)
						self.parent.assertTrue(hasattr(A				,   'depth_multiplier'							)							)







class 					A_:







			"""simple docstring"""



			def __init__(	self				,   A				,   A=13				,   A=3				,   A=32				,   A=0.2_5				,   A=8				,   A=8				,   A=6				,   A=32				,   A=True				,   A=True				,   A=True				,   A="relu6"				,   A=1280				,   A=0.1				,   A=0.0_2				,   A=True				,   A=True				,   A=10				,   A=None				,   ):
						_lowerCamelCase					:					str	       =    parent
						_lowerCamelCase					:					Union[str, Any]	       =    batch_size
						_lowerCamelCase					:					List[str]	       =    num_channels
						_lowerCamelCase					:					int	       =    image_size
						_lowerCamelCase					:					str	       =    depth_multiplier
						_lowerCamelCase					:					Optional[int]	       =    depth_divisible_by
						_lowerCamelCase					:					Any	       =    min_depth
						_lowerCamelCase					:					Optional[Any]	       =    expand_ratio
						_lowerCamelCase					:					Tuple	       =    tf_padding
						_lowerCamelCase					:					Optional[Any]	       =    output_stride
						_lowerCamelCase					:					Optional[int]	       =    first_layer_is_expansion
						_lowerCamelCase					:					List[str]	       =    finegrained_output
						_lowerCamelCase					:					Any	       =    hidden_act
						_lowerCamelCase					:					Dict	       =    last_hidden_size if finegrained_output else int(last_hidden_size * depth_multiplier							)
						_lowerCamelCase					:					Any	       =    classifier_dropout_prob
						_lowerCamelCase					:					Optional[Any]	       =    use_labels
						_lowerCamelCase					:					Any	       =    is_training
						_lowerCamelCase					:					List[str]	       =    num_labels
						_lowerCamelCase					:					int	       =    initializer_range
						_lowerCamelCase					:					Tuple	       =    scope
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Tuple	       =    floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]							)

						_lowerCamelCase					:					Union[str, Any]	       =    None
						_lowerCamelCase					:					str	       =    None
						if self.use_labels:
									_lowerCamelCase					:					Dict	       =    ids_tensor([self.batch_size]				,   self.num_labels							)
									_lowerCamelCase					:					Dict	       =    ids_tensor([self.batch_size, self.image_size, self.image_size]				,   self.num_labels							)

						_lowerCamelCase					:					List[Any]	       =    self.get_config()

						return config, pixel_values, labels, pixel_labels
			def    _lowerCAmelCase		(	self							):
						return MobileNetVaConfig(
						    num_channels=self.num_channels				,   image_size=self.image_size				,   depth_multiplier=self.depth_multiplier				,   depth_divisible_by=self.depth_divisible_by				,   min_depth=self.min_depth				,   expand_ratio=self.expand_ratio				,   output_stride=self.output_stride				,   first_layer_is_expansion=self.first_layer_is_expansion				,   finegrained_output=self.finegrained_output				,   hidden_act=self.hidden_act				,   tf_padding=self.tf_padding				,   classifier_dropout_prob=self.classifier_dropout_prob				,   initializer_range=self.initializer_range				,   )
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					int	       =    MobileNetVaModel(config=A							)
						model.to(A							)
						model.eval()
						_lowerCamelCase					:					str	       =    model(A							)
						self.parent.assertEqual(
						    result.last_hidden_state.shape				,   (
						        self.batch_size,
						        self.last_hidden_size,
						        self.image_size // self.output_stride,
						        self.image_size // self.output_stride,
						    )				,   )
						self.parent.assertEqual(
						    result.pooler_output.shape				,   (self.batch_size, self.last_hidden_size)				,   )
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					List[Any]	       =    self.num_labels
						_lowerCamelCase					:					Tuple	       =    MobileNetVaForImageClassification(A							)
						model.to(A							)
						model.eval()
						_lowerCamelCase					:					List[str]	       =    model(A				,   labels=A							)
						self.parent.assertEqual(result.logits.shape				,   (self.batch_size, self.num_labels)							)
			def    _lowerCAmelCase		(	self				,   A				,   A				,   A				,   A							):
						_lowerCamelCase					:					int	       =    self.num_labels
						_lowerCamelCase					:					List[str]	       =    MobileNetVaForSemanticSegmentation(A							)
						model.to(A							)
						model.eval()
						_lowerCamelCase					:					Dict	       =    model(A							)
						self.parent.assertEqual(
						    result.logits.shape				,   (
						        self.batch_size,
						        self.num_labels,
						        self.image_size // self.output_stride,
						        self.image_size // self.output_stride,
						    )				,   )
						_lowerCamelCase					:					str	       =    model(A				,   labels=A							)
						self.parent.assertEqual(
						    result.logits.shape				,   (
						        self.batch_size,
						        self.num_labels,
						        self.image_size // self.output_stride,
						        self.image_size // self.output_stride,
						    )				,   )

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







@require_torch
class 					A_(SCREAMING_SNAKE_CASE_   ,   SCREAMING_SNAKE_CASE_   ,   unittest.TestCase      ):







			"""simple docstring"""



			a_       :			List[Any]												=			(
			    (MobileNetVaModel, MobileNetVaForImageClassification, MobileNetVaForSemanticSegmentation)
			    if is_torch_available()
			    else ()
			)
			a_       :			Optional[int]												=			(
			    {
			        """feature-extraction""": MobileNetVaModel,
			        """image-classification""": MobileNetVaForImageClassification,
			        """image-segmentation""": MobileNetVaForSemanticSegmentation,
			    }
			    if is_torch_available()
			    else {}
			)

			a_       :			List[Any]												=			False
			a_       :			Union[str, Any]												=			False
			a_       :			Union[str, Any]												=			False
			a_       :			str												=			False
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					int	       =    MobileNetVaModelTester(self							)
						_lowerCamelCase					:					int	       =    MobileNetVaConfigTester(self				,   config_class=A				,   has_text_modality=A							)
			def    _lowerCAmelCase		(	self							):
						self.config_tester.run_common_tests()
			@unittest.skip(reason='MobileNetV2 does not use inputs_embeds'							)
			def    _lowerCAmelCase		(	self							):
						pass
			@unittest.skip(reason='MobileNetV2 does not support input and output embeddings'							)
			def    _lowerCAmelCase		(	self							):
						pass
			@unittest.skip(reason='MobileNetV2 does not output attentions'							)
			def    _lowerCAmelCase		(	self							):
						pass
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase       ,							_lowerCamelCase					:					List[Any]	       =    self.model_tester.prepare_config_and_inputs_for_common()

						for model_class in self.all_model_classes:
									_lowerCamelCase					:					int	       =    model_class(A							)
									_lowerCamelCase					:					Optional[Any]	       =    inspect.signature(model.forward							)
									# signature.parameters is an OrderedDict => so arg_names order is deterministic
									_lowerCamelCase					:					Tuple	       =    [*signature.parameters.keys()]

									_lowerCamelCase					:					Tuple	       =    ['pixel_values']
									self.assertListEqual(arg_names[:1]				,   A							)
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Tuple	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*A							)
			def    _lowerCAmelCase		(	self							):
						def check_hidden_states_output(A				,   A				,   A							):
									_lowerCamelCase					:					Any	       =    model_class(A							)
									model.to(A							)
									model.eval()

									with torch.no_grad():
												_lowerCamelCase					:					Optional[int]	       =    model(**self._prepare_for_class(A				,   A							)							)

									_lowerCamelCase					:					int	       =    outputs.hidden_states

									_lowerCamelCase					:					Dict	       =    16
									self.assertEqual(len(A							)				,   A							)

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

						for model_class in self.all_model_classes:
									_lowerCamelCase					:					Optional[Any]	       =    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							):
						_lowerCamelCase					:					Union[str, Any]	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_image_classification(*A							)
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Any	       =    self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_for_semantic_segmentation(*A							)

			@slow
			def    _lowerCAmelCase		(	self							):
						for model_name in MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									_lowerCamelCase					:					Any	       =    MobileNetVaModel.from_pretrained(A							)
									self.assertIsNotNone(A							)






def     UpperCAmelCase_					(				):




			'''simple docstring'''



			_lowerCamelCase					:					List[Any]	       =    Image.open('./tests/fixtures/tests_samples/COCO/000000039769.png'						)
			return image







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







			"""simple docstring"""



			@cached_property
			def    _lowerCAmelCase		(	self							):
						return (
						    MobileNetVaImageProcessor.from_pretrained('google/mobilenet_v2_1.0_224'							) if is_vision_available() else None
						)
			@slow
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					Optional[Any]	       =    MobileNetVaForImageClassification.from_pretrained('google/mobilenet_v2_1.0_224'							).to(A							)

						_lowerCamelCase					:					int	       =    self.default_image_processor
						_lowerCamelCase					:					Tuple	       =    prepare_img()
						_lowerCamelCase					:					int	       =    image_processor(images=A				,   return_tensors='pt'							).to(A							)

						# forward pass
						with torch.no_grad():
									_lowerCamelCase					:					int	       =    model(**A							)

						# verify the logits
						_lowerCamelCase					:					Tuple	       =    torch.Size((1, 1001)							)
						self.assertEqual(outputs.logits.shape				,   A							)

						_lowerCamelCase					:					Union[str, Any]	       =    torch.tensor([0.2_4_4_5, -1.1_9_9_3, 0.1_9_0_5]							).to(A							)

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

			@slow
			def    _lowerCAmelCase		(	self							):
						_lowerCamelCase					:					str	       =    MobileNetVaForSemanticSegmentation.from_pretrained('google/deeplabv3_mobilenet_v2_1.0_513'							)
						_lowerCamelCase					:					Tuple	       =    model.to(A							)

						_lowerCamelCase					:					Tuple	       =    MobileNetVaImageProcessor.from_pretrained('google/deeplabv3_mobilenet_v2_1.0_513'							)

						_lowerCamelCase					:					Any	       =    prepare_img()
						_lowerCamelCase					:					Any	       =    image_processor(images=A				,   return_tensors='pt'							).to(A							)

						# forward pass
						with torch.no_grad():
									_lowerCamelCase					:					Optional[Any]	       =    model(**A							)
						_lowerCamelCase					:					Optional[int]	       =    outputs.logits

						# verify the logits
						_lowerCamelCase					:					Tuple	       =    torch.Size((1, 21, 65, 65)							)
						self.assertEqual(logits.shape				,   A							)

						_lowerCamelCase					:					Optional[int]	       =    torch.tensor(
						    [
						        [[1_7.5_7_9_0, 1_7.7_5_8_1, 1_8.3_3_5_5], [1_8.3_2_5_7, 1_8.4_2_3_0, 1_8.8_9_7_3], [1_8.6_1_6_9, 1_8.8_6_5_0, 1_9.2_1_8_7]],
						        [[-2.1_5_9_5, -2.0_9_7_7, -2.3_7_4_1], [-2.4_2_2_6, -2.3_0_2_8, -2.6_8_3_5], [-2.7_8_1_9, -2.5_9_9_1, -2.7_7_0_6]],
						        [[4.2_0_5_8, 4.8_3_1_7, 4.7_6_3_8], [4.4_1_3_6, 5.0_3_6_1, 4.9_3_8_3], [4.5_0_2_8, 4.9_6_4_4, 4.8_7_3_4]],
						    ]				,   device=A				,   )

						self.assertTrue(torch.allclose(logits[0, :3, :3, :3]				,   A				,   atol=1E-4							)							)





