


"""simple docstring"""


import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_convbert import ConvBertTokenizer


UpperCamelCase						:				List[Any]             =    logging.get_logger(__name__)

UpperCamelCase						:				Union[str, Any]             =    {"vocab_file": "vocab.txt"}

UpperCamelCase						:				Any             =    {
    "vocab_file": {
        "YituTech/conv-bert-base": "https://huggingface.co/YituTech/conv-bert-base/resolve/main/vocab.txt",
        "YituTech/conv-bert-medium-small": (
            "https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/vocab.txt"
        ),
        "YituTech/conv-bert-small": "https://huggingface.co/YituTech/conv-bert-small/resolve/main/vocab.txt",
    }
}

UpperCamelCase						:				List[Any]             =    {
    "YituTech/conv-bert-base": 512,
    "YituTech/conv-bert-medium-small": 512,
    "YituTech/conv-bert-small": 512,
}


UpperCamelCase						:				Optional[int]             =    {
    "YituTech/conv-bert-base": {"do_lower_case": True},
    "YituTech/conv-bert-medium-small": {"do_lower_case": True},
    "YituTech/conv-bert-small": {"do_lower_case": True},
}



class 			lowerCamelCase__						(   UpperCAmelCase_			):
						lowerCAmelCase       =     VOCAB_FILES_NAMES
						lowerCAmelCase       =     PRETRAINED_VOCAB_FILES_MAP
						lowerCAmelCase       =     PRETRAINED_INIT_CONFIGURATION
						lowerCAmelCase       =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						lowerCAmelCase       =     ConvBertTokenizer







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

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

								A					       = do_lower_case







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









"""simple docstring"""


from dataclasses import dataclass, field
from typing import Tuple

from ..utils import cached_property, is_tf_available, logging, requires_backends
from .benchmark_args_utils import BenchmarkArguments


if is_tf_available():
	import tensorflow as tf


UpperCamelCase						:				Optional[Any]             =      logging.get_logger(__name__)



@dataclass
class 			lowerCamelCase__						(   UpperCAmelCase_			):
						lowerCAmelCase       =     [
						    """no_inference""",
						    """no_cuda""",
						    """no_tpu""",
						    """no_speed""",
						    """no_memory""",
						    """no_env_print""",
						    """no_multi_process""",
						]







						def __init__(							self   :    str			,			**_lowercase   :    Union[str, Any]		):
								for deprecated_arg in self.deprecated_args:
										if deprecated_arg in kwargs:
												A					       = deprecated_arg[3:]
												A					       = not kwargs.pop(_lowercase		)
												logger.warning(
												    f'{deprecated_arg} is depreciated. Please use --no-{positive_arg} or'
												    f' {positive_arg}={kwargs[positive_arg]}'		)
								A					       = kwargs.pop('tpu_name'			,			self.tpu_name		)
								A					       = kwargs.pop('device_idx'			,			self.device_idx		)
								A					       = kwargs.pop('eager_mode'			,			self.eager_mode		)
								A					       = kwargs.pop('use_xla'			,			self.use_xla		)
								super().__init__(**_lowercase		)

						lowerCAmelCase       =     field(
						    default=UpperCAmelCase_							,    metadata={"""help""": """Name of TPU"""}							,    )
						lowerCAmelCase       =     field(
						    default=0							,    metadata={"""help""": """CPU / GPU device index. Defaults to 0."""}							,    )
						lowerCAmelCase       =     field(default=UpperCAmelCase_							,    metadata={"""help""": """Benchmark models in eager model."""}			)
						lowerCAmelCase       =     field(
						    default=UpperCAmelCase_							,    metadata={
						        """help""": """Benchmark models using XLA JIT compilation. Note that `eager_model` has to be set to `False`."""
						    }							,    )







						@cached_property
						def __a						(							self   :    Optional[Any]		):
								requires_backends(self			,			['tf']		)
								A					       = None
								if self.tpu:
										try:
												if self.tpu_name:
														A					       = tf.distribute.cluster_resolver.TPUClusterResolver(self.tpu_name		)
												else:
														A					       = tf.distribute.cluster_resolver.TPUClusterResolver()
										except ValueError:
												A					       = None
								return tpu







						@cached_property
						def __a						(							self   :    Dict		):
								requires_backends(self			,			['tf']		)
								if self.is_tpu:
										tf.config.experimental_connect_to_cluster(self._setup_tpu		)
										tf.tpu.experimental.initialize_tpu_system(self._setup_tpu		)

										A					       = tf.distribute.TPUStrategy(self._setup_tpu		)
								else:
										# currently no multi gpu is allowed
										if self.is_gpu:
												# TODO: Currently only single GPU is supported
												tf.config.set_visible_devices(self.gpu_list[self.device_idx]			,			'GPU'		)
												A					       = tf.distribute.OneDeviceStrategy(device=f'/gpu:{self.device_idx}'		)
										else:
												tf.config.set_visible_devices([]			,			'GPU'		)  # disable GPU
												A					       = tf.distribute.OneDeviceStrategy(device=f'/cpu:{self.device_idx}'		)

								return strategy







						@property
						def __a						(							self   :    List[Any]		):
								requires_backends(self			,			['tf']		)
								return self._setup_tpu is not None







						@property
						def __a						(							self   :    Optional[Any]		):
								requires_backends(self			,			['tf']		)
								return self._setup_strategy







						@property
						def __a						(							self   :    str		):
								requires_backends(self			,			['tf']		)
								return tf.config.list_physical_devices('GPU'		)







						@property
						def __a						(							self   :    Any		):
								requires_backends(self			,			['tf']		)
								if self.cuda:
										return len(self.gpu_list		)
								return 0







						@property
						def __a						(							self   :    Dict		):
								return self.n_gpu > 0





