




'''simple docstring'''



import tempfile
import unittest

from transformers import DPRConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
 import torch

 from transformers import DPRContextEncoder, DPRQuestionEncoder, DPRReader, DPRReaderTokenizer
 from transformers.models.dpr.modeling_dpr import (
     DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
     DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
     DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
 )







class 	lowercase_					:


   """simple docstring"""

   def __init__(					self      :			Dict						,   __lowerCamelCase      :			Any						,   __lowerCamelCase      :			List[Any]=1_3						,   __lowerCamelCase      :			int=7						,   __lowerCamelCase      :			str=False						,   __lowerCamelCase      :			Any=True						,   __lowerCamelCase      :			List[str]=True						,   __lowerCamelCase      :			List[Any]=True						,   __lowerCamelCase      :			List[str]=9_9						,   __lowerCamelCase      :			Optional[int]=3_2						,   __lowerCamelCase      :			Dict=5						,   __lowerCamelCase      :			Union[str, Any]=4						,   __lowerCamelCase      :			Union[str, Any]=3_7						,   __lowerCamelCase      :			Union[str, Any]="gelu"						,   __lowerCamelCase      :			Tuple=0.1						,   __lowerCamelCase      :			Tuple=0.1						,   __lowerCamelCase      :			Tuple=5_1_2						,   __lowerCamelCase      :			List[str]=1_6						,   __lowerCamelCase      :			Any=2						,   __lowerCamelCase      :			List[Any]=0.0_2						,   __lowerCamelCase      :			Any=3						,   __lowerCamelCase      :			int=4						,   __lowerCamelCase      :			Optional[int]=None						,   __lowerCamelCase      :			int=0						,   ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   parent
      _SCREAMING_SNAKE_CASE =   batch_size
      _SCREAMING_SNAKE_CASE =   seq_length
      _SCREAMING_SNAKE_CASE =   is_training
      _SCREAMING_SNAKE_CASE =   use_input_mask
      _SCREAMING_SNAKE_CASE =   use_token_type_ids
      _SCREAMING_SNAKE_CASE =   use_labels
      _SCREAMING_SNAKE_CASE =   vocab_size
      _SCREAMING_SNAKE_CASE =   hidden_size
      _SCREAMING_SNAKE_CASE =   num_hidden_layers
      _SCREAMING_SNAKE_CASE =   num_attention_heads
      _SCREAMING_SNAKE_CASE =   intermediate_size
      _SCREAMING_SNAKE_CASE =   hidden_act
      _SCREAMING_SNAKE_CASE =   hidden_dropout_prob
      _SCREAMING_SNAKE_CASE =   attention_probs_dropout_prob
      _SCREAMING_SNAKE_CASE =   max_position_embeddings
      _SCREAMING_SNAKE_CASE =   type_vocab_size
      _SCREAMING_SNAKE_CASE =   type_sequence_label_size
      _SCREAMING_SNAKE_CASE =   initializer_range
      _SCREAMING_SNAKE_CASE =   num_labels
      _SCREAMING_SNAKE_CASE =   num_choices
      _SCREAMING_SNAKE_CASE =   scope
      _SCREAMING_SNAKE_CASE =   projection_dim



   def 							lowerCAmelCase_    (					self      :			Optional[int]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   ids_tensor([self.batch_size, self.seq_length]						,   self.vocab_size					)

      _SCREAMING_SNAKE_CASE =   None
      if self.use_input_mask:
         _SCREAMING_SNAKE_CASE =   random_attention_mask([self.batch_size, self.seq_length]					)

      _SCREAMING_SNAKE_CASE =   None
      if self.use_token_type_ids:
         _SCREAMING_SNAKE_CASE =   ids_tensor([self.batch_size, self.seq_length]						,   self.type_vocab_size					)

      _SCREAMING_SNAKE_CASE =   None
      _SCREAMING_SNAKE_CASE =   None
      _SCREAMING_SNAKE_CASE =   None
      if self.use_labels:
         _SCREAMING_SNAKE_CASE =   ids_tensor([self.batch_size]						,   self.type_sequence_label_size					)
         _SCREAMING_SNAKE_CASE =   ids_tensor([self.batch_size, self.seq_length]						,   self.num_labels					)
         _SCREAMING_SNAKE_CASE =   ids_tensor([self.batch_size]						,   self.num_choices					)

      _SCREAMING_SNAKE_CASE =   self.get_config()

      return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels



   def 							lowerCAmelCase_    (					self      :			Any					):

      """simple docstring"""
      return DPRConfig(
          projection_dim=self.projection_dim						,   vocab_size=self.vocab_size						,   hidden_size=self.hidden_size						,   num_hidden_layers=self.num_hidden_layers						,   num_attention_heads=self.num_attention_heads						,   intermediate_size=self.intermediate_size						,   hidden_act=self.hidden_act						,   hidden_dropout_prob=self.hidden_dropout_prob						,   attention_probs_dropout_prob=self.attention_probs_dropout_prob						,   max_position_embeddings=self.max_position_embeddings						,   type_vocab_size=self.type_vocab_size						,   initializer_range=self.initializer_range						,   )



   def 							lowerCAmelCase_    (					self      :			Optional[int]						,   __lowerCamelCase      :			Tuple						,   __lowerCamelCase      :			Union[str, Any]						,   __lowerCamelCase      :			Tuple						,   __lowerCamelCase      :			Tuple						,   __lowerCamelCase      :			int						,   __lowerCamelCase      :			List[str]						,   __lowerCamelCase      :			Optional[int]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   DPRContextEncoder(config=__lowerCamelCase					)
      model.to(__lowerCamelCase					)
      model.eval()
      _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase						,   attention_mask=__lowerCamelCase						,   token_type_ids=__lowerCamelCase					)
      _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase						,   token_type_ids=__lowerCamelCase					)
      _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase					)
      self.parent.assertEqual(result.pooler_output.shape						,   (self.batch_size, self.projection_dim or self.hidden_size)					)



   def 							lowerCAmelCase_    (					self      :			Any						,   __lowerCamelCase      :			Optional[Any]						,   __lowerCamelCase      :			Optional[Any]						,   __lowerCamelCase      :			int						,   __lowerCamelCase      :			Optional[Any]						,   __lowerCamelCase      :			Optional[int]						,   __lowerCamelCase      :			Union[str, Any]						,   __lowerCamelCase      :			Tuple					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   DPRQuestionEncoder(config=__lowerCamelCase					)
      model.to(__lowerCamelCase					)
      model.eval()
      _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase						,   attention_mask=__lowerCamelCase						,   token_type_ids=__lowerCamelCase					)
      _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase						,   token_type_ids=__lowerCamelCase					)
      _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase					)
      self.parent.assertEqual(result.pooler_output.shape						,   (self.batch_size, self.projection_dim or self.hidden_size)					)



   def 							lowerCAmelCase_    (					self      :			Any						,   __lowerCamelCase      :			str						,   __lowerCamelCase      :			Tuple						,   __lowerCamelCase      :			Any						,   __lowerCamelCase      :			Optional[int]						,   __lowerCamelCase      :			Dict						,   __lowerCamelCase      :			Tuple						,   __lowerCamelCase      :			Optional[int]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   DPRReader(config=__lowerCamelCase					)
      model.to(__lowerCamelCase					)
      model.eval()
      _SCREAMING_SNAKE_CASE =   model(
          __lowerCamelCase						,   attention_mask=__lowerCamelCase						,   )

      self.parent.assertEqual(result.start_logits.shape						,   (self.batch_size, self.seq_length)					)
      self.parent.assertEqual(result.end_logits.shape						,   (self.batch_size, self.seq_length)					)
      self.parent.assertEqual(result.relevance_logits.shape						,   (self.batch_size,)					)



   def 							lowerCAmelCase_    (					self      :			str					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   self.prepare_config_and_inputs()
      (
          (
          _SCREAMING_SNAKE_CASE
      ), (
          _SCREAMING_SNAKE_CASE
      ), (
          _SCREAMING_SNAKE_CASE
      ), (
          _SCREAMING_SNAKE_CASE
      ), (
          _SCREAMING_SNAKE_CASE
      ), (
          _SCREAMING_SNAKE_CASE
      ), (
          _SCREAMING_SNAKE_CASE
      ), 
      ) =   config_and_inputs
      _SCREAMING_SNAKE_CASE =   {"input_ids": input_ids}
      return config, inputs_dict







@require_torch
class 	lowercase_					(				A  ,						A  ,						unittest.TestCase     ):


   """simple docstring"""

   lowerCamelCase_       						=		(
       (
           DPRContextEncoder,
           DPRQuestionEncoder,
           DPRReader,
       )
       if is_torch_available()
       else ()
   )
   lowerCamelCase_       						=		{'''feature-extraction''': DPRQuestionEncoder} if is_torch_available() else {}

   lowerCamelCase_       						=		False
   lowerCamelCase_       						=		False  # why?
   lowerCamelCase_       						=		False
   lowerCamelCase_       						=		False



   def 							lowerCAmelCase_    (					self      :			Dict					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   DPRModelTester(self					)
      _SCREAMING_SNAKE_CASE =   ConfigTester(self						,   config_class=__lowerCamelCase						,   hidden_size=3_7					)



   def 							lowerCAmelCase_    (					self      :			Union[str, Any]					):

      """simple docstring"""
      self.config_tester.run_common_tests()



   def 							lowerCAmelCase_    (					self      :			Any					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_context_encoder(*__lowerCamelCase					)



   def 							lowerCAmelCase_    (					self      :			Union[str, Any]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_question_encoder(*__lowerCamelCase					)



   def 							lowerCAmelCase_    (					self      :			Tuple					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_reader(*__lowerCamelCase					)



   def 							lowerCAmelCase_    (					self      :			int					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   self.model_tester.prepare_config_and_inputs()[0]

      _SCREAMING_SNAKE_CASE =   DPRQuestionEncoder(config=__lowerCamelCase					)
      model.to(__lowerCamelCase					)
      model.eval()

      with tempfile.TemporaryDirectory() as tmp_dirname:
         model.save_pretrained(__lowerCamelCase					)
         _SCREAMING_SNAKE_CASE =   DPRQuestionEncoder.from_pretrained(__lowerCamelCase						,   projection_dim=5_1_2					)

      self.assertIsNotNone(__lowerCamelCase					)



   @slow
   def 							lowerCAmelCase_    (					self      :			Optional[Any]					):

      """simple docstring"""
      for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         _SCREAMING_SNAKE_CASE =   DPRContextEncoder.from_pretrained(__lowerCamelCase					)
         self.assertIsNotNone(__lowerCamelCase					)

      for model_name in DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         _SCREAMING_SNAKE_CASE =   DPRContextEncoder.from_pretrained(__lowerCamelCase					)
         self.assertIsNotNone(__lowerCamelCase					)

      for model_name in DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         _SCREAMING_SNAKE_CASE =   DPRQuestionEncoder.from_pretrained(__lowerCamelCase					)
         self.assertIsNotNone(__lowerCamelCase					)

      for model_name in DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
         _SCREAMING_SNAKE_CASE =   DPRReader.from_pretrained(__lowerCamelCase					)
         self.assertIsNotNone(__lowerCamelCase					)







@require_torch
class 	lowercase_					(				unittest.TestCase     ):


   """simple docstring"""

   @slow
   def 							lowerCAmelCase_    (					self      :			Optional[int]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   DPRQuestionEncoder.from_pretrained("facebook/dpr-question_encoder-single-nq-base"						,   return_dict=__lowerCamelCase					)
      model.to(__lowerCamelCase					)

      _SCREAMING_SNAKE_CASE =   torch.tensor(
          [[1_0_1, 7_5_9_2, 1_0_1_0, 2_0_0_3, 2_0_2_6, 3_8_9_9, 1_0_1_4_0, 1_0_2_9, 1_0_2]]						,   dtype=torch.long						,   device=__lowerCamelCase					)  # [CLS] hello, is my dog cute? [SEP]
      _SCREAMING_SNAKE_CASE =   model(__lowerCamelCase					)[0]  # embedding shape = (1, 768)
      # compare the actual values for a slice.
      _SCREAMING_SNAKE_CASE =   torch.tensor(
          [
              [
                  0.0_3_2_3_6_2_5_3,
                  0.1_2_7_5_3_3_3_5,
                  0.1_6_8_1_8_5_0_9,
                  0.0_0_2_7_9_7_8_6,
                  0.3_8_9_6_9_3_3,
                  0.2_4_2_6_4_9_4_5,
                  0.2_1_7_8_9_7_1,
                  -0.0_2_3_3_5_2_2_7,
                  -0.0_8_4_8_1_9_5_9,
                  -0.1_4_3_2_4_1_1_7,
              ]
          ]						,   dtype=torch.float						,   device=__lowerCamelCase						,   )
      self.assertTrue(torch.allclose(output[:, :1_0]						,   __lowerCamelCase						,   atol=1e-4					)					)



   @slow
   def 							lowerCAmelCase_    (					self      :			Union[str, Any]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   DPRReaderTokenizer.from_pretrained("facebook/dpr-reader-single-nq-base"					)
      _SCREAMING_SNAKE_CASE =   DPRReader.from_pretrained("facebook/dpr-reader-single-nq-base"					)
      model.to(__lowerCamelCase					)

      _SCREAMING_SNAKE_CASE =   tokenizer(
          questions="What is love ?"						,   titles="Haddaway"						,   texts="What Is Love is a song recorded by the artist Haddaway"						,   padding=__lowerCamelCase						,   return_tensors="pt"						,   )
      encoded_inputs.to(__lowerCamelCase					)

      _SCREAMING_SNAKE_CASE =   model(**__lowerCamelCase					)

      # compare the actual values for a slice.
      _SCREAMING_SNAKE_CASE =   torch.tensor(
          [[-1_0.3_0_0_5, -1_0.7_7_6_5, -1_1.4_8_7_2, -1_1.6_8_4_1, -1_1.9_3_1_2, -1_0.3_0_0_2, -9.8_5_4_4, -1_1.7_3_7_8, -1_2.0_8_2_1, -1_0.2_9_7_5]]						,   dtype=torch.float						,   device=__lowerCamelCase						,   )

      _SCREAMING_SNAKE_CASE =   torch.tensor(
          [[-1_1.0_6_8_4, -1_1.7_0_4_1, -1_1.5_3_9_7, -1_0.3_4_6_5, -1_0.8_7_9_1, -6.8_4_4_3, -1_1.9_9_5_9, -1_1.0_3_6_4, -1_0.0_0_9_6, -6.8_4_0_5]]						,   dtype=torch.float						,   device=__lowerCamelCase						,   )
      self.assertTrue(torch.allclose(outputs.start_logits[:, :1_0]						,   __lowerCamelCase						,   atol=1e-4					)					)
      self.assertTrue(torch.allclose(outputs.end_logits[:, :1_0]						,   __lowerCamelCase						,   atol=1e-4					)					)







'''simple docstring'''



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


    """simple docstring"""

    @staticmethod
    def 							lowerCAmelCase_    (					*__lowerCamelCase      :			Union[str, Any]						,   **__lowerCamelCase      :			str					):

       """simple docstring"""
       pass







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


   """simple docstring"""

   lowerCamelCase_       						=		MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
   lowerCamelCase_       						=		TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING



   def 							lowerCAmelCase_    (					self      :			Any						,   __lowerCamelCase      :			Tuple						,   __lowerCamelCase      :			Dict						,   __lowerCamelCase      :			Optional[Any]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   ImageClassificationPipeline(model=__lowerCamelCase						,   image_processor=__lowerCamelCase						,   top_k=2					)
      _SCREAMING_SNAKE_CASE =   [
          Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"					),
          "http://images.cocodataset.org/val2017/000000039769.jpg",
      ]
      return image_classifier, examples



   def 							lowerCAmelCase_    (					self      :			Any						,   __lowerCamelCase      :			Optional[Any]						,   __lowerCamelCase      :			Tuple					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   image_classifier("./tests/fixtures/tests_samples/COCO/000000039769.png"					)

      self.assertEqual(
          __lowerCamelCase						,   [
              {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
              {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
          ]						,   )

      import datasets

      _SCREAMING_SNAKE_CASE =   datasets.load_dataset("hf-internal-testing/fixtures_image_utils"						,   "image"						,   split="test"					)

      # Accepts URL + PIL.Image + lists
      _SCREAMING_SNAKE_CASE =   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(
          __lowerCamelCase						,   [
              [
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
              ],
              [
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
              ],
              [
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
              ],
              [
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
              ],
              [
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
                  {"score": ANY(__lowerCamelCase					), "label": ANY(__lowerCamelCase					)},
              ],
          ]						,   )



   @require_torch
   def 							lowerCAmelCase_    (					self      :			Dict					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   "hf-internal-testing/tiny-random-vit"
      _SCREAMING_SNAKE_CASE =   pipeline("image-classification"						,   model=__lowerCamelCase					)

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

      _SCREAMING_SNAKE_CASE =   image_classifier(
          [
              "http://images.cocodataset.org/val2017/000000039769.jpg",
              "http://images.cocodataset.org/val2017/000000039769.jpg",
          ]						,   top_k=2						,   )
      self.assertEqual(
          nested_simplify(__lowerCamelCase						,   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 							lowerCAmelCase_    (					self      :			Optional[Any]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   "hf-internal-testing/tiny-random-vit"
      _SCREAMING_SNAKE_CASE =   pipeline("image-classification"						,   model=__lowerCamelCase						,   framework="tf"					)

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

      _SCREAMING_SNAKE_CASE =   image_classifier(
          [
              "http://images.cocodataset.org/val2017/000000039769.jpg",
              "http://images.cocodataset.org/val2017/000000039769.jpg",
          ]						,   top_k=2						,   )
      self.assertEqual(
          nested_simplify(__lowerCamelCase						,   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 							lowerCAmelCase_    (					self      :			Any					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   PreTrainedTokenizer()

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

      self.assertIs(image_classifier.tokenizer						,   __lowerCamelCase					)



   @slow
   @require_torch
   def 							lowerCAmelCase_    (					self      :			List[str]					):

      """simple docstring"""
      # Perceiver is not tested by `run_pipeline_test` properly.
      # That is because the type of feature_extractor and model preprocessor need to be kept
      # in sync, which is not the case in the current design
      _SCREAMING_SNAKE_CASE =   pipeline("image-classification"						,   model="deepmind/vision-perceiver-conv"					)
      _SCREAMING_SNAKE_CASE =   image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg"					)
      self.assertEqual(
          nested_simplify(__lowerCamelCase						,   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"},
          ]						,   )

      _SCREAMING_SNAKE_CASE =   pipeline("image-classification"						,   model="deepmind/vision-perceiver-fourier"					)
      _SCREAMING_SNAKE_CASE =   image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg"					)
      self.assertEqual(
          nested_simplify(__lowerCamelCase						,   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"},
          ]						,   )

      _SCREAMING_SNAKE_CASE =   pipeline("image-classification"						,   model="deepmind/vision-perceiver-learned"					)
      _SCREAMING_SNAKE_CASE =   image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg"					)
      self.assertEqual(
          nested_simplify(__lowerCamelCase						,   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"},
          ]						,   )

