


from typing import Optional

import torch
import torch.utils.checkpoint
from torch import Tensor, nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_outputs import (
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import logging
from .configuration_regnet import RegNetConfig


__UpperCAmelCase : Dict 			=				logging.get_logger(__name__)

# General docstring
__UpperCAmelCase : int 			=				'RegNetConfig'

# Base docstring
__UpperCAmelCase : Optional[int] 			=				'facebook/regnet-y-040'
__UpperCAmelCase : Dict 			=				[1, 1088, 7, 7]

# Image classification docstring
__UpperCAmelCase : Any 			=				'facebook/regnet-y-040'
__UpperCAmelCase : Dict 			=				'tabby, tabby cat'

__UpperCAmelCase : int 			=				[
    'facebook/regnet-y-040',
    # See all regnet models at https://huggingface.co/models?filter=regnet
]



class    UpperCAmelCase_	(							nn.Module):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = 3 ,					__SCREAMING_SNAKE_CASE = 1 ,					__SCREAMING_SNAKE_CASE = 1 ,					__SCREAMING_SNAKE_CASE = "relu" ,					):




              """simple docstring"""




              super().__init__()
              a_    :	Tuple   	=		nn.Convad(
                  UpperCAmelCase__ ,					UpperCAmelCase__ ,					kernel_size=UpperCAmelCase__ ,					stride=UpperCAmelCase__ ,					padding=kernel_size // 2 ,					groups=UpperCAmelCase__ ,					bias=UpperCAmelCase__ ,					)
              a_    :	Dict   	=		nn.BatchNormad(UpperCAmelCase__						)
              a_    :	Union[str, Any]   	=		ACTaFN[activation] if activation is not None else nn.Identity()






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              a_    :	Optional[int]   	=		self.convolution(UpperCAmelCase__						)
              a_    :	Tuple   	=		self.normalization(UpperCAmelCase__						)
              a_    :	Optional[int]   	=		self.activation(UpperCAmelCase__						)
              return hidden_state




class    UpperCAmelCase_	(							nn.Module):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              super().__init__()
              a_    :	Tuple   	=		RegNetConvLayer(
                  config.num_channels ,					config.embedding_size ,					kernel_size=3 ,					stride=2 ,					activation=config.hidden_act						)
              a_    :	Optional[int]   	=		config.num_channels






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              a_    :	Tuple   	=		pixel_values.shape[1]
              if num_channels != self.num_channels:
                     raise ValueError(
                         '''Make sure that the channel dimension of the pixel values match with the one set in the configuration.'''						)
              a_    :	str   	=		self.embedder(UpperCAmelCase__						)
              return hidden_state




class    UpperCAmelCase_	(							nn.Module):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = 2						):




              """simple docstring"""




              super().__init__()
              a_    :	Optional[int]   	=		nn.Convad(UpperCAmelCase__ ,					UpperCAmelCase__ ,					kernel_size=1 ,					stride=UpperCAmelCase__ ,					bias=UpperCAmelCase__						)
              a_    :	str   	=		nn.BatchNormad(UpperCAmelCase__						)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              a_    :	int   	=		self.convolution(UpperCAmelCase__						)
              a_    :	List[Any]   	=		self.normalization(UpperCAmelCase__						)
              return hidden_state




class    UpperCAmelCase_	(							nn.Module):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              super().__init__()

              a_    :	Dict   	=		nn.AdaptiveAvgPoolad((1, 1)						)
              a_    :	Union[str, Any]   	=		nn.Sequential(
                  nn.Convad(UpperCAmelCase__ ,					UpperCAmelCase__ ,					kernel_size=1						) ,					nn.ReLU() ,					nn.Convad(UpperCAmelCase__ ,					UpperCAmelCase__ ,					kernel_size=1						) ,					nn.Sigmoid() ,					)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              a_    :	Tuple   	=		self.pooler(UpperCAmelCase__						)
              a_    :	str   	=		self.attention(UpperCAmelCase__						)
              a_    :	Tuple   	=		hidden_state * attention
              return hidden_state




