
import collections
import importlib.util
import os
import re
from pathlib import Path


_snake_case      :							Optional[int]     	=    "src/transformers"


# Matches is_xxx_available()
_snake_case      :							List[str]     	=    re.compile(r"is\_([a-z_]*)_available()")
# Catches a one-line _import_struct = {xxx}
_snake_case      :							Optional[Any]     	=    re.compile(r"^_import_structure\s+=\s+\{([^\}]+)\}")
# Catches a line with a key-values pattern: "bla": ["foo", "bar"]
_snake_case      :							Tuple     	=    re.compile(r"\s+\"\S*\":\s+\[([^\]]*)\]")
# Catches a line if not is_foo_available
_snake_case      :							Any     	=    re.compile(r"^\s*if\s+not\s+is\_[a-z_]*\_available\(\)")
# Catches a line _import_struct["bla"].append("foo")
_snake_case      :							Tuple     	=    re.compile(r"^\s*_import_structure\[\"\S*\"\]\.append\(\"(\S*)\"\)")
# Catches a line _import_struct["bla"].extend(["foo", "bar"]) or _import_struct["bla"] = ["foo", "bar"]
_snake_case      :							Optional[Any]     	=    re.compile(r"^\s*_import_structure\[\S*\](?:\.extend\(|\s*=\s+)\[([^\]]*)\]")
# Catches a line with an object between quotes and a comma:     "MyModel",
_snake_case      :							Union[str, Any]     	=    re.compile("^\s+\"([^\"]+)\",")
# Catches a line with objects between brackets only:    ["foo", "bar"],
_snake_case      :							int     	=    re.compile("^\s+\[([^\]]+)\]")
# Catches a line with from foo import bar, bla, boo
_snake_case      :							Union[str, Any]     	=    re.compile(r"\s+from\s+\S*\s+import\s+([^\(\s].*)\n")
# Catches a line with try:
_snake_case      :							Optional[int]     	=    re.compile(r"^\s*try:")
# Catches a line with else:
_snake_case      :							int     	=    re.compile(r"^\s*else:")

def  __snake_case							(	__magic_name__						):







				'''simple docstring'''


				if _re_test_backend.search(__magic_name__						) is None:
								return None
				lowercase         =      [b[0] for b in _re_backend.findall(__magic_name__						)]
				backends.sort()
				return "_and_".join(__magic_name__						)

