
import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


SCREAMING_SNAKE_CASE__   :			Tuple												=    {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

SCREAMING_SNAKE_CASE__   :			Tuple												=    {
    "vocab_file": {
        "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt",
    },
    "tokenizer_file": {
        "unc-nlp/lxmert-base-uncased": (
            "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json"
        ),
    },
}

SCREAMING_SNAKE_CASE__   :			str												=    {
    "unc-nlp/lxmert-base-uncased": 512,
}

SCREAMING_SNAKE_CASE__   :			Dict												=    {
    "unc-nlp/lxmert-base-uncased": {"do_lower_case": True},
}

class    lowerCAmelCase__     (	__lowercase			):
		a__       :						Any        =		VOCAB_FILES_NAMES
		a__       :						List[str]        =		PRETRAINED_VOCAB_FILES_MAP
		a__       :						Dict        =		PRETRAINED_INIT_CONFIGURATION
		a__       :						Optional[Any]        =		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
		a__       :						Optional[int]        =		LxmertTokenizer






		def __init__(		self		:							Optional[Any]							,			SCREAMING_SNAKE_CASE__		:							str=None							,			SCREAMING_SNAKE_CASE__		:							int=None							,			SCREAMING_SNAKE_CASE__		:							int=True							,			SCREAMING_SNAKE_CASE__		:							Any="[UNK]"							,			SCREAMING_SNAKE_CASE__		:							List[Any]="[SEP]"							,			SCREAMING_SNAKE_CASE__		:							Union[str, Any]="[PAD]"							,			SCREAMING_SNAKE_CASE__		:							str="[CLS]"							,			SCREAMING_SNAKE_CASE__		:							int="[MASK]"							,			SCREAMING_SNAKE_CASE__		:							Union[str, Any]=True							,			SCREAMING_SNAKE_CASE__		:							int=None							,			**SCREAMING_SNAKE_CASE__		:							int							,			)     ->							List[str]:
						super().__init__(
						    SCREAMING_SNAKE_CASE__							,			tokenizer_file=SCREAMING_SNAKE_CASE__							,			do_lower_case=SCREAMING_SNAKE_CASE__							,			unk_token=SCREAMING_SNAKE_CASE__							,			sep_token=SCREAMING_SNAKE_CASE__							,			pad_token=SCREAMING_SNAKE_CASE__							,			cls_token=SCREAMING_SNAKE_CASE__							,			mask_token=SCREAMING_SNAKE_CASE__							,			tokenize_chinese_chars=SCREAMING_SNAKE_CASE__							,			strip_accents=SCREAMING_SNAKE_CASE__							,			**SCREAMING_SNAKE_CASE__							,			)

						__lowerCamelCase    					=	json.loads(self.backend_tokenizer.normalizer.__getstate__()  )
						if (
						    normalizer_state.get('''lowercase'''							,			SCREAMING_SNAKE_CASE__  ) != do_lower_case
						    or normalizer_state.get('''strip_accents'''							,			SCREAMING_SNAKE_CASE__  ) != strip_accents
						    or normalizer_state.get('''handle_chinese_chars'''							,			SCREAMING_SNAKE_CASE__  ) != tokenize_chinese_chars
						):
										__lowerCamelCase    					=	getattr(SCREAMING_SNAKE_CASE__							,			normalizer_state.pop('''type'''  )  )
										__lowerCamelCase    					=	do_lower_case
										__lowerCamelCase    					=	strip_accents
										__lowerCamelCase    					=	tokenize_chinese_chars
										__lowerCamelCase    					=	normalizer_class(**SCREAMING_SNAKE_CASE__  )

						__lowerCamelCase    					=	do_lower_case






		def  __A       (		self		:							Any							,			SCREAMING_SNAKE_CASE__		:							Optional[Any]							,			SCREAMING_SNAKE_CASE__		:							List[Any]=None  )     ->							str:
						__lowerCamelCase    					=	[self.cls_token_id] + token_ids_a + [self.sep_token_id]

						if token_ids_a:
										output += token_ids_a + [self.sep_token_id]

						return output






		def  __A       (		self		:							str							,			SCREAMING_SNAKE_CASE__		:							List[int]							,			SCREAMING_SNAKE_CASE__		:							Optional[List[int]] = None  )     ->							List[int]:
						__lowerCamelCase    					=	[self.sep_token_id]
						__lowerCamelCase    					=	[self.cls_token_id]
						if token_ids_a is None:
										return len(cls + token_ids_a + sep  ) * [0]
						return len(cls + token_ids_a + sep  ) * [0] + len(token_ids_a + sep  ) * [1]







		def  __A       (		self		:							Optional[Any]							,			SCREAMING_SNAKE_CASE__		:							str							,			SCREAMING_SNAKE_CASE__		:							Optional[str] = None  )     ->							Tuple[str]:
						__lowerCamelCase    					=	self._tokenizer.model.save(SCREAMING_SNAKE_CASE__							,			name=SCREAMING_SNAKE_CASE__  )
						return tuple(SCREAMING_SNAKE_CASE__  )





import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey

class    lowerCAmelCase__     :






		def __init__(		self		:							Any							,			SCREAMING_SNAKE_CASE__		:							List[str]							,			SCREAMING_SNAKE_CASE__		:							int							,			SCREAMING_SNAKE_CASE__		:							int  )     ->							Dict:
						if dst_width < 0 or dst_height < 0:
										raise ValueError('''Destination width/height should be > 0'''  )

						__lowerCamelCase    					=	img
						__lowerCamelCase    					=	img.shape[1]
						__lowerCamelCase    					=	img.shape[0]
						__lowerCamelCase    					=	dst_width
						__lowerCamelCase    					=	dst_height

						__lowerCamelCase    					=	self.src_w / self.dst_w
						__lowerCamelCase    					=	self.src_h / self.dst_h

						__lowerCamelCase    					=	__lowerCamelCase    					=	(
						    np.ones((self.dst_h, self.dst_w, 3)							,			np.uinta  ) * 2_55
						)






		def  __A       (		self		:							List[Any]  )     ->							str:
						for i in range(self.dst_h  ):
										for j in range(self.dst_w  ):
														__lowerCamelCase    					=	self.img[self.get_y(SCREAMING_SNAKE_CASE__  )][self.get_x(SCREAMING_SNAKE_CASE__  )]






		def  __A       (		self		:							str							,			SCREAMING_SNAKE_CASE__		:							int  )     ->							int:
						return int(self.ratio_x * x  )







		def  __A       (		self		:							str							,			SCREAMING_SNAKE_CASE__		:							int  )     ->							int:
						return int(self.ratio_y * y  )


if __name__ == "__main__":
					SCREAMING_SNAKE_CASE__							,    SCREAMING_SNAKE_CASE__   :			List[str]												=    800, 600
					SCREAMING_SNAKE_CASE__   :			int												=    imread("image_data/lena.jpg", 1)
					SCREAMING_SNAKE_CASE__   :			Union[str, Any]												=    NearestNeighbour(im, dst_w, dst_h)
					n.process()

					imshow(
					    F'Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}', n.output
					)
					waitKey(0)
					destroyAllWindows()



