



"""simple docstring"""





import shutil
import tempfile
import unittest

from transformers import (
    SPIECE_UNDERLINE,
    AddedToken,
    BatchEncoding,
    NllbTokenizer,
    NllbTokenizerFast,
    is_torch_available,
)
from transformers.testing_utils import (
    get_tests_dir,
    nested_simplify,
    require_sentencepiece,
    require_tokenizers,
    require_torch,
)

from ...test_tokenization_common import TokenizerTesterMixin


__lowerCAmelCase							:       List[Any]          =       get_tests_dir('''fixtures/test_sentencepiece.model''')


if is_torch_available():
					from transformers.models.mam_aaa.modeling_mam_aaa import shift_tokens_right

__lowerCAmelCase							:       Tuple          =       25_6047
__lowerCAmelCase							:       int          =       25_6145



@require_sentencepiece
@require_tokenizers
class  _lowerCAmelCase     (					SCREAMING_SNAKE_CASE__	,					unittest.TestCase		):





		"""simple docstring"""






		_lowerCamelCase      	=							NllbTokenizer
		_lowerCamelCase      	=							NllbTokenizerFast
		_lowerCamelCase      	=							True
		_lowerCamelCase      	=							True
		_lowerCamelCase      	=							{}





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







								'''simple docstring'''

								super().setUp()

								# We have a SentencePiece fixture for testing
								snake_case_ :			str            =      NllbTokenizer(_lowercase				,     keep_accents=_lowercase )
								tokenizer.save_pretrained(self.tmpdirname )





		def  UpperCAmelCase__				(       self )			->    Any:







								'''simple docstring'''

								snake_case_ :			Tuple            =      NllbTokenizer(_lowercase				,     keep_accents=_lowercase )

								snake_case_ :			Optional[Any]            =      tokenizer.tokenize("""This is a test""" )
								self.assertListEqual(_lowercase				,     ["""▁This""", """▁is""", """▁a""", """▁t""", """est"""] )

								self.assertListEqual(
								    tokenizer.convert_tokens_to_ids(_lowercase )				,     [value + tokenizer.fairseq_offset for value in [2_8_5, 4_6, 1_0, 1_7_0, 3_8_2]]				,     )

								snake_case_ :			Optional[int]            =      tokenizer.tokenize("""I was born in 92000, and this is falsé.""" )
								self.assertListEqual(
								    _lowercase				,     [
								        SPIECE_UNDERLINE + """I""",
								        SPIECE_UNDERLINE + """was""",
								        SPIECE_UNDERLINE + """b""",
								        """or""",
								        """n""",
								        SPIECE_UNDERLINE + """in""",
								        SPIECE_UNDERLINE + """""",
								        """9""",
								        """2""",
								        """0""",
								        """0""",
								        """0""",
								        """,""",
								        SPIECE_UNDERLINE + """and""",
								        SPIECE_UNDERLINE + """this""",
								        SPIECE_UNDERLINE + """is""",
								        SPIECE_UNDERLINE + """f""",
								        """al""",
								        """s""",
								        """é""",
								        """.""",
								    ]				,     )
								snake_case_ :			Union[str, Any]            =      tokenizer.convert_tokens_to_ids(_lowercase )
								self.assertListEqual(
								    _lowercase				,     [
								        value + tokenizer.fairseq_offset
								        for value in [8, 2_1, 8_4, 5_5, 2_4, 1_9, 7, 2, 6_0_2, 3_4_7, 3_4_7, 3_4_7, 3, 1_2, 6_6, 4_6, 7_2, 8_0, 6, 2, 4]
								    ]				,     )

								snake_case_ :			List[Any]            =      tokenizer.convert_ids_to_tokens(_lowercase )
								self.assertListEqual(
								    _lowercase				,     [
								        SPIECE_UNDERLINE + """I""",
								        SPIECE_UNDERLINE + """was""",
								        SPIECE_UNDERLINE + """b""",
								        """or""",
								        """n""",
								        SPIECE_UNDERLINE + """in""",
								        SPIECE_UNDERLINE + """""",
								        """<unk>""",
								        """2""",
								        """0""",
								        """0""",
								        """0""",
								        """,""",
								        SPIECE_UNDERLINE + """and""",
								        SPIECE_UNDERLINE + """this""",
								        SPIECE_UNDERLINE + """is""",
								        SPIECE_UNDERLINE + """f""",
								        """al""",
								        """s""",
								        """<unk>""",
								        """.""",
								    ]				,     )





		def  UpperCAmelCase__				(       self )			->    Any:







								'''simple docstring'''

								snake_case_ :			Tuple            =      (self.rust_tokenizer_class, """hf-internal-testing/tiny-random-nllb""", {})
								for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
														with self.subTest(f'{tokenizer.__class__.__name__} ({pretrained_name})' ):
																				snake_case_ :			Union[str, Any]            =      self.rust_tokenizer_class.from_pretrained(_lowercase				,     **_lowercase )
																				snake_case_ :			Optional[int]            =      self.tokenizer_class.from_pretrained(_lowercase				,     **_lowercase )

																				snake_case_ :			Any            =      tempfile.mkdtemp()

																				snake_case_ :			Optional[int]            =      tokenizer_r.save_pretrained(_lowercase )
																				snake_case_ :			Optional[int]            =      tokenizer_p.save_pretrained(_lowercase )

																				# Checks it save with the same files + the tokenizer.json file for the fast one
																				self.assertTrue(any("""tokenizer.json""" in f for f in tokenizer_r_files ) )
																				snake_case_ :			Dict            =      tuple(f for f in tokenizer_r_files if """tokenizer.json""" not in f )
																				self.assertSequenceEqual(_lowercase				,     _lowercase )

																				# Checks everything loads correctly in the same way
																				snake_case_ :			Optional[int]            =      tokenizer_r.from_pretrained(_lowercase )
																				snake_case_ :			str            =      tokenizer_p.from_pretrained(_lowercase )

																				# Check special tokens are set accordingly on Rust and Python
																				for key in tokenizer_pp.special_tokens_map:
																										self.assertTrue(hasattr(_lowercase				,     _lowercase ) )

																				shutil.rmtree(_lowercase )

																				# Save tokenizer rust, legacy_format=True
																				snake_case_ :			Optional[Any]            =      tempfile.mkdtemp()

																				snake_case_ :			Optional[Any]            =      tokenizer_r.save_pretrained(_lowercase				,     legacy_format=_lowercase )
																				snake_case_ :			Optional[int]            =      tokenizer_p.save_pretrained(_lowercase )

																				# Checks it save with the same files
																				self.assertSequenceEqual(_lowercase				,     _lowercase )

																				# Checks everything loads correctly in the same way
																				snake_case_ :			Union[str, Any]            =      tokenizer_r.from_pretrained(_lowercase )
																				snake_case_ :			str            =      tokenizer_p.from_pretrained(_lowercase )

																				# Check special tokens are set accordingly on Rust and Python
																				for key in tokenizer_pp.special_tokens_map:
																										self.assertTrue(hasattr(_lowercase				,     _lowercase ) )

																				shutil.rmtree(_lowercase )

																				# Save tokenizer rust, legacy_format=False
																				snake_case_ :			str            =      tempfile.mkdtemp()

																				snake_case_ :			Any            =      tokenizer_r.save_pretrained(_lowercase				,     legacy_format=_lowercase )
																				snake_case_ :			Optional[int]            =      tokenizer_p.save_pretrained(_lowercase )

																				# Checks it saved the tokenizer.json file
																				self.assertTrue(any("""tokenizer.json""" in f for f in tokenizer_r_files ) )

																				# Checks everything loads correctly in the same way
																				snake_case_ :			List[str]            =      tokenizer_r.from_pretrained(_lowercase )
																				snake_case_ :			Optional[int]            =      tokenizer_p.from_pretrained(_lowercase )

																				# Check special tokens are set accordingly on Rust and Python
																				for key in tokenizer_pp.special_tokens_map:
																										self.assertTrue(hasattr(_lowercase				,     _lowercase ) )

																				shutil.rmtree(_lowercase )





		@require_torch
		def  UpperCAmelCase__				(       self )			->    List[Any]:







								'''simple docstring'''

								if not self.test_seqaseq:
														return

								snake_case_ :			Union[str, Any]            =      self.get_tokenizers()
								for tokenizer in tokenizers:
														with self.subTest(f'{tokenizer.__class__.__name__}' ):
																				# Longer text that will definitely require truncation.
																				snake_case_ :			Optional[Any]            =      [
																				    """ UN Chief Says There Is No Military Solution in Syria""",
																				    """ Secretary-General Ban Ki-moon says his response to Russia's stepped up military support for"""
																				    """ Syria is that 'there is no military solution' to the nearly five-year conflict and more weapons"""
																				    """ will only worsen the violence and misery for millions of people.""",
																				]
																				snake_case_ :			Optional[int]            =      [
																				    """Şeful ONU declară că nu există o soluţie militară în Siria""",
																				    """Secretarul General Ban Ki-moon declară că răspunsul său la intensificarea sprijinului militar al"""
																				    """ Rusiei pentru Siria este că \"nu există o soluţie militară\" la conflictul de aproape cinci ani şi"""
																				    """ că noi arme nu vor face decât să înrăutăţească violenţele şi mizeria pentru milioane de oameni.""",
																				]
																				try:
																										snake_case_ :			Any            =      tokenizer.prepare_seqaseq_batch(
																										    src_texts=_lowercase				,     tgt_texts=_lowercase				,     max_length=3				,     max_target_length=1_0				,     return_tensors="""pt"""				,     src_lang="""eng_Latn"""				,     tgt_lang="""ron_Latn"""				,     )
																				except NotImplementedError:
																										return
																				self.assertEqual(batch.input_ids.shape[1]				,     3 )
																				self.assertEqual(batch.labels.shape[1]				,     1_0 )
																				# max_target_length will default to max_length if not specified
																				snake_case_ :			str            =      tokenizer.prepare_seqaseq_batch(
																				    _lowercase				,     tgt_texts=_lowercase				,     max_length=3				,     return_tensors="""pt""" )
																				self.assertEqual(batch.input_ids.shape[1]				,     3 )
																				self.assertEqual(batch.labels.shape[1]				,     3 )

																				snake_case_ :			Optional[int]            =      tokenizer.prepare_seqaseq_batch(
																				    src_texts=_lowercase				,     max_length=3				,     max_target_length=1_0				,     return_tensors="""pt""" )
																				self.assertEqual(batch_encoder_only.input_ids.shape[1]				,     3 )
																				self.assertEqual(batch_encoder_only.attention_mask.shape[1]				,     3 )
																				self.assertNotIn("""decoder_input_ids"""				,     _lowercase )





		@unittest.skip("""Unfortunately way too slow to build a BPE with SentencePiece.""" )
		def  UpperCAmelCase__				(       self )			->    Dict:







								'''simple docstring'''

								pass





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







								'''simple docstring'''

								for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
														with self.subTest(f'{tokenizer.__class__.__name__} ({pretrained_name})' ):
																				snake_case_ :			List[str]            =      [AddedToken("""<special>"""				,     lstrip=_lowercase )]

																				snake_case_ :			List[Any]            =      self.rust_tokenizer_class.from_pretrained(
																				    _lowercase				,     additional_special_tokens=_lowercase				,     **_lowercase )
																				snake_case_ :			Dict            =      tokenizer_r.encode("""Hey this is a <special> token""" )

																				snake_case_ :			int            =      tokenizer_r.encode("""<special>"""				,     add_special_tokens=_lowercase )[0]

																				self.assertTrue(special_token_id in r_output )

																				if self.test_slow_tokenizer:
																										snake_case_ :			Optional[Any]            =      self.rust_tokenizer_class.from_pretrained(
																										    _lowercase				,     additional_special_tokens=_lowercase				,     **_lowercase				,     )
																										snake_case_ :			List[Any]            =      self.tokenizer_class.from_pretrained(
																										    _lowercase				,     additional_special_tokens=_lowercase				,     **_lowercase )

																										snake_case_ :			Tuple            =      tokenizer_p.encode("""Hey this is a <special> token""" )

																										snake_case_ :			int            =      tokenizer_cr.encode("""Hey this is a <special> token""" )

																										self.assertEqual(_lowercase				,     _lowercase )
																										self.assertEqual(_lowercase				,     _lowercase )
																										self.assertTrue(special_token_id in p_output )
																										self.assertTrue(special_token_id in cr_output )