def  __snake_case							(	__magic_name__						):







				'''simple docstring'''


				with open(__magic_name__		,    "r"		,    encoding="utf-8"		,    newline="\n"						) as f:
								lowercase         =      f.readlines()

				lowercase         =      0
				while line_index < len(__magic_name__						) and not lines[line_index].startswith("_import_structure = {"						):
								line_index += 1

				# If this is a traditional init, just return.
				if line_index >= len(__magic_name__						):
								return None

				# First grab the objects without a specific backend in _import_structure
				lowercase         =      []
				while not lines[line_index].startswith("if TYPE_CHECKING"						) and find_backend(lines[line_index]						) is None:
								lowercase         =      lines[line_index]
								# If we have everything on a single line, let's deal with it.
								if _re_one_line_import_struct.search(__magic_name__						):
												lowercase         =      _re_one_line_import_struct.search(__magic_name__						).groups()[0]
												lowercase         =      re.findall("\[([^\]]+)\]"		,    __magic_name__						)
												for imp in imports:
																objects.extend([obj[1:-1] for obj in imp.split(", "						)]						)
												line_index += 1
												continue
								lowercase         =      _re_import_struct_key_value.search(__magic_name__						)
								if single_line_import_search is not None:
												lowercase         =      [obj[1:-1] for obj in single_line_import_search.groups()[0].split(", "						) if len(__magic_name__						) > 0]
												objects.extend(__magic_name__						)
								elif line.startswith(" " * 8 + "\""						):
												objects.append(line[9:-3]						)
								line_index += 1

				lowercase         =      {"none": objects}
				# Let's continue with backend-specific objects in _import_structure
				while not lines[line_index].startswith("if TYPE_CHECKING"						):
								# If the line is an if not is_backend_available, we grab all objects associated.
								lowercase         =      find_backend(lines[line_index]						)
								# Check if the backend declaration is inside a try block:
								if _re_try.search(lines[line_index - 1]						) is None:
												lowercase         =      None

								if backend is not None:
												line_index += 1

												# Scroll until we hit the else block of try-except-else
												while _re_else.search(lines[line_index]						) is None:
																line_index += 1

												line_index += 1

												lowercase         =      []
												# Until we unindent, add backend objects to the list
												while len(lines[line_index]						) <= 1 or lines[line_index].startswith(" " * 4						):
																lowercase         =      lines[line_index]
																if _re_import_struct_add_one.search(__magic_name__						) is not None:
																				objects.append(_re_import_struct_add_one.search(__magic_name__						).groups()[0]						)
																elif _re_import_struct_add_many.search(__magic_name__						) is not None:
																				lowercase         =      _re_import_struct_add_many.search(__magic_name__						).groups()[0].split(", "						)
																				lowercase         =      [obj[1:-1] for obj in imports if len(__magic_name__						) > 0]
																				objects.extend(__magic_name__						)
																elif _re_between_brackets.search(__magic_name__						) is not None:
																				lowercase         =      _re_between_brackets.search(__magic_name__						).groups()[0].split(", "						)
																				lowercase         =      [obj[1:-1] for obj in imports if len(__magic_name__						) > 0]
																				objects.extend(__magic_name__						)
																elif _re_quote_object.search(__magic_name__						) is not None:
																				objects.append(_re_quote_object.search(__magic_name__						).groups()[0]						)
																elif line.startswith(" " * 8 + "\""						):
																				objects.append(line[9:-3]						)
																elif line.startswith(" " * 12 + "\""						):
																				objects.append(line[13:-3]						)
																line_index += 1

												lowercase         =      objects
								else:
												line_index += 1

    # At this stage we are in the TYPE_CHECKING part, first grab the objects without a specific backend
				lowercase         =      []
				while (
				    line_index < len(__magic_name__						)
				    and find_backend(lines[line_index]						) is None
				    and not lines[line_index].startswith("else"						)
				):
								lowercase         =      lines[line_index]
								lowercase         =      _re_import.search(__magic_name__						)
								if single_line_import_search is not None:
												objects.extend(single_line_import_search.groups()[0].split(", "						)						)
								elif line.startswith(" " * 8						):
												objects.append(line[8:-2]						)
								line_index += 1

				lowercase         =      {"none": objects}
				# Let's continue with backend-specific objects
				while line_index < len(__magic_name__						):
								# If the line is an if is_backend_available, we grab all objects associated.
								lowercase         =      find_backend(lines[line_index]						)
								# Check if the backend declaration is inside a try block:
								if _re_try.search(lines[line_index - 1]						) is None:
												lowercase         =      None

								if backend is not None:
												line_index += 1

												# Scroll until we hit the else block of try-except-else
												while _re_else.search(lines[line_index]						) is None:
																line_index += 1

												line_index += 1

												lowercase         =      []
												# Until we unindent, add backend objects to the list
												while len(lines[line_index]						) <= 1 or lines[line_index].startswith(" " * 8						):
																lowercase         =      lines[line_index]
																lowercase         =      _re_import.search(__magic_name__						)
																if single_line_import_search is not None:
																				objects.extend(single_line_import_search.groups()[0].split(", "						)						)
																elif line.startswith(" " * 12						):
																				objects.append(line[12:-2]						)
																line_index += 1

												lowercase         =      objects
								else:
												line_index += 1

				return import_dict_objects, type_hint_objects