class    UpperCAmelCase_	(							nn.Module):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = 1						):




              """simple docstring"""




              super().__init__()
              a_    :	str   	=		in_channels != out_channels or stride != 1
              a_    :	str   	=		max(1 ,					out_channels // config.groups_width						)
              a_    :	Dict   	=		(
                  RegNetShortCut(UpperCAmelCase__ ,					UpperCAmelCase__ ,					stride=UpperCAmelCase__						) if should_apply_shortcut else nn.Identity()
              )
              a_    :	Dict   	=		nn.Sequential(
                  RegNetConvLayer(UpperCAmelCase__ ,					UpperCAmelCase__ ,					kernel_size=1 ,					activation=config.hidden_act						) ,					RegNetConvLayer(UpperCAmelCase__ ,					UpperCAmelCase__ ,					stride=UpperCAmelCase__ ,					groups=UpperCAmelCase__ ,					activation=config.hidden_act						) ,					RegNetConvLayer(UpperCAmelCase__ ,					UpperCAmelCase__ ,					kernel_size=1 ,					activation=UpperCAmelCase__						) ,					)
              a_    :	Optional[int]   	=		ACTaFN[config.hidden_act]






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              a_    :	str   	=		hidden_state
              a_    :	int   	=		self.layer(UpperCAmelCase__						)
              a_    :	Dict   	=		self.shortcut(UpperCAmelCase__						)
              hidden_state += residual
              a_    :	List[Any]   	=		self.activation(UpperCAmelCase__						)
              return hidden_state




class    UpperCAmelCase_	(							nn.Module):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = 1						):




              """simple docstring"""




              super().__init__()
              a_    :	Dict   	=		in_channels != out_channels or stride != 1
              a_    :	Tuple   	=		max(1 ,					out_channels // config.groups_width						)
              a_    :	str   	=		(
                  RegNetShortCut(UpperCAmelCase__ ,					UpperCAmelCase__ ,					stride=UpperCAmelCase__						) if should_apply_shortcut else nn.Identity()
              )
              a_    :	List[Any]   	=		nn.Sequential(
                  RegNetConvLayer(UpperCAmelCase__ ,					UpperCAmelCase__ ,					kernel_size=1 ,					activation=config.hidden_act						) ,					RegNetConvLayer(UpperCAmelCase__ ,					UpperCAmelCase__ ,					stride=UpperCAmelCase__ ,					groups=UpperCAmelCase__ ,					activation=config.hidden_act						) ,					RegNetSELayer(UpperCAmelCase__ ,					reduced_channels=int(round(in_channels / 4						)						)						) ,					RegNetConvLayer(UpperCAmelCase__ ,					UpperCAmelCase__ ,					kernel_size=1 ,					activation=UpperCAmelCase__						) ,					)
              a_    :	Union[str, Any]   	=		ACTaFN[config.hidden_act]






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              a_    :	List[Any]   	=		hidden_state
              a_    :	int   	=		self.layer(UpperCAmelCase__						)
              a_    :	Union[str, Any]   	=		self.shortcut(UpperCAmelCase__						)
              hidden_state += residual
              a_    :	str   	=		self.activation(UpperCAmelCase__						)
              return hidden_state




class    UpperCAmelCase_	(							nn.Module):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = 2 ,					__SCREAMING_SNAKE_CASE = 2 ,					):




              """simple docstring"""




              super().__init__()

              a_    :	int   	=		RegNetXLayer if config.layer_type == '''x''' else RegNetYLayer

              a_    :	List[Any]   	=		nn.Sequential(
                  # downsampling is done in the first layer with stride of 2
                  layer(
                      UpperCAmelCase__ ,					UpperCAmelCase__ ,					UpperCAmelCase__ ,					stride=UpperCAmelCase__ ,					) ,					*[layer(UpperCAmelCase__ ,					UpperCAmelCase__ ,					UpperCAmelCase__						) for _ in range(depth - 1						)] ,					)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              a_    :	str   	=		self.layers(UpperCAmelCase__						)
              return hidden_state