@require_torch
@require_sentencepiece
@require_tokenizers
class  _lowerCAmelCase     (					unittest.TestCase		):





		"""simple docstring"""






		_lowerCamelCase      	=							'''facebook/nllb-200-distilled-600M'''
		_lowerCamelCase      	=							[
		    ''' UN Chief Says There Is No Military Solution in Syria''',
		    ''' Secretary-General Ban Ki-moon says his response to Russia\'s stepped up military support for Syria is that "there is no military solution" to the nearly five-year conflict and more weapons will only worsen the violence and misery for millions of people.''',
		]
		_lowerCamelCase      	=							[
		    '''Şeful ONU declară că nu există o soluţie militară în Siria''',
		    '''Secretarul General Ban Ki-moon declară că răspunsul său la intensificarea sprijinului militar al Rusiei'''
		    ''' pentru Siria este că "nu există o soluţie militară" la conflictul de aproape cinci ani şi că noi arme nu vor'''
		    ''' face decât să înrăutăţească violenţele şi mizeria pentru milioane de oameni.''',
		]
		_lowerCamelCase      	=							[
		    256_047,
		    16_297,
		    134_408,
		    8_165,
		    248_066,
		    14_734,
		    950,
		    1_135,
		    105_721,
		    3_573,
		    83,
		    27_352,
		    108,
		    49_486,
		    2,
		]





		@classmethod
		def  UpperCAmelCase__				(       cls )			->    List[str]:







								'''simple docstring'''

								snake_case_ :			NllbTokenizer            =      NllbTokenizer.from_pretrained(
								    cls.checkpoint_name				,     src_lang="""eng_Latn"""				,     tgt_lang="""ron_Latn""" )
								snake_case_ :			Dict            =      1
								return cls





		def  UpperCAmelCase__				(       self )			->    Tuple:







								'''simple docstring'''

								self.assertEqual(self.tokenizer.fairseq_tokens_to_ids["""ace_Arab"""]				,     2_5_6_0_0_1 )
								self.assertEqual(self.tokenizer.fairseq_tokens_to_ids["""ace_Latn"""]				,     2_5_6_0_0_2 )
								self.assertEqual(self.tokenizer.fairseq_tokens_to_ids["""fra_Latn"""]				,     2_5_6_0_5_7 )





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







								'''simple docstring'''

								snake_case_ :			int            =      self.tokenizer.batch_encode_plus(self.src_text ).input_ids[0]
								self.assertListEqual(self.expected_src_tokens				,     _lowercase )





		def  UpperCAmelCase__				(       self )			->    Tuple:







								'''simple docstring'''

								self.assertIn(_lowercase				,     self.tokenizer.all_special_ids )
								# fmt: off
								snake_case_ :			List[Any]            =      [RO_CODE, 4_2_5_4, 9_8_0_6_8, 1_1_2_9_2_3, 3_9_0_7_2, 3_9_0_9, 7_1_3, 1_0_2_7_6_7, 2_6, 1_7_3_1_4, 3_5_6_4_2, 1_4_6_8_3, 3_3_1_1_8, 2_0_2_2, 6_6_9_8_7, 2, 2_5_6_0_4_7]
								# fmt: on

								snake_case_ :			int            =      self.tokenizer.decode(_lowercase				,     skip_special_tokens=_lowercase )
								snake_case_ :			List[str]            =      self.tokenizer.decode(generated_ids[1:]				,     skip_special_tokens=_lowercase )
								self.assertEqual(_lowercase				,     _lowercase )
								self.assertNotIn(self.tokenizer.eos_token				,     _lowercase )





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







								'''simple docstring'''

								snake_case_ :			List[str]            =      ["""this is gunna be a long sentence """ * 2_0]
								assert isinstance(src_text[0]				,     _lowercase )
								snake_case_ :			Optional[int]            =      1_0
								snake_case_ :			Optional[int]            =      self.tokenizer(_lowercase				,     max_length=_lowercase				,     truncation=_lowercase ).input_ids[0]
								self.assertEqual(ids[-1]				,     2 )
								self.assertEqual(ids[0]				,     _lowercase )
								self.assertEqual(len(_lowercase )				,     _lowercase )





		def  UpperCAmelCase__				(       self )			->    str:







								'''simple docstring'''

								self.assertListEqual(self.tokenizer.convert_tokens_to_ids(["""<mask>""", """ar_AR"""] )				,     [2_5_6_2_0_3, 3] )





		def  UpperCAmelCase__				(       self )			->    Tuple:







								'''simple docstring'''

								snake_case_ :			Dict            =      tempfile.mkdtemp()
								snake_case_ :			List[Any]            =      self.tokenizer.fairseq_tokens_to_ids
								self.tokenizer.save_pretrained(_lowercase )
								snake_case_ :			Union[str, Any]            =      NllbTokenizer.from_pretrained(_lowercase )
								self.assertDictEqual(new_tok.fairseq_tokens_to_ids				,     _lowercase )





		@require_torch
		def  UpperCAmelCase__				(       self )			->    Tuple:







								'''simple docstring'''

								snake_case_ :			str            =      self.tokenizer(
								    self.src_text				,     text_target=self.tgt_text				,     padding=_lowercase				,     truncation=_lowercase				,     max_length=len(self.expected_src_tokens )				,     return_tensors="""pt"""				,     )
								snake_case_ :			Optional[Any]            =      shift_tokens_right(
								    batch["""labels"""]				,     self.tokenizer.pad_token_id				,     self.tokenizer.lang_code_to_id["""ron_Latn"""] )

								self.assertIsInstance(_lowercase				,     _lowercase )

								self.assertEqual((2, 1_5)				,     batch.input_ids.shape )
								self.assertEqual((2, 1_5)				,     batch.attention_mask.shape )
								snake_case_ :			List[str]            =      batch.input_ids.tolist()[0]
								self.assertListEqual(self.expected_src_tokens				,     _lowercase )
								self.assertEqual(_lowercase				,     batch.decoder_input_ids[0, 0] )  # EOS
								# Test that special tokens are reset
								self.assertEqual(self.tokenizer.prefix_tokens				,     [EN_CODE] )
								self.assertEqual(self.tokenizer.suffix_tokens				,     [self.tokenizer.eos_token_id] )





		def  UpperCAmelCase__				(       self )			->    int:







								'''simple docstring'''

								snake_case_ :			Tuple            =      self.tokenizer(self.src_text				,     padding=_lowercase				,     truncation=_lowercase				,     max_length=3				,     return_tensors="""pt""" )
								snake_case_ :			Optional[Any]            =      self.tokenizer(
								    text_target=self.tgt_text				,     padding=_lowercase				,     truncation=_lowercase				,     max_length=1_0				,     return_tensors="""pt""" )
								snake_case_ :			str            =      targets["""input_ids"""]
								snake_case_ :			Optional[int]            =      shift_tokens_right(
								    _lowercase				,     self.tokenizer.pad_token_id				,     decoder_start_token_id=self.tokenizer.lang_code_to_id[self.tokenizer.tgt_lang]				,     )

								self.assertEqual(batch.input_ids.shape[1]				,     3 )
								self.assertEqual(batch.decoder_input_ids.shape[1]				,     1_0 )





		@require_torch
		def  UpperCAmelCase__				(       self )			->    List[str]:







								'''simple docstring'''

								snake_case_ :			List[str]            =      self.tokenizer._build_translation_inputs(
								    """A test"""				,     return_tensors="""pt"""				,     src_lang="""eng_Latn"""				,     tgt_lang="""fra_Latn""" )

								self.assertEqual(
								    nested_simplify(_lowercase )				,     {
								        # A, test, EOS, en_XX
								        """input_ids""": [[2_5_6_0_4_7, 7_0, 7_3_5_6, 2]],
								        """attention_mask""": [[1, 1, 1, 1]],
								        # ar_AR
								        """forced_bos_token_id""": 2_5_6_0_5_7,
								    }				,     )





		@require_torch
		def  UpperCAmelCase__				(       self )			->    List[str]:







								'''simple docstring'''

								snake_case_ :			List[Any]            =      True
								snake_case_ :			Optional[int]            =      self.tokenizer(
								    """UN Chief says there is no military solution in Syria"""				,     src_lang="""eng_Latn"""				,     tgt_lang="""fra_Latn""" )
								self.assertEqual(
								    inputs.input_ids				,     [1_6_2_9_7, 1_3_4_4_0_8, 2_5_6_5_3, 6_3_7_0, 2_4_8, 2_5_4, 1_0_3_9_2_9, 9_4_9_9_5, 1_0_8, 4_9_4_8_6, 2, 2_5_6_0_4_7] )

								snake_case_ :			str            =      False
								snake_case_ :			List[Any]            =      self.tokenizer(
								    """UN Chief says there is no military solution in Syria"""				,     src_lang="""eng_Latn"""				,     tgt_lang="""fra_Latn""" )
								self.assertEqual(
								    inputs.input_ids				,     [2_5_6_0_4_7, 1_6_2_9_7, 1_3_4_4_0_8, 2_5_6_5_3, 6_3_7_0, 2_4_8, 2_5_4, 1_0_3_9_2_9, 9_4_9_9_5, 1_0_8, 4_9_4_8_6, 2] )






