




'''simple docstring'''


import gc
import random
import unittest

import numpy as np
import torch
from PIL import Image
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()

class       A   (		unittest.TestCase   ):







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


														"""simple docstring"""


														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()







							@property
							def        __lowerCAmelCase      (  self	:  Union[str, Any] )      ->							List[str]:


														"""simple docstring"""


														_a     					=    1
														_a     					=    3
														_a     					=    (32, 32)

														_a     					=    floats_tensor((batch_size, num_channels) + sizes							,      rng=random.Random(0 ) ).to(lowerCAmelCase_ )
														return image







							@property
							def        __lowerCAmelCase      (  self	:  Any )      ->							Optional[Any]:


														"""simple docstring"""


														torch.manual_seed(0 )
														_a     					=    UNetaDConditionModel(
														    block_out_channels=(32, 32, 64)							,      layers_per_block=2							,      sample_size=32							,      in_channels=7							,      out_channels=4							,      down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''', '''CrossAttnDownBlock2D''')							,      up_block_types=('''CrossAttnUpBlock2D''', '''CrossAttnUpBlock2D''', '''UpBlock2D''')							,      cross_attention_dim=32							,      attention_head_dim=8							,      use_linear_projection=lowerCAmelCase_							,      only_cross_attention=(True, True, False)							,      num_class_embeds=1_00							,      )
														return model







							@property
							def        __lowerCAmelCase      (  self	:  Dict )      ->							int:


														"""simple docstring"""


														torch.manual_seed(0 )
														_a     					=    AutoencoderKL(
														    block_out_channels=[32, 32, 64]							,      in_channels=3							,      out_channels=3							,      down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D''', '''DownEncoderBlock2D''']							,      up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D''', '''UpDecoderBlock2D''']							,      latent_channels=4							,      )
														return model







							@property
							def        __lowerCAmelCase      (  self	:  Dict )      ->							Tuple:


														"""simple docstring"""


														torch.manual_seed(0 )
														_a     					=    CLIPTextConfig(
														    bos_token_id=0							,      eos_token_id=2							,      hidden_size=32							,      intermediate_size=37							,      layer_norm_eps=1e-05							,      num_attention_heads=4							,      num_hidden_layers=5							,      pad_token_id=1							,      vocab_size=10_00							,      hidden_act='''gelu'''							,      projection_dim=5_12							,      )
														return CLIPTextModel(lowerCAmelCase_ )







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


														"""simple docstring"""


														_a     					=    '''cpu'''  # ensure determinism for the device-dependent torch.Generator
														_a     					=    self.dummy_cond_unet_upscale
														_a     					=    DDPMScheduler()
														_a     					=    DDIMScheduler(prediction_type='''v_prediction''' )
														_a     					=    self.dummy_vae
														_a     					=    self.dummy_text_encoder
														_a     					=    CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip''' )

														_a     					=    self.dummy_image.cpu().permute(0							,      2							,      3							,      1 )[0]
														_a     					=    Image.fromarray(np.uinta(lowerCAmelCase_ ) ).convert('''RGB''' ).resize((64, 64) )

														# make sure here that pndm scheduler skips prk
														_a     					=    StableDiffusionUpscalePipeline(
														    unet=lowerCAmelCase_							,      low_res_scheduler=lowerCAmelCase_							,      scheduler=lowerCAmelCase_							,      vae=lowerCAmelCase_							,      text_encoder=lowerCAmelCase_							,      tokenizer=lowerCAmelCase_							,      max_noise_level=3_50							,      )
														_a     					=    sd_pipe.to(lowerCAmelCase_ )
														sd_pipe.set_progress_bar_config(disable=lowerCAmelCase_ )

														_a     					=    '''A painting of a squirrel eating a burger'''
														_a     					=    torch.Generator(device=lowerCAmelCase_ ).manual_seed(0 )
														_a     					=    sd_pipe(
														    [prompt]							,      image=lowerCAmelCase_							,      generator=lowerCAmelCase_							,      guidance_scale=6.0							,      noise_level=20							,      num_inference_steps=2							,      output_type='''np'''							,      )

														_a     					=    output.images

														_a     					=    torch.Generator(device=lowerCAmelCase_ ).manual_seed(0 )
														_a     					=    sd_pipe(
														    [prompt]							,      image=lowerCAmelCase_							,      generator=lowerCAmelCase_							,      guidance_scale=6.0							,      noise_level=20							,      num_inference_steps=2							,      output_type='''np'''							,      return_dict=lowerCAmelCase_							,      )[0]

														_a     					=    image[0, -3:, -3:, -1]
														_a     					=    image_from_tuple[0, -3:, -3:, -1]

														_a     					=    low_res_image.size[0] * 4
														assert image.shape == (1, expected_height_width, expected_height_width, 3)
														_a     					=    np.array([0.3_1_1_3, 0.3_9_1_0, 0.4_2_7_2, 0.4_8_5_9, 0.5_0_6_1, 0.4_6_5_2, 0.5_3_6_2, 0.5_7_1_5, 0.5_6_6_1] )

														assert np.abs(image_slice.flatten() - expected_slice ).max() < 1e-2
														assert np.abs(image_from_tuple_slice.flatten() - expected_slice ).max() < 1e-2







							def        __lowerCAmelCase      (  self	:  Dict )      ->							List[Any]:


														"""simple docstring"""


														_a     					=    '''cpu'''  # ensure determinism for the device-dependent torch.Generator
														_a     					=    self.dummy_cond_unet_upscale
														_a     					=    DDPMScheduler()
														_a     					=    DDIMScheduler(prediction_type='''v_prediction''' )
														_a     					=    self.dummy_vae
														_a     					=    self.dummy_text_encoder
														_a     					=    CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip''' )

														_a     					=    self.dummy_image.cpu().permute(0							,      2							,      3							,      1 )[0]
														_a     					=    Image.fromarray(np.uinta(lowerCAmelCase_ ) ).convert('''RGB''' ).resize((64, 64) )

														# make sure here that pndm scheduler skips prk
														_a     					=    StableDiffusionUpscalePipeline(
														    unet=lowerCAmelCase_							,      low_res_scheduler=lowerCAmelCase_							,      scheduler=lowerCAmelCase_							,      vae=lowerCAmelCase_							,      text_encoder=lowerCAmelCase_							,      tokenizer=lowerCAmelCase_							,      max_noise_level=3_50							,      )
														_a     					=    sd_pipe.to(lowerCAmelCase_ )
														sd_pipe.set_progress_bar_config(disable=lowerCAmelCase_ )

														_a     					=    '''A painting of a squirrel eating a burger'''
														_a     					=    sd_pipe(
														    2 * [prompt]							,      image=2 * [low_res_image]							,      guidance_scale=6.0							,      noise_level=20							,      num_inference_steps=2							,      output_type='''np'''							,      )
														_a     					=    output.images
														assert image.shape[0] == 2

														_a     					=    torch.Generator(device=lowerCAmelCase_ ).manual_seed(0 )
														_a     					=    sd_pipe(
														    [prompt]							,      image=lowerCAmelCase_							,      generator=lowerCAmelCase_							,      num_images_per_prompt=2							,      guidance_scale=6.0							,      noise_level=20							,      num_inference_steps=2							,      output_type='''np'''							,      )
														_a     					=    output.images
														assert image.shape[0] == 2







							@unittest.skipIf(torch_device != '''cuda'''							,      '''This test requires a GPU''' )
							def        __lowerCAmelCase      (  self	:  List[Any] )      ->							Dict:


														"""simple docstring"""


														_a     					=    self.dummy_cond_unet_upscale
														_a     					=    DDPMScheduler()
														_a     					=    DDIMScheduler(prediction_type='''v_prediction''' )
														_a     					=    self.dummy_vae
														_a     					=    self.dummy_text_encoder
														_a     					=    CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip''' )

														_a     					=    self.dummy_image.cpu().permute(0							,      2							,      3							,      1 )[0]
														_a     					=    Image.fromarray(np.uinta(lowerCAmelCase_ ) ).convert('''RGB''' ).resize((64, 64) )

														# put models in fp16, except vae as it overflows in fp16
														_a     					=    unet.half()
														_a     					=    text_encoder.half()

														# make sure here that pndm scheduler skips prk
														_a     					=    StableDiffusionUpscalePipeline(
														    unet=lowerCAmelCase_							,      low_res_scheduler=lowerCAmelCase_							,      scheduler=lowerCAmelCase_							,      vae=lowerCAmelCase_							,      text_encoder=lowerCAmelCase_							,      tokenizer=lowerCAmelCase_							,      max_noise_level=3_50							,      )
														_a     					=    sd_pipe.to(lowerCAmelCase_ )
														sd_pipe.set_progress_bar_config(disable=lowerCAmelCase_ )

														_a     					=    '''A painting of a squirrel eating a burger'''
														_a     					=    torch.manual_seed(0 )
														_a     					=    sd_pipe(
														    [prompt]							,      image=lowerCAmelCase_							,      generator=lowerCAmelCase_							,      num_inference_steps=2							,      output_type='''np'''							,      ).images

														_a     					=    low_res_image.size[0] * 4
														assert image.shape == (1, expected_height_width, expected_height_width, 3)



