"""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


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

_A   					=    {
    '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'
        ),
    },
}

_A   					=    {
    'unc-nlp/lxmert-base-uncased': 5_1_2,
}

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

class lowerCamelCase		(_SCREAMING_SNAKE_CASE      ):






					'''simple docstring'''


					a   	=		VOCAB_FILES_NAMES
					a   	=		PRETRAINED_VOCAB_FILES_MAP
					a   	=		PRETRAINED_INIT_CONFIGURATION
					a   	=		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					a   	=		LxmertTokenizer



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

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

									SCREAMING_SNAKE_CASE__		  =				do_lower_case



					def 			lowerCAmelCase_					(						self			:				Optional[Any]   , _snake_case			:				List[str]   , _snake_case			:				str=None		)							->       Optional[Any]:
									SCREAMING_SNAKE_CASE__		  =				[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			:				str   , _snake_case			:				List[int]   , _snake_case			:				Optional[List[int]] = None		)							->       List[int]:
									SCREAMING_SNAKE_CASE__		  =				[self.sep_token_id]
									SCREAMING_SNAKE_CASE__		  =				[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			:				Optional[int]   , _snake_case			:				str   , _snake_case			:				Optional[str] = None		)							->       Tuple[str]:
									SCREAMING_SNAKE_CASE__		  =				self._tokenizer.model.save(_snake_case   , name=_snake_case		)
									return tuple(_snake_case		)





"""simple docstring"""






def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   List[str]:
				if not head:
								return True
				# split the list to two parts
				SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				head.next, head
				while fast and fast.next:
								SCREAMING_SNAKE_CASE__		  =				fast.next.next
								SCREAMING_SNAKE_CASE__		  =				slow.next
				SCREAMING_SNAKE_CASE__		  =				slow.next
				SCREAMING_SNAKE_CASE__		  =				None  # Don't forget here! But forget still works!
				# reverse the second part
				SCREAMING_SNAKE_CASE__		  =				None
				while second:
								SCREAMING_SNAKE_CASE__		  =				second.next
								SCREAMING_SNAKE_CASE__		  =				node
								SCREAMING_SNAKE_CASE__		  =				second
								SCREAMING_SNAKE_CASE__		  =				nxt
				# compare two parts
				# second part has the same or one less node
				while node:
								if node.val != head.val:
												return False
								SCREAMING_SNAKE_CASE__		  =				node.next
								SCREAMING_SNAKE_CASE__		  =				head.next
				return True




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   str:
				if not head or not head.next:
								return True

				# 1. Get the midpoint (slow)
				SCREAMING_SNAKE_CASE__		  =				SCREAMING_SNAKE_CASE__		  =				SCREAMING_SNAKE_CASE__		  =				head
				while fast and fast.next:
								SCREAMING_SNAKE_CASE__  ,       SCREAMING_SNAKE_CASE__		  =				fast.next.next, slow.next

				# 2. Push the second half into the stack
				SCREAMING_SNAKE_CASE__		  =				[slow.val]
				while slow.next:
								SCREAMING_SNAKE_CASE__		  =				slow.next
								stack.append(slow.val       )

				# 3. Comparison
				while stack:
								if stack.pop() != cur.val:
												return False
								SCREAMING_SNAKE_CASE__		  =				cur.next

				return True




def 						SCREAMING_SNAKE_CASE					(  __UpperCAmelCase       )							->   str:
				if not head or not head.next:
								return True
				SCREAMING_SNAKE_CASE__		  =				{}
				SCREAMING_SNAKE_CASE__		  =				0
				while head:
								if head.val in d:
												d[head.val].append(__UpperCAmelCase       )
								else:
												SCREAMING_SNAKE_CASE__		  =				[pos]
								SCREAMING_SNAKE_CASE__		  =				head.next
								pos += 1
				SCREAMING_SNAKE_CASE__		  =				pos - 1
				SCREAMING_SNAKE_CASE__		  =				0
				for v in d.values():
								if len(__UpperCAmelCase       ) % 2 != 0:
												middle += 1
								else:
												SCREAMING_SNAKE_CASE__		  =				0
												for i in range(0  ,					len(__UpperCAmelCase       )       ):
																if v[i] + v[len(__UpperCAmelCase       ) - 1 - step] != checksum:
																				return False
																step += 1
								if middle > 1:
												return False
				return True




