




'''simple docstring'''




import json
import os
import re
import unicodedata
from typing import Dict, List, Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


snake_case__ 							=    logging.get_logger(__name__)

snake_case__ 							=    {
    """src_vocab_file""": """vocab-src.json""",
    """tgt_vocab_file""": """vocab-tgt.json""",
    """merges_file""": """merges.txt""",
}

snake_case__ 							=    {
    """src_vocab_file""": {
        """stas/tiny-wmt19-en-de""": """https://huggingface.co/stas/tiny-wmt19-en-de/resolve/main/vocab-src.json"""
    },
    """tgt_vocab_file""": {
        """stas/tiny-wmt19-en-de""": """https://huggingface.co/stas/tiny-wmt19-en-de/resolve/main/vocab-tgt.json"""
    },
    """merges_file""": {"""stas/tiny-wmt19-en-de""": """https://huggingface.co/stas/tiny-wmt19-en-de/resolve/main/merges.txt"""},
}

snake_case__ 							=    {"""stas/tiny-wmt19-en-de""": 10_24}
snake_case__ 							=    {
    """stas/tiny-wmt19-en-de""": {
        """langs""": ["""en""", """de"""],
        """model_max_length""": 10_24,
        """special_tokens_map_file""": None,
        """full_tokenizer_file""": None,
    }
}




def     snake_case__     (			lowerCamelCase__					: Dict      ) -> List[Any]:
					A_			:  Optional[Any]			=				set()
					A_			:  Optional[int]			=				word[0]
					for char in word[1:]:
										pairs.add((prev_char, char)      )
										A_			:  Optional[int]			=				char
					return pairs




def     snake_case__     (			lowerCamelCase__					: Optional[Any]      ) -> Dict:
					A_			:  Dict			=				text.replace('''，'''      ,		''','''      )
					A_			:  List[Any]			=				re.sub(R'''。\s*'''      ,		'''. '''      ,		lowerCamelCase__      )
					A_			:  Union[str, Any]			=				text.replace('''、'''      ,		''','''      )
					A_			:  Tuple			=				text.replace('''”'''      ,		'''"'''      )
					A_			:  Optional[int]			=				text.replace('''“'''      ,		'''"'''      )
					A_			:  List[Any]			=				text.replace('''∶'''      ,		''':'''      )
					A_			:  List[str]			=				text.replace('''：'''      ,		''':'''      )
					A_			:  Dict			=				text.replace('''？'''      ,		'''?'''      )
					A_			:  Optional[int]			=				text.replace('''《'''      ,		'''"'''      )
					A_			:  Any			=				text.replace('''》'''      ,		'''"'''      )
					A_			:  Dict			=				text.replace('''）'''      ,		''')'''      )
					A_			:  Union[str, Any]			=				text.replace('''！'''      ,		'''!'''      )
					A_			:  Optional[int]			=				text.replace('''（'''      ,		'''('''      )
					A_			:  Union[str, Any]			=				text.replace('''；'''      ,		''';'''      )
					A_			:  int			=				text.replace('''１'''      ,		'''1'''      )
					A_			:  Union[str, Any]			=				text.replace('''」'''      ,		'''"'''      )
					A_			:  Union[str, Any]			=				text.replace('''「'''      ,		'''"'''      )
					A_			:  List[Any]			=				text.replace('''０'''      ,		'''0'''      )
					A_			:  List[str]			=				text.replace('''３'''      ,		'''3'''      )
					A_			:  Dict			=				text.replace('''２'''      ,		'''2'''      )
					A_			:  Any			=				text.replace('''５'''      ,		'''5'''      )
					A_			:  int			=				text.replace('''６'''      ,		'''6'''      )
					A_			:  str			=				text.replace('''９'''      ,		'''9'''      )
					A_			:  Union[str, Any]			=				text.replace('''７'''      ,		'''7'''      )
					A_			:  Tuple			=				text.replace('''８'''      ,		'''8'''      )
					A_			:  Tuple			=				text.replace('''４'''      ,		'''4'''      )
					A_			:  Dict			=				re.sub(R'''．\s*'''      ,		'''. '''      ,		lowerCamelCase__      )
					A_			:  List[Any]			=				text.replace('''～'''      ,		'''~'''      )
					A_			:  Any			=				text.replace('''’'''      ,		'''\''''      )
					A_			:  Optional[int]			=				text.replace('''…'''      ,		'''...'''      )
					A_			:  Dict			=				text.replace('''━'''      ,		'''-'''      )
					A_			:  Optional[Any]			=				text.replace('''〈'''      ,		'''<'''      )
					A_			:  List[Any]			=				text.replace('''〉'''      ,		'''>'''      )
					A_			:  Any			=				text.replace('''【'''      ,		'''['''      )
					A_			:  str			=				text.replace('''】'''      ,		''']'''      )
					A_			:  Any			=				text.replace('''％'''      ,		'''%'''      )
					return text




