






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


A_		:		Union[str, Any]		     =			logging.get_logger(__name__)

# General docstring
A_		:		Dict		     =			'RegNetConfig'

# Base docstring
A_		:		Optional[Any]		     =			'facebook/regnet-y-040'
A_		:		Optional[Any]		     =			[1, 1088, 7, 7]

# Image classification docstring
A_		:		Optional[Any]		     =			'facebook/regnet-y-040'
A_		:		Tuple		     =			'tabby, tabby cat'

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




class     _lowerCAmelCase(	nn.Module ):





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase = 3  ,      _lowerCamelCase = 1  ,      _lowerCamelCase = 1  ,      _lowerCamelCase = "relu"  ,      ):
         super().__init__()
         UpperCamelCase_: Optional[int]   				=    nn.Convad(
             _lowerCamelCase  ,      _lowerCamelCase  ,      kernel_size=_lowerCamelCase  ,      stride=_lowerCamelCase  ,      padding=kernel_size // 2  ,      groups=_lowerCamelCase  ,      bias=_lowerCamelCase  ,      )
         UpperCamelCase_: List[Any]   				=    nn.BatchNormad(_lowerCamelCase							)
         UpperCamelCase_: int   				=    ACTaFN[activation] if activation is not None else nn.Identity()





       def       _a   ( self  ,      _lowerCamelCase							):
         UpperCamelCase_: Optional[int]   				=    self.convolution(_lowerCamelCase							)
         UpperCamelCase_: Tuple   				=    self.normalization(_lowerCamelCase							)
         UpperCamelCase_: List[str]   				=    self.activation(_lowerCamelCase							)
         return hidden_state







class     _lowerCAmelCase(	nn.Module ):





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase							):
         super().__init__()
         UpperCamelCase_: List[str]   				=    RegNetConvLayer(
             config.num_channels  ,      config.embedding_size  ,      kernel_size=3  ,      stride=2  ,      activation=config.hidden_act							)
         UpperCamelCase_: Union[str, Any]   				=    config.num_channels





       def       _a   ( self  ,      _lowerCamelCase							):
         UpperCamelCase_: List[str]   				=    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.'							)
         UpperCamelCase_: int   				=    self.embedder(_lowerCamelCase							)
         return hidden_state







class     _lowerCAmelCase(	nn.Module ):





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase = 2							):
         super().__init__()
         UpperCamelCase_: str   				=    nn.Convad(_lowerCamelCase  ,      _lowerCamelCase  ,      kernel_size=1  ,      stride=_lowerCamelCase  ,      bias=_lowerCamelCase							)
         UpperCamelCase_: Tuple   				=    nn.BatchNormad(_lowerCamelCase							)





       def       _a   ( self  ,      _lowerCamelCase							):
         UpperCamelCase_: int   				=    self.convolution(_lowerCamelCase							)
         UpperCamelCase_: Tuple   				=    self.normalization(_lowerCamelCase							)
         return hidden_state







class     _lowerCAmelCase(	nn.Module ):





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase  ,      _lowerCamelCase							):
         super().__init__()

         UpperCamelCase_: Dict   				=    nn.AdaptiveAvgPoolad((1, 1)							)
         UpperCamelCase_: List[str]   				=    nn.Sequential(
             nn.Convad(_lowerCamelCase  ,      _lowerCamelCase  ,      kernel_size=1							)  ,      nn.ReLU()  ,      nn.Convad(_lowerCamelCase  ,      _lowerCamelCase  ,      kernel_size=1							)  ,      nn.Sigmoid()  ,      )





       def       _a   ( self  ,      _lowerCamelCase							):
         # b c h w -> b c 1 1
         UpperCamelCase_: Tuple   				=    self.pooler(_lowerCamelCase							)
         UpperCamelCase_: Optional[Any]   				=    self.attention(_lowerCamelCase							)
         UpperCamelCase_: Union[str, Any]   				=    hidden_state * attention
         return hidden_state







