

import unittest

import numpy as np

from transformers import is_flax_available
from transformers.testing_utils import require_flax

from ..test_modeling_flax_common import ids_tensor


if is_flax_available():
    import jax
    import jax.numpy as jnp

    from transformers.generation import (
        FlaxForcedBOSTokenLogitsProcessor,
        FlaxForcedEOSTokenLogitsProcessor,
        FlaxLogitsProcessorList,
        FlaxMinLengthLogitsProcessor,
        FlaxTemperatureLogitsWarper,
        FlaxTopKLogitsWarper,
        FlaxTopPLogitsWarper,
    )

@require_flax
class     __snake_case    (				unittest.TestCase  ):
       """simple docstring"""







       def 			a		(		self      , _UpperCamelCase      , _UpperCamelCase   )      ->							Union[str, Any]:






              """simple docstring"""


              __snake_case       	=							jnp.ones((batch_size, length)   ) / length
              return scores


       def 			a		(		self   )      ->							List[str]:






              """simple docstring"""


              __snake_case       	=							None
              __snake_case       	=							20

              __snake_case       	=							self._get_uniform_logits(batch_size=2      , length=_UpperCamelCase   )

              # tweak scores to not be uniform anymore
              __snake_case       	=							scores.at[1, 5].set((1 / length) + 0.1   )  # peak, 1st batch
              __snake_case       	=							scores.at[1, 10].set((1 / length) - 0.4   )  # valley, 1st batch

              # compute softmax
              __snake_case       	=							jax.nn.softmax(_UpperCamelCase      , axis=-1   )

              __snake_case       	=							FlaxTemperatureLogitsWarper(temperature=0.5   )
              __snake_case       	=							FlaxTemperatureLogitsWarper(temperature=1.3   )

              __snake_case       	=							jax.nn.softmax(temp_dist_warper_sharper(_UpperCamelCase      , scores.copy()      , cur_len=_UpperCamelCase   )      , axis=-1   )
              __snake_case       	=							jax.nn.softmax(temp_dist_warper_smoother(_UpperCamelCase      , scores.copy()      , cur_len=_UpperCamelCase   )      , axis=-1   )

              # uniform distribution stays uniform
              self.assertTrue(jnp.allclose(probs[0, :]      , warped_prob_sharp[0, :]      , atol=1E-3   )   )
              self.assertTrue(jnp.allclose(probs[0, :]      , warped_prob_smooth[0, :]      , atol=1E-3   )   )

              # sharp peaks get higher, valleys get lower
              self.assertLess(probs[1, :].max()      , warped_prob_sharp[1, :].max()   )
              self.assertGreater(probs[1, :].min()      , warped_prob_sharp[1, :].min()   )

              # smooth peaks get lower, valleys get higher
              self.assertGreater(probs[1, :].max()      , warped_prob_smooth[1, :].max()   )
              self.assertLess(probs[1, :].min()      , warped_prob_smooth[1, :].min()   )


       def 			a		(		self   )      ->							str:






              """simple docstring"""


              __snake_case       	=							None
              __snake_case       	=							10
              __snake_case       	=							2

              # create ramp distribution
              __snake_case       	=							np.broadcast_to(np.arange(_UpperCamelCase   )[None, :]      , (batch_size, vocab_size)   ).copy()
              __snake_case       	=							ramp_logits[1:, : vocab_size // 2] + vocab_size

              __snake_case       	=							FlaxTopKLogitsWarper(3   )

              __snake_case       	=							top_k_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )

              # check that correct tokens are filtered
              self.assertListEqual(jnp.isinf(scores[0]   ).tolist()      , 7 * [True] + 3 * [False]   )
              self.assertListEqual(jnp.isinf(scores[1]   ).tolist()      , 2 * [True] + 3 * [False] + 5 * [True]   )

              # check special case
              __snake_case       	=							5
              __snake_case       	=							FlaxTopKLogitsWarper(top_k=1      , filter_value=0.0      , min_tokens_to_keep=3   )

              __snake_case       	=							np.broadcast_to(np.arange(_UpperCamelCase   )[None, :]      , (batch_size, length)   ).copy()
              __snake_case       	=							top_k_warp_safety_check(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )

              # min_tokens overwrites k: 3 tokens are kept => 2 tokens are nullified
              self.assertListEqual((scores == 0.0).sum(axis=-1   ).tolist()      , [2, 2]   )


       def 			a		(		self   )      ->							int:






              """simple docstring"""


              __snake_case       	=							None
              __snake_case       	=							10
              __snake_case       	=							2

              # create distribution and take log (inverse to Softmax as taken in TopPLogitsWarper)
              __snake_case       	=							np.log(np.array([[0.3, 0.1, 0.1, 0.5], [0.15, 0.3, 0.3, 0.25]]   )   )

              __snake_case       	=							FlaxTopPLogitsWarper(0.8   )
              __snake_case       	=							np.exp(top_p_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )   )

              # dist should be filtered to keep min num values so that sum is >= top_p
              # exp (-inf) => 0
              __snake_case       	=							np.array([[0.3, 0.0, 0.0, 0.5], [0.0, 0.3, 0.3, 0.25]]   )
              self.assertTrue(np.allclose(_UpperCamelCase      , _UpperCamelCase      , atol=1E-3   )   )

              # check edge cases with negative and extreme logits
              __snake_case       	=							np.broadcast_to(np.arange(_UpperCamelCase   )[None, :]      , (batch_size, vocab_size)   ).copy() - (
                  vocab_size // 2
              )

              # make ramp_logits more extreme
              __snake_case       	=							ramp_logits[1] * 100.0

              # make sure at least 2 tokens are kept
              __snake_case       	=							FlaxTopPLogitsWarper(0.9      , min_tokens_to_keep=2      , filter_value=0.0   )
              __snake_case       	=							top_p_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )

              # first batch should keep three tokens, second batch would keep only 1, but due to `min_tokens_to_keep=2` keeps 2.
              self.assertListEqual((filtered_dist != 0.0).sum(axis=-1   ).tolist()      , [3, 2]   )


       def 			a		(		self   )      ->							Union[str, Any]:






              """simple docstring"""


              __snake_case       	=							20
              __snake_case       	=							4
              __snake_case       	=							0

              __snake_case       	=							FlaxMinLengthLogitsProcessor(min_length=10      , eos_token_id=_UpperCamelCase   )

              # check that min length is applied at length 5
              __snake_case       	=							ids_tensor((batch_size, 20)      , vocab_size=20   )
              __snake_case       	=							5
              __snake_case       	=							self._get_uniform_logits(_UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							min_dist_processor(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              self.assertListEqual(scores_before_min_length[:, eos_token_id].tolist()      , 4 * [-float("""inf"""   )]   )

              # check that min length is not applied anymore at length 15
              __snake_case       	=							self._get_uniform_logits(_UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							15
              __snake_case       	=							min_dist_processor(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              self.assertFalse(jnp.isinf(_UpperCamelCase   ).any()   )


       def 			a		(		self   )      ->							Optional[Any]:






              """simple docstring"""


              __snake_case       	=							20
              __snake_case       	=							4
              __snake_case       	=							0

              __snake_case       	=							FlaxForcedBOSTokenLogitsProcessor(bos_token_id=_UpperCamelCase   )

              # check that all scores are -inf except the bos_token_id score
              __snake_case       	=							ids_tensor((batch_size, 1)      , vocab_size=20   )
              __snake_case       	=							1
              __snake_case       	=							self._get_uniform_logits(_UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							logits_processor(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              self.assertTrue(jnp.isneginf(scores[:, bos_token_id + 1 :]   ).all()   )
              self.assertListEqual(scores[:, bos_token_id].tolist()      , 4 * [0]   )  # score for bos_token_id shold be zero

              # check that bos_token_id is not forced if current length is greater than 1
              __snake_case       	=							3
              __snake_case       	=							self._get_uniform_logits(_UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							logits_processor(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              self.assertFalse(jnp.isinf(_UpperCamelCase   ).any()   )


       def 			a		(		self   )      ->							Tuple:






              """simple docstring"""


              __snake_case       	=							20
              __snake_case       	=							4
              __snake_case       	=							0
              __snake_case       	=							5

              __snake_case       	=							FlaxForcedEOSTokenLogitsProcessor(max_length=_UpperCamelCase      , eos_token_id=_UpperCamelCase   )

              # check that all scores are -inf except the eos_token_id when max_length is reached
              __snake_case       	=							ids_tensor((batch_size, 4)      , vocab_size=20   )
              __snake_case       	=							4
              __snake_case       	=							self._get_uniform_logits(_UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							logits_processor(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              self.assertTrue(jnp.isneginf(scores[:, eos_token_id + 1 :]   ).all()   )
              self.assertListEqual(scores[:, eos_token_id].tolist()      , 4 * [0]   )  # score for eos_token_id should be zero

              # check that eos_token_id is not forced if max_length is not reached
              __snake_case       	=							3
              __snake_case       	=							self._get_uniform_logits(_UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							logits_processor(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              self.assertFalse(jnp.isinf(_UpperCamelCase   ).any()   )


       def 			a		(		self   )      ->							Optional[Any]:






              """simple docstring"""


              __snake_case       	=							4
              __snake_case       	=							10
              __snake_case       	=							15
              __snake_case       	=							2
              __snake_case       	=							1
              __snake_case       	=							15

              # dummy input_ids and scores
              __snake_case       	=							ids_tensor((batch_size, sequence_length)      , _UpperCamelCase   )
              __snake_case       	=							input_ids.copy()

              __snake_case       	=							self._get_uniform_logits(_UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							scores.copy()

              # instantiate all dist processors
              __snake_case       	=							FlaxTemperatureLogitsWarper(temperature=0.5   )
              __snake_case       	=							FlaxTopKLogitsWarper(3   )
              __snake_case       	=							FlaxTopPLogitsWarper(0.8   )

              # instantiate all logits processors
              __snake_case       	=							FlaxMinLengthLogitsProcessor(min_length=10      , eos_token_id=_UpperCamelCase   )
              __snake_case       	=							FlaxForcedBOSTokenLogitsProcessor(bos_token_id=_UpperCamelCase   )
              __snake_case       	=							FlaxForcedEOSTokenLogitsProcessor(max_length=_UpperCamelCase      , eos_token_id=_UpperCamelCase   )

              __snake_case       	=							10

              # no processor list
              __snake_case       	=							temp_dist_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              __snake_case       	=							top_k_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              __snake_case       	=							top_p_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              __snake_case       	=							min_dist_proc(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              __snake_case       	=							bos_dist_proc(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
              __snake_case       	=							eos_dist_proc(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )

              # with processor list
              __snake_case       	=							FlaxLogitsProcessorList(
                  [temp_dist_warp, top_k_warp, top_p_warp, min_dist_proc, bos_dist_proc, eos_dist_proc]   )
              __snake_case       	=							processor(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )

              # scores should be equal
              self.assertTrue(jnp.allclose(_UpperCamelCase      , _UpperCamelCase      , atol=1E-3   )   )

              # input_ids should never be changed
              self.assertListEqual(input_ids.tolist()      , input_ids_comp.tolist()   )






       def 			a		(		self   )      ->							str:






              """simple docstring"""


              __snake_case       	=							4
              __snake_case       	=							10
              __snake_case       	=							15
              __snake_case       	=							2
              __snake_case       	=							1
              __snake_case       	=							15

              # dummy input_ids and scores
              __snake_case       	=							ids_tensor((batch_size, sequence_length)      , _UpperCamelCase   )
              __snake_case       	=							input_ids.copy()

              __snake_case       	=							self._get_uniform_logits(_UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							scores.copy()

              # instantiate all dist processors
              __snake_case       	=							FlaxTemperatureLogitsWarper(temperature=0.5   )
              __snake_case       	=							FlaxTopKLogitsWarper(3   )
              __snake_case       	=							FlaxTopPLogitsWarper(0.8   )

              # instantiate all logits processors
              __snake_case       	=							FlaxMinLengthLogitsProcessor(min_length=10      , eos_token_id=_UpperCamelCase   )
              __snake_case       	=							FlaxForcedBOSTokenLogitsProcessor(bos_token_id=_UpperCamelCase   )
              __snake_case       	=							FlaxForcedEOSTokenLogitsProcessor(max_length=_UpperCamelCase      , eos_token_id=_UpperCamelCase   )

              __snake_case       	=							10

              # no processor list
              def run_no_processor_list(_UpperCamelCase      , _UpperCamelCase      , _UpperCamelCase   ):
                     __snake_case       	=							temp_dist_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
                     __snake_case       	=							top_k_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
                     __snake_case       	=							top_p_warp(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
                     __snake_case       	=							min_dist_proc(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
                     __snake_case       	=							bos_dist_proc(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
                     __snake_case       	=							eos_dist_proc(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
                     return scores

              # with processor list
              def run_processor_list(_UpperCamelCase      , _UpperCamelCase      , _UpperCamelCase   ):
                     __snake_case       	=							FlaxLogitsProcessorList(
                         [temp_dist_warp, top_k_warp, top_p_warp, min_dist_proc, bos_dist_proc, eos_dist_proc]   )
                     __snake_case       	=							processor(_UpperCamelCase      , _UpperCamelCase      , cur_len=_UpperCamelCase   )
                     return scores

              __snake_case       	=							jax.jit(_UpperCamelCase   )
              __snake_case       	=							jax.jit(_UpperCamelCase   )

              __snake_case       	=							jitted_run_no_processor_list(_UpperCamelCase      , _UpperCamelCase      , _UpperCamelCase   )
              __snake_case       	=							jitted_run_processor_list(_UpperCamelCase      , _UpperCamelCase      , _UpperCamelCase   )

              # scores should be equal
              self.assertTrue(jnp.allclose(_UpperCamelCase      , _UpperCamelCase      , atol=1E-3   )   )

              # input_ids should never be changed
              self.assertListEqual(input_ids.tolist()      , input_ids_comp.tolist()   )




import json
import os
import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers import CLIPTokenizer, CLIPTokenizerFast
from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES
from transformers.testing_utils import require_vision
from transformers.utils import IMAGE_PROCESSOR_NAME, is_vision_available


if is_vision_available():
    from PIL import Image

    from transformers import CLIPImageProcessor, CLIPProcessor

@require_vision
class     __snake_case    (				unittest.TestCase  ):
       """simple docstring"""







       def 			a		(		self   )      ->							Optional[int]:






              """simple docstring"""


              __snake_case       	=							tempfile.mkdtemp()

              # fmt: off
              __snake_case       	=							["""l""", """o""", """w""", """e""", """r""", """s""", """t""", """i""", """d""", """n""", """lo""", """l</w>""", """w</w>""", """r</w>""", """t</w>""", """low</w>""", """er</w>""", """lowest</w>""", """newer</w>""", """wider""", """<unk>""", """<|startoftext|>""", """<|endoftext|>"""]
              # fmt: on
              __snake_case       	=							dict(zip(_UpperCamelCase      , range(len(_UpperCamelCase   )   )   )   )
              __snake_case       	=							["""#version: 0.2""", """l o""", """lo w</w>""", """e r</w>""", """"""]
              __snake_case       	=							{"""unk_token""": """<unk>"""}

              __snake_case       	=							os.path.join(self.tmpdirname      , VOCAB_FILES_NAMES["""vocab_file"""]   )
              __snake_case       	=							os.path.join(self.tmpdirname      , VOCAB_FILES_NAMES["""merges_file"""]   )
              with open(self.vocab_file      , """w"""      , encoding="""utf-8"""   ) as fp:
                     fp.write(json.dumps(_UpperCamelCase   ) + """\n"""   )
              with open(self.merges_file      , """w"""      , encoding="""utf-8"""   ) as fp:
                     fp.write("""\n""".join(_UpperCamelCase   )   )

              __snake_case       	=							{
                  """do_resize""": True,
                  """size""": 20,
                  """do_center_crop""": True,
                  """crop_size""": 18,
                  """do_normalize""": True,
                  """image_mean""": [0.4814_5466, 0.457_8275, 0.4082_1073],
                  """image_std""": [0.2686_2954, 0.2613_0258, 0.2757_7711],
              }
              __snake_case       	=							os.path.join(self.tmpdirname      , _UpperCamelCase   )
              with open(self.image_processor_file      , """w"""      , encoding="""utf-8"""   ) as fp:
                     json.dump(_UpperCamelCase      , _UpperCamelCase   )


       def 			a		(		self      , **_UpperCamelCase   )      ->							Optional[int]:






              """simple docstring"""


              return CLIPTokenizer.from_pretrained(self.tmpdirname      , **_UpperCamelCase   )


       def 			a		(		self      , **_UpperCamelCase   )      ->							Union[str, Any]:






              """simple docstring"""


              return CLIPTokenizerFast.from_pretrained(self.tmpdirname      , **_UpperCamelCase   )


       def 			a		(		self      , **_UpperCamelCase   )      ->							List[str]:






              """simple docstring"""


              return CLIPImageProcessor.from_pretrained(self.tmpdirname      , **_UpperCamelCase   )


       def 			a		(		self   )      ->							int:






              """simple docstring"""


              shutil.rmtree(self.tmpdirname   )


       def 			a		(		self   )      ->							Optional[Any]:






              """simple docstring"""


              __snake_case       	=							[np.random.randint(2_55      , size=(3, 30, 4_00)      , dtype=np.uinta   )]

              __snake_case       	=							[Image.fromarray(np.moveaxis(_UpperCamelCase      , 0      , -1   )   ) for x in image_inputs]

              return image_inputs


       def 			a		(		self   )      ->							List[Any]:






              """simple docstring"""


              __snake_case       	=							self.get_tokenizer()
              __snake_case       	=							self.get_rust_tokenizer()
              __snake_case       	=							self.get_image_processor()

              __snake_case       	=							CLIPProcessor(tokenizer=_UpperCamelCase      , image_processor=_UpperCamelCase   )
              processor_slow.save_pretrained(self.tmpdirname   )
              __snake_case       	=							CLIPProcessor.from_pretrained(self.tmpdirname      , use_fast=_UpperCamelCase   )

              __snake_case       	=							CLIPProcessor(tokenizer=_UpperCamelCase      , image_processor=_UpperCamelCase   )
              processor_fast.save_pretrained(self.tmpdirname   )
              __snake_case       	=							CLIPProcessor.from_pretrained(self.tmpdirname   )

              self.assertEqual(processor_slow.tokenizer.get_vocab()      , tokenizer_slow.get_vocab()   )
              self.assertEqual(processor_fast.tokenizer.get_vocab()      , tokenizer_fast.get_vocab()   )
              self.assertEqual(tokenizer_slow.get_vocab()      , tokenizer_fast.get_vocab()   )
              self.assertIsInstance(processor_slow.tokenizer      , _UpperCamelCase   )
              self.assertIsInstance(processor_fast.tokenizer      , _UpperCamelCase   )

              self.assertEqual(processor_slow.image_processor.to_json_string()      , image_processor.to_json_string()   )
              self.assertEqual(processor_fast.image_processor.to_json_string()      , image_processor.to_json_string()   )
              self.assertIsInstance(processor_slow.image_processor      , _UpperCamelCase   )
              self.assertIsInstance(processor_fast.image_processor      , _UpperCamelCase   )


       def 			a		(		self   )      ->							List[str]:






              """simple docstring"""


              __snake_case       	=							CLIPProcessor(tokenizer=self.get_tokenizer()      , image_processor=self.get_image_processor()   )
              processor.save_pretrained(self.tmpdirname   )

              __snake_case       	=							self.get_tokenizer(bos_token="""(BOS)"""      , eos_token="""(EOS)"""   )
              __snake_case       	=							self.get_image_processor(do_normalize=_UpperCamelCase      , padding_value=1.0   )

              __snake_case       	=							CLIPProcessor.from_pretrained(
                  self.tmpdirname      , bos_token="""(BOS)"""      , eos_token="""(EOS)"""      , do_normalize=_UpperCamelCase      , padding_value=1.0   )

              self.assertEqual(processor.tokenizer.get_vocab()      , tokenizer_add_kwargs.get_vocab()   )
              self.assertIsInstance(processor.tokenizer      , _UpperCamelCase   )

              self.assertEqual(processor.image_processor.to_json_string()      , image_processor_add_kwargs.to_json_string()   )
              self.assertIsInstance(processor.image_processor      , _UpperCamelCase   )


       def 			a		(		self   )      ->							Any:






              """simple docstring"""


              __snake_case       	=							self.get_image_processor()
              __snake_case       	=							self.get_tokenizer()

              __snake_case       	=							CLIPProcessor(tokenizer=_UpperCamelCase      , image_processor=_UpperCamelCase   )

              __snake_case       	=							self.prepare_image_inputs()

              __snake_case       	=							image_processor(_UpperCamelCase      , return_tensors="""np"""   )
              __snake_case       	=							processor(images=_UpperCamelCase      , return_tensors="""np"""   )

              for key in input_image_proc.keys():
                     self.assertAlmostEqual(input_image_proc[key].sum()      , input_processor[key].sum()      , delta=1E-2   )


       def 			a		(		self   )      ->							str:






              """simple docstring"""


              __snake_case       	=							self.get_image_processor()
              __snake_case       	=							self.get_tokenizer()

              __snake_case       	=							CLIPProcessor(tokenizer=_UpperCamelCase      , image_processor=_UpperCamelCase   )

              __snake_case       	=							"""lower newer"""

              __snake_case       	=							processor(text=_UpperCamelCase   )

              __snake_case       	=							tokenizer(_UpperCamelCase   )

              for key in encoded_tok.keys():
                     self.assertListEqual(encoded_tok[key]      , encoded_processor[key]   )


       def 			a		(		self   )      ->							str:






              """simple docstring"""


              __snake_case       	=							self.get_image_processor()
              __snake_case       	=							self.get_tokenizer()

              __snake_case       	=							CLIPProcessor(tokenizer=_UpperCamelCase      , image_processor=_UpperCamelCase   )

              __snake_case       	=							"""lower newer"""
              __snake_case       	=							self.prepare_image_inputs()

              __snake_case       	=							processor(text=_UpperCamelCase      , images=_UpperCamelCase   )

              self.assertListEqual(list(inputs.keys()   )      , ["""input_ids""", """attention_mask""", """pixel_values"""]   )

              # test if it raises when no input is passed
              with pytest.raises(_UpperCamelCase   ):
                     processor()


       def 			a		(		self   )      ->							Any:






              """simple docstring"""


              __snake_case       	=							self.get_image_processor()
              __snake_case       	=							self.get_tokenizer()

              __snake_case       	=							CLIPProcessor(tokenizer=_UpperCamelCase      , image_processor=_UpperCamelCase   )

              __snake_case       	=							[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

              __snake_case       	=							processor.batch_decode(_UpperCamelCase   )
              __snake_case       	=							tokenizer.batch_decode(_UpperCamelCase   )

              self.assertListEqual(_UpperCamelCase      , _UpperCamelCase   )






       def 			a		(		self   )      ->							int:






              """simple docstring"""


              __snake_case       	=							self.get_image_processor()
              __snake_case       	=							self.get_tokenizer()

              __snake_case       	=							CLIPProcessor(tokenizer=_UpperCamelCase      , image_processor=_UpperCamelCase   )

              __snake_case       	=							"""lower newer"""
              __snake_case       	=							self.prepare_image_inputs()

              __snake_case       	=							processor(text=_UpperCamelCase      , images=_UpperCamelCase   )

              self.assertListEqual(list(inputs.keys()   )      , processor.model_input_names   )

