



'''simple docstring'''




import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

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


UpperCamelCase__       :	str    = {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

UpperCamelCase__       :	int    = {
    '''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'''
        ),
    },
}

UpperCamelCase__       :	Tuple    = {
    '''unc-nlp/lxmert-base-uncased''': 5_12,
}

UpperCamelCase__       :	Dict    = {
    '''unc-nlp/lxmert-base-uncased''': {'''do_lower_case''': True},
}






class 						_UpperCamelCase  (							lowerCamelCase__    ):


			'''simple docstring'''

			_A      :		List[str]			    =		VOCAB_FILES_NAMES
			_A      :		Dict			    =		PRETRAINED_VOCAB_FILES_MAP
			_A      :		List[Any]			    =		PRETRAINED_INIT_CONFIGURATION
			_A      :		Dict			    =		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			_A      :		int			    =		LxmertTokenizer

			def __init__(							self     : List[str]							,     lowerCAmelCase__     : Union[str, Any]=None							,     lowerCAmelCase__     : Tuple=None							,     lowerCAmelCase__     : Optional[int]=True							,     lowerCAmelCase__     : Optional[Any]="[UNK]"							,     lowerCAmelCase__     : str="[SEP]"							,     lowerCAmelCase__     : Optional[int]="[PAD]"							,     lowerCAmelCase__     : Tuple="[CLS]"							,     lowerCAmelCase__     : str="[MASK]"							,     lowerCAmelCase__     : Optional[int]=True							,     lowerCAmelCase__     : str=None							,     **lowerCAmelCase__     : Tuple							,     ):





					"""simple docstring"""






					super().__init__(
					    lowerCAmelCase__							,     tokenizer_file=lowerCAmelCase__							,     do_lower_case=lowerCAmelCase__							,     unk_token=lowerCAmelCase__							,     sep_token=lowerCAmelCase__							,     pad_token=lowerCAmelCase__							,     cls_token=lowerCAmelCase__							,     mask_token=lowerCAmelCase__							,     tokenize_chinese_chars=lowerCAmelCase__							,     strip_accents=lowerCAmelCase__							,     **lowerCAmelCase__							,     )

					__SCREAMING_SNAKE_CASE       :		List[Any]           =		json.loads(self.backend_tokenizer.normalizer.__getstate__()						)
					if (
					    normalizer_state.get("""lowercase"""							,     lowerCAmelCase__						) != do_lower_case
					    or normalizer_state.get("""strip_accents"""							,     lowerCAmelCase__						) != strip_accents
					    or normalizer_state.get("""handle_chinese_chars"""							,     lowerCAmelCase__						) != tokenize_chinese_chars
					):
							__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		getattr(lowerCAmelCase__							,     normalizer_state.pop("""type"""						)						)
							__SCREAMING_SNAKE_CASE       :		Tuple           =		do_lower_case
							__SCREAMING_SNAKE_CASE       :		Tuple           =		strip_accents
							__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		tokenize_chinese_chars
							__SCREAMING_SNAKE_CASE       :		List[str]           =		normalizer_class(**lowerCAmelCase__						)

					__SCREAMING_SNAKE_CASE       :		str           =		do_lower_case

			def UpperCamelCase__					(							self     : Optional[Any]							,     lowerCAmelCase__     : List[Any]							,     lowerCAmelCase__     : Tuple=None						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		str           =		[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 UpperCamelCase__					(							self     : Optional[Any]							,     lowerCAmelCase__     : List[int]							,     lowerCAmelCase__     : Optional[List[int]] = None						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		Dict           =		[self.sep_token_id]
					__SCREAMING_SNAKE_CASE       :		Dict           =		[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 UpperCamelCase__					(							self     : Dict							,     lowerCAmelCase__     : str							,     lowerCAmelCase__     : Optional[str] = None						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		List[Any]           =		self._tokenizer.model.save(lowerCAmelCase__							,     name=lowerCAmelCase__						)
					return tuple(lowerCAmelCase__						)




'''simple docstring'''




# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse

from ...utils.dataclasses import (
    ComputeEnvironment,
    DistributedType,
    DynamoBackend,
    PrecisionType,
    SageMakerDistributedType,
)
from ..menu import BulletMenu


UpperCamelCase__       :	List[Any]    = [
    '''EAGER''',
    '''AOT_EAGER''',
    '''INDUCTOR''',
    '''NVFUSER''',
    '''AOT_NVFUSER''',
    '''AOT_CUDAGRAPHS''',
    '''OFI''',
    '''FX2TRT''',
    '''ONNXRT''',
    '''IPEX''',
]


def 				lowerCAmelCase_   (	_lowerCamelCase:   str       ,      _lowerCamelCase:   Union[str, Any]=None       ,      _lowerCamelCase:   Optional[int]=None       ,      _lowerCamelCase:   str=None					):
		__SCREAMING_SNAKE_CASE       :		Optional[int]           =		True
		while ask_again:
				__SCREAMING_SNAKE_CASE       :		Tuple           =		input(_lowerCamelCase					)
				try:
						if default is not None and len(_lowerCamelCase					) == 0:
								return default
						return convert_value(_lowerCamelCase					) if convert_value is not None else result
				except Exception:
						if error_message is not None:
								print(_lowerCamelCase					)


def 				lowerCAmelCase_   (	_lowerCamelCase:   Tuple       ,      _lowerCamelCase:   Union[str, Any]=[]       ,      _lowerCamelCase:   List[Any]=None       ,      _lowerCamelCase:   Optional[Any]=0					):
		__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		BulletMenu(_lowerCamelCase       ,      _lowerCamelCase					)
		__SCREAMING_SNAKE_CASE       :		Dict           =		menu.run(default_choice=_lowerCamelCase					)
		return convert_value(_lowerCamelCase					) if convert_value is not None else result


def 				lowerCAmelCase_   (	_lowerCamelCase:   Optional[Any]					):
		__SCREAMING_SNAKE_CASE       :		List[str]           =		int(_lowerCamelCase					)
		return ComputeEnvironment(["""LOCAL_MACHINE""", """AMAZON_SAGEMAKER"""][value]					)


def 				lowerCAmelCase_   (	_lowerCamelCase:   Any					):
		__SCREAMING_SNAKE_CASE       :		str           =		int(_lowerCamelCase					)
		return DistributedType(["""NO""", """MULTI_CPU""", """MULTI_XPU""", """MULTI_GPU""", """MULTI_NPU""", """TPU"""][value]					)


def 				lowerCAmelCase_   (	_lowerCamelCase:   Tuple					):
		__SCREAMING_SNAKE_CASE       :		Tuple           =		int(_lowerCamelCase					)
		return DynamoBackend(DYNAMO_BACKENDS[value]					).value


def 				lowerCAmelCase_   (	_lowerCamelCase:   Union[str, Any]					):
		__SCREAMING_SNAKE_CASE       :		List[str]           =		int(_lowerCamelCase					)
		return PrecisionType(["""no""", """fp16""", """bf16""", """fp8"""][value]					)


def 				lowerCAmelCase_   (	_lowerCamelCase:   Tuple					):
		__SCREAMING_SNAKE_CASE       :		int           =		int(_lowerCamelCase					)
		return SageMakerDistributedType(["""NO""", """DATA_PARALLEL""", """MODEL_PARALLEL"""][value]					)


def 				lowerCAmelCase_   (	_lowerCamelCase:   List[Any]					):
		return {"yes": True, "no": False}[value.lower()]






class 						_UpperCamelCase  (							argparse.RawDescriptionHelpFormatter    ):


			'''simple docstring'''

			def UpperCamelCase__					(							self     : Tuple							,     lowerCAmelCase__     : Optional[Any]							,     lowerCAmelCase__     : Dict							,     lowerCAmelCase__     : List[Any]							,     lowerCAmelCase__     : List[Any]						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		super()._format_usage(lowerCAmelCase__							,     lowerCAmelCase__							,     lowerCAmelCase__							,     lowerCAmelCase__						)
					__SCREAMING_SNAKE_CASE       :		Any           =		usage.replace("""<command> [<args>] """							,     """"""						)
					return usage