def     snake_case__     (			lowerCamelCase__					: Any      ) -> Optional[Any]:
					A_			:  Optional[int]			=				[]
					for char in text:
										A_			:  Tuple			=				unicodedata.category(lowerCamelCase__      )
										if cat.startswith('''C'''      ):
															continue
										output.append(lowerCamelCase__      )
					return "".join(lowerCamelCase__      )






class      UpperCamelCase_  (a__  ):







						"""simple docstring"""


						_lowerCAmelCase         =       VOCAB_FILES_NAMES
						_lowerCAmelCase         =       PRETRAINED_VOCAB_FILES_MAP
						_lowerCAmelCase         =       PRETRAINED_INIT_CONFIGURATION
						_lowerCAmelCase         =       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						_lowerCAmelCase         =       ['input_ids', 'attention_mask']







						def __init__(  self   :							str				,			_lowerCamelCase   :							Dict=None				,			_lowerCamelCase   :							Any=None				,			_lowerCamelCase   :							List[str]=None				,			_lowerCamelCase   :							List[str]=None				,			_lowerCamelCase   :							Tuple=False				,			_lowerCamelCase   :							Union[str, Any]="<unk>"				,			_lowerCamelCase   :							Union[str, Any]="<s>"				,			_lowerCamelCase   :							Optional[Any]="</s>"				,			_lowerCamelCase   :							int="<pad>"				,			**_lowerCamelCase   :							List[str]				,			):





											"""simple docstring"""







											super().__init__(
											    langs=_lowerCamelCase				,			src_vocab_file=_lowerCamelCase				,			tgt_vocab_file=_lowerCamelCase				,			merges_file=_lowerCamelCase				,			do_lower_case=_lowerCamelCase				,			unk_token=_lowerCamelCase				,			bos_token=_lowerCamelCase				,			sep_token=_lowerCamelCase				,			pad_token=_lowerCamelCase				,			**_lowerCamelCase				,			)

											try:
																import sacremoses
											except ImportError:
																raise ImportError(
																    '''You need to install sacremoses to use XLMTokenizer. '''
																    '''See https://pypi.org/project/sacremoses/ for installation.'''     )

											A_			:  Dict			=				sacremoses

											A_			:  Tuple			=				src_vocab_file
											A_			:  int			=				tgt_vocab_file
											A_			:  Any			=				merges_file
											A_			:  int			=				do_lower_case

											# cache of sm.MosesPunctNormalizer instance
											A_			:  str			=				{}
											# cache of sm.MosesTokenizer instance
											A_			:  Optional[int]			=				{}
											A_			:  Dict			=				{}

											if langs and len(_lowerCamelCase     ) == 2:
																A_			,A_			:  Union[str, Any]			=				langs
											else:
																raise ValueError(
																    f'arg `langs` needs to be a list of 2 langs, e.g. [\'en\', \'ru\'], but got {langs}. '
																    '''Usually that means that tokenizer can\'t find a mapping for the given model path '''
																    '''in PRETRAINED_VOCAB_FILES_MAP, and other maps of this tokenizer.'''     )

											with open(_lowerCamelCase				,			encoding='''utf-8'''     ) as src_vocab_handle:
																A_			:  Dict			=				json.load(_lowerCamelCase     )
											with open(_lowerCamelCase				,			encoding='''utf-8'''     ) as tgt_vocab_handle:
																A_			:  Union[str, Any]			=				json.load(_lowerCamelCase     )
																A_			:  Any			=				{v: k for k, v in tgt_vocab.items()}
											with open(_lowerCamelCase				,			encoding='''utf-8'''     ) as merges_handle:
																A_			:  Optional[Any]			=				merges_handle.read().split('''\n'''     )[:-1]
											A_			:  Tuple			=				[tuple(merge.split()[:2]     ) for merge in merges]
											A_			:  Tuple			=				dict(zip(_lowerCamelCase				,			range(len(_lowerCamelCase     )     )     )     )
											A_			:  List[Any]			=				{}







						def    _a     (  self   :							int     ):





											"""simple docstring"""







											return self.get_src_vocab()







						@property
						def    _a     (  self   :							Union[str, Any]     ):





											"""simple docstring"""







											return self.src_vocab_size







						def    _a     (  self   :							Union[str, Any]				,			_lowerCamelCase   :							Optional[Any]				,			_lowerCamelCase   :							List[Any]     ):





											"""simple docstring"""







											if lang not in self.cache_moses_punct_normalizer:
																A_			:  Union[str, Any]			=				self.sm.MosesPunctNormalizer(lang=_lowerCamelCase     )
																A_			:  List[Any]			=				punct_normalizer
											return self.cache_moses_punct_normalizer[lang].normalize(_lowerCamelCase     )







						def    _a     (  self   :							str				,			_lowerCamelCase   :							Optional[int]				,			_lowerCamelCase   :							Optional[int]     ):





											"""simple docstring"""







											if lang not in self.cache_moses_tokenizer:
																A_			:  str			=				self.sm.MosesTokenizer(lang=_lowerCamelCase     )
																A_			:  int			=				moses_tokenizer
											return self.cache_moses_tokenizer[lang].tokenize(
											    _lowerCamelCase				,			aggressive_dash_splits=_lowerCamelCase				,			return_str=_lowerCamelCase				,			escape=_lowerCamelCase     )







						def    _a     (  self   :							Optional[int]				,			_lowerCamelCase   :							str				,			_lowerCamelCase   :							List[str]     ):





											"""simple docstring"""







											if lang not in self.cache_moses_detokenizer:
																A_			:  Dict			=				self.sm.MosesDetokenizer(lang=_lowerCamelCase     )
																A_			:  Union[str, Any]			=				moses_detokenizer
											return self.cache_moses_detokenizer[lang].detokenize(_lowerCamelCase     )







						def    _a     (  self   :							List[str]				,			_lowerCamelCase   :							Optional[int]				,			_lowerCamelCase   :							Any     ):





											"""simple docstring"""







											A_			:  Dict			=				replace_unicode_punct(_lowerCamelCase     )
											A_			:  Any			=				self.moses_punct_norm(_lowerCamelCase				,			_lowerCamelCase     )
											A_			:  int			=				remove_non_printing_char(_lowerCamelCase     )
											return text







						@property
						def    _a     (  self   :							Tuple     ):





											"""simple docstring"""







											return len(self.encoder     )







						@property
						def    _a     (  self   :							int     ):





											"""simple docstring"""







											return len(self.decoder     )







						def    _a     (  self   :							int     ):





											"""simple docstring"""







											return dict(self.encoder				,			**self.added_tokens_encoder     )







						def    _a     (  self   :							Optional[Any]     ):





											"""simple docstring"""







											return dict(self.decoder				,			**self.added_tokens_decoder     )







						def    _a     (  self   :							Tuple				,			_lowerCamelCase   :							Dict     ):





											"""simple docstring"""







											A_			:  Union[str, Any]			=				tuple(token[:-1]     ) + (token[-1] + '''</w>''',)
											if token in self.cache:
																return self.cache[token]
											A_			:  str			=				get_pairs(_lowerCamelCase     )

											if not pairs:
																return token + "</w>"

											while True:
																A_			:  Tuple			=				min(_lowerCamelCase				,			key=lambda _lowerCamelCase     : self.bpe_ranks.get(_lowerCamelCase				,			float('''inf'''     )     )     )
																if bigram not in self.bpe_ranks:
																					break
																A_			,A_			:  Optional[int]			=				bigram
																A_			:  str			=				[]
																A_			:  int			=				0
																while i < len(_lowerCamelCase     ):
																					try:
																										A_			:  Any			=				word.index(_lowerCamelCase				,			_lowerCamelCase     )
																					except ValueError:
																										new_word.extend(word[i:]     )
																										break
																					else:
																										new_word.extend(word[i:j]     )
																										A_			:  List[Any]			=				j

																					if word[i] == first and i < len(_lowerCamelCase     ) - 1 and word[i + 1] == second:
																										new_word.append(first + second     )
																										i += 2
																					else:
																										new_word.append(word[i]     )
																										i += 1
																A_			:  Any			=				tuple(_lowerCamelCase     )
																A_			:  Dict			=				new_word
																if len(_lowerCamelCase     ) == 1:
																					break
																else:
																					A_			:  Any			=				get_pairs(_lowerCamelCase     )
											A_			:  str			=				''' '''.join(_lowerCamelCase     )
											if word == "\n  </w>":
																A_			:  Tuple			=				'''\n</w>'''
											A_			:  Tuple			=				word
											return word







						def    _a     (  self   :							str				,			_lowerCamelCase   :							List[Any]				,			_lowerCamelCase   :							Union[str, Any]="en"				,			_lowerCamelCase   :							List[Any]=False     ):





											"""simple docstring"""







											A_			:  Union[str, Any]			=				self.src_lang

											if self.do_lower_case:
																A_			:  Any			=				text.lower()

											if bypass_tokenizer:
																A_			:  Optional[Any]			=				text.split()
											else:
																A_			:  Optional[Any]			=				self.moses_pipeline(_lowerCamelCase				,			lang=_lowerCamelCase     )
																A_			:  str			=				self.moses_tokenize(_lowerCamelCase				,			lang=_lowerCamelCase     )

											A_			:  Dict			=				[]
											for token in text:
																if token:
																					split_tokens.extend(list(self.bpe(_lowerCamelCase     ).split(''' '''     )     )     )

											return split_tokens







						def    _a     (  self   :							Any				,			_lowerCamelCase   :							int     ):





											"""simple docstring"""







											return self.encoder.get(_lowerCamelCase				,			self.encoder.get(self.unk_token     )     )







						def    _a     (  self   :							int				,			_lowerCamelCase   :							Union[str, Any]     ):





											"""simple docstring"""







											return self.decoder.get(_lowerCamelCase				,			self.unk_token     )







						def    _a     (  self   :							Any				,			_lowerCamelCase   :							Any     ):





											"""simple docstring"""







											A_			:  Union[str, Any]			=				[t.replace(''' '''				,			''''''     ).replace('''</w>'''				,			''' '''     ) for t in tokens]
											A_			:  Optional[int]			=				''''''.join(_lowerCamelCase     ).split()
											# detokenize
											A_			:  Optional[Any]			=				self.moses_detokenize(_lowerCamelCase				,			self.tgt_lang     )
											return text







						def    _a     (  self   :							List[Any]				,			_lowerCamelCase   :							List[int]				,			_lowerCamelCase   :							Optional[List[int]] = None     ):





											"""simple docstring"""







											A_			:  Dict			=				[self.sep_token_id]

											# no bos used in fairseq
											if token_ids_a is None:
																return token_ids_a + sep
											return token_ids_a + sep + token_ids_a + sep







						def    _a     (  self   :							Tuple				,			_lowerCamelCase   :							List[int]				,			_lowerCamelCase   :							Optional[List[int]] = None				,			_lowerCamelCase   :							bool = False     ):





											"""simple docstring"""







											if already_has_special_tokens:
																return super().get_special_tokens_mask(
																    token_ids_a=_lowerCamelCase				,			token_ids_a=_lowerCamelCase				,			already_has_special_tokens=_lowerCamelCase     )
											# no bos used in fairseq
											if token_ids_a is not None:
																return ([0] * len(_lowerCamelCase     )) + [1] + ([0] * len(_lowerCamelCase     )) + [1]
											return ([0] * len(_lowerCamelCase     )) + [1]







						def    _a     (  self   :							Dict				,			_lowerCamelCase   :							List[int]				,			_lowerCamelCase   :							Optional[List[int]] = None     ):





											"""simple docstring"""







											A_			:  Any			=				[self.sep_token_id]

											# no bos used in fairseq
											if token_ids_a is None:
																return len(token_ids_a + sep     ) * [0]
											return len(token_ids_a + sep     ) * [0] + len(token_ids_a + sep     ) * [1]







						def    _a     (  self   :							List[Any]				,			_lowerCamelCase   :							str				,			_lowerCamelCase   :							Optional[str] = None     ):





											"""simple docstring"""







											if not os.path.isdir(_lowerCamelCase     ):
																logger.error(f'Vocabulary path ({save_directory}) should be a directory'     )
																return

											A_			:  str			=				os.path.join(
											    _lowerCamelCase				,			(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''src_vocab_file''']     )
											A_			:  Optional[Any]			=				os.path.join(
											    _lowerCamelCase				,			(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''tgt_vocab_file''']     )
											A_			:  List[Any]			=				os.path.join(
											    _lowerCamelCase				,			(filename_prefix + '''-''' if filename_prefix else '''''') + VOCAB_FILES_NAMES['''merges_file''']     )

											with open(_lowerCamelCase				,			'''w'''				,			encoding='''utf-8'''     ) as f:
																f.write(json.dumps(self.encoder				,			indent=2				,			sort_keys=_lowerCamelCase				,			ensure_ascii=_lowerCamelCase     ) + '''\n'''     )

											with open(_lowerCamelCase				,			'''w'''				,			encoding='''utf-8'''     ) as f:
																A_			:  List[str]			=				{v: k for k, v in self.decoder.items()}
																f.write(json.dumps(_lowerCamelCase				,			indent=2				,			sort_keys=_lowerCamelCase				,			ensure_ascii=_lowerCamelCase     ) + '''\n'''     )

											A_			:  List[str]			=				0
											with open(_lowerCamelCase				,			'''w'''				,			encoding='''utf-8'''     ) as writer:
																for bpe_tokens, token_index in sorted(self.bpe_ranks.items()				,			key=lambda _lowerCamelCase     : kv[1]     ):
																					if index != token_index:
																										logger.warning(
																										    f'Saving vocabulary to {merges_file}: BPE merge indices are not consecutive.'
																										    ''' Please check that the tokenizer is not corrupted!'''     )
																										A_			:  Union[str, Any]			=				token_index
																					writer.write(''' '''.join(_lowerCamelCase     ) + '''\n'''     )
																					index += 1

											return src_vocab_file, tgt_vocab_file, merges_file







						def __getstate__(  self   :							List[Any]     ):





											"""simple docstring"""







											A_			:  Dict			=				self.__dict__.copy()
											A_			:  Optional[int]			=				None
											return state







						def __setstate__(  self   :							List[str]				,			_lowerCamelCase   :							List[str]     ):





											"""simple docstring"""







											A_			:  List[Any]			=				d

											try:
																import sacremoses
											except ImportError:
																raise ImportError(
																    '''You need to install sacremoses to use XLMTokenizer. '''
																    '''See https://pypi.org/project/sacremoses/ for installation.'''     )

											A_			:  Union[str, Any]			=				sacremoses