class    UpperCAmelCase_	(							nn.Module):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              super().__init__()
              a_    :	Any   	=		nn.ModuleList([]						)
              # based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
              self.stages.append(
                  RegNetStage(
                      UpperCAmelCase__ ,					config.embedding_size ,					config.hidden_sizes[0] ,					stride=2 if config.downsample_in_first_stage else 1 ,					depth=config.depths[0] ,					)						)
              a_    :	List[str]   	=		zip(config.hidden_sizes ,					config.hidden_sizes[1:]						)
              for (in_channels, out_channels), depth in zip(UpperCAmelCase__ ,					config.depths[1:]						):
                     self.stages.append(RegNetStage(UpperCAmelCase__ ,					UpperCAmelCase__ ,					UpperCAmelCase__ ,					depth=UpperCAmelCase__						)						)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = False ,					__SCREAMING_SNAKE_CASE = True						):




              """simple docstring"""




              a_    :	List[str]   	=		() if output_hidden_states else None

              for stage_module in self.stages:
                     if output_hidden_states:
                            a_    :	List[Any]   	=		hidden_states + (hidden_state,)

                     a_    :	Optional[int]   	=		stage_module(UpperCAmelCase__						)

              if output_hidden_states:
                     a_    :	Optional[int]   	=		hidden_states + (hidden_state,)

              if not return_dict:
                     return tuple(v for v in [hidden_state, hidden_states] if v is not None						)

              return BaseModelOutputWithNoAttention(last_hidden_state=UpperCAmelCase__ ,					hidden_states=UpperCAmelCase__						)




class    UpperCAmelCase_	(							_a):
       '''simple docstring'''
       __UpperCamelCase      :     List[Any]							=					RegNetConfig
       __UpperCamelCase      :     Tuple							=					'regnet'
       __UpperCamelCase      :     str							=					'pixel_values'
       __UpperCamelCase      :     Union[str, Any]							=					True






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              if isinstance(UpperCAmelCase__ ,					nn.Convad						):
                     nn.init.kaiming_normal_(module.weight ,					mode='''fan_out''' ,					nonlinearity='''relu'''						)
              elif isinstance(UpperCAmelCase__ ,					(nn.BatchNormad, nn.GroupNorm)						):
                     nn.init.constant_(module.weight ,					1						)
                     nn.init.constant_(module.bias ,					0						)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE=False						):




              """simple docstring"""




              if isinstance(UpperCAmelCase__ ,					UpperCAmelCase__						):
                     a_    :	str   	=		value




__UpperCAmelCase : str 			=				R'\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it\n    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n    behavior.\n\n    Parameters:\n        config ([`RegNetConfig`]): Model configuration class with all the parameters of the model.\n            Initializing with a config file does not load the weights associated with the model, only the\n            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.\n'

__UpperCAmelCase : Optional[Any] 			=				R'\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`ConvNextImageProcessor.__call__`] for details.\n\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for\n            more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.\n'



@add_start_docstrings(
    "The bare RegNet model outputting raw features without any specific head on top.",     _a,     )
# Copied from transformers.models.resnet.modeling_resnet.ResNetModel with RESNET->REGNET,ResNet->RegNet
class    UpperCAmelCase_	(							_a):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              super().__init__(UpperCAmelCase__						)
              a_    :	Dict   	=		config
              a_    :	int   	=		RegNetEmbeddings(UpperCAmelCase__						)
              a_    :	int   	=		RegNetEncoder(UpperCAmelCase__						)
              a_    :	Union[str, Any]   	=		nn.AdaptiveAvgPoolad((1, 1)						)
              # Initialize weights and apply final processing
              self.post_init()






       @add_start_docstrings_to_model_forward(UpperCAmelCase__						)
       @add_code_sample_docstrings(
           checkpoint=_CHECKPOINT_FOR_DOC ,					output_type=UpperCAmelCase__ ,					config_class=_CONFIG_FOR_DOC ,					modality='''vision''' ,					expected_output=_EXPECTED_OUTPUT_SHAPE ,					)
       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = None						):




              """simple docstring"""




              a_    :	Dict   	=		(
                  output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
              )
              a_    :	str   	=		return_dict if return_dict is not None else self.config.use_return_dict

              a_    :	List[str]   	=		self.embedder(UpperCAmelCase__						)

              a_    :	List[str]   	=		self.encoder(
                  UpperCAmelCase__ ,					output_hidden_states=UpperCAmelCase__ ,					return_dict=UpperCAmelCase__						)

              a_    :	str   	=		encoder_outputs[0]

              a_    :	Optional[int]   	=		self.pooler(UpperCAmelCase__						)

              if not return_dict:
                     return (last_hidden_state, pooled_output) + encoder_outputs[1:]

              return BaseModelOutputWithPoolingAndNoAttention(
                  last_hidden_state=UpperCAmelCase__ ,					pooler_output=UpperCAmelCase__ ,					hidden_states=encoder_outputs.hidden_states ,					)




