



"""simple docstring"""




import inspect
import unittest

from transformers import is_torch_available, is_vision_available
from transformers.models.auto import get_values
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 transformers import MODEL_MAPPING, GLPNConfig, GLPNForDepthEstimation, GLPNModel
				from transformers.models.glpn.modeling_glpn import GLPN_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
				from PIL import Image

				from transformers import GLPNImageProcessor

class 		UpperCAmelCase__      (      __UpperCamelCase       ):




			'''simple docstring'''






			def 			snake_case__					(       self							:			Tuple			):
					'''simple docstring'''





					__UpperCAmelCase   :					Tuple													=     self.config_class(**self.inputs_dict			)
					self.parent.assertTrue(hasattr(a_	,	'''hidden_sizes'''			)			)
					self.parent.assertTrue(hasattr(a_	,	'''num_attention_heads'''			)			)
					self.parent.assertTrue(hasattr(a_	,	'''num_encoder_blocks'''			)			)

class 		UpperCAmelCase__      :




			'''simple docstring'''






			def __init__(       self							:			Tuple	,	a_							:			int	,	a_							:			Optional[Any]=13	,	a_							:			Tuple=64	,	a_							:			str=3	,	a_							:			Any=4	,	a_							:			List[Any]=[2, 2, 2, 2]	,	a_							:			Optional[Any]=[8, 4, 2, 1]	,	a_							:			Dict=[16, 32, 64, 1_28]	,	a_							:			List[str]=[1, 4, 8, 16]	,	a_							:			Dict=[1, 2, 4, 8]	,	a_							:			Optional[Any]=True	,	a_							:			Tuple=True	,	a_							:			Union[str, Any]="gelu"	,	a_							:			Dict=0.1	,	a_							:			Optional[Any]=0.1	,	a_							:			Optional[Any]=0.0_2	,	a_							:			str=16	,	a_							:			str=3	,	a_							:			int=None	,	):
					'''simple docstring'''





					__UpperCAmelCase   :					Any													=     parent
					__UpperCAmelCase   :					str													=     batch_size
					__UpperCAmelCase   :					Tuple													=     image_size
					__UpperCAmelCase   :					str													=     num_channels
					__UpperCAmelCase   :					str													=     num_encoder_blocks
					__UpperCAmelCase   :					Optional[Any]													=     sr_ratios
					__UpperCAmelCase   :					Tuple													=     depths
					__UpperCAmelCase   :					List[str]													=     hidden_sizes
					__UpperCAmelCase   :					str													=     downsampling_rates
					__UpperCAmelCase   :					str													=     num_attention_heads
					__UpperCAmelCase   :					Optional[int]													=     is_training
					__UpperCAmelCase   :					List[str]													=     use_labels
					__UpperCAmelCase   :					Optional[Any]													=     hidden_act
					__UpperCAmelCase   :					List[Any]													=     hidden_dropout_prob
					__UpperCAmelCase   :					Optional[int]													=     attention_probs_dropout_prob
					__UpperCAmelCase   :					Dict													=     initializer_range
					__UpperCAmelCase   :					Any													=     decoder_hidden_size
					__UpperCAmelCase   :					int													=     num_labels
					__UpperCAmelCase   :					Dict													=     scope




			def 			snake_case__					(       self							:			str			):
					'''simple docstring'''





					__UpperCAmelCase   :					str													=     floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

					__UpperCAmelCase   :					Tuple													=     None
					if self.use_labels:
							__UpperCAmelCase   :					List[str]													=     ids_tensor([self.batch_size, self.image_size, self.image_size]	,	self.num_labels			)

					__UpperCAmelCase   :					Tuple													=     self.get_config()
					return config, pixel_values, labels




			def 			snake_case__					(       self							:			Tuple			):
					'''simple docstring'''





					return GLPNConfig(
					    image_size=self.image_size	,	num_channels=self.num_channels	,	num_encoder_blocks=self.num_encoder_blocks	,	depths=self.depths	,	hidden_sizes=self.hidden_sizes	,	num_attention_heads=self.num_attention_heads	,	hidden_act=self.hidden_act	,	hidden_dropout_prob=self.hidden_dropout_prob	,	attention_probs_dropout_prob=self.attention_probs_dropout_prob	,	initializer_range=self.initializer_range	,	decoder_hidden_size=self.decoder_hidden_size	,	)




			def 			snake_case__					(       self							:			int	,	a_							:			List[Any]	,	a_							:			Optional[Any]	,	a_							:			int			):
					'''simple docstring'''





					__UpperCAmelCase   :					Union[str, Any]													=     GLPNModel(config=a_			)
					model.to(a_			)
					model.eval()
					__UpperCAmelCase   :					List[str]													=     model(a_			)
					__UpperCAmelCase   :					List[Any]													=     self.image_size // (self.downsampling_rates[-1] * 2)
					self.parent.assertEqual(
					    result.last_hidden_state.shape	,	(self.batch_size, self.hidden_sizes[-1], expected_height, expected_width)			)




			def 			snake_case__					(       self							:			Union[str, Any]	,	a_							:			int	,	a_							:			Optional[int]	,	a_							:			Any			):
					'''simple docstring'''





					__UpperCAmelCase   :					Any													=     self.num_labels
					__UpperCAmelCase   :					List[Any]													=     GLPNForDepthEstimation(a_			)
					model.to(a_			)
					model.eval()
					__UpperCAmelCase   :					str													=     model(a_			)
					self.parent.assertEqual(result.predicted_depth.shape	,	(self.batch_size, self.image_size, self.image_size)			)
					__UpperCAmelCase   :					int													=     model(a_	,	labels=a_			)
					self.parent.assertEqual(result.predicted_depth.shape	,	(self.batch_size, self.image_size, self.image_size)			)




			def 			snake_case__					(       self							:			Tuple			):
					'''simple docstring'''





					__UpperCAmelCase   :					Optional[int]													=     self.prepare_config_and_inputs()
					__UpperCAmelCase   :					Optional[int]													=     config_and_inputs
					__UpperCAmelCase   :					Tuple													=     {'''pixel_values''': pixel_values}
					return config, inputs_dict

