
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						       =						{'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'}

__SCREAMING_SNAKE_CASE						       =						{
    '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						       =						{
    'unc-nlp/lxmert-base-uncased': 512,
}

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





class 							lowerCAmelCase_						(    lowercase__							):




			'''simple docstring'''


			_lowercase      =							VOCAB_FILES_NAMES
			_lowercase      =							PRETRAINED_VOCAB_FILES_MAP
			_lowercase      =							PRETRAINED_INIT_CONFIGURATION
			_lowercase      =							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			_lowercase      =							LxmertTokenizer







			def __init__(	self    ,							__UpperCAmelCase=None    ,							__UpperCAmelCase=None    ,							__UpperCAmelCase=True    ,							__UpperCAmelCase="[UNK]"    ,							__UpperCAmelCase="[SEP]"    ,							__UpperCAmelCase="[PAD]"    ,							__UpperCAmelCase="[CLS]"    ,							__UpperCAmelCase="[MASK]"    ,							__UpperCAmelCase=True    ,							__UpperCAmelCase=None    ,							**__UpperCAmelCase    ,							):
										super().__init__(
										    UpperCAmelCase__    ,							tokenizer_file=UpperCAmelCase__    ,							do_lower_case=UpperCAmelCase__    ,							unk_token=UpperCAmelCase__    ,							sep_token=UpperCAmelCase__    ,							pad_token=UpperCAmelCase__    ,							cls_token=UpperCAmelCase__    ,							mask_token=UpperCAmelCase__    ,							tokenize_chinese_chars=UpperCAmelCase__    ,							strip_accents=UpperCAmelCase__    ,							**UpperCAmelCase__    ,							)

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

										SCREAMING_SNAKE_CASE_	:							int											=do_lower_case







			def      __lowerCamelCase    (	self    ,							__UpperCAmelCase    ,							__UpperCAmelCase=None  ):
										SCREAMING_SNAKE_CASE_	:							Union[str, Any]											=[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      __lowerCamelCase    (	self    ,							__UpperCAmelCase    ,							__UpperCAmelCase = None  ):
										SCREAMING_SNAKE_CASE_	:							List[Any]											=[self.sep_token_id]
										SCREAMING_SNAKE_CASE_	:							List[str]											=[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      __lowerCamelCase    (	self    ,							__UpperCAmelCase    ,							__UpperCAmelCase = None  ):
										SCREAMING_SNAKE_CASE_	:							List[Any]											=self._tokenizer.model.save(UpperCAmelCase__    ,							name=UpperCAmelCase__  )
										return tuple(UpperCAmelCase__  )








'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCamelCase_    						=       {"""configuration_mbart""": ["""MBART_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MBartConfig""", """MBartOnnxConfig"""]}

try:
							if not is_sentencepiece_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCamelCase_    						=       ["""MBartTokenizer"""]

try:
							if not is_tokenizers_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCamelCase_    						=       ["""MBartTokenizerFast"""]

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCamelCase_    						=       [
							    """MBART_PRETRAINED_MODEL_ARCHIVE_LIST""",
							    """MBartForCausalLM""",
							    """MBartForConditionalGeneration""",
							    """MBartForQuestionAnswering""",
							    """MBartForSequenceClassification""",
							    """MBartModel""",
							    """MBartPreTrainedModel""",
							]

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCamelCase_    						=       [
							    """TFMBartForConditionalGeneration""",
							    """TFMBartModel""",
							    """TFMBartPreTrainedModel""",
							]

try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCamelCase_    						=       [
							    """FlaxMBartForConditionalGeneration""",
							    """FlaxMBartForQuestionAnswering""",
							    """FlaxMBartForSequenceClassification""",
							    """FlaxMBartModel""",
							    """FlaxMBartPreTrainedModel""",
							]


if TYPE_CHECKING:
							from .configuration_mbart import MBART_PRETRAINED_CONFIG_ARCHIVE_MAP, MBartConfig, MBartOnnxConfig

							try:
														if not is_sentencepiece_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_mbart import MBartTokenizer

							try:
														if not is_tokenizers_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_mbart_fast import MBartTokenizerFast

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_mbart import (
														    MBART_PRETRAINED_MODEL_ARCHIVE_LIST,
														    MBartForCausalLM,
														    MBartForConditionalGeneration,
														    MBartForQuestionAnswering,
														    MBartForSequenceClassification,
														    MBartModel,
														    MBartPreTrainedModel,
														)

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_mbart import TFMBartForConditionalGeneration, TFMBartModel, TFMBartPreTrainedModel

							try:
														if not is_flax_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_flax_mbart import (
														    FlaxMBartForConditionalGeneration,
														    FlaxMBartForQuestionAnswering,
														    FlaxMBartForSequenceClassification,
														    FlaxMBartModel,
														    FlaxMBartPreTrainedModel,
														)

else:
							import sys

							UpperCamelCase_    						=       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