'''simple docstring'''





import unittest

import numpy as np

from transformers.file_utils import is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_vision

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import DPTImageProcessor






class __A     (    unittest.TestCase		):



 '''simple docstring'''







 def __init__(self					,  A					,  A=7					,  A=3					,  A=18					,  A=30					,  A=400					,  A=True					,  A=None					,  A=True					,  A=[0.5, 0.5, 0.5]					,  A=[0.5, 0.5, 0.5]					,  )       ->	str:


      """simple docstring"""



      _a           =    size if size is not None else {'''height''': 18, '''width''': 18}
      _a           =    parent
      _a           =    batch_size
      _a           =    num_channels
      _a           =    image_size
      _a           =    min_resolution
      _a           =    max_resolution
      _a           =    do_resize
      _a           =    size
      _a           =    do_normalize
      _a           =    image_mean
      _a           =    image_std



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


      """simple docstring"""



      return {
          "image_mean": self.image_mean,
          "image_std": self.image_std,
          "do_normalize": self.do_normalize,
          "do_resize": self.do_resize,
          "size": self.size,
      }






@require_torch
@require_vision
class __A     (    A  ,  unittest.TestCase		):



 '''simple docstring'''







 __lowerCamelCase       :			str		=			DPTImageProcessor if is_vision_available() else None



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


      """simple docstring"""



      _a           =    DPTImageProcessingTester(self			)



 @property
 def    a__    (self			)       ->	int:


      """simple docstring"""



      return self.image_processor_tester.prepare_image_processor_dict()



 def    a__    (self			)       ->	Dict:


      """simple docstring"""



      _a           =    self.image_processing_class(**self.image_processor_dict			)
      self.assertTrue(hasattr(A					,  '''image_mean'''			)			)
      self.assertTrue(hasattr(A					,  '''image_std'''			)			)
      self.assertTrue(hasattr(A					,  '''do_normalize'''			)			)
      self.assertTrue(hasattr(A					,  '''do_resize'''			)			)
      self.assertTrue(hasattr(A					,  '''size'''			)			)



 def    a__    (self			)       ->	Any:


      """simple docstring"""



      _a           =    self.image_processing_class.from_dict(self.image_processor_dict			)
      self.assertEqual(image_processor.size					,  {'''height''': 18, '''width''': 18}			)

      _a           =    self.image_processing_class.from_dict(self.image_processor_dict					,  size=42			)
      self.assertEqual(image_processor.size					,  {'''height''': 42, '''width''': 42}			)



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


      """simple docstring"""



      _a           =    self.image_processing_class(**self.image_processor_dict			)
      # create random PIL images
      _a           =    prepare_image_inputs(self.image_processor_tester					,  equal_resolution=A			)
      for image in image_inputs:
           self.assertIsInstance(A					,  Image.Image			)

      # Test not batched input
      _a           =    image_processing(image_inputs[0]					,  return_tensors='''pt'''			).pixel_values
      self.assertEqual(
          encoded_images.shape					,  (
              1,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['''height'''],
              self.image_processor_tester.size['''width'''],
          )					,  )

      # Test batched
      _a           =    image_processing(A					,  return_tensors='''pt'''			).pixel_values
      self.assertEqual(
          encoded_images.shape					,  (
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['''height'''],
              self.image_processor_tester.size['''width'''],
          )					,  )



 def    a__    (self			)       ->	str:


      """simple docstring"""



      _a           =    self.image_processing_class(**self.image_processor_dict			)
      # create random numpy tensors
      _a           =    prepare_image_inputs(self.image_processor_tester					,  equal_resolution=A					,  numpify=A			)
      for image in image_inputs:
           self.assertIsInstance(A					,  np.ndarray			)

      # Test not batched input
      _a           =    image_processing(image_inputs[0]					,  return_tensors='''pt'''			).pixel_values
      self.assertEqual(
          encoded_images.shape					,  (
              1,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['''height'''],
              self.image_processor_tester.size['''width'''],
          )					,  )

      # Test batched
      _a           =    image_processing(A					,  return_tensors='''pt'''			).pixel_values
      self.assertEqual(
          encoded_images.shape					,  (
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['''height'''],
              self.image_processor_tester.size['''width'''],
          )					,  )



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


      """simple docstring"""



      _a           =    self.image_processing_class(**self.image_processor_dict			)
      # create random PyTorch tensors
      _a           =    prepare_image_inputs(self.image_processor_tester					,  equal_resolution=A					,  torchify=A			)
      for image in image_inputs:
           self.assertIsInstance(A					,  torch.Tensor			)

      # Test not batched input
      _a           =    image_processing(image_inputs[0]					,  return_tensors='''pt'''			).pixel_values
      self.assertEqual(
          encoded_images.shape					,  (
              1,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['''height'''],
              self.image_processor_tester.size['''width'''],
          )					,  )

      # Test batched
      _a           =    image_processing(A					,  return_tensors='''pt'''			).pixel_values
      self.assertEqual(
          encoded_images.shape					,  (
              self.image_processor_tester.batch_size,
              self.image_processor_tester.num_channels,
              self.image_processor_tester.size['''height'''],
              self.image_processor_tester.size['''width'''],
          )					,  )