'''simple docstring'''




import unittest

import numpy as np

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

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
							import torch

if is_vision_available():
							from PIL import Image

							from transformers import SwinaSRImageProcessor
							from transformers.image_transforms import get_image_size






class      UpperCamelCase_  (unittest.TestCase  ):







						"""simple docstring"""


						def __init__(  self   :							Tuple				,			_lowerCamelCase   :							str				,			_lowerCamelCase   :							str=7				,			_lowerCamelCase   :							Tuple=3				,			_lowerCamelCase   :							Any=18				,			_lowerCamelCase   :							Optional[int]=30				,			_lowerCamelCase   :							List[Any]=400				,			_lowerCamelCase   :							int=True				,			_lowerCamelCase   :							Dict=1 / 255				,			_lowerCamelCase   :							List[str]=True				,			_lowerCamelCase   :							Optional[int]=8				,			):





											"""simple docstring"""







											A_			:  Tuple			=				parent
											A_			:  str			=				batch_size
											A_			:  Optional[Any]			=				num_channels
											A_			:  Union[str, Any]			=				image_size
											A_			:  Optional[int]			=				min_resolution
											A_			:  List[Any]			=				max_resolution
											A_			:  int			=				do_rescale
											A_			:  Optional[Any]			=				rescale_factor
											A_			:  Any			=				do_pad
											A_			:  Tuple			=				pad_size







						def    _a     (  self   :							List[Any]     ):





											"""simple docstring"""







											return {
											    "do_rescale": self.do_rescale,
											    "rescale_factor": self.rescale_factor,
											    "do_pad": self.do_pad,
											    "pad_size": self.pad_size,
											}







						def    _a     (  self   :							Tuple				,			_lowerCamelCase   :							List[str]=False				,			_lowerCamelCase   :							Tuple=False				,			_lowerCamelCase   :							str=False     ):





											"""simple docstring"""







											assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

											if equal_resolution:
																A_			:  List[Any]			=				[]
																for i in range(self.batch_size     ):
																					image_inputs.append(
																					    np.random.randint(
																					        255				,			size=(self.num_channels, self.max_resolution, self.max_resolution)				,			dtype=np.uinta     )     )
											else:
																A_			:  List[Any]			=				[]
																for i in range(self.batch_size     ):
																					A_			,A_			:  List[str]			=				np.random.choice(np.arange(self.min_resolution				,			self.max_resolution     )				,			2     )
																					image_inputs.append(np.random.randint(255				,			size=(self.num_channels, width, height)				,			dtype=np.uinta     )     )

											if not numpify and not torchify:
																# PIL expects the channel dimension as last dimension
																A_			:  Any			=				[Image.fromarray(np.moveaxis(_lowerCamelCase				,			0				,			-1     )     ) for x in image_inputs]

											if torchify:
																A_			:  str			=				[torch.from_numpy(_lowerCamelCase     ) for x in image_inputs]

											return image_inputs