@require_torch
class 		UpperCAmelCase__      (      __UpperCamelCase						,__UpperCamelCase						,unittest.TestCase       ):




			'''simple docstring'''






			UpperCamelCase      						=	(GLPNModel, GLPNForDepthEstimation) if is_torch_available() else ()
			UpperCamelCase      						=	(
			    {"""depth-estimation""": GLPNForDepthEstimation, """feature-extraction""": GLPNModel} if is_torch_available() else {}
			)

			UpperCamelCase      						=	False
			UpperCamelCase      						=	False
			UpperCamelCase      						=	False




			def 			snake_case__					(       self							:			str			):
					'''simple docstring'''





					__UpperCAmelCase   :					List[str]													=     GLPNModelTester(self			)
					__UpperCAmelCase   :					str													=     GLPNConfigTester(self	,	config_class=a_			)




			def 			snake_case__					(       self							:			int			):
					'''simple docstring'''





					self.config_tester.run_common_tests()




			def 			snake_case__					(       self							:			Tuple			):
					'''simple docstring'''





					__UpperCAmelCase   :					int													=     self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_model(*a_			)




			def 			snake_case__					(       self							:			Tuple			):
					'''simple docstring'''





					__UpperCAmelCase   :					Optional[Any]													=     self.model_tester.prepare_config_and_inputs()
					self.model_tester.create_and_check_for_depth_estimation(*a_			)




			@unittest.skip('''GLPN does not use inputs_embeds'''			)
			def 			snake_case__					(       self							:			List[Any]			):
					'''simple docstring'''





					pass




			@unittest.skip('''GLPN does not have get_input_embeddings method and get_output_embeddings methods'''			)
			def 			snake_case__					(       self							:			Optional[int]			):
					'''simple docstring'''





					pass




			def 			snake_case__					(       self							:			int			):
					'''simple docstring'''





					__UpperCAmelCase   :					Any													=     self.model_tester.prepare_config_and_inputs_for_common()

					for model_class in self.all_model_classes:
							__UpperCAmelCase   :					int													=     model_class(a_			)
							__UpperCAmelCase   :					Dict													=     inspect.signature(model.forward			)
							# signature.parameters is an OrderedDict => so arg_names order is deterministic
							__UpperCAmelCase   :					Union[str, Any]													=     [*signature.parameters.keys()]

							__UpperCAmelCase   :					Dict													=     ['''pixel_values''']
							self.assertListEqual(arg_names[:1]	,	a_			)




			def 			snake_case__					(       self							:			Tuple			):
					'''simple docstring'''





					__UpperCAmelCase   :					Optional[Any]													=     self.model_tester.prepare_config_and_inputs_for_common()
					__UpperCAmelCase   :					Any													=     True

					for model_class in self.all_model_classes:
							__UpperCAmelCase   :					Union[str, Any]													=     True
							__UpperCAmelCase   :					str													=     False
							__UpperCAmelCase   :					Tuple													=     True
							__UpperCAmelCase   :					Optional[int]													=     model_class(a_			)
							model.to(a_			)
							model.eval()
							with torch.no_grad():
									__UpperCAmelCase   :					int													=     model(**self._prepare_for_class(a_	,	a_			)			)
							__UpperCAmelCase   :					Tuple													=     outputs.attentions

							__UpperCAmelCase   :					Any													=     sum(self.model_tester.depths			)
							self.assertEqual(len(a_			)	,	a_			)

							# check that output_attentions also work using config
							del inputs_dict["output_attentions"]
							__UpperCAmelCase   :					Any													=     True
							__UpperCAmelCase   :					Union[str, Any]													=     model_class(a_			)
							model.to(a_			)
							model.eval()
							with torch.no_grad():
									__UpperCAmelCase   :					Any													=     model(**self._prepare_for_class(a_	,	a_			)			)
							__UpperCAmelCase   :					Optional[Any]													=     outputs.attentions

							self.assertEqual(len(a_			)	,	a_			)

							# verify the first attentions (first block, first layer)
							__UpperCAmelCase   :					Optional[Any]													=     (self.model_tester.image_size // 4) ** 2
							__UpperCAmelCase   :					Dict													=     (self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
							self.assertListEqual(
							    list(attentions[0].shape[-3:]			)	,	[self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len]	,	)

							# verify the last attentions (last block, last layer)
							__UpperCAmelCase   :					Union[str, Any]													=     (self.model_tester.image_size // 32) ** 2
							__UpperCAmelCase   :					List[str]													=     (self.model_tester.image_size // (32 * self.model_tester.sr_ratios[-1])) ** 2
							self.assertListEqual(
							    list(attentions[-1].shape[-3:]			)	,	[self.model_tester.num_attention_heads[-1], expected_seq_len, expected_reduced_seq_len]	,	)
							__UpperCAmelCase   :					List[str]													=     len(a_			)

							# Check attention is always last and order is fine
							__UpperCAmelCase   :					str													=     True
							__UpperCAmelCase   :					List[Any]													=     True
							__UpperCAmelCase   :					List[str]													=     model_class(a_			)
							model.to(a_			)
							model.eval()
							with torch.no_grad():
									__UpperCAmelCase   :					Optional[int]													=     model(**self._prepare_for_class(a_	,	a_			)			)

							self.assertEqual(out_len + 1	,	len(a_			)			)

							__UpperCAmelCase   :					Tuple													=     outputs.attentions

							self.assertEqual(len(a_			)	,	a_			)
							# verify the first attentions (first block, first layer)
							__UpperCAmelCase   :					Union[str, Any]													=     (self.model_tester.image_size // 4) ** 2
							__UpperCAmelCase   :					int													=     (self.model_tester.image_size // (4 * self.model_tester.sr_ratios[0])) ** 2
							self.assertListEqual(
							    list(self_attentions[0].shape[-3:]			)	,	[self.model_tester.num_attention_heads[0], expected_seq_len, expected_reduced_seq_len]	,	)




			def 			snake_case__					(       self							:			str			):
					'''simple docstring'''





					def check_hidden_states_output(a_							:			Optional[Any]	,	a_							:			Any	,	a_							:			int			):
							__UpperCAmelCase   :					Optional[int]													=     model_class(a_			)
							model.to(a_			)
							model.eval()

							with torch.no_grad():
									__UpperCAmelCase   :					int													=     model(**self._prepare_for_class(a_	,	a_			)			)

							__UpperCAmelCase   :					List[Any]													=     outputs.hidden_states

							__UpperCAmelCase   :					Union[str, Any]													=     self.model_tester.num_encoder_blocks
							self.assertEqual(len(a_			)	,	a_			)

							# verify the first hidden states (first block)
							self.assertListEqual(
							    list(hidden_states[0].shape[-3:]			)	,	[
							        self.model_tester.hidden_sizes[0],
							        self.model_tester.image_size // 4,
							        self.model_tester.image_size // 4,
							    ]	,	)

					__UpperCAmelCase   :					List[str]													=     self.model_tester.prepare_config_and_inputs_for_common()

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

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

							check_hidden_states_output(a_	,	a_	,	a_			)




			def 			snake_case__					(       self							:			Tuple			):
					'''simple docstring'''





					if not self.model_tester.is_training:
							return

					__UpperCAmelCase   :					int													=     self.model_tester.prepare_config_and_inputs_for_common()
					__UpperCAmelCase   :					Union[str, Any]													=     True

					for model_class in self.all_model_classes:
							if model_class in get_values(a_			):
									continue
							# TODO: remove the following 3 lines once we have a MODEL_FOR_DEPTH_ESTIMATION_MAPPING
							# this can then be incorporated into _prepare_for_class in test_modeling_common.py
							if model_class.__name__ == "GLPNForDepthEstimation":
									__UpperCAmelCase   :					Any													=     inputs_dict['''pixel_values'''].shape
									__UpperCAmelCase   :					Union[str, Any]													=     torch.zeros(
									    [self.model_tester.batch_size, height, width]	,	device=a_			).long()
							__UpperCAmelCase   :					Optional[Any]													=     model_class(a_			)
							model.to(a_			)
							model.train()
							__UpperCAmelCase   :					List[str]													=     self._prepare_for_class(a_	,	a_	,	return_labels=a_			)
							__UpperCAmelCase   :					Union[str, Any]													=     model(**a_			).loss
							loss.backward()




			@slow
			def 			snake_case__					(       self							:			Tuple			):
					'''simple docstring'''





					for model_name in GLPN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							__UpperCAmelCase   :					List[str]													=     GLPNModel.from_pretrained(a_			)
							self.assertIsNotNone(a_			)

def 	a						(				):







		'''simple docstring'''





		__UpperCAmelCase   :					Union[str, Any]													=     Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''						)
		return image

@require_torch
@require_vision
@slow
class 		UpperCAmelCase__      (      unittest.TestCase       ):




			'''simple docstring'''






			@slow
			def 			snake_case__					(       self							:			Union[str, Any]			):
					'''simple docstring'''





					__UpperCAmelCase   :					List[str]													=     GLPNImageProcessor.from_pretrained(GLPN_PRETRAINED_MODEL_ARCHIVE_LIST[0]			)
					__UpperCAmelCase   :					List[str]													=     GLPNForDepthEstimation.from_pretrained(GLPN_PRETRAINED_MODEL_ARCHIVE_LIST[0]			).to(a_			)

					__UpperCAmelCase   :					Tuple													=     prepare_img()
					__UpperCAmelCase   :					List[Any]													=     image_processor(images=a_	,	return_tensors='''pt'''			).to(a_			)

					# forward pass
					with torch.no_grad():
							__UpperCAmelCase   :					Union[str, Any]													=     model(**a_			)

					# verify the predicted depth
					__UpperCAmelCase   :					str													=     torch.Size([1, 4_80, 6_40]			)
					self.assertEqual(outputs.predicted_depth.shape	,	a_			)

					__UpperCAmelCase   :					Optional[int]													=     torch.tensor(
					    [[3.4_2_9_1, 2.7_8_6_5, 2.5_1_5_1], [3.2_8_4_1, 2.7_0_2_1, 2.3_5_0_2], [3.1_1_4_7, 2.4_6_2_5, 2.2_4_8_1]]			).to(a_			)

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










import unittest

from transformers import (
    MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
    TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
    PreTrainedTokenizer,
    is_vision_available,
)
from transformers.pipelines import ImageClassificationPipeline, pipeline
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_tf,
    require_torch,
    require_torch_or_tf,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
				from PIL import Image
else:

				class 		UpperCAmelCase__      :




							'''simple docstring'''






							@staticmethod
							def 			snake_case__					(       *a_							:			Union[str, Any]	,	**a_							:			Any			):
									'''simple docstring'''





									pass

@is_pipeline_test
@require_torch_or_tf
@require_vision
class 		UpperCAmelCase__      (      unittest.TestCase       ):




			'''simple docstring'''






			UpperCamelCase      						=	MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
			UpperCamelCase      						=	TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING




			def 			snake_case__					(       self							:			Any	,	a_							:			str	,	a_							:			Dict	,	a_							:			Dict			):
					'''simple docstring'''





					__UpperCAmelCase   :					Any													=     ImageClassificationPipeline(model=a_	,	image_processor=a_	,	top_k=2			)
					__UpperCAmelCase   :					int													=     [
					    Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''			),
					    '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					]
					return image_classifier, examples




			def 			snake_case__					(       self							:			str	,	a_							:			Optional[int]	,	a_							:			List[str]			):
					'''simple docstring'''





					__UpperCAmelCase   :					Tuple													=     image_classifier('''./tests/fixtures/tests_samples/COCO/000000039769.png'''			)

					self.assertEqual(
					    a_	,	[
					        {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					        {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					    ]	,	)

					import datasets

					__UpperCAmelCase   :					Optional[Any]													=     datasets.load_dataset('''hf-internal-testing/fixtures_image_utils'''	,	'''image'''	,	split='''test'''			)

					# Accepts URL + PIL.Image + lists
					__UpperCAmelCase   :					Any													=     image_classifier(
					    [
					        Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''			),
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					        # RGBA
					        dataset[0]['''file'''],
					        # LA
					        dataset[1]['''file'''],
					        # L
					        dataset[2]['''file'''],
					    ]			)
					self.assertEqual(
					    a_	,	[
					        [
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					        ],
					        [
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					        ],
					        [
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					        ],
					        [
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					        ],
					        [
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					            {'''score''': ANY(a_			), '''label''': ANY(a_			)},
					        ],
					    ]	,	)




			@require_torch
			def 			snake_case__					(       self							:			int			):
					'''simple docstring'''





					__UpperCAmelCase   :					Dict													=     '''hf-internal-testing/tiny-random-vit'''
					__UpperCAmelCase   :					Optional[int]													=     pipeline('''image-classification'''	,	model=a_			)

					__UpperCAmelCase   :					Optional[int]													=     image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''			)
					self.assertEqual(
					    nested_simplify(a_	,	decimals=4			)	,	[{'''label''': '''LABEL_1''', '''score''': 0.5_7_4}, {'''label''': '''LABEL_0''', '''score''': 0.4_2_6}]	,	)

					__UpperCAmelCase   :					Dict													=     image_classifier(
					    [
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					    ]	,	top_k=2	,	)
					self.assertEqual(
					    nested_simplify(a_	,	decimals=4			)	,	[
					        [{'''label''': '''LABEL_1''', '''score''': 0.5_7_4}, {'''label''': '''LABEL_0''', '''score''': 0.4_2_6}],
					        [{'''label''': '''LABEL_1''', '''score''': 0.5_7_4}, {'''label''': '''LABEL_0''', '''score''': 0.4_2_6}],
					    ]	,	)




			@require_tf
			def 			snake_case__					(       self							:			Optional[int]			):
					'''simple docstring'''





					__UpperCAmelCase   :					Tuple													=     '''hf-internal-testing/tiny-random-vit'''
					__UpperCAmelCase   :					Optional[Any]													=     pipeline('''image-classification'''	,	model=a_	,	framework='''tf'''			)

					__UpperCAmelCase   :					Optional[Any]													=     image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''			)
					self.assertEqual(
					    nested_simplify(a_	,	decimals=4			)	,	[{'''label''': '''LABEL_1''', '''score''': 0.5_7_4}, {'''label''': '''LABEL_0''', '''score''': 0.4_2_6}]	,	)

					__UpperCAmelCase   :					Any													=     image_classifier(
					    [
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					        '''http://images.cocodataset.org/val2017/000000039769.jpg''',
					    ]	,	top_k=2	,	)
					self.assertEqual(
					    nested_simplify(a_	,	decimals=4			)	,	[
					        [{'''label''': '''LABEL_1''', '''score''': 0.5_7_4}, {'''label''': '''LABEL_0''', '''score''': 0.4_2_6}],
					        [{'''label''': '''LABEL_1''', '''score''': 0.5_7_4}, {'''label''': '''LABEL_0''', '''score''': 0.4_2_6}],
					    ]	,	)




			def 			snake_case__					(       self							:			Optional[int]			):
					'''simple docstring'''





					__UpperCAmelCase   :					Union[str, Any]													=     PreTrainedTokenizer()

					# Assert that the pipeline can be initialized with a feature extractor that is not in any mapping
					__UpperCAmelCase   :					Dict													=     pipeline(
					    '''image-classification'''	,	model='''hf-internal-testing/tiny-random-vit'''	,	tokenizer=a_			)

					self.assertIs(image_classifier.tokenizer	,	a_			)




			@slow
			@require_torch
			def 			snake_case__					(       self							:			Optional[int]			):
					'''simple docstring'''





					__UpperCAmelCase   :					List[str]													=     pipeline('''image-classification'''	,	model='''deepmind/vision-perceiver-conv'''			)
					__UpperCAmelCase   :					List[Any]													=     image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''			)
					self.assertEqual(
					    nested_simplify(a_	,	decimals=4			)	,	[
					        {'''score''': 0.4_3_8_5, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.3_2_1, '''label''': '''tiger cat'''},
					        {'''score''': 0.0_5_0_2, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.0_1_3_7, '''label''': '''crib, cot'''},
					        {'''score''': 0.0_0_7, '''label''': '''radiator'''},
					    ]	,	)

					__UpperCAmelCase   :					List[str]													=     pipeline('''image-classification'''	,	model='''deepmind/vision-perceiver-fourier'''			)
					__UpperCAmelCase   :					List[Any]													=     image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''			)
					self.assertEqual(
					    nested_simplify(a_	,	decimals=4			)	,	[
					        {'''score''': 0.5_6_5_8, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.1_3_0_9, '''label''': '''tiger cat'''},
					        {'''score''': 0.0_7_2_2, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.0_7_0_7, '''label''': '''remote control, remote'''},
					        {'''score''': 0.0_0_8_2, '''label''': '''computer keyboard, keypad'''},
					    ]	,	)

					__UpperCAmelCase   :					List[str]													=     pipeline('''image-classification'''	,	model='''deepmind/vision-perceiver-learned'''			)
					__UpperCAmelCase   :					Union[str, Any]													=     image_classifier('''http://images.cocodataset.org/val2017/000000039769.jpg'''			)
					self.assertEqual(
					    nested_simplify(a_	,	decimals=4			)	,	[
					        {'''score''': 0.3_0_2_2, '''label''': '''tabby, tabby cat'''},
					        {'''score''': 0.2_3_6_2, '''label''': '''Egyptian cat'''},
					        {'''score''': 0.1_8_5_6, '''label''': '''tiger cat'''},
					        {'''score''': 0.0_3_2_4, '''label''': '''remote control, remote'''},
					        {'''score''': 0.0_0_9_6, '''label''': '''quilt, comforter, comfort, puff'''},
					    ]	,	)