def  __snake_case							(	__magic_name__		,    __magic_name__						):







				'''simple docstring'''


				def find_duplicates(__magic_name__						):
								return [k for k, v in collections.Counter(__magic_name__						).items() if v > 1]

				if list(import_dict_objects.keys()						) != list(type_hint_objects.keys()						):
								return ["Both sides of the init do not have the same backends!"]

				lowercase         =      []
				for key in import_dict_objects.keys():
								lowercase         =      find_duplicates(import_dict_objects[key]						)
								if duplicate_imports:
												errors.append(F'''Duplicate _import_structure definitions for: {duplicate_imports}'''						)
								lowercase         =      find_duplicates(type_hint_objects[key]						)
								if duplicate_type_hints:
												errors.append(F'''Duplicate TYPE_CHECKING objects for: {duplicate_type_hints}'''						)

								if sorted(set(import_dict_objects[key]						)						) != sorted(set(type_hint_objects[key]						)						):
												lowercase         =      "base imports" if key == "none" else F'''{key} backend'''
												errors.append(F'''Differences for {name}:'''						)
												for a in type_hint_objects[key]:
																if a not in import_dict_objects[key]:
																				errors.append(F'''  {a} in TYPE_HINT but not in _import_structure.'''						)
												for a in import_dict_objects[key]:
																if a not in type_hint_objects[key]:
																				errors.append(F'''  {a} in _import_structure but not in TYPE_HINT.'''						)
				return errors

def  __snake_case							(	):







				'''simple docstring'''


				lowercase         =      []
				for root, _, files in os.walk(__magic_name__						):
								if "__init__.py" in files:
												lowercase         =      os.path.join(__magic_name__		,    "__init__.py"						)
												lowercase         =      parse_init(__magic_name__						)
												if objects is not None:
																lowercase         =      analyze_results(*__magic_name__						)
																if len(__magic_name__						) > 0:
																				lowercase         =      F'''Problem in {fname}, both halves do not define the same objects.\n{errors[0]}'''
																				failures.append("\n".join(__magic_name__						)						)
				if len(__magic_name__						) > 0:
								raise ValueError("\n\n".join(__magic_name__						)						)

def  __snake_case							(	):







				'''simple docstring'''


				lowercase         =      []
				for path, directories, files in os.walk(__magic_name__						):
								for folder in directories:
												# Ignore private modules
												if folder.startswith("_"						):
																directories.remove(__magic_name__						)
																continue
												# Ignore leftovers from branches (empty folders apart from pycache)
												if len(list((Path(__magic_name__						) / folder).glob("*.py"						)						)						) == 0:
																continue
												lowercase         =      str((Path(__magic_name__						) / folder).relative_to(__magic_name__						)						)
												lowercase         =      short_path.replace(os.path.sep		,    "."						)
												submodules.append(__magic_name__						)
								for fname in files:
												if fname == "__init__.py":
																continue
												lowercase         =      str((Path(__magic_name__						) / fname).relative_to(__magic_name__						)						)
												lowercase         =      short_path.replace(".py"		,    ""						).replace(os.path.sep		,    "."						)
												if len(submodule.split("."						)						) == 1:
																submodules.append(__magic_name__						)
				return submodules


_snake_case      :							Optional[int]     	=    [
    "convert_pytorch_checkpoint_to_tf2",
    "modeling_flax_pytorch_utils",
]

def  __snake_case							(	):







				'''simple docstring'''


				lowercase         =      importlib.util.spec_from_file_location(
				    "transformers"		,    os.path.join(__magic_name__		,    "__init__.py"						)		,    submodule_search_locations=[PATH_TO_TRANSFORMERS]		,    )
				lowercase         =      spec.loader.load_module()

				lowercase         =      [
				    module
				    for module in get_transformers_submodules()
				    if module not in IGNORE_SUBMODULES and module not in transformers._import_structure.keys()
				]
				if len(__magic_name__						) > 0:
								lowercase         =      "\n".join(F'''- {module}''' for module in module_not_registered						)
								raise ValueError(
								    "The following submodules are not properly registered in the main init of Transformers:\n"
								    F'''{list_of_modules}\n'''
								    "Make sure they appear somewhere in the keys of `_import_structure` with an empty list as value."						)