@slow
@require_torch_gpu
class       A   (		unittest.TestCase   ):







							def        __lowerCAmelCase      (  self	:  Optional[Any] )      ->							int:


														"""simple docstring"""


														super().tearDown()
														gc.collect()
														torch.cuda.empty_cache()







							def        __lowerCAmelCase      (  self	:  Dict )      ->							List[Any]:


														"""simple docstring"""


														_a     					=    load_image(
														    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
														    '''/sd2-upscale/low_res_cat.png''' )
														_a     					=    load_numpy(
														    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-upscale'''
														    '''/upsampled_cat.npy''' )

														_a     					=    '''stabilityai/stable-diffusion-x4-upscaler'''
														_a     					=    StableDiffusionUpscalePipeline.from_pretrained(lowerCAmelCase_ )
														pipe.to(lowerCAmelCase_ )
														pipe.set_progress_bar_config(disable=lowerCAmelCase_ )
														pipe.enable_attention_slicing()

														_a     					=    '''a cat sitting on a park bench'''

														_a     					=    torch.manual_seed(0 )
														_a     					=    pipe(
														    prompt=lowerCAmelCase_							,      image=lowerCAmelCase_							,      generator=lowerCAmelCase_							,      output_type='''np'''							,      )
														_a     					=    output.images[0]

														assert image.shape == (5_12, 5_12, 3)
														assert np.abs(expected_image - image ).max() < 1e-3







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


														"""simple docstring"""


														_a     					=    load_image(
														    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
														    '''/sd2-upscale/low_res_cat.png''' )
														_a     					=    load_numpy(
														    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-upscale'''
														    '''/upsampled_cat_fp16.npy''' )

														_a     					=    '''stabilityai/stable-diffusion-x4-upscaler'''
														_a     					=    StableDiffusionUpscalePipeline.from_pretrained(
														    lowerCAmelCase_							,      torch_dtype=torch.floataa							,      )
														pipe.to(lowerCAmelCase_ )
														pipe.set_progress_bar_config(disable=lowerCAmelCase_ )
														pipe.enable_attention_slicing()

														_a     					=    '''a cat sitting on a park bench'''

														_a     					=    torch.manual_seed(0 )
														_a     					=    pipe(
														    prompt=lowerCAmelCase_							,      image=lowerCAmelCase_							,      generator=lowerCAmelCase_							,      output_type='''np'''							,      )
														_a     					=    output.images[0]

														assert image.shape == (5_12, 5_12, 3)
														assert np.abs(expected_image - image ).max() < 5e-1







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


														"""simple docstring"""


														torch.cuda.empty_cache()
														torch.cuda.reset_max_memory_allocated()
														torch.cuda.reset_peak_memory_stats()

														_a     					=    load_image(
														    '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main'''
														    '''/sd2-upscale/low_res_cat.png''' )

														_a     					=    '''stabilityai/stable-diffusion-x4-upscaler'''
														_a     					=    StableDiffusionUpscalePipeline.from_pretrained(
														    lowerCAmelCase_							,      torch_dtype=torch.floataa							,      )
														pipe.to(lowerCAmelCase_ )
														pipe.set_progress_bar_config(disable=lowerCAmelCase_ )
														pipe.enable_attention_slicing(1 )
														pipe.enable_sequential_cpu_offload()

														_a     					=    '''a cat sitting on a park bench'''

														_a     					=    torch.manual_seed(0 )
														_a     					=    pipe(
														    prompt=lowerCAmelCase_							,      image=lowerCAmelCase_							,      generator=lowerCAmelCase_							,      num_inference_steps=5							,      output_type='''np'''							,      )

														_a     					=    torch.cuda.max_memory_allocated()
														# make sure that less than 2.9 GB is allocated
														assert mem_bytes < 2.9 * 10**9







