'''simple docstring'''





import io
import math
from typing import Dict, Optional, Union

import numpy as np
from huggingface_hub import hf_hub_download

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image
from ...image_utils import (
    ChannelDimension,
    ImageInput,
    get_image_size,
    infer_channel_dimension_format,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_torch_available, is_vision_available, logging
from ...utils.import_utils import requires_backends


if is_vision_available():
 import textwrap

 from PIL import Image, ImageDraw, ImageFont

if is_torch_available():
 import torch

 from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_11
else:
 _lowerCAmelCase  :Tuple  				=    False


_lowerCAmelCase  :Optional[Any]  				=    logging.get_logger(__name__)
_lowerCAmelCase  :Union[str, Any]  				=    """ybelkada/fonts"""


def     __lowerCAmelCase						(       )      ->	Dict:





     '''simple docstring'''





     if is_torch_available() and not is_torch_greater_or_equal_than_1_11:
          raise ImportError(
              f"""You are using torch=={torch.__version__}, but torch>=1.11.0 is required to use """
              'Pix2StructImageProcessor. Please upgrade torch.'		)


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





     '''simple docstring'''





     requires_backends(a_       ,      ['torch']		)
     _check_torch_version()

     SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       image_tensor.unsqueeze(0		)
     SCREAMING_SNAKE_CASE					:			Optional[int]    	=       torch.nn.functional.unfold(a_       ,      (patch_height, patch_width)       ,      stride=(patch_height, patch_width)		)
     SCREAMING_SNAKE_CASE					:			List[Any]    	=       patches.reshape(image_tensor.size(0		)       ,      image_tensor.size(1		)       ,      a_       ,      a_       ,      -1		)
     SCREAMING_SNAKE_CASE					:			Dict    	=       patches.permute(0       ,      4       ,      2       ,      3       ,      1		).reshape(
         image_tensor.size(2		) // patch_height       ,      image_tensor.size(3		) // patch_width       ,      image_tensor.size(1		) * patch_height * patch_width       ,      )
     return patches.unsqueeze(0		)


def     __lowerCAmelCase						(       a_       ,      a_ = 36       ,      a_ = "black"       ,      a_ = "white"       ,      a_ = 5       ,      a_ = 5       ,      a_ = 5       ,      a_ = 5       ,      a_ = None       ,      a_ = None       ,      )      ->	Image.Image:





     '''simple docstring'''





     requires_backends(a_       ,      'vision'		)
     # Add new lines so that each line is no more than 80 characters.

     SCREAMING_SNAKE_CASE					:			str    	=       textwrap.TextWrapper(width=80		)
     SCREAMING_SNAKE_CASE					:			Optional[int]    	=       wrapper.wrap(text=a_		)
     SCREAMING_SNAKE_CASE					:			Any    	=       '\n'.join(a_		)

     if font_bytes is not None and font_path is None:
          SCREAMING_SNAKE_CASE					:			Dict    	=       io.BytesIO(a_		)
     elif font_path is not None:
          SCREAMING_SNAKE_CASE					:			Any    	=       font_path
     else:
          SCREAMING_SNAKE_CASE					:			Optional[int]    	=       hf_hub_download(a_       ,      'Arial.TTF'		)
     SCREAMING_SNAKE_CASE					:			int    	=       ImageFont.truetype(a_       ,      encoding='UTF-8'       ,      size=a_		)

     # Use a temporary canvas to determine the width and height in pixels when
     # rendering the text.
     SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       ImageDraw.Draw(Image.new('RGB'       ,      (1, 1)       ,      a_		)		)
     SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			str    	=       temp_draw.textbbox((0, 0)       ,      a_       ,      a_		)

     # Create the actual image with a bit of padding around the text.
     SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       text_width + left_padding + right_padding
     SCREAMING_SNAKE_CASE					:			int    	=       text_height + top_padding + bottom_padding
     SCREAMING_SNAKE_CASE					:			str    	=       Image.new('RGB'       ,      (image_width, image_height)       ,      a_		)
     SCREAMING_SNAKE_CASE					:			Optional[int]    	=       ImageDraw.Draw(a_		)
     draw.text(xy=(left_padding, top_padding)       ,      text=a_       ,      fill=a_       ,      font=a_		)
     return image


def     __lowerCAmelCase						(       a_       ,      a_       ,      **a_		)      ->	List[Any]:





     '''simple docstring'''





     requires_backends(a_       ,      'vision'		)

     # Convert to PIL image if necessary
     SCREAMING_SNAKE_CASE					:			List[Any]    	=       to_pil_image(a_		)

     SCREAMING_SNAKE_CASE					:			Dict    	=       render_text(a_       ,      **a_		)
     SCREAMING_SNAKE_CASE					:			Any    	=       max(header_image.width       ,      image.width		)

     SCREAMING_SNAKE_CASE					:			Any    	=       int(image.height * (new_width / image.width)		)
     SCREAMING_SNAKE_CASE					:			List[Any]    	=       int(header_image.height * (new_width / header_image.width)		)

     SCREAMING_SNAKE_CASE					:			int    	=       Image.new('RGB'       ,      (new_width, new_height + new_header_height)       ,      'white'		)
     new_image.paste(header_image.resize((new_width, new_header_height)		)       ,      (0, 0)		)
     new_image.paste(image.resize((new_width, new_height)		)       ,      (0, new_header_height)		)

     # Convert back to the original framework if necessary
     SCREAMING_SNAKE_CASE					:			List[str]    	=       to_numpy_array(a_		)

     if infer_channel_dimension_format(a_		) == ChannelDimension.LAST:
          SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       to_channel_dimension_format(a_       ,      ChannelDimension.LAST		)

     return new_image






class 				UpperCAmelCase (       _SCREAMING_SNAKE_CASE ):




    '''simple docstring'''







    snake_case__							:   Any							=						["flattened_patches"]






    def __init__(       self    ,							lowercase__ = True    ,							lowercase__ = True    ,							lowercase__ = None    ,							lowercase__ = 2_048    ,							lowercase__ = False    ,							**lowercase__    ,							)							-> None:
         super().__init__(**lowercase__ )
         SCREAMING_SNAKE_CASE					:			Any    	=       patch_size if patch_size is not None else {'height': 16, 'width': 16}
         SCREAMING_SNAKE_CASE					:			Tuple    	=       do_normalize
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       do_convert_rgb
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       max_patches
         SCREAMING_SNAKE_CASE					:			Dict    	=       is_vqa






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__    ,							lowercase__    ,							**lowercase__ )							-> np.ndarray:
         requires_backends(self.extract_flattened_patches    ,							'torch' )
         _check_torch_version()

         # convert to torch
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       to_channel_dimension_format(lowercase__    ,							ChannelDimension.FIRST )
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       torch.from_numpy(lowercase__ )

         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       patch_size['height'], patch_size['width']
         SCREAMING_SNAKE_CASE	,   SCREAMING_SNAKE_CASE					:			List[str]    	=       get_image_size(lowercase__ )

         # maximize scale s.t.
         SCREAMING_SNAKE_CASE					:			List[str]    	=       math.sqrt(max_patches * (patch_height / image_height) * (patch_width / image_width) )
         SCREAMING_SNAKE_CASE					:			List[str]    	=       max(min(math.floor(scale * image_height / patch_height )    ,							lowercase__ )    ,							1 )
         SCREAMING_SNAKE_CASE					:			Tuple    	=       max(min(math.floor(scale * image_width / patch_width )    ,							lowercase__ )    ,							1 )
         SCREAMING_SNAKE_CASE					:			str    	=       max(num_feasible_rows * patch_height    ,							1 )
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       max(num_feasible_cols * patch_width    ,							1 )

         SCREAMING_SNAKE_CASE					:			Dict    	=       torch.nn.functional.interpolate(
             image.unsqueeze(0 )    ,							size=(resized_height, resized_width)    ,							mode='bilinear'    ,							align_corners=lowercase__    ,							antialias=lowercase__    ,							).squeeze(0 )

         # [1, rows, columns, patch_height * patch_width * image_channels]
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       torch_extract_patches(lowercase__    ,							lowercase__    ,							lowercase__ )

         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       patches.shape
         SCREAMING_SNAKE_CASE					:			str    	=       patches_shape[1]
         SCREAMING_SNAKE_CASE					:			List[str]    	=       patches_shape[2]
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       patches_shape[3]

         # [rows * columns, patch_height * patch_width * image_channels]
         SCREAMING_SNAKE_CASE					:			Dict    	=       patches.reshape([rows * columns, depth] )

         # [rows * columns, 1]
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       torch.arange(lowercase__ ).reshape([rows, 1] ).repeat(1    ,							lowercase__ ).reshape([rows * columns, 1] )
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       torch.arange(lowercase__ ).reshape([1, columns] ).repeat(lowercase__    ,							1 ).reshape([rows * columns, 1] )

         # Offset by 1 so the ids do not contain zeros, which represent padding.
         row_ids += 1
         col_ids += 1

         # Prepare additional patch features.
         # [rows * columns, 1]
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       row_ids.to(torch.floataa )
         SCREAMING_SNAKE_CASE					:			str    	=       col_ids.to(torch.floataa )

         # [rows * columns, 2 + patch_height * patch_width * image_channels]
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       torch.cat([row_ids, col_ids, patches]    ,							-1 )

         # [max_patches, 2 + patch_height * patch_width * image_channels]
         SCREAMING_SNAKE_CASE					:			Tuple    	=       torch.nn.functional.pad(lowercase__    ,							[0, 0, 0, max_patches - (rows * columns)] ).float()

         SCREAMING_SNAKE_CASE					:			int    	=       to_numpy_array(lowercase__ )

         return result






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__ = None    ,							**lowercase__ )							-> np.ndarray:
         if image.dtype == np.uinta:
              SCREAMING_SNAKE_CASE					:			Tuple    	=       image.astype(np.floataa )

         # take mean across the whole `image`
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       np.mean(lowercase__ )
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       np.std(lowercase__ )
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       max(lowercase__    ,							1.0 / math.sqrt(np.prod(image.shape ) ) )

         return normalize(lowercase__    ,							mean=lowercase__    ,							std=lowercase__    ,							**lowercase__ )






    def       _UpperCamelCase    (       self    ,							lowercase__    ,							lowercase__ = None    ,							lowercase__ = None    ,							lowercase__ = None    ,							lowercase__ = None    ,							lowercase__ = None    ,							lowercase__ = None    ,							lowercase__ = ChannelDimension.FIRST    ,							**lowercase__    ,							)							-> ImageInput:
         SCREAMING_SNAKE_CASE					:			Any    	=       do_normalize if do_normalize is not None else self.do_normalize
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb
         SCREAMING_SNAKE_CASE					:			List[str]    	=       patch_size if patch_size is not None else self.patch_size
         SCREAMING_SNAKE_CASE					:			Any    	=       max_patches if max_patches is not None else self.max_patches
         SCREAMING_SNAKE_CASE					:			List[str]    	=       self.is_vqa

         if kwargs.get('data_format'    ,							lowercase__ ) is not None:
              raise ValueError('data_format is not an accepted input as the outputs are ' )

         SCREAMING_SNAKE_CASE					:			int    	=       make_list_of_images(lowercase__ )

         if not valid_images(lowercase__ ):
              raise ValueError(
                  'Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '
                  'torch.Tensor, tf.Tensor or jax.ndarray.' )

         # PIL RGBA images are converted to RGB
         if do_convert_rgb:
              SCREAMING_SNAKE_CASE					:			Tuple    	=       [convert_to_rgb(lowercase__ ) for image in images]

         # All transformations expect numpy arrays.
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       [to_numpy_array(lowercase__ ) for image in images]

         if is_vqa:
              if header_text is None:
                   raise ValueError('A header text must be provided for VQA models.' )
              SCREAMING_SNAKE_CASE					:			Any    	=       kwargs.pop('font_bytes'    ,							lowercase__ )
              SCREAMING_SNAKE_CASE					:			List[str]    	=       kwargs.pop('font_path'    ,							lowercase__ )

              if isinstance(lowercase__    ,							lowercase__ ):
                   SCREAMING_SNAKE_CASE					:			List[Any]    	=       [header_text] * len(lowercase__ )

              SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       [
                  render_header(lowercase__    ,							header_text[i]    ,							font_bytes=lowercase__    ,							font_path=lowercase__ )
                  for i, image in enumerate(lowercase__ )
              ]

         if do_normalize:
              SCREAMING_SNAKE_CASE					:			Optional[int]    	=       [self.normalize(image=lowercase__ ) for image in images]

         # convert to torch tensor and permute
         SCREAMING_SNAKE_CASE					:			int    	=       [
             self.extract_flattened_patches(image=lowercase__    ,							max_patches=lowercase__    ,							patch_size=lowercase__ )
             for image in images
         ]

         # create attention mask in numpy
         SCREAMING_SNAKE_CASE					:			List[str]    	=       [(image.sum(axis=-1 ) != 0).astype(np.floataa ) for image in images]

         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       BatchFeature(
             data={'flattened_patches': images, 'attention_mask': attention_masks}    ,							tensor_type=lowercase__ )

         return encoded_outputs