if __name__ == "__main__":
						check_all_inits()
						check_submodules()


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   UpperCamelCase_      (      __a		):







						'''simple docstring'''



						def        SCREAMING_SNAKE_CASE(			self							:Tuple     )  ->Optional[int]:
										lowercase         =      self.config_class(**self.inputs_dict     )
										self.parent.assertTrue(hasattr(lowerCAmelCase__		,    "tf_padding"     )     )
										self.parent.assertTrue(hasattr(lowerCAmelCase__		,    "depth_multiplier"     )     )





class   UpperCamelCase_      :







						'''simple docstring'''



						def __init__(			self							:Dict		,    lowerCAmelCase__							:Any		,    lowerCAmelCase__							:Union[str, Any]=13		,    lowerCAmelCase__							:Tuple=3		,    lowerCAmelCase__							:Optional[int]=32		,    lowerCAmelCase__							:Any=0.25		,    lowerCAmelCase__							:Dict=8		,    lowerCAmelCase__							:Optional[int]=8		,    lowerCAmelCase__							:List[str]=6		,    lowerCAmelCase__							:List[Any]=32		,    lowerCAmelCase__							:Optional[Any]=True		,    lowerCAmelCase__							:str=True		,    lowerCAmelCase__							:Optional[int]=True		,    lowerCAmelCase__							:Dict="relu6"		,    lowerCAmelCase__							:Tuple=1280		,    lowerCAmelCase__							:Dict=0.1		,    lowerCAmelCase__							:List[str]=0.02		,    lowerCAmelCase__							:Dict=True		,    lowerCAmelCase__							:List[Any]=True		,    lowerCAmelCase__							:Tuple=10		,    lowerCAmelCase__							:int=None		,    )  ->List[str]:
										lowercase         =      parent
										lowercase         =      batch_size
										lowercase         =      num_channels
										lowercase         =      image_size
										lowercase         =      depth_multiplier
										lowercase         =      depth_divisible_by
										lowercase         =      min_depth
										lowercase         =      expand_ratio
										lowercase         =      tf_padding
										lowercase         =      output_stride
										lowercase         =      first_layer_is_expansion
										lowercase         =      finegrained_output
										lowercase         =      hidden_act
										lowercase         =      last_hidden_size if finegrained_output else int(last_hidden_size * depth_multiplier     )
										lowercase         =      classifier_dropout_prob
										lowercase         =      use_labels
										lowercase         =      is_training
										lowercase         =      num_labels
										lowercase         =      initializer_range
										lowercase         =      scope





						def        SCREAMING_SNAKE_CASE(			self							:str     )  ->Dict:
										lowercase         =      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]     )

										lowercase         =      None
										lowercase         =      None
										if self.use_labels:
														lowercase         =      ids_tensor([self.batch_size]		,    self.num_labels     )
														lowercase         =      ids_tensor([self.batch_size, self.image_size, self.image_size]		,    self.num_labels     )

										lowercase         =      self.get_config()

										return config, pixel_values, labels, pixel_labels





						def        SCREAMING_SNAKE_CASE(			self							:Optional[int]     )  ->List[Any]:
										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        SCREAMING_SNAKE_CASE(			self							:Dict		,    lowerCAmelCase__							:Dict		,    lowerCAmelCase__							:Optional[Any]		,    lowerCAmelCase__							:Optional[Any]		,    lowerCAmelCase__							:Tuple     )  ->Any:
										lowercase         =      MobileNetVaModel(config=lowerCAmelCase__     )
										model.to(lowerCAmelCase__     )
										model.eval()
										lowercase         =      model(lowerCAmelCase__     )
										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        SCREAMING_SNAKE_CASE(			self							:Tuple		,    lowerCAmelCase__							:int		,    lowerCAmelCase__							:List[str]		,    lowerCAmelCase__							:str		,    lowerCAmelCase__							:Optional[Any]     )  ->Union[str, Any]:
										lowercase         =      self.num_labels
										lowercase         =      MobileNetVaForImageClassification(lowerCAmelCase__     )
										model.to(lowerCAmelCase__     )
										model.eval()
										lowercase         =      model(lowerCAmelCase__		,    labels=lowerCAmelCase__     )
										self.parent.assertEqual(result.logits.shape		,    (self.batch_size, self.num_labels)     )





						def        SCREAMING_SNAKE_CASE(			self							:Tuple		,    lowerCAmelCase__							:List[str]		,    lowerCAmelCase__							:Any		,    lowerCAmelCase__							:Union[str, Any]		,    lowerCAmelCase__							:Optional[int]     )  ->Union[str, Any]:
										lowercase         =      self.num_labels
										lowercase         =      MobileNetVaForSemanticSegmentation(lowerCAmelCase__     )
										model.to(lowerCAmelCase__     )
										model.eval()
										lowercase         =      model(lowerCAmelCase__     )
										self.parent.assertEqual(
										    result.logits.shape		,    (
										        self.batch_size,
										        self.num_labels,
										        self.image_size // self.output_stride,
										        self.image_size // self.output_stride,
										    )		,    )
										lowercase         =      model(lowerCAmelCase__		,    labels=lowerCAmelCase__     )
										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        SCREAMING_SNAKE_CASE(			self							:Any     )  ->int:
										lowercase         =      self.prepare_config_and_inputs()
										lowercase     ,	lowercase     ,	lowercase     ,	lowercase         =      config_and_inputs
										lowercase         =      {"pixel_values": pixel_values}
										return config, inputs_dict