@require_torch
@require_vision
class      UpperCamelCase_  (a__,   unittest.TestCase  ):







						"""simple docstring"""


						_lowerCAmelCase         =       SwinaSRImageProcessor if is_vision_available() else None







						def    _a     (  self   :							List[str]     ):





											"""simple docstring"""







											A_			:  int			=				SwinaSRImageProcessingTester(self     )







						@property
						def    _a     (  self   :							Union[str, Any]     ):





											"""simple docstring"""







											return self.image_processor_tester.prepare_image_processor_dict()







						def    _a     (  self   :							Any     ):





											"""simple docstring"""







											A_			:  Optional[int]			=				self.image_processing_class(**self.image_processor_dict     )
											self.assertTrue(hasattr(_lowerCamelCase				,			'''do_rescale'''     )     )
											self.assertTrue(hasattr(_lowerCamelCase				,			'''rescale_factor'''     )     )
											self.assertTrue(hasattr(_lowerCamelCase				,			'''do_pad'''     )     )
											self.assertTrue(hasattr(_lowerCamelCase				,			'''pad_size'''     )     )







						def    _a     (  self   :							Tuple     ):





											"""simple docstring"""







											pass







						def    _a     (  self   :							Optional[int]				,			_lowerCamelCase   :							Optional[int]     ):





											"""simple docstring"""







											A_			,A_			:  Any			=				get_image_size(_lowerCamelCase     )
											A_			:  List[Any]			=				self.image_processor_tester.pad_size

											A_			:  Dict			=				(old_height // size + 1) * size - old_height
											A_			:  Optional[Any]			=				(old_width // size + 1) * size - old_width
											return old_height + pad_height, old_width + pad_width







						def    _a     (  self   :							int     ):





											"""simple docstring"""







											A_			:  Dict			=				self.image_processing_class(**self.image_processor_dict     )
											# create random PIL images
											A_			:  Optional[int]			=				self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase     )
											for image in image_inputs:
																self.assertIsInstance(_lowerCamelCase				,			Image.Image     )

											# Test not batched input
											A_			:  Any			=				image_processor(image_inputs[0]				,			return_tensors='''pt'''     ).pixel_values
											A_			,A_			:  List[Any]			=				self.calculate_expected_size(np.array(image_inputs[0]     )     )
											self.assertEqual(
											    encoded_images.shape				,			(
											        1,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )				,			)







						def    _a     (  self   :							Optional[Any]     ):





											"""simple docstring"""







											A_			:  Optional[Any]			=				self.image_processing_class(**self.image_processor_dict     )
											# create random numpy tensors
											A_			:  Dict			=				self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase				,			numpify=_lowerCamelCase     )
											for image in image_inputs:
																self.assertIsInstance(_lowerCamelCase				,			np.ndarray     )

											# Test not batched input
											A_			:  Union[str, Any]			=				image_processor(image_inputs[0]				,			return_tensors='''pt'''     ).pixel_values
											A_			,A_			:  Union[str, Any]			=				self.calculate_expected_size(image_inputs[0]     )
											self.assertEqual(
											    encoded_images.shape				,			(
											        1,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )				,			)







						def    _a     (  self   :							int     ):





											"""simple docstring"""







											A_			:  Union[str, Any]			=				self.image_processing_class(**self.image_processor_dict     )
											# create random PyTorch tensors
											A_			:  List[Any]			=				self.image_processor_tester.prepare_inputs(equal_resolution=_lowerCamelCase				,			torchify=_lowerCamelCase     )
											for image in image_inputs:
																self.assertIsInstance(_lowerCamelCase				,			torch.Tensor     )

											# Test not batched input
											A_			:  int			=				image_processor(image_inputs[0]				,			return_tensors='''pt'''     ).pixel_values
											A_			,A_			:  str			=				self.calculate_expected_size(image_inputs[0]     )
											self.assertEqual(
											    encoded_images.shape				,			(
											        1,
											        self.image_processor_tester.num_channels,
											        expected_height,
											        expected_width,
											    )				,			)



