


import collections.abc
from typing import Optional, Tuple, Union

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

from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import PreTrainedModel
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_poolformer import PoolFormerConfig


SCREAMING_SNAKE_CASE		:Any     						=   logging.get_logger(__name__)

# General docstring
SCREAMING_SNAKE_CASE		:int     						=   '''PoolFormerConfig'''

# Base docstring
SCREAMING_SNAKE_CASE		:str     						=   '''sail/poolformer_s12'''
SCREAMING_SNAKE_CASE		:Dict     						=   [1, 5_12, 7, 7]

# Image classification docstring
SCREAMING_SNAKE_CASE		:List[Any]     						=   '''sail/poolformer_s12'''
SCREAMING_SNAKE_CASE		:Any     						=   '''tabby, tabby cat'''

SCREAMING_SNAKE_CASE		:List[str]     						=   [
    '''sail/poolformer_s12''',
    # See all PoolFormer models at https://huggingface.co/models?filter=poolformer
]



def 	_lowerCAmelCase  (							lowerCAmelCase_							:Tuple						,  lowerCAmelCase_							:float = 0.0						,  lowerCAmelCase_							:bool = False							)->Optional[int]:
   '''simple docstring'''






   if drop_prob == 0.0 or not training:
      return input
   snake_case_    			=    1 - drop_prob
   snake_case_    			=    (input.shape[0],) + (1,) * (input.ndim - 1)  # work with diff dim tensors, not just 2D ConvNets
   snake_case_    			=    keep_prob + torch.rand(SCREAMING_SNAKE_CASE_						,  dtype=input.dtype						,  device=input.device							)
   random_tensor.floor_()  # binarize
   snake_case_    			=    input.div(SCREAMING_SNAKE_CASE_							) * random_tensor
   return output


class 			__lowerCAmelCase   (       nn.Module    ):






  """simple docstring"""





  def __init__(   self				:				List[str]			, _lowerCAmelCase				:				List[Any] = None     )      ->       None:




     """simple docstring"""
     super().__init__()
     snake_case_    			=    drop_prob



  def     lowerCAmelCase__     (   self				:				Union[str, Any]			, _lowerCAmelCase				:				List[str]     )      ->       torch.Tensor:




     """simple docstring"""
     return drop_path(lowerCAmelCase__			, self.drop_prob			, self.training     )



  def     lowerCAmelCase__     (   self				:				Union[str, Any]     )      ->       str:




     """simple docstring"""
     return "p={}".format(self.drop_prob     )






class 			__lowerCAmelCase   (       nn.Module    ):






  """simple docstring"""





  def __init__(   self				:				Union[str, Any]			, _lowerCAmelCase				:				List[str]			, _lowerCAmelCase				:				Dict			, _lowerCAmelCase				:				List[Any]			, _lowerCAmelCase				:				Dict			, _lowerCAmelCase				:				List[str]			, _lowerCAmelCase				:				str=None     )      ->       Union[str, Any]:




     """simple docstring"""
     super().__init__()
     snake_case_    			=    patch_size if isinstance(lowerCAmelCase__			, collections.abc.Iterable     ) else (patch_size, patch_size)
     snake_case_    			=    stride if isinstance(lowerCAmelCase__			, collections.abc.Iterable     ) else (stride, stride)
     snake_case_    			=    padding if isinstance(lowerCAmelCase__			, collections.abc.Iterable     ) else (padding, padding)

     snake_case_    			=    nn.Convad(lowerCAmelCase__			, lowerCAmelCase__			, kernel_size=lowerCAmelCase__			, stride=lowerCAmelCase__			, padding=lowerCAmelCase__     )
     snake_case_    			=    norm_layer(lowerCAmelCase__     ) if norm_layer else nn.Identity()



  def     lowerCAmelCase__     (   self				:				int			, _lowerCAmelCase				:				Any     )      ->       Union[str, Any]:




     """simple docstring"""
     snake_case_    			=    self.projection(lowerCAmelCase__     )
     snake_case_    			=    self.norm(lowerCAmelCase__     )
     return embeddings






