
"""simple docstring"""






import json
import os
from typing import TYPE_CHECKING, List, Optional, Tuple

import regex as re

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


if TYPE_CHECKING:
				from transformers.pipelines.conversational import Conversation

__UpperCAmelCase 					=    logging.get_logger(__name__)

__UpperCAmelCase 					=    {'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt'''}

__UpperCAmelCase 					=    {
    '''vocab_file''': {
        '''microsoft/deberta-base''': '''https://huggingface.co/microsoft/deberta-base/resolve/main/vocab.json''',
        '''microsoft/deberta-large''': '''https://huggingface.co/microsoft/deberta-large/resolve/main/vocab.json''',
        '''microsoft/deberta-xlarge''': '''https://huggingface.co/microsoft/deberta-xlarge/resolve/main/vocab.json''',
        '''microsoft/deberta-base-mnli''': '''https://huggingface.co/microsoft/deberta-base-mnli/resolve/main/vocab.json''',
        '''microsoft/deberta-large-mnli''': '''https://huggingface.co/microsoft/deberta-large-mnli/resolve/main/vocab.json''',
        '''microsoft/deberta-xlarge-mnli''': (
            '''https://huggingface.co/microsoft/deberta-xlarge-mnli/resolve/main/vocab.json'''
        ),
    },
    '''merges_file''': {
        '''microsoft/deberta-base''': '''https://huggingface.co/microsoft/deberta-base/resolve/main/merges.txt''',
        '''microsoft/deberta-large''': '''https://huggingface.co/microsoft/deberta-large/resolve/main/merges.txt''',
        '''microsoft/deberta-xlarge''': '''https://huggingface.co/microsoft/deberta-xlarge/resolve/main/merges.txt''',
        '''microsoft/deberta-base-mnli''': '''https://huggingface.co/microsoft/deberta-base-mnli/resolve/main/merges.txt''',
        '''microsoft/deberta-large-mnli''': '''https://huggingface.co/microsoft/deberta-large-mnli/resolve/main/merges.txt''',
        '''microsoft/deberta-xlarge-mnli''': (
            '''https://huggingface.co/microsoft/deberta-xlarge-mnli/resolve/main/merges.txt'''
        ),
    },
}

__UpperCAmelCase 					=    {
    '''microsoft/deberta-base''': 5_12,
    '''microsoft/deberta-large''': 5_12,
    '''microsoft/deberta-xlarge''': 5_12,
    '''microsoft/deberta-base-mnli''': 5_12,
    '''microsoft/deberta-large-mnli''': 5_12,
    '''microsoft/deberta-xlarge-mnli''': 5_12,
}

__UpperCAmelCase 					=    {
    '''microsoft/deberta-base''': {'''do_lower_case''': False},
    '''microsoft/deberta-large''': {'''do_lower_case''': False},
}






def 		_snake_case			(      )    ->							List[str]:


			'''simple docstring'''





			lowerCAmelCase_       :Union[str, Any]     	=    (
			    list(range(ord("""!"""						) ,	ord("""~"""						) + 1						)						) + list(range(ord("""¡"""						) ,	ord("""¬"""						) + 1						)						) + list(range(ord("""®"""						) ,	ord("""ÿ"""						) + 1						)						)
			)
			lowerCAmelCase_       :Union[str, Any]     	=    bs[:]
			lowerCAmelCase_       :Union[str, Any]     	=    0
			for b in range(2**8						):
						if b not in bs:
									bs.append(UpperCAmelCase__						)
									cs.append(2**8 + n						)
									n += 1
			lowerCAmelCase_       :str     	=    [chr(UpperCAmelCase__						) for n in cs]
			return dict(zip(UpperCAmelCase__ ,	UpperCAmelCase__						)						)






def 		_snake_case			(      lowercase__						:    Optional[int]						)    ->							List[str]:


			'''simple docstring'''





			lowerCAmelCase_       :List[Any]     	=    set()
			lowerCAmelCase_       :List[Any]     	=    word[0]
			for char in word[1:]:
						pairs.add((prev_char, char)						)
						lowerCAmelCase_       :Optional[int]     	=    char
			return pairs