'''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_bert import BertTokenizer


_snake_case				:				Any       							=		logging.get_logger(__name__)

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

_snake_case				:				List[str]       							=		{
    'vocab_file': {
        'bert-base-uncased': 'https://huggingface.co/bert-base-uncased/resolve/main/vocab.txt',
        'bert-large-uncased': 'https://huggingface.co/bert-large-uncased/resolve/main/vocab.txt',
        'bert-base-cased': 'https://huggingface.co/bert-base-cased/resolve/main/vocab.txt',
        'bert-large-cased': 'https://huggingface.co/bert-large-cased/resolve/main/vocab.txt',
        'bert-base-multilingual-uncased': (
            'https://huggingface.co/bert-base-multilingual-uncased/resolve/main/vocab.txt'
        ),
        'bert-base-multilingual-cased': 'https://huggingface.co/bert-base-multilingual-cased/resolve/main/vocab.txt',
        'bert-base-chinese': 'https://huggingface.co/bert-base-chinese/resolve/main/vocab.txt',
        'bert-base-german-cased': 'https://huggingface.co/bert-base-german-cased/resolve/main/vocab.txt',
        'bert-large-uncased-whole-word-masking': (
            'https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/vocab.txt'
        ),
        'bert-large-cased-whole-word-masking': (
            'https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/vocab.txt'
        ),
        'bert-large-uncased-whole-word-masking-finetuned-squad': (
            'https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt'
        ),
        'bert-large-cased-whole-word-masking-finetuned-squad': (
            'https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/vocab.txt'
        ),
        'bert-base-cased-finetuned-mrpc': (
            'https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/vocab.txt'
        ),
        'bert-base-german-dbmdz-cased': 'https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/vocab.txt',
        'bert-base-german-dbmdz-uncased': (
            'https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/vocab.txt'
        ),
        'TurkuNLP/bert-base-finnish-cased-v1': (
            'https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/vocab.txt'
        ),
        'TurkuNLP/bert-base-finnish-uncased-v1': (
            'https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/vocab.txt'
        ),
        'wietsedv/bert-base-dutch-cased': (
            'https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/vocab.txt'
        ),
    },
    'tokenizer_file': {
        'bert-base-uncased': 'https://huggingface.co/bert-base-uncased/resolve/main/tokenizer.json',
        'bert-large-uncased': 'https://huggingface.co/bert-large-uncased/resolve/main/tokenizer.json',
        'bert-base-cased': 'https://huggingface.co/bert-base-cased/resolve/main/tokenizer.json',
        'bert-large-cased': 'https://huggingface.co/bert-large-cased/resolve/main/tokenizer.json',
        'bert-base-multilingual-uncased': (
            'https://huggingface.co/bert-base-multilingual-uncased/resolve/main/tokenizer.json'
        ),
        'bert-base-multilingual-cased': (
            'https://huggingface.co/bert-base-multilingual-cased/resolve/main/tokenizer.json'
        ),
        'bert-base-chinese': 'https://huggingface.co/bert-base-chinese/resolve/main/tokenizer.json',
        'bert-base-german-cased': 'https://huggingface.co/bert-base-german-cased/resolve/main/tokenizer.json',
        'bert-large-uncased-whole-word-masking': (
            'https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/tokenizer.json'
        ),
        'bert-large-cased-whole-word-masking': (
            'https://huggingface.co/bert-large-cased-whole-word-masking/resolve/main/tokenizer.json'
        ),
        'bert-large-uncased-whole-word-masking-finetuned-squad': (
            'https://huggingface.co/bert-large-uncased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json'
        ),
        'bert-large-cased-whole-word-masking-finetuned-squad': (
            'https://huggingface.co/bert-large-cased-whole-word-masking-finetuned-squad/resolve/main/tokenizer.json'
        ),
        'bert-base-cased-finetuned-mrpc': (
            'https://huggingface.co/bert-base-cased-finetuned-mrpc/resolve/main/tokenizer.json'
        ),
        'bert-base-german-dbmdz-cased': (
            'https://huggingface.co/bert-base-german-dbmdz-cased/resolve/main/tokenizer.json'
        ),
        'bert-base-german-dbmdz-uncased': (
            'https://huggingface.co/bert-base-german-dbmdz-uncased/resolve/main/tokenizer.json'
        ),
        'TurkuNLP/bert-base-finnish-cased-v1': (
            'https://huggingface.co/TurkuNLP/bert-base-finnish-cased-v1/resolve/main/tokenizer.json'
        ),
        'TurkuNLP/bert-base-finnish-uncased-v1': (
            'https://huggingface.co/TurkuNLP/bert-base-finnish-uncased-v1/resolve/main/tokenizer.json'
        ),
        'wietsedv/bert-base-dutch-cased': (
            'https://huggingface.co/wietsedv/bert-base-dutch-cased/resolve/main/tokenizer.json'
        ),
    },
}

_snake_case				:				int       							=		{
    'bert-base-uncased': 512,
    'bert-large-uncased': 512,
    'bert-base-cased': 512,
    'bert-large-cased': 512,
    'bert-base-multilingual-uncased': 512,
    'bert-base-multilingual-cased': 512,
    'bert-base-chinese': 512,
    'bert-base-german-cased': 512,
    'bert-large-uncased-whole-word-masking': 512,
    'bert-large-cased-whole-word-masking': 512,
    'bert-large-uncased-whole-word-masking-finetuned-squad': 512,
    'bert-large-cased-whole-word-masking-finetuned-squad': 512,
    'bert-base-cased-finetuned-mrpc': 512,
    'bert-base-german-dbmdz-cased': 512,
    'bert-base-german-dbmdz-uncased': 512,
    'TurkuNLP/bert-base-finnish-cased-v1': 512,
    'TurkuNLP/bert-base-finnish-uncased-v1': 512,
    'wietsedv/bert-base-dutch-cased': 512,
}

_snake_case				:				int       							=		{
    'bert-base-uncased': {'do_lower_case': True},
    'bert-large-uncased': {'do_lower_case': True},
    'bert-base-cased': {'do_lower_case': False},
    'bert-large-cased': {'do_lower_case': False},
    'bert-base-multilingual-uncased': {'do_lower_case': True},
    'bert-base-multilingual-cased': {'do_lower_case': False},
    'bert-base-chinese': {'do_lower_case': False},
    'bert-base-german-cased': {'do_lower_case': False},
    'bert-large-uncased-whole-word-masking': {'do_lower_case': True},
    'bert-large-cased-whole-word-masking': {'do_lower_case': False},
    'bert-large-uncased-whole-word-masking-finetuned-squad': {'do_lower_case': True},
    'bert-large-cased-whole-word-masking-finetuned-squad': {'do_lower_case': False},
    'bert-base-cased-finetuned-mrpc': {'do_lower_case': False},
    'bert-base-german-dbmdz-cased': {'do_lower_case': False},
    'bert-base-german-dbmdz-uncased': {'do_lower_case': True},
    'TurkuNLP/bert-base-finnish-cased-v1': {'do_lower_case': False},
    'TurkuNLP/bert-base-finnish-uncased-v1': {'do_lower_case': True},
    'wietsedv/bert-base-dutch-cased': {'do_lower_case': False},
}

class       A   (		_a   ):
							lowercase_          =    VOCAB_FILES_NAMES
							lowercase_          =    PRETRAINED_VOCAB_FILES_MAP
							lowercase_          =    PRETRAINED_INIT_CONFIGURATION
							lowercase_          =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							lowercase_          =    BertTokenizer







							def __init__(  self	:  str							,      lowerCAmelCase_	:  Union[str, Any]=None							,      lowerCAmelCase_	:  str=None							,      lowerCAmelCase_	:  List[Any]=True							,      lowerCAmelCase_	:  Any="[UNK]"							,      lowerCAmelCase_	:  Union[str, Any]="[SEP]"							,      lowerCAmelCase_	:  Tuple="[PAD]"							,      lowerCAmelCase_	:  Tuple="[CLS]"							,      lowerCAmelCase_	:  Optional[int]="[MASK]"							,      lowerCAmelCase_	:  Dict=True							,      lowerCAmelCase_	:  Union[str, Any]=None							,      **lowerCAmelCase_	:  Union[str, Any]							,      )      ->							Union[str, Any]:


														"""simple docstring"""


														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_							,      tokenize_chinese_chars=lowerCAmelCase_							,      strip_accents=lowerCAmelCase_							,      **lowerCAmelCase_							,      )

														_a     					=    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
														):
																					_a     					=    getattr(lowerCAmelCase_							,      normalizer_state.pop('''type''' ) )
																					_a     					=    do_lower_case
																					_a     					=    strip_accents
																					_a     					=    tokenize_chinese_chars
																					_a     					=    normalizer_class(**lowerCAmelCase_ )

														_a     					=    do_lower_case







							def        __lowerCAmelCase      (  self	:  str							,      lowerCAmelCase_	:  Dict							,      lowerCAmelCase_	:  int=None )      ->							List[str]:


														"""simple docstring"""


														_a     					=    [self.cls_token_id] + token_ids_a + [self.sep_token_id]

														if token_ids_a:
																					output += token_ids_a + [self.sep_token_id]

														return output







							def        __lowerCAmelCase      (  self	:  Any							,      lowerCAmelCase_	:  List[int]							,      lowerCAmelCase_	:  Optional[List[int]] = None )      ->							List[int]:


														"""simple docstring"""


														_a     					=    [self.sep_token_id]
														_a     					=    [self.cls_token_id]
														if token_ids_a is None:
																					return len(cls + token_ids_a + sep ) * [0]
														return len(cls + token_ids_a + sep ) * [0] + len(token_ids_a + sep ) * [1]







							def        __lowerCAmelCase      (  self	:  List[Any]							,      lowerCAmelCase_	:  str							,      lowerCAmelCase_	:  Optional[str] = None )      ->							Tuple[str]:


														"""simple docstring"""


														_a     					=    self._tokenizer.model.save(lowerCAmelCase_							,      name=lowerCAmelCase_ )
														return tuple(lowerCAmelCase_ )