class     _lowerCAmelCase(	nn.Module ):





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase = 1							):
         super().__init__()
         UpperCamelCase_: Optional[int]   				=    in_channels != out_channels or stride != 1
         UpperCamelCase_: Union[str, Any]   				=    max(1  ,      out_channels // config.groups_width							)
         UpperCamelCase_: Union[str, Any]   				=    (
             RegNetShortCut(_lowerCamelCase  ,      _lowerCamelCase  ,      stride=_lowerCamelCase							) if should_apply_shortcut else nn.Identity()
         )
         UpperCamelCase_: Any   				=    nn.Sequential(
             RegNetConvLayer(_lowerCamelCase  ,      _lowerCamelCase  ,      kernel_size=1  ,      activation=config.hidden_act							)  ,      RegNetConvLayer(_lowerCamelCase  ,      _lowerCamelCase  ,      stride=_lowerCamelCase  ,      groups=_lowerCamelCase  ,      activation=config.hidden_act							)  ,      RegNetConvLayer(_lowerCamelCase  ,      _lowerCamelCase  ,      kernel_size=1  ,      activation=_lowerCamelCase							)  ,      )
         UpperCamelCase_: List[str]   				=    ACTaFN[config.hidden_act]





       def       _a   ( self  ,      _lowerCamelCase							):
         UpperCamelCase_: str   				=    hidden_state
         UpperCamelCase_: List[Any]   				=    self.layer(_lowerCamelCase							)
         UpperCamelCase_: int   				=    self.shortcut(_lowerCamelCase							)
         hidden_state += residual
         UpperCamelCase_: Optional[Any]   				=    self.activation(_lowerCamelCase							)
         return hidden_state







class     _lowerCAmelCase(	nn.Module ):





       """simple docstring"""







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





       def       _a   ( self  ,      _lowerCamelCase							):
         UpperCamelCase_: str   				=    hidden_state
         UpperCamelCase_: List[str]   				=    self.layer(_lowerCamelCase							)
         UpperCamelCase_: Union[str, Any]   				=    self.shortcut(_lowerCamelCase							)
         hidden_state += residual
         UpperCamelCase_: Union[str, Any]   				=    self.activation(_lowerCamelCase							)
         return hidden_state







class     _lowerCAmelCase(	nn.Module ):





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase = 2  ,      _lowerCamelCase = 2  ,      ):
         super().__init__()

         UpperCamelCase_: Union[str, Any]   				=    RegNetXLayer if config.layer_type == 'x' else RegNetYLayer

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





       def       _a   ( self  ,      _lowerCamelCase							):
         UpperCamelCase_: Union[str, Any]   				=    self.layers(_lowerCamelCase							)
         return hidden_state







class     _lowerCAmelCase(	nn.Module ):





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase							):
         super().__init__()
         UpperCamelCase_: Union[str, 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(
                 _lowerCamelCase  ,      config.embedding_size  ,      config.hidden_sizes[0]  ,      stride=2 if config.downsample_in_first_stage else 1  ,      depth=config.depths[0]  ,      )							)
         UpperCamelCase_: Optional[Any]   				=    zip(config.hidden_sizes  ,      config.hidden_sizes[1:]							)
         for (in_channels, out_channels), depth in zip(_lowerCamelCase  ,      config.depths[1:]							):
           self.stages.append(RegNetStage(_lowerCamelCase  ,      _lowerCamelCase  ,      _lowerCamelCase  ,      depth=_lowerCamelCase							)							)





       def       _a   ( self  ,      _lowerCamelCase  ,      _lowerCamelCase = False  ,      _lowerCamelCase = True							):
         UpperCamelCase_: Optional[Any]   				=    () if output_hidden_states else None

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

           UpperCamelCase_: Tuple   				=    stage_module(_lowerCamelCase							)

         if output_hidden_states:
           UpperCamelCase_: 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=_lowerCamelCase  ,      hidden_states=_lowerCamelCase							)







class     _lowerCAmelCase(	UpperCAmelCase_ ):





       """simple docstring"""







       a    :		List[Any]									=RegNetConfig
       a    :		List[Any]									='''regnet'''
       a    :		Optional[Any]									='''pixel_values'''
       a    :		Dict									=True





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





       def       _a   ( self  ,      _lowerCamelCase  ,      _lowerCamelCase=False							):
         if isinstance(_lowerCamelCase  ,      _lowerCamelCase							):
           UpperCamelCase_: Optional[int]   				=    value