@require_torch
class   UpperCamelCase_      (      __a		,    __a		,    unittest.TestCase		):







						'''simple docstring'''



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

						UpperCamelCase      :  Union[str, Any]				   =					False
						UpperCamelCase      :  int				   =					False
						UpperCamelCase      :  str				   =					False
						UpperCamelCase      :  Dict				   =					False





						def        SCREAMING_SNAKE_CASE(			self							:Optional[int]     )  ->Dict:
										lowercase         =      MobileNetVaModelTester(self     )
										lowercase         =      MobileNetVaConfigTester(self		,    config_class=lowerCAmelCase__		,    has_text_modality=lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:Dict     )  ->Any:
										self.config_tester.run_common_tests()





						@unittest.skip(reason="MobileNetV2 does not use inputs_embeds"     )
						def        SCREAMING_SNAKE_CASE(			self							:Tuple     )  ->Optional[int]:
										pass





						@unittest.skip(reason="MobileNetV2 does not support input and output embeddings"     )
						def        SCREAMING_SNAKE_CASE(			self							:Any     )  ->str:
										pass





						@unittest.skip(reason="MobileNetV2 does not output attentions"     )
						def        SCREAMING_SNAKE_CASE(			self							:List[Any]     )  ->str:
										pass





						def        SCREAMING_SNAKE_CASE(			self							:Union[str, Any]     )  ->Dict:
										lowercase     ,	lowercase         =      self.model_tester.prepare_config_and_inputs_for_common()

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

														lowercase         =      ["pixel_values"]
														self.assertListEqual(arg_names[:1]		,    lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:int     )  ->List[str]:
										lowercase         =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_model(*lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:int     )  ->Optional[int]:
										def check_hidden_states_output(lowerCAmelCase__							:str		,    lowerCAmelCase__							:Union[str, Any]		,    lowerCAmelCase__							:int     ):
														lowercase         =      model_class(lowerCAmelCase__     )
														model.to(lowerCAmelCase__     )
														model.eval()

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

														lowercase         =      outputs.hidden_states

														lowercase         =      16
														self.assertEqual(len(lowerCAmelCase__     )		,    lowerCAmelCase__     )

										lowercase     ,	lowercase         =      self.model_tester.prepare_config_and_inputs_for_common()

										for model_class in self.all_model_classes:
														lowercase         =      True
														check_hidden_states_output(lowerCAmelCase__		,    lowerCAmelCase__		,    lowerCAmelCase__     )

														# check that output_hidden_states also work using config
														del inputs_dict["output_hidden_states"]
														lowercase         =      True

														check_hidden_states_output(lowerCAmelCase__		,    lowerCAmelCase__		,    lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:Any     )  ->Tuple:
										lowercase         =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase__     )





						def        SCREAMING_SNAKE_CASE(			self							:int     )  ->str:
										lowercase         =      self.model_tester.prepare_config_and_inputs()
										self.model_tester.create_and_check_for_semantic_segmentation(*lowerCAmelCase__     )





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:Union[str, Any]     )  ->str:
										for model_name in MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														lowercase         =      MobileNetVaModel.from_pretrained(lowerCAmelCase__     )
														self.assertIsNotNone(lowerCAmelCase__     )




