




'''simple docstring'''



import os
import pickle
import tempfile
import unittest
from typing import Callable, Optional

import numpy as np

from transformers import (
    BatchEncoding,
    BertTokenizer,
    BertTokenizerFast,
    PreTrainedTokenizer,
    PreTrainedTokenizerFast,
    TensorType,
    TokenSpan,
    is_tokenizers_available,
)
from transformers.models.gpta.tokenization_gpta import GPTaTokenizer
from transformers.testing_utils import CaptureStderr, require_flax, require_tf, require_tokenizers, require_torch, slow


if is_tokenizers_available():
 from tokenizers import Tokenizer
 from tokenizers.models import WordPiece







class 	lowercase_					(				unittest.TestCase     ):


   """simple docstring"""

   def 							lowerCAmelCase_    (					self      :			Dict						,   __lowerCamelCase      :			str					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   list(tokenizer_class.max_model_input_sizes.keys()					)
      for model_name in sa_models[:1]:
         _SCREAMING_SNAKE_CASE =   tokenizer_class.from_pretrained(__lowerCamelCase					)
         self.assertIsNotNone(__lowerCamelCase					)
         self.assertIsInstance(__lowerCamelCase						,   __lowerCamelCase					)
         self.assertIsInstance(__lowerCamelCase						,   __lowerCamelCase					)

         for special_tok in tokenizer.all_special_tokens:
            self.assertIsInstance(__lowerCamelCase						,   __lowerCamelCase					)
            _SCREAMING_SNAKE_CASE =   tokenizer.convert_tokens_to_ids(__lowerCamelCase					)
            self.assertIsInstance(__lowerCamelCase						,   __lowerCamelCase					)



   def 							lowerCAmelCase_    (					self      :			List[Any]						,   __lowerCamelCase      :			BatchEncoding						,   __lowerCamelCase      :			Optional[Callable] = None					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   pickle.dumps(__lowerCamelCase					)
      self.assertIsNotNone(__lowerCamelCase					)

      _SCREAMING_SNAKE_CASE =   pickle.loads(__lowerCamelCase					)

      # Ensure is_fast is correctly restored
      self.assertEqual(be_restored.is_fast						,   be_original.is_fast					)

      # Ensure encodings are potentially correctly restored
      if be_original.is_fast:
         self.assertIsNotNone(be_restored.encodings					)
      else:
         self.assertIsNone(be_restored.encodings					)

      # Ensure the keys are the same
      for original_v, restored_v in zip(be_original.values()						,   be_restored.values()					):
         if equal_op:
            self.assertTrue(equal_op(__lowerCamelCase						,   __lowerCamelCase					)					)
         else:
            self.assertEqual(__lowerCamelCase						,   __lowerCamelCase					)



   @slow
   def 							lowerCAmelCase_    (					self      :			Any					):

      """simple docstring"""
      self.check_tokenizer_from_pretrained(__lowerCamelCase					)



   def 							lowerCAmelCase_    (					self      :			Optional[int]					):

      """simple docstring"""
      self.assertEqual(TensorType("tf"					)						,   TensorType.TENSORFLOW					)
      self.assertEqual(TensorType("pt"					)						,   TensorType.PYTORCH					)
      self.assertEqual(TensorType("np"					)						,   TensorType.NUMPY					)



   @require_tokenizers
   def 							lowerCAmelCase_    (					self      :			Any					):

      """simple docstring"""
      import numpy as np

      _SCREAMING_SNAKE_CASE =   BertTokenizer.from_pretrained("bert-base-cased"					)
      _SCREAMING_SNAKE_CASE =   BertTokenizerFast.from_pretrained("bert-base-cased"					)

      # Python no tensor
      with self.subTest("BatchEncoding (Python, return_tensors=None)"					):
         self.assert_dump_and_restore(tokenizer_p("Small example to encode"					)					)

      with self.subTest("BatchEncoding (Python, return_tensors=NUMPY)"					):
         self.assert_dump_and_restore(
             tokenizer_p("Small example to encode"						,   return_tensors=TensorType.NUMPY					)						,   np.array_equal					)

      with self.subTest("BatchEncoding (Rust, return_tensors=None)"					):
         self.assert_dump_and_restore(tokenizer_r("Small example to encode"					)					)

      with self.subTest("BatchEncoding (Rust, return_tensors=NUMPY)"					):
         self.assert_dump_and_restore(
             tokenizer_r("Small example to encode"						,   return_tensors=TensorType.NUMPY					)						,   np.array_equal					)



   @require_tf
   @require_tokenizers
   def 							lowerCAmelCase_    (					self      :			Dict					):

      """simple docstring"""
      import tensorflow as tf

      def tf_array_equals(__lowerCamelCase      :			List[Any]						,   __lowerCamelCase      :			List[Any]					):
         return tf.reduce_all(tf.equal(__lowerCamelCase						,   __lowerCamelCase					)					)

      _SCREAMING_SNAKE_CASE =   BertTokenizer.from_pretrained("bert-base-cased"					)
      _SCREAMING_SNAKE_CASE =   BertTokenizerFast.from_pretrained("bert-base-cased"					)

      with self.subTest("BatchEncoding (Python, return_tensors=TENSORFLOW)"					):
         self.assert_dump_and_restore(
             tokenizer_p("Small example to encode"						,   return_tensors=TensorType.TENSORFLOW					)						,   __lowerCamelCase					)

      with self.subTest("BatchEncoding (Rust, return_tensors=TENSORFLOW)"					):
         self.assert_dump_and_restore(
             tokenizer_r("Small example to encode"						,   return_tensors=TensorType.TENSORFLOW					)						,   __lowerCamelCase					)



   @require_torch
   @require_tokenizers
   def 							lowerCAmelCase_    (					self      :			Optional[Any]					):

      """simple docstring"""
      import torch

      _SCREAMING_SNAKE_CASE =   BertTokenizer.from_pretrained("bert-base-cased"					)
      _SCREAMING_SNAKE_CASE =   BertTokenizerFast.from_pretrained("bert-base-cased"					)

      with self.subTest("BatchEncoding (Python, return_tensors=PYTORCH)"					):
         self.assert_dump_and_restore(
             tokenizer_p("Small example to encode"						,   return_tensors=TensorType.PYTORCH					)						,   torch.equal					)

      with self.subTest("BatchEncoding (Rust, return_tensors=PYTORCH)"					):
         self.assert_dump_and_restore(
             tokenizer_r("Small example to encode"						,   return_tensors=TensorType.PYTORCH					)						,   torch.equal					)



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

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   BertTokenizer.from_pretrained("bert-base-cased"					)
      _SCREAMING_SNAKE_CASE =   BertTokenizerFast.from_pretrained("bert-base-cased"					)

      with self.subTest("Python Tokenizer"					):
         self.assertFalse(tokenizer_p("Small example to_encode"					).is_fast					)

      with self.subTest("Rust Tokenizer"					):
         self.assertTrue(tokenizer_r("Small example to_encode"					).is_fast					)



   @require_tokenizers
   def 							lowerCAmelCase_    (					self      :			Any					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   BertTokenizerFast.from_pretrained("bert-base-cased"					)
      _SCREAMING_SNAKE_CASE =   tokenizer_r(["Test", "\xad", "test"]						,   is_split_into_words=__lowerCamelCase					)

      self.assertEqual(encoded.word_to_tokens(0					)						,   TokenSpan(start=1						,   end=2					)					)
      self.assertEqual(encoded.word_to_tokens(1					)						,   __lowerCamelCase					)
      self.assertEqual(encoded.word_to_tokens(2					)						,   TokenSpan(start=2						,   end=3					)					)



   def 							lowerCAmelCase_    (					self      :			List[str]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   BatchEncoding({"inputs": [[1, 2, 3], [4, 5, 6]], "labels": [0, 1]}					)
      _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="np"					)
      self.assertEqual(tensor_batch["inputs"].shape						,   (2, 3)					)
      self.assertEqual(tensor_batch["labels"].shape						,   (2,)					)
      # test converting the converted
      with CaptureStderr() as cs:
         _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="np"					)
      self.assertFalse(len(cs.err					)						,   msg=F"""should have no warning, but got {cs.err}"""					)

      _SCREAMING_SNAKE_CASE =   BatchEncoding({"inputs": [1, 2, 3], "labels": 0}					)
      _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="np"						,   prepend_batch_axis=__lowerCamelCase					)
      self.assertEqual(tensor_batch["inputs"].shape						,   (1, 3)					)
      self.assertEqual(tensor_batch["labels"].shape						,   (1,)					)



   @require_torch
   def 							lowerCAmelCase_    (					self      :			List[Any]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   BatchEncoding({"inputs": [[1, 2, 3], [4, 5, 6]], "labels": [0, 1]}					)
      _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="pt"					)
      self.assertEqual(tensor_batch["inputs"].shape						,   (2, 3)					)
      self.assertEqual(tensor_batch["labels"].shape						,   (2,)					)
      # test converting the converted
      with CaptureStderr() as cs:
         _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="pt"					)
      self.assertFalse(len(cs.err					)						,   msg=F"""should have no warning, but got {cs.err}"""					)

      _SCREAMING_SNAKE_CASE =   BatchEncoding({"inputs": [1, 2, 3], "labels": 0}					)
      _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="pt"						,   prepend_batch_axis=__lowerCamelCase					)
      self.assertEqual(tensor_batch["inputs"].shape						,   (1, 3)					)
      self.assertEqual(tensor_batch["labels"].shape						,   (1,)					)



   @require_tf
   def 							lowerCAmelCase_    (					self      :			int					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   BatchEncoding({"inputs": [[1, 2, 3], [4, 5, 6]], "labels": [0, 1]}					)
      _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="tf"					)
      self.assertEqual(tensor_batch["inputs"].shape						,   (2, 3)					)
      self.assertEqual(tensor_batch["labels"].shape						,   (2,)					)
      # test converting the converted
      with CaptureStderr() as cs:
         _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="tf"					)
      self.assertFalse(len(cs.err					)						,   msg=F"""should have no warning, but got {cs.err}"""					)

      _SCREAMING_SNAKE_CASE =   BatchEncoding({"inputs": [1, 2, 3], "labels": 0}					)
      _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="tf"						,   prepend_batch_axis=__lowerCamelCase					)
      self.assertEqual(tensor_batch["inputs"].shape						,   (1, 3)					)
      self.assertEqual(tensor_batch["labels"].shape						,   (1,)					)



   @require_flax
   def 							lowerCAmelCase_    (					self      :			Tuple					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   BatchEncoding({"inputs": [[1, 2, 3], [4, 5, 6]], "labels": [0, 1]}					)
      _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="jax"					)
      self.assertEqual(tensor_batch["inputs"].shape						,   (2, 3)					)
      self.assertEqual(tensor_batch["labels"].shape						,   (2,)					)
      # test converting the converted
      with CaptureStderr() as cs:
         _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="jax"					)
      self.assertFalse(len(cs.err					)						,   msg=F"""should have no warning, but got {cs.err}"""					)

      _SCREAMING_SNAKE_CASE =   BatchEncoding({"inputs": [1, 2, 3], "labels": 0}					)
      _SCREAMING_SNAKE_CASE =   batch.convert_to_tensors(tensor_type="jax"						,   prepend_batch_axis=__lowerCamelCase					)
      self.assertEqual(tensor_batch["inputs"].shape						,   (1, 3)					)
      self.assertEqual(tensor_batch["labels"].shape						,   (1,)					)



   def 							lowerCAmelCase_    (					self      :			List[str]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   [{"input_ids": np.array([0, 1, 2]					)}, {"input_ids": np.array([0, 1, 2, 3]					)}]
      _SCREAMING_SNAKE_CASE =   BertTokenizer.from_pretrained("bert-base-cased"					)

      _SCREAMING_SNAKE_CASE =   tokenizer.pad(__lowerCamelCase						,   padding=__lowerCamelCase					)
      self.assertTrue(isinstance(batch["input_ids"]						,   np.ndarray					)					)
      self.assertEqual(batch["input_ids"].tolist()						,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]					)
      _SCREAMING_SNAKE_CASE =   tokenizer.pad(__lowerCamelCase						,   padding=__lowerCamelCase						,   return_tensors="np"					)
      self.assertTrue(isinstance(batch["input_ids"]						,   np.ndarray					)					)
      self.assertEqual(batch["input_ids"].tolist()						,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]					)



   @require_torch
   def 							lowerCAmelCase_    (					self      :			str					):

      """simple docstring"""
      import torch

      _SCREAMING_SNAKE_CASE =   [{"input_ids": torch.tensor([0, 1, 2]					)}, {"input_ids": torch.tensor([0, 1, 2, 3]					)}]
      _SCREAMING_SNAKE_CASE =   BertTokenizer.from_pretrained("bert-base-cased"					)

      _SCREAMING_SNAKE_CASE =   tokenizer.pad(__lowerCamelCase						,   padding=__lowerCamelCase					)
      self.assertTrue(isinstance(batch["input_ids"]						,   torch.Tensor					)					)
      self.assertEqual(batch["input_ids"].tolist()						,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]					)
      _SCREAMING_SNAKE_CASE =   tokenizer.pad(__lowerCamelCase						,   padding=__lowerCamelCase						,   return_tensors="pt"					)
      self.assertTrue(isinstance(batch["input_ids"]						,   torch.Tensor					)					)
      self.assertEqual(batch["input_ids"].tolist()						,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]					)



   @require_tf
   def 							lowerCAmelCase_    (					self      :			int					):

      """simple docstring"""
      import tensorflow as tf

      _SCREAMING_SNAKE_CASE =   [{"input_ids": tf.constant([0, 1, 2]					)}, {"input_ids": tf.constant([0, 1, 2, 3]					)}]
      _SCREAMING_SNAKE_CASE =   BertTokenizer.from_pretrained("bert-base-cased"					)

      _SCREAMING_SNAKE_CASE =   tokenizer.pad(__lowerCamelCase						,   padding=__lowerCamelCase					)
      self.assertTrue(isinstance(batch["input_ids"]						,   tf.Tensor					)					)
      self.assertEqual(batch["input_ids"].numpy().tolist()						,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]					)
      _SCREAMING_SNAKE_CASE =   tokenizer.pad(__lowerCamelCase						,   padding=__lowerCamelCase						,   return_tensors="tf"					)
      self.assertTrue(isinstance(batch["input_ids"]						,   tf.Tensor					)					)
      self.assertEqual(batch["input_ids"].numpy().tolist()						,   [[0, 1, 2, tokenizer.pad_token_id], [0, 1, 2, 3]]					)



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

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   Tokenizer(WordPiece(unk_token="[UNK]"					)					)
      PreTrainedTokenizerFast(tokenizer_object=__lowerCamelCase					)



   @require_tokenizers
   def 							lowerCAmelCase_    (					self      :			List[str]					):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE =   Tokenizer(WordPiece(unk_token="[UNK]"					)					)
      with tempfile.TemporaryDirectory() as tmpdirname:
         bert_tokenizer.save(os.path.join(__lowerCamelCase						,   "tokenizer.json"					)					)
         PreTrainedTokenizerFast(tokenizer_file=os.path.join(__lowerCamelCase						,   "tokenizer.json"					)					)







'''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"},
          ]						,   )