class 			__lowerCAmelCase   (       nn.GroupNorm    ):






  """simple docstring"""





  def __init__(   self				:				Tuple			, _lowerCAmelCase				:				int			, **_lowerCAmelCase				:				Tuple     )      ->       str:




     """simple docstring"""
     super().__init__(1			, lowerCAmelCase__			, **lowerCAmelCase__     )






class 			__lowerCAmelCase   (       nn.Module    ):






  """simple docstring"""





  def __init__(   self				:				Dict			, _lowerCAmelCase				:				str     )      ->       Any:




     """simple docstring"""
     super().__init__()
     snake_case_    			=    nn.AvgPoolad(lowerCAmelCase__			, stride=1			, padding=pool_size // 2			, count_include_pad=lowerCAmelCase__     )



  def     lowerCAmelCase__     (   self				:				Tuple			, _lowerCAmelCase				:				Optional[int]     )      ->       int:




     """simple docstring"""
     return self.pool(lowerCAmelCase__     ) - hidden_states






class 			__lowerCAmelCase   (       nn.Module    ):






  """simple docstring"""





  def __init__(   self				:				List[Any]			, _lowerCAmelCase				:				List[str]			, _lowerCAmelCase				:				List[str]			, _lowerCAmelCase				:				Dict			, _lowerCAmelCase				:				Optional[int]     )      ->       List[str]:




     """simple docstring"""
     super().__init__()
     snake_case_    			=    nn.Convad(lowerCAmelCase__			, lowerCAmelCase__			, 1     )
     snake_case_    			=    nn.Convad(lowerCAmelCase__			, lowerCAmelCase__			, 1     )
     snake_case_    			=    PoolFormerDropPath(lowerCAmelCase__     )
     if isinstance(config.hidden_act			, lowerCAmelCase__     ):
        snake_case_    			=    ACTaFN[config.hidden_act]
     else:
        snake_case_    			=    config.hidden_act



  def     lowerCAmelCase__     (   self				:				Dict			, _lowerCAmelCase				:				Optional[Any]     )      ->       Optional[int]:




     """simple docstring"""
     snake_case_    			=    self.conva(lowerCAmelCase__     )
     snake_case_    			=    self.act_fn(lowerCAmelCase__     )
     snake_case_    			=    self.drop(lowerCAmelCase__     )
     snake_case_    			=    self.conva(lowerCAmelCase__     )
     snake_case_    			=    self.drop(lowerCAmelCase__     )

     return hidden_states






class 			__lowerCAmelCase   (       nn.Module    ):






  """simple docstring"""





  def __init__(   self				:				Union[str, Any]			, _lowerCAmelCase				:				int			, _lowerCAmelCase				:				Optional[Any]			, _lowerCAmelCase				:				int			, _lowerCAmelCase				:				int			, _lowerCAmelCase				:				List[str]			, _lowerCAmelCase				:				List[str]     )      ->       Any:




     """simple docstring"""
     super().__init__()
     snake_case_    			=    PoolFormerPooling(lowerCAmelCase__     )
     snake_case_    			=    PoolFormerOutput(lowerCAmelCase__			, lowerCAmelCase__			, lowerCAmelCase__			, lowerCAmelCase__     )
     snake_case_    			=    PoolFormerGroupNorm(lowerCAmelCase__     )
     snake_case_    			=    PoolFormerGroupNorm(lowerCAmelCase__     )

     # Useful for training neural nets
     snake_case_    			=    PoolFormerDropPath(lowerCAmelCase__     ) if drop_path > 0.0 else nn.Identity()
     snake_case_    			=    config.use_layer_scale
     if config.use_layer_scale:
        snake_case_    			=    nn.Parameter(
            config.layer_scale_init_value * torch.ones((lowerCAmelCase__)     )			, requires_grad=lowerCAmelCase__     )
        snake_case_    			=    nn.Parameter(
            config.layer_scale_init_value * torch.ones((lowerCAmelCase__)     )			, requires_grad=lowerCAmelCase__     )



  def     lowerCAmelCase__     (   self				:				str			, _lowerCAmelCase				:				List[Any]     )      ->       Union[str, Any]:




     """simple docstring"""
     if self.use_layer_scale:
        snake_case_    			=    self.pooling(self.before_norm(lowerCAmelCase__     )     )
        snake_case_    			=    self.layer_scale_a.unsqueeze(-1     ).unsqueeze(-1     ) * pooling_output
        # First residual connection
        snake_case_    			=    hidden_states + self.drop_path(lowerCAmelCase__     )
        snake_case_    			=    ()

        snake_case_    			=    self.output(self.after_norm(lowerCAmelCase__     )     )
        snake_case_    			=    self.layer_scale_a.unsqueeze(-1     ).unsqueeze(-1     ) * layer_output
        # Second residual connection
        snake_case_    			=    hidden_states + self.drop_path(lowerCAmelCase__     )

        snake_case_    			=    (output,) + outputs
        return outputs

     else:
        snake_case_    			=    self.drop_path(self.pooling(self.before_norm(lowerCAmelCase__     )     )     )
        # First residual connection
        snake_case_    			=    pooling_output + hidden_states
        snake_case_    			=    ()

        # Second residual connection inside the PoolFormerOutput block
        snake_case_    			=    self.drop_path(self.output(self.after_norm(lowerCAmelCase__     )     )     )
        snake_case_    			=    hidden_states + layer_output

        snake_case_    			=    (output,) + outputs
        return outputs






class 			__lowerCAmelCase   (       nn.Module    ):






  """simple docstring"""





  def __init__(   self				:				str			, _lowerCAmelCase				:				Dict     )      ->       Optional[Any]:




     """simple docstring"""
     super().__init__()
     snake_case_    			=    config
     # stochastic depth decay rule
     snake_case_    			=    [x.item() for x in torch.linspace(0			, config.drop_path_rate			, sum(config.depths     )     )]

     # patch embeddings
     snake_case_    			=    []
     for i in range(config.num_encoder_blocks     ):
        embeddings.append(
            PoolFormerEmbeddings(
                patch_size=config.patch_sizes[i]			, stride=config.strides[i]			, padding=config.padding[i]			, num_channels=config.num_channels if i == 0 else config.hidden_sizes[i - 1]			, hidden_size=config.hidden_sizes[i]			, )     )
     snake_case_    			=    nn.ModuleList(lowerCAmelCase__     )

     # Transformer blocks
     snake_case_    			=    []
     snake_case_    			=    0
     for i in range(config.num_encoder_blocks     ):
        # each block consists of layers
        snake_case_    			=    []
        if i != 0:
           cur += config.depths[i - 1]
        for j in range(config.depths[i]     ):
           layers.append(
               PoolFormerLayer(
                   lowerCAmelCase__			, num_channels=config.hidden_sizes[i]			, pool_size=config.pool_size			, hidden_size=config.hidden_sizes[i]			, intermediate_size=int(config.hidden_sizes[i] * config.mlp_ratio     )			, drop_path=dpr[cur + j]			, )     )
        blocks.append(nn.ModuleList(lowerCAmelCase__     )     )

     snake_case_    			=    nn.ModuleList(lowerCAmelCase__     )



  def     lowerCAmelCase__     (   self				:				str			, _lowerCAmelCase				:				Dict			, _lowerCAmelCase				:				int=False			, _lowerCAmelCase				:				str=True     )      ->       int:




     """simple docstring"""
     snake_case_    			=    () if output_hidden_states else None

     snake_case_    			=    pixel_values
     for idx, layers in enumerate(zip(self.patch_embeddings			, self.block     )     ):
        snake_case_			,			snake_case_    			=    layers
        # Get patch embeddings from hidden_states
        snake_case_    			=    embedding_layer(lowerCAmelCase__     )
        # Send the embeddings through the blocks
        for _, blk in enumerate(lowerCAmelCase__     ):
           snake_case_    			=    blk(lowerCAmelCase__     )
           snake_case_    			=    layer_outputs[0]

        if output_hidden_states:
           snake_case_    			=    all_hidden_states + (hidden_states,)

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

     return BaseModelOutputWithNoAttention(last_hidden_state=lowerCAmelCase__			, hidden_states=lowerCAmelCase__     )






class 			__lowerCAmelCase   (       lowerCamelCase_    ):






  """simple docstring"""





  _SCREAMING_SNAKE_CASE									=				PoolFormerConfig
  _SCREAMING_SNAKE_CASE									=				"""poolformer"""
  _SCREAMING_SNAKE_CASE									=				"""pixel_values"""
  _SCREAMING_SNAKE_CASE									=				True



  def     lowerCAmelCase__     (   self				:				Union[str, Any]			, _lowerCAmelCase				:				int     )      ->       List[str]:




     """simple docstring"""
     if isinstance(lowerCAmelCase__			, (nn.Linear, nn.Convad)     ):
        module.weight.data.normal_(mean=0.0			, std=self.config.initializer_range     )
        if module.bias is not None:
           module.bias.data.zero_()
     elif isinstance(lowerCAmelCase__			, nn.LayerNorm     ):
        module.bias.data.zero_()
        module.weight.data.fill_(1.0     )



  def     lowerCAmelCase__     (   self				:				Union[str, Any]			, _lowerCAmelCase				:				List[str]			, _lowerCAmelCase				:				int=False     )      ->       int:




     """simple docstring"""
     if isinstance(lowerCAmelCase__			, lowerCAmelCase__     ):
        snake_case_    			=    value






SCREAMING_SNAKE_CASE		:Any     						=   R'''
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
    it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`PoolFormerConfig`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
'''

SCREAMING_SNAKE_CASE		:Optional[Any]     						=   R'''
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`PoolFormerImageProcessor.__call__`] for details.
'''


@add_start_docstrings(
    'The bare PoolFormer Model transformer outputting raw hidden-states without any specific head on top.'       ,     lowerCamelCase_       ,     )
class 			__lowerCAmelCase   (       lowerCamelCase_    ):






  """simple docstring"""





  def __init__(   self				:				Optional[Any]			, _lowerCAmelCase				:				Optional[int]     )      ->       Optional[Any]:




     """simple docstring"""
     super().__init__(lowerCAmelCase__     )
     snake_case_    			=    config

     snake_case_    			=    PoolFormerEncoder(lowerCAmelCase__     )

     # Initialize weights and apply final processing
     self.post_init()



  def     lowerCAmelCase__     (   self				:				List[str]     )      ->       Optional[Any]:




     """simple docstring"""
     return self.embeddings.patch_embeddings



  @add_start_docstrings_to_model_forward(lowerCAmelCase__     )
  @add_code_sample_docstrings(
      checkpoint=_CHECKPOINT_FOR_DOC			, output_type=lowerCAmelCase__			, config_class=_CONFIG_FOR_DOC			, modality="vision"			, expected_output=_EXPECTED_OUTPUT_SHAPE			, )
  def     lowerCAmelCase__     (   self				:				Optional[Any]			, _lowerCAmelCase				:				Any = None			, _lowerCAmelCase				:				List[str] = None			, _lowerCAmelCase				:				List[Any] = None			, )      ->       Union[Tuple, BaseModelOutputWithNoAttention]:




     """simple docstring"""
     snake_case_    			=    (
         output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
     )
     snake_case_    			=    return_dict if return_dict is not None else self.config.use_return_dict

     if pixel_values is None:
        raise ValueError("You have to specify pixel_values"     )

     snake_case_    			=    self.encoder(
         lowerCAmelCase__			, output_hidden_states=lowerCAmelCase__			, return_dict=lowerCAmelCase__			, )
     snake_case_    			=    encoder_outputs[0]

     if not return_dict:
        return (sequence_output, None) + encoder_outputs[1:]

     return BaseModelOutputWithNoAttention(
         last_hidden_state=lowerCAmelCase__			, hidden_states=encoder_outputs.hidden_states			, )






class 			__lowerCAmelCase   (       nn.Module    ):






  """simple docstring"""





  def __init__(   self				:				List[str]			, _lowerCAmelCase				:				Optional[Any]     )      ->       Union[str, Any]:




     """simple docstring"""
     super().__init__()
     snake_case_    			=    nn.Linear(config.hidden_size			, config.hidden_size     )



  def     lowerCAmelCase__     (   self				:				Dict			, _lowerCAmelCase				:				Tuple     )      ->       Any:




     """simple docstring"""
     snake_case_    			=    self.dense(lowerCAmelCase__     )
     return output






@add_start_docstrings(
    '\n    PoolFormer Model transformer with an image classification head on top\n    '       ,     lowerCamelCase_       ,     )
class 			__lowerCAmelCase   (       lowerCamelCase_    ):






  """simple docstring"""





  def __init__(   self				:				Union[str, Any]			, _lowerCAmelCase				:				List[str]     )      ->       int:




     """simple docstring"""
     super().__init__(lowerCAmelCase__     )
     snake_case_    			=    config.num_labels
     snake_case_    			=    PoolFormerModel(lowerCAmelCase__     )

     # Final norm
     snake_case_    			=    PoolFormerGroupNorm(config.hidden_sizes[-1]     )
     # Classifier head
     snake_case_    			=    (
         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(lowerCAmelCase__     )
  @add_code_sample_docstrings(
      checkpoint=_IMAGE_CLASS_CHECKPOINT			, output_type=lowerCAmelCase__			, config_class=_CONFIG_FOR_DOC			, expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT			, )
  def     lowerCAmelCase__     (   self				:				Optional[int]			, _lowerCAmelCase				:				List[str] = None			, _lowerCAmelCase				:				List[str] = None			, _lowerCAmelCase				:				Tuple = None			, _lowerCAmelCase				:				str = None			, )      ->       Union[Tuple, ImageClassifierOutputWithNoAttention]:




     """simple docstring"""
     snake_case_    			=    return_dict if return_dict is not None else self.config.use_return_dict

     snake_case_    			=    self.poolformer(
         lowerCAmelCase__			, output_hidden_states=lowerCAmelCase__			, return_dict=lowerCAmelCase__			, )

     snake_case_    			=    outputs[0]

     snake_case_    			=    self.classifier(self.norm(lowerCAmelCase__     ).mean([-2, -1]     )     )

     snake_case_    			=    None
     if labels is not None:
        if self.config.problem_type is None:
           if self.num_labels == 1:
              snake_case_    			=    "regression"
           elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
              snake_case_    			=    "single_label_classification"
           else:
              snake_case_    			=    "multi_label_classification"

        if self.config.problem_type == "regression":
           snake_case_    			=    MSELoss()
           if self.num_labels == 1:
              snake_case_    			=    loss_fct(logits.squeeze()			, labels.squeeze()     )
           else:
              snake_case_    			=    loss_fct(lowerCAmelCase__			, lowerCAmelCase__     )
        elif self.config.problem_type == "single_label_classification":
           snake_case_    			=    CrossEntropyLoss()
           snake_case_    			=    loss_fct(logits.view(-1			, self.num_labels     )			, labels.view(-1     )     )
        elif self.config.problem_type == "multi_label_classification":
           snake_case_    			=    BCEWithLogitsLoss()
           snake_case_    			=    loss_fct(lowerCAmelCase__			, lowerCAmelCase__     )

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

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








"""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_funnel import FunnelTokenizer


__UpperCamelCase						=      logging.get_logger(__name__)

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

__UpperCamelCase						=      [
    '''small''',
    '''small-base''',
    '''medium''',
    '''medium-base''',
    '''intermediate''',
    '''intermediate-base''',
    '''large''',
    '''large-base''',
    '''xlarge''',
    '''xlarge-base''',
]

__UpperCamelCase						=      {
    '''vocab_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt''',
        '''funnel-transformer/small-base''': '''https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt''',
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt''',
        '''funnel-transformer/large-base''': '''https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json''',
        '''funnel-transformer/small-base''': (
            '''https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json''',
        '''funnel-transformer/large-base''': (
            '''https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json'''
        ),
    },
}
__UpperCamelCase						=      {f'''funnel-transformer/{name}''': 512 for name in _model_names}
__UpperCamelCase						=      {f'''funnel-transformer/{name}''': {'''do_lower_case''': True} for name in _model_names}
class 					lowerCAmelCase	(					lowerCamelCase_    ):




		'''simple docstring'''







		SCREAMING_SNAKE_CASE_						:     int								=     VOCAB_FILES_NAMES
		SCREAMING_SNAKE_CASE_						:     List[str]								=     PRETRAINED_VOCAB_FILES_MAP
		SCREAMING_SNAKE_CASE_						:     List[Any]								=     PRETRAINED_INIT_CONFIGURATION
		SCREAMING_SNAKE_CASE_						:     str								=     FunnelTokenizer
		SCREAMING_SNAKE_CASE_						:     Dict								=     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
		SCREAMING_SNAKE_CASE_						:     int								=     2







		def __init__(	self						,       lowerCAmelCase__=None						,       lowerCAmelCase__=None						,       lowerCAmelCase__=True						,       lowerCAmelCase__="<unk>"						,       lowerCAmelCase__="<sep>"						,       lowerCAmelCase__="<pad>"						,       lowerCAmelCase__="<cls>"						,       lowerCAmelCase__="<mask>"						,       lowerCAmelCase__="<s>"						,       lowerCAmelCase__="</s>"						,       lowerCAmelCase__=True						,       lowerCAmelCase__=True						,       lowerCAmelCase__=None						,       lowerCAmelCase__="##"						,       **lowerCAmelCase__						,       )     ->							Tuple:
								super().__init__(
								    lowerCAmelCase__						,       tokenizer_file=lowerCAmelCase__						,       do_lower_case=lowerCAmelCase__						,       unk_token=lowerCAmelCase__						,       sep_token=lowerCAmelCase__						,       pad_token=lowerCAmelCase__						,       cls_token=lowerCAmelCase__						,       mask_token=lowerCAmelCase__						,       bos_token=lowerCAmelCase__						,       eos_token=lowerCAmelCase__						,       clean_text=lowerCAmelCase__						,       tokenize_chinese_chars=lowerCAmelCase__						,       strip_accents=lowerCAmelCase__						,       wordpieces_prefix=lowerCAmelCase__						,       **lowerCAmelCase__						,       )

								SCREAMING_SNAKE_CASE													=					json.loads(self.backend_tokenizer.normalizer.__getstate__()				)
								if (
								    normalizer_state.get('lowercase'						,       lowerCAmelCase__				) != do_lower_case
								    or normalizer_state.get('strip_accents'						,       lowerCAmelCase__				) != strip_accents
								    or normalizer_state.get('handle_chinese_chars'						,       lowerCAmelCase__				) != tokenize_chinese_chars
								):
														SCREAMING_SNAKE_CASE													=					getattr(lowerCAmelCase__						,       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(**lowerCAmelCase__				)

								SCREAMING_SNAKE_CASE													=					do_lower_case







		def 							__A						(	self						,       lowerCAmelCase__						,       lowerCAmelCase__=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 							__A						(	self						,       lowerCAmelCase__						,       lowerCAmelCase__ = 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				) * [self.cls_token_type_id] + len(token_ids_a + sep				) * [0]
								return len(cls				) * [self.cls_token_type_id] + len(token_ids_a + sep				) * [0] + len(token_ids_a + sep				) * [1]







		def 							__A						(	self						,       lowerCAmelCase__						,       lowerCAmelCase__ = None				)     ->							Tuple[str]:
								SCREAMING_SNAKE_CASE													=					self._tokenizer.model.save(lowerCAmelCase__						,       name=lowerCAmelCase__				)
								return tuple(lowerCAmelCase__				)