@add_start_docstrings(
    "\n    RegNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    ",     _a,     )
# Copied from transformers.models.resnet.modeling_resnet.ResNetForImageClassification with RESNET->REGNET,ResNet->RegNet,resnet->regnet
class    UpperCAmelCase_	(							_a):
       '''simple docstring'''






       def __init__(     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              super().__init__(UpperCAmelCase__						)
              a_    :	List[str]   	=		config.num_labels
              a_    :	Optional[Any]   	=		RegNetModel(UpperCAmelCase__						)
              # classification head
              a_    :	Optional[Any]   	=		nn.Sequential(
                  nn.Flatten() ,					nn.Linear(config.hidden_sizes[-1] ,					config.num_labels						) if config.num_labels > 0 else nn.Identity() ,					)
              # initialize weights and apply final processing
              self.post_init()






       @add_start_docstrings_to_model_forward(UpperCAmelCase__						)
       @add_code_sample_docstrings(
           checkpoint=_IMAGE_CLASS_CHECKPOINT ,					output_type=UpperCAmelCase__ ,					config_class=_CONFIG_FOR_DOC ,					expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT ,					)
       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = None ,					__SCREAMING_SNAKE_CASE = None ,					):




              """simple docstring"""




              a_    :	Optional[Any]   	=		return_dict if return_dict is not None else self.config.use_return_dict

              a_    :	List[str]   	=		self.regnet(UpperCAmelCase__ ,					output_hidden_states=UpperCAmelCase__ ,					return_dict=UpperCAmelCase__						)

              a_    :	Optional[int]   	=		outputs.pooler_output if return_dict else outputs[1]

              a_    :	str   	=		self.classifier(UpperCAmelCase__						)

              a_    :	Dict   	=		None

              if labels is not None:
                     if self.config.problem_type is None:
                            if self.num_labels == 1:
                                   a_    :	int   	=		'''regression'''
                            elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
                                   a_    :	List[str]   	=		'''single_label_classification'''
                            else:
                                   a_    :	List[str]   	=		'''multi_label_classification'''
                     if self.config.problem_type == "regression":
                            a_    :	List[Any]   	=		MSELoss()
                            if self.num_labels == 1:
                                   a_    :	List[str]   	=		loss_fct(logits.squeeze() ,					labels.squeeze()						)
                            else:
                                   a_    :	int   	=		loss_fct(UpperCAmelCase__ ,					UpperCAmelCase__						)
                     elif self.config.problem_type == "single_label_classification":
                            a_    :	Optional[int]   	=		CrossEntropyLoss()
                            a_    :	List[Any]   	=		loss_fct(logits.view(-1 ,					self.num_labels						) ,					labels.view(-1						)						)
                     elif self.config.problem_type == "multi_label_classification":
                            a_    :	int   	=		BCEWithLogitsLoss()
                            a_    :	Tuple   	=		loss_fct(UpperCAmelCase__ ,					UpperCAmelCase__						)

              if not return_dict:
                     a_    :	List[str]   	=		(logits,) + outputs[2:]
                     return (loss,) + output if loss is not None else output

              return ImageClassifierOutputWithNoAttention(loss=UpperCAmelCase__ ,					logits=UpperCAmelCase__ ,					hidden_states=outputs.hidden_states						)





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers
from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_roformer import RoFormerTokenizer
from .tokenization_utils import JiebaPreTokenizer


__UpperCAmelCase : Dict 			=				logging.get_logger(__name__)