class      _SCREAMING_SNAKE_CASE   (     UpperCAmelCase__				):
			UpperCAmelCase_    :List[Any]												=		VOCAB_FILES_NAMES
			UpperCAmelCase_    :Union[str, Any]												=		PRETRAINED_VOCAB_FILES_MAP
			UpperCAmelCase_    :Tuple												=		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
			UpperCAmelCase_    :Dict												=		["input_ids", "attention_mask", "token_type_ids"]






			def __init__(   self			,  __A			,  __A			,  __A="replace"			,  __A="[CLS]"			,  __A="[SEP]"			,  __A="[SEP]"			,  __A="[CLS]"			,  __A="[UNK]"			,  __A="[PAD]"			,  __A="[MASK]"			,  __A=False			,  __A=False			,  **__A			,  )     ->	Dict:
						lowerCAmelCase_       :str     	=    AddedToken(__lowerCAmelCase			,  lstrip=__lowerCAmelCase			,  rstrip=__lowerCAmelCase			) if isinstance(__lowerCAmelCase			,  __lowerCAmelCase			) else bos_token
						lowerCAmelCase_       :Tuple     	=    AddedToken(__lowerCAmelCase			,  lstrip=__lowerCAmelCase			,  rstrip=__lowerCAmelCase			) if isinstance(__lowerCAmelCase			,  __lowerCAmelCase			) else eos_token
						lowerCAmelCase_       :List[Any]     	=    AddedToken(__lowerCAmelCase			,  lstrip=__lowerCAmelCase			,  rstrip=__lowerCAmelCase			) if isinstance(__lowerCAmelCase			,  __lowerCAmelCase			) else sep_token
						lowerCAmelCase_       :Any     	=    AddedToken(__lowerCAmelCase			,  lstrip=__lowerCAmelCase			,  rstrip=__lowerCAmelCase			) if isinstance(__lowerCAmelCase			,  __lowerCAmelCase			) else cls_token
						lowerCAmelCase_       :str     	=    AddedToken(__lowerCAmelCase			,  lstrip=__lowerCAmelCase			,  rstrip=__lowerCAmelCase			) if isinstance(__lowerCAmelCase			,  __lowerCAmelCase			) else unk_token
						lowerCAmelCase_       :int     	=    AddedToken(__lowerCAmelCase			,  lstrip=__lowerCAmelCase			,  rstrip=__lowerCAmelCase			) if isinstance(__lowerCAmelCase			,  __lowerCAmelCase			) else pad_token

						# Mask token behave like a normal word, i.e. include the space before it
						lowerCAmelCase_       :str     	=    AddedToken(__lowerCAmelCase			,  lstrip=__lowerCAmelCase			,  rstrip=__lowerCAmelCase			) if isinstance(__lowerCAmelCase			,  __lowerCAmelCase			) else mask_token

						super().__init__(
						    errors=__lowerCAmelCase			,  bos_token=__lowerCAmelCase			,  eos_token=__lowerCAmelCase			,  unk_token=__lowerCAmelCase			,  sep_token=__lowerCAmelCase			,  cls_token=__lowerCAmelCase			,  pad_token=__lowerCAmelCase			,  mask_token=__lowerCAmelCase			,  add_prefix_space=__lowerCAmelCase			,  add_bos_token=__lowerCAmelCase			,  **__lowerCAmelCase			,  )
						lowerCAmelCase_       :List[str]     	=    add_bos_token

						with open(__lowerCAmelCase			,  encoding="""utf-8"""			) as vocab_handle:
									lowerCAmelCase_       :str     	=    json.load(__lowerCAmelCase			)
						lowerCAmelCase_       :Tuple     	=    {v: k for k, v in self.encoder.items()}
						lowerCAmelCase_       :List[Any]     	=    errors  # how to handle errors in decoding
						lowerCAmelCase_       :Tuple     	=    bytes_to_unicode()
						lowerCAmelCase_       :Tuple     	=    {v: k for k, v in self.byte_encoder.items()}
						with open(__lowerCAmelCase			,  encoding="""utf-8"""			) as merges_handle:
									lowerCAmelCase_       :Optional[int]     	=    merges_handle.read().split("""\n"""			)[1:-1]
						lowerCAmelCase_       :Optional[int]     	=    [tuple(merge.split()			) for merge in bpe_merges]
						lowerCAmelCase_       :List[Any]     	=    dict(zip(__lowerCAmelCase			,  range(len(__lowerCAmelCase			)			)			)			)
						lowerCAmelCase_       :Any     	=    {}
						lowerCAmelCase_       :Union[str, Any]     	=    add_prefix_space

						# Should have added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
						lowerCAmelCase_       :List[str]     	=    re.compile(r"""'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+"""			)






			@property
			# Copied from transformers.models.gpt2.tokenization_gpt2.GPT2Tokenizer.vocab_size
			def 					__lowerCAmelCase					(   self			)     ->	int:
						return len(self.encoder			)






			def 					__lowerCAmelCase					(   self			)     ->	str:
						return dict(self.encoder			,  **self.added_tokens_encoder			)






			def 					__lowerCAmelCase					(   self			,  __A			)     ->	List[Any]:






						if token in self.cache:
									return self.cache[token]
						lowerCAmelCase_       :Union[str, Any]     	=    tuple(__lowerCAmelCase			)
						lowerCAmelCase_       :Dict     	=    get_pairs(__lowerCAmelCase			)

						if not pairs:
									return token

						while True:
									lowerCAmelCase_       :List[str]     	=    min(__lowerCAmelCase			,  key=lambda __A			: self.bpe_ranks.get(__lowerCAmelCase			,  float("""inf"""			)			)			)
									if bigram not in self.bpe_ranks:
												break
									lowerCAmelCase_	,			lowerCAmelCase_       :Any     	=    bigram
									lowerCAmelCase_       :List[str]     	=    []
									lowerCAmelCase_       :List[str]     	=    0
									while i < len(__lowerCAmelCase			):
												try:
															lowerCAmelCase_       :Optional[int]     	=    word.index(__lowerCAmelCase			,  __lowerCAmelCase			)
												except ValueError:
															new_word.extend(word[i:]			)
															break
												else:
															new_word.extend(word[i:j]			)
															lowerCAmelCase_       :Dict     	=    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
									lowerCAmelCase_       :Union[str, Any]     	=    tuple(__lowerCAmelCase			)
									lowerCAmelCase_       :Any     	=    new_word
									if len(__lowerCAmelCase			) == 1:
												break
									else:
												lowerCAmelCase_       :Any     	=    get_pairs(__lowerCAmelCase			)
						lowerCAmelCase_       :Union[str, Any]     	=    """ """.join(__lowerCAmelCase			)
						lowerCAmelCase_       :int     	=    word
						return word






			def 					__lowerCAmelCase					(   self			,  __A			,  __A = None			)     ->	List[int]:






						if token_ids_a is None:
									return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
						lowerCAmelCase_       :Optional[int]     	=    [self.cls_token_id]
						lowerCAmelCase_       :Optional[int]     	=    [self.sep_token_id]
						return cls + token_ids_a + sep + token_ids_a + sep






			def 					__lowerCAmelCase					(   self			,  __A			,  __A = None			,  __A = False			)     ->	List[int]:






						if already_has_special_tokens:
									return super().get_special_tokens_mask(
									    token_ids_a=__lowerCAmelCase			,  token_ids_a=__lowerCAmelCase			,  already_has_special_tokens=__lowerCAmelCase			)

						if token_ids_a is None:
									return [1] + ([0] * len(__lowerCAmelCase			)) + [1]
						return [1] + ([0] * len(__lowerCAmelCase			)) + [1] + ([0] * len(__lowerCAmelCase			)) + [1]






			def 					__lowerCAmelCase					(   self			,  __A			,  __A = None			)     ->	List[int]:
						lowerCAmelCase_       :Optional[int]     	=    [self.sep_token_id]
						lowerCAmelCase_       :Optional[Any]     	=    [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			,  __A			)     ->	List[Any]:
						lowerCAmelCase_       :List[str]     	=    []
						for token in re.findall(self.pat			,  __lowerCAmelCase			):
									lowerCAmelCase_       :Tuple     	=    """""".join(
									    self.byte_encoder[b] for b in token.encode("""utf-8"""			)			)  # Maps all our bytes to unicode strings, avoiding control tokens of the BPE (spaces in our case)
									bpe_tokens.extend(bpe_token for bpe_token in self.bpe(__lowerCAmelCase			).split(""" """			)			)
						return bpe_tokens






			def 					__lowerCAmelCase					(   self			,  __A			)     ->	Optional[int]:
						return self.encoder.get(__lowerCAmelCase			,  self.encoder.get(self.unk_token			)			)






			def 					__lowerCAmelCase					(   self			,  __A			)     ->	Union[str, Any]:
						return self.decoder.get(__lowerCAmelCase			)






			def 					__lowerCAmelCase					(   self			,  __A			)     ->	str:
						lowerCAmelCase_       :Optional[Any]     	=    """""".join(__lowerCAmelCase			)
						lowerCAmelCase_       :Optional[Any]     	=    bytearray([self.byte_decoder[c] for c in text]			).decode("""utf-8"""			,  errors=self.errors			)
						return text






			def 					__lowerCAmelCase					(   self			,  __A			,  __A = None			)     ->	Tuple[str]:






						if not os.path.isdir(__lowerCAmelCase			):
									logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""			)
									return
						lowerCAmelCase_       :int     	=    os.path.join(
						    __lowerCAmelCase			,  (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]			)
						lowerCAmelCase_       :Tuple     	=    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"""			)

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

						return vocab_file, merge_file






			def 					__lowerCAmelCase					(   self			,  __A			,  __A=False			,  **__A			)     ->	Union[str, Any]:
						lowerCAmelCase_       :Optional[Any]     	=    kwargs.pop("""add_prefix_space"""			,  self.add_prefix_space			)
						if (is_split_into_words or add_prefix_space) and (len(__lowerCAmelCase			) > 0 and not text[0].isspace()):
									lowerCAmelCase_       :Optional[Any]     	=    """ """ + text
						return (text, kwargs)






			def 					__lowerCAmelCase					(   self			,  __A			)     ->	List[int]:
						lowerCAmelCase_       :List[str]     	=    []
						for is_user, text in conversation.iter_texts():
									input_ids.extend(self.encode(__lowerCAmelCase			,  add_special_tokens=__lowerCAmelCase			) + [self.eos_token_id]			)
						if len(__lowerCAmelCase			) > self.model_max_length:
									lowerCAmelCase_       :int     	=    input_ids[-self.model_max_length :]
						return input_ids











from collections import Counter


def 						UpperCAmelCase__   (   UpperCAmelCase__			:list[int]       ):






 '''simple docstring'''

 return sum(socks_by_color // 2 for socks_by_color in Counter(UpperCAmelCase__       ).values()       )


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     A_		:  List[str]										=  [int(x) for x in input('''Enter socks by color :''').rstrip().split()]
     print(F"""sock_merchant({colors}) = {sock_merchant(colors)}""")