A_		:		Optional[int]		     =			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'

A_		:		List[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.'''							,     UpperCAmelCase_							,     )
# Copied from transformers.models.resnet.modeling_resnet.ResNetModel with RESNET->REGNET,ResNet->RegNet
class     _lowerCAmelCase(	UpperCAmelCase_ ):





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase							):
         super().__init__(_lowerCamelCase							)
         UpperCamelCase_: str   				=    config
         UpperCamelCase_: Optional[int]   				=    RegNetEmbeddings(_lowerCamelCase							)
         UpperCamelCase_: str   				=    RegNetEncoder(_lowerCamelCase							)
         UpperCamelCase_: Any   				=    nn.AdaptiveAvgPoolad((1, 1)							)
         # Initialize weights and apply final processing
         self.post_init()





       @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       _a   ( self  ,      _lowerCamelCase  ,      _lowerCamelCase = None  ,      _lowerCamelCase = None							):
         UpperCamelCase_: Tuple   				=    (
             output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
         )
         UpperCamelCase_: Dict   				=    return_dict if return_dict is not None else self.config.use_return_dict

         UpperCamelCase_: Union[str, Any]   				=    self.embedder(_lowerCamelCase							)

         UpperCamelCase_: int   				=    self.encoder(
             _lowerCamelCase  ,      output_hidden_states=_lowerCamelCase  ,      return_dict=_lowerCamelCase							)

         UpperCamelCase_: Tuple   				=    encoder_outputs[0]

         UpperCamelCase_: int   				=    self.pooler(_lowerCamelCase							)

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

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







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





       """simple docstring"""







       def __init__( self  ,      _lowerCamelCase							):
         super().__init__(_lowerCamelCase							)
         UpperCamelCase_: Optional[Any]   				=    config.num_labels
         UpperCamelCase_: Tuple   				=    RegNetModel(_lowerCamelCase							)
         # classification head
         UpperCamelCase_: Optional[int]   				=    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(_lowerCamelCase							)
       @add_code_sample_docstrings(
           checkpoint=_IMAGE_CLASS_CHECKPOINT  ,      output_type=_lowerCamelCase  ,      config_class=_CONFIG_FOR_DOC  ,      expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT  ,      )
       def       _a   ( self  ,      _lowerCamelCase = None  ,      _lowerCamelCase = None  ,      _lowerCamelCase = None  ,      _lowerCamelCase = None  ,      ):
         UpperCamelCase_: Optional[Any]   				=    return_dict if return_dict is not None else self.config.use_return_dict

         UpperCamelCase_: Dict   				=    self.regnet(_lowerCamelCase  ,      output_hidden_states=_lowerCamelCase  ,      return_dict=_lowerCamelCase							)

         UpperCamelCase_: Optional[Any]   				=    outputs.pooler_output if return_dict else outputs[1]

         UpperCamelCase_: Optional[Any]   				=    self.classifier(_lowerCamelCase							)

         UpperCamelCase_: List[str]   				=    None

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

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

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







import json
import os
import unittest

from transformers import CLIPTokenizer, CLIPTokenizerFast
from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES
from transformers.testing_utils import require_ftfy, require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin




@require_tokenizers
class     _lowerCAmelCase(	UpperCAmelCase_							,     unittest.TestCase ):





       """simple docstring"""







       a    :		Optional[Any]									=CLIPTokenizer
       a    :		List[Any]									=CLIPTokenizerFast
       a    :		str									=True
       a    :		List[Any]									={}
       a    :		str									=False





       def       _a   ( self							):
         super().setUp()

         # fmt: off
         UpperCamelCase_: str   				=    ['l', 'o', 'w', 'e', 'r', 's', 't', 'i', 'd', 'n', 'lo', 'l</w>', 'w</w>', 'r</w>', 't</w>', 'low</w>', 'er</w>', 'lowest</w>', 'newer</w>', 'wider', '<unk>', '<|startoftext|>', '<|endoftext|>']
         # fmt: on
         UpperCamelCase_: Any   				=    dict(zip(_lowerCamelCase  ,      range(len(_lowerCamelCase							)							)							)							)
         UpperCamelCase_: Optional[int]   				=    ['#version: 0.2', 'l o', 'lo w</w>', 'e r</w>']
         UpperCamelCase_: Any   				=    {'unk_token': '<unk>'}

         UpperCamelCase_: List[Any]   				=    os.path.join(self.tmpdirname  ,      VOCAB_FILES_NAMES['vocab_file']							)
         UpperCamelCase_: Optional[int]   				=    os.path.join(self.tmpdirname  ,      VOCAB_FILES_NAMES['merges_file']							)
         with open(self.vocab_file  ,      'w'  ,      encoding='utf-8'							) as fp:
           fp.write(json.dumps(_lowerCamelCase							) + '\n'							)
         with open(self.merges_file  ,      'w'  ,      encoding='utf-8'							) as fp:
           fp.write('\n'.join(_lowerCamelCase							)							)





       def       _a   ( self  ,      **_lowerCamelCase							):
         kwargs.update(self.special_tokens_map							)
         return CLIPTokenizer.from_pretrained(self.tmpdirname  ,      **_lowerCamelCase							)





       def       _a   ( self  ,      **_lowerCamelCase							):
         kwargs.update(self.special_tokens_map							)
         return CLIPTokenizerFast.from_pretrained(self.tmpdirname  ,      **_lowerCamelCase							)





       def       _a   ( self  ,      _lowerCamelCase							):
         UpperCamelCase_: Union[str, Any]   				=    'lower newer'
         UpperCamelCase_: Tuple   				=    'lower newer'
         return input_text, output_text





       def       _a   ( self							):
         UpperCamelCase_: Dict   				=    CLIPTokenizer(self.vocab_file  ,      self.merges_file  ,      **self.special_tokens_map							)
         UpperCamelCase_: Optional[int]   				=    'lower newer'
         UpperCamelCase_: Any   				=    ['lo', 'w', 'er</w>', 'n', 'e', 'w', 'er</w>']
         UpperCamelCase_: Union[str, Any]   				=    tokenizer.tokenize(_lowerCamelCase							)
         self.assertListEqual(_lowerCamelCase  ,      _lowerCamelCase							)

         UpperCamelCase_: str   				=    tokens + [tokenizer.unk_token]
         UpperCamelCase_: Optional[Any]   				=    [1_0, 2, 1_6, 9, 3, 2, 1_6, 2_0]
         self.assertListEqual(tokenizer.convert_tokens_to_ids(_lowerCamelCase							)  ,      _lowerCamelCase							)





       @require_ftfy
       def       _a   ( self							):
         for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
           with self.subTest(f'''{tokenizer.__class__.__name__} ({pretrained_name})'''							):
             UpperCamelCase_: Optional[int]   				=    self.tokenizer_class.from_pretrained(_lowerCamelCase  ,      **_lowerCamelCase							)
             UpperCamelCase_: List[str]   				=    self.rust_tokenizer_class.from_pretrained(_lowerCamelCase  ,      **_lowerCamelCase							)

             UpperCamelCase_: Optional[int]   				=    'A\n\'ll 11p223RF☆ho!!to?\'d\'d\'\'d of a cat to-$\'\'d.'
             UpperCamelCase_: Tuple   				=    tokenizer_s.tokenize(_lowerCamelCase							)
             UpperCamelCase_: Any   				=    tokenizer_r.tokenize(_lowerCamelCase							)

             self.assertListEqual(_lowerCamelCase  ,      _lowerCamelCase							)

             # Test that the tokenization is identical on an example containing a character (Latin Small Letter A
             # with Tilde) encoded in 2 different ways
             UpperCamelCase_: List[str]   				=    'xa\u0303y' + ' ' + 'x\xe3y'
             UpperCamelCase_: List[Any]   				=    tokenizer_s.tokenize(_lowerCamelCase							)
             UpperCamelCase_: int   				=    tokenizer_r.tokenize(_lowerCamelCase							)

             self.assertListEqual(_lowerCamelCase  ,      _lowerCamelCase							)

             # Test that the tokenization is identical on unicode of space type
             UpperCamelCase_: Dict   				=    [
                 '\u0009',  # (horizontal tab, '\t')
                 '\u000B',  # (vertical tab)
                 '\u000C',  # (form feed)
                 '\u0020',  # (space, ' ')
                 '\u200E',  # (left-to-right mark):w
                 '\u200F',  # (right-to-left mark)
             ]
             for unicode_seq in spaces_unicodes:
               UpperCamelCase_: int   				=    tokenizer_s.tokenize(_lowerCamelCase							)
               UpperCamelCase_: Dict   				=    tokenizer_r.tokenize(_lowerCamelCase							)

               self.assertListEqual(_lowerCamelCase  ,      _lowerCamelCase							)

             # Test that the tokenization is identical on unicode of line break type
             UpperCamelCase_: List[str]   				=    [
                 '\u000A',  # (line feed, '\n')
                 '\r\n',  # (carriage return and line feed, '\r\n')
                 '\u000D',  # (carriage return, '\r')
                 '\r',  # (carriage return, '\r')
                 '\u000D',  # (carriage return, '\r')
                 '\u2028',  # (line separator)
                 '\u2029',  # (paragraph separator)
                 # "\u0085", # (next line)
             ]

             # The tokenization is not identical for the character "\u0085" (next line). The slow version using ftfy transforms
             # it into the Horizontal Ellipsis character "…" ("\u2026") while the fast version transforms it into a
             # space (and thus into an empty list).

             for unicode_seq in line_break_unicodes:
               UpperCamelCase_: Optional[Any]   				=    tokenizer_s.tokenize(_lowerCamelCase							)
               UpperCamelCase_: str   				=    tokenizer_r.tokenize(_lowerCamelCase							)

               self.assertListEqual(_lowerCamelCase  ,      _lowerCamelCase							)





       def       _a   ( self							):
         # Test which aims to verify that the offsets are well adapted to the argument `add_prefix_space`
         for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
           with self.subTest(f'''{tokenizer.__class__.__name__} ({pretrained_name})'''							):
             UpperCamelCase_: str   				=    'hello'  # `hello` is a token in the vocabulary of `pretrained_name`
             UpperCamelCase_: str   				=    f'''{text_of_1_token} {text_of_1_token}'''

             UpperCamelCase_: Optional[Any]   				=    self.rust_tokenizer_class.from_pretrained(
                 _lowerCamelCase  ,      use_fast=_lowerCamelCase  ,      )
             UpperCamelCase_: int   				=    tokenizer_r(_lowerCamelCase  ,      return_offsets_mapping=_lowerCamelCase  ,      add_special_tokens=_lowerCamelCase							)
             self.assertEqual(encoding.offset_mapping[0]  ,      (0, len(_lowerCamelCase							))							)
             self.assertEqual(
                 encoding.offset_mapping[1]  ,      (len(_lowerCamelCase							) + 1, len(_lowerCamelCase							) + 1 + len(_lowerCamelCase							))  ,      )

             UpperCamelCase_: List[str]   				=    f''' {text}'''

             UpperCamelCase_: str   				=    self.rust_tokenizer_class.from_pretrained(
                 _lowerCamelCase  ,      use_fast=_lowerCamelCase  ,      )
             UpperCamelCase_: Dict   				=    tokenizer_r(_lowerCamelCase  ,      return_offsets_mapping=_lowerCamelCase  ,      add_special_tokens=_lowerCamelCase							)
             self.assertEqual(encoding.offset_mapping[0]  ,      (1, 1 + len(_lowerCamelCase							))							)
             self.assertEqual(
                 encoding.offset_mapping[1]  ,      (1 + len(_lowerCamelCase							) + 1, 1 + len(_lowerCamelCase							) + 1 + len(_lowerCamelCase							))  ,      )





       def       _a   ( self							):
         # Test related to the breaking change introduced in transformers v4.17.0
         # We need to check that an error in raised when the user try to load a previous version of the tokenizer.
         with self.assertRaises(_lowerCamelCase							) as context:
           self.rust_tokenizer_class.from_pretrained('robot-test/old-clip-tokenizer'							)

         self.assertTrue(
             context.exception.args[0].startswith(
                 'The `backend_tokenizer` provided does not match the expected format.'							)							)





       @require_ftfy
       def       _a   ( self							):
         super().test_tokenization_python_rust_equals()





       def       _a   ( self							):
         # CLIP always lower cases letters
         pass