__UpperCAmelCase : Optional[Any] 			=				{"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

__UpperCAmelCase : Dict 			=				{
    "vocab_file": {
        "junnyu/roformer_chinese_small": "https://huggingface.co/junnyu/roformer_chinese_small/resolve/main/vocab.txt",
        "junnyu/roformer_chinese_base": "https://huggingface.co/junnyu/roformer_chinese_base/resolve/main/vocab.txt",
        "junnyu/roformer_chinese_char_small": (
            "https://huggingface.co/junnyu/roformer_chinese_char_small/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_chinese_char_base": (
            "https://huggingface.co/junnyu/roformer_chinese_char_base/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_small_discriminator": (
            "https://huggingface.co/junnyu/roformer_small_discriminator/resolve/main/vocab.txt"
        ),
        "junnyu/roformer_small_generator": (
            "https://huggingface.co/junnyu/roformer_small_generator/resolve/main/vocab.txt"
        ),
    }
}

__UpperCAmelCase : Tuple 			=				{
    "junnyu/roformer_chinese_small": 1536,
    "junnyu/roformer_chinese_base": 1536,
    "junnyu/roformer_chinese_char_small": 512,
    "junnyu/roformer_chinese_char_base": 512,
    "junnyu/roformer_small_discriminator": 128,
    "junnyu/roformer_small_generator": 128,
}


__UpperCAmelCase : Any 			=				{
    "junnyu/roformer_chinese_small": {"do_lower_case": True},
    "junnyu/roformer_chinese_base": {"do_lower_case": True},
    "junnyu/roformer_chinese_char_small": {"do_lower_case": True},
    "junnyu/roformer_chinese_char_base": {"do_lower_case": True},
    "junnyu/roformer_small_discriminator": {"do_lower_case": True},
    "junnyu/roformer_small_generator": {"do_lower_case": True},
}



class    UpperCAmelCase_	(							_a):
       '''simple docstring'''
       __UpperCamelCase      :     str							=					VOCAB_FILES_NAMES
       __UpperCamelCase      :     Optional[int]							=					PRETRAINED_VOCAB_FILES_MAP
       __UpperCamelCase      :     Union[str, Any]							=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
       __UpperCamelCase      :     int							=					PRETRAINED_INIT_CONFIGURATION
       __UpperCamelCase      :     Any							=					RoFormerTokenizer






       def __init__(     self ,					__SCREAMING_SNAKE_CASE=None ,					__SCREAMING_SNAKE_CASE=None ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE="[UNK]" ,					__SCREAMING_SNAKE_CASE="[SEP]" ,					__SCREAMING_SNAKE_CASE="[PAD]" ,					__SCREAMING_SNAKE_CASE="[CLS]" ,					__SCREAMING_SNAKE_CASE="[MASK]" ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE=None ,					**__SCREAMING_SNAKE_CASE ,					):




              """simple docstring"""




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

              UpperCamelCase    :	List[Any]   	=		json.loads(self.backend_tokenizer.normalizer.__getstate__()						)
              if (
                  pre_tok_state.get('''lowercase''' ,					__SCREAMING_SNAKE_CASE						) != do_lower_case
                  or pre_tok_state.get('''strip_accents''' ,					__SCREAMING_SNAKE_CASE						) != strip_accents
              ):
                     UpperCamelCase    :	List[Any]   	=		getattr(__SCREAMING_SNAKE_CASE ,					pre_tok_state.pop('''type'''						)						)
                     UpperCamelCase    :	Optional[int]   	=		do_lower_case
                     UpperCamelCase    :	Optional[Any]   	=		strip_accents
                     UpperCamelCase    :	List[Any]   	=		pre_tok_class(**__SCREAMING_SNAKE_CASE						)

              UpperCamelCase    :	List[Any]   	=		do_lower_case






       def __getstate__(     self						):




              """simple docstring"""




              UpperCamelCase    :	Optional[int]   	=		self.__dict__.copy()
              UpperCamelCase    :	Any   	=		BertPreTokenizer()
              return state






       def __setstate__(     self ,					__SCREAMING_SNAKE_CASE						):




              """simple docstring"""




              UpperCamelCase    :	Any   	=		d
              UpperCamelCase    :	List[str]   	=		self.__dict__['''_tokenizer'''].get_vocab()
              UpperCamelCase    :	Any   	=		PreTokenizer.custom(JiebaPreTokenizer(__SCREAMING_SNAKE_CASE						)						)






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE=None						):




              """simple docstring"""




              UpperCamelCase    :	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  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = None						):




              """simple docstring"""




              UpperCamelCase    :	Dict   	=		[self.sep_token_id]
              UpperCamelCase    :	int   	=		[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  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE = None						):




              """simple docstring"""




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






       def  _lowercase   (     self ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE=None ,					__SCREAMING_SNAKE_CASE=None ,					__SCREAMING_SNAKE_CASE=False ,					**__SCREAMING_SNAKE_CASE ,					):




              """simple docstring"""




              UpperCamelCase    :	Any   	=		BertPreTokenizer()
              return super().save_pretrained(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE ,					**__SCREAMING_SNAKE_CASE						)