def  __snake_case							(	):







				'''simple docstring'''


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





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







						'''simple docstring'''



						@cached_property
						def        SCREAMING_SNAKE_CASE(			self							:str     )  ->Any:
										return (
										    MobileNetVaImageProcessor.from_pretrained("google/mobilenet_v2_1.0_224"     ) if is_vision_available() else None
										)





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:Tuple     )  ->Union[str, Any]:
										lowercase         =      MobileNetVaForImageClassification.from_pretrained("google/mobilenet_v2_1.0_224"     ).to(lowerCAmelCase__     )

										lowercase         =      self.default_image_processor
										lowercase         =      prepare_img()
										lowercase         =      image_processor(images=lowerCAmelCase__		,    return_tensors="pt"     ).to(lowerCAmelCase__     )

										# forward pass
										with torch.no_grad():
														lowercase         =      model(**lowerCAmelCase__     )

										# verify the logits
										lowercase         =      torch.Size((1, 1001)     )
										self.assertEqual(outputs.logits.shape		,    lowerCAmelCase__     )

										lowercase         =      torch.tensor([0.24_45, -1.19_93, 0.19_05]     ).to(lowerCAmelCase__     )

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





						@slow
						def        SCREAMING_SNAKE_CASE(			self							:Tuple     )  ->List[Any]:
										lowercase         =      MobileNetVaForSemanticSegmentation.from_pretrained("google/deeplabv3_mobilenet_v2_1.0_513"     )
										lowercase         =      model.to(lowerCAmelCase__     )

										lowercase         =      MobileNetVaImageProcessor.from_pretrained("google/deeplabv3_mobilenet_v2_1.0_513"     )

										lowercase         =      prepare_img()
										lowercase         =      image_processor(images=lowerCAmelCase__		,    return_tensors="pt"     ).to(lowerCAmelCase__     )

										# forward pass
										with torch.no_grad():
														lowercase         =      model(**lowerCAmelCase__     )
										lowercase         =      outputs.logits

										# verify the logits
										lowercase         =      torch.Size((1, 21, 65, 65)     )
										self.assertEqual(logits.shape		,    lowerCAmelCase__     )

										lowercase         =      torch.tensor(
										    [
										        [[17.57_90, 17.75_81, 18.33_55], [18.32_57, 18.42_30, 18.89_73], [18.61_69, 18.86_50, 19.21_87]],
										        [[-2.15_95, -2.09_77, -2.37_41], [-2.42_26, -2.30_28, -2.68_35], [-2.78_19, -2.59_91, -2.77_06]],
										        [[4.20_58, 4.83_17, 4.76_38], [4.41_36, 5.03_61, 4.93_83], [4.50_28, 4.96_44, 4.87_34]],
										    ]		,    device=lowerCAmelCase__		,    )

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