'''simple docstring'''





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 				UpperCAmelCase (       _SCREAMING_SNAKE_CASE   ,    unittest.TestCase ):




    '''simple docstring'''







    snake_case__							:   int							=						CLIPTokenizer
    snake_case__							:   Union[str, Any]							=						CLIPTokenizerFast
    snake_case__							:   str							=						True
    snake_case__							:   Optional[int]							=						{}
    snake_case__							:   int							=						False






    def       _UpperCamelCase    (       self )							-> Tuple:
         super().setUp()

         # fmt: off
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       ['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
         SCREAMING_SNAKE_CASE					:			int    	=       dict(zip(lowercase__    ,							range(len(lowercase__ ) ) ) )
         SCREAMING_SNAKE_CASE					:			Dict    	=       ['#version: 0.2', 'l o', 'lo w</w>', 'e r</w>']
         SCREAMING_SNAKE_CASE					:			List[str]    	=       {'unk_token': '<unk>'}

         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       os.path.join(self.tmpdirname    ,							VOCAB_FILES_NAMES['vocab_file'] )
         SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       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(lowercase__ ) + '\n' )
         with open(self.merges_file    ,							'w'    ,							encoding='utf-8' ) as fp:
              fp.write('\n'.join(lowercase__ ) )






    def       _UpperCamelCase    (       self    ,							**lowercase__ )							-> Dict:
         kwargs.update(self.special_tokens_map )
         return CLIPTokenizer.from_pretrained(self.tmpdirname    ,							**lowercase__ )






    def       _UpperCamelCase    (       self    ,							**lowercase__ )							-> Union[str, Any]:
         kwargs.update(self.special_tokens_map )
         return CLIPTokenizerFast.from_pretrained(self.tmpdirname    ,							**lowercase__ )






    def       _UpperCamelCase    (       self    ,							lowercase__ )							-> List[Any]:
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       'lower newer'
         SCREAMING_SNAKE_CASE					:			Dict    	=       'lower newer'
         return input_text, output_text






    def       _UpperCamelCase    (       self )							-> List[Any]:
         SCREAMING_SNAKE_CASE					:			str    	=       CLIPTokenizer(self.vocab_file    ,							self.merges_file    ,							**self.special_tokens_map )
         SCREAMING_SNAKE_CASE					:			Optional[int]    	=       'lower newer'
         SCREAMING_SNAKE_CASE					:			List[Any]    	=       ['lo', 'w', 'er</w>', 'n', 'e', 'w', 'er</w>']
         SCREAMING_SNAKE_CASE					:			Optional[Any]    	=       tokenizer.tokenize(lowercase__ )
         self.assertListEqual(lowercase__    ,							lowercase__ )

         SCREAMING_SNAKE_CASE					:			Any    	=       tokens + [tokenizer.unk_token]
         SCREAMING_SNAKE_CASE					:			int    	=       [10, 2, 16, 9, 3, 2, 16, 20]
         self.assertListEqual(tokenizer.convert_tokens_to_ids(lowercase__ )    ,							lowercase__ )






    @require_ftfy
    def       _UpperCamelCase    (       self )							-> List[str]:
         for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
              with self.subTest(F"""{tokenizer.__class__.__name__} ({pretrained_name})""" ):
                   SCREAMING_SNAKE_CASE					:			Dict    	=       self.tokenizer_class.from_pretrained(lowercase__    ,							**lowercase__ )
                   SCREAMING_SNAKE_CASE					:			List[Any]    	=       self.rust_tokenizer_class.from_pretrained(lowercase__    ,							**lowercase__ )

                   SCREAMING_SNAKE_CASE					:			Tuple    	=       'A\n\'ll 11p223RF☆ho!!to?\'d\'d\'\'d of a cat to-$\'\'d.'
                   SCREAMING_SNAKE_CASE					:			List[str]    	=       tokenizer_s.tokenize(lowercase__ )
                   SCREAMING_SNAKE_CASE					:			List[str]    	=       tokenizer_r.tokenize(lowercase__ )

                   self.assertListEqual(lowercase__    ,							lowercase__ )

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

                   self.assertListEqual(lowercase__    ,							lowercase__ )

                   # Test that the tokenization is identical on unicode of space type
                   SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       [
                       '\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:
                        SCREAMING_SNAKE_CASE					:			Tuple    	=       tokenizer_s.tokenize(lowercase__ )
                        SCREAMING_SNAKE_CASE					:			Optional[int]    	=       tokenizer_r.tokenize(lowercase__ )

                        self.assertListEqual(lowercase__    ,							lowercase__ )

                   # Test that the tokenization is identical on unicode of line break type
                   SCREAMING_SNAKE_CASE					:			int    	=       [
                       '\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:
                        SCREAMING_SNAKE_CASE					:			List[Any]    	=       tokenizer_s.tokenize(lowercase__ )
                        SCREAMING_SNAKE_CASE					:			int    	=       tokenizer_r.tokenize(lowercase__ )

                        self.assertListEqual(lowercase__    ,							lowercase__ )






    def       _UpperCamelCase    (       self )							-> int:
         # 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})""" ):
                   SCREAMING_SNAKE_CASE					:			str    	=       'hello'  # `hello` is a token in the vocabulary of `pretrained_name`
                   SCREAMING_SNAKE_CASE					:			Union[str, Any]    	=       F"""{text_of_1_token} {text_of_1_token}"""

                   SCREAMING_SNAKE_CASE					:			List[str]    	=       self.rust_tokenizer_class.from_pretrained(
                       lowercase__    ,							use_fast=lowercase__    ,							)
                   SCREAMING_SNAKE_CASE					:			Tuple    	=       tokenizer_r(lowercase__    ,							return_offsets_mapping=lowercase__    ,							add_special_tokens=lowercase__ )
                   self.assertEqual(encoding.offset_mapping[0]    ,							(0, len(lowercase__ )) )
                   self.assertEqual(
                       encoding.offset_mapping[1]    ,							(len(lowercase__ ) + 1, len(lowercase__ ) + 1 + len(lowercase__ ))    ,							)

                   SCREAMING_SNAKE_CASE					:			Optional[int]    	=       F""" {text}"""

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






    def       _UpperCamelCase    (       self )							-> int:
         # 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(lowercase__ ) 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       _UpperCamelCase    (       self )							-> Union[str, Any]:
         super().test_tokenization_python_rust_equals()






    def       _UpperCamelCase    (       self )							-> int:
         # CLIP always lower cases letters
         pass



