
import gc
import unittest

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

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    EulerAncestralDiscreteScheduler,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionPanoramaPipeline,
    UNetaDConditionModel,
)
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()







@skip_mps
class 					lowerCamelCase		(  A_							,			A_							,			unittest.TestCase  ):
					UpperCAmelCase__    :							List[Any]									=		StableDiffusionPanoramaPipeline
					UpperCAmelCase__    :							List[Any]									=		TEXT_TO_IMAGE_PARAMS
					UpperCAmelCase__    :							str									=		TEXT_TO_IMAGE_BATCH_PARAMS
					UpperCAmelCase__    :							Dict									=		TEXT_TO_IMAGE_IMAGE_PARAMS
					UpperCAmelCase__    :							List[str]									=		TEXT_TO_IMAGE_IMAGE_PARAMS





					def 		UpperCAmelCase(self				:   List[str]       )						->						Union[str, Any]:
									torch.manual_seed(0       )
									snake_case								= UNetaDConditionModel(
									    block_out_channels=(3_2, 6_4)    ,   layers_per_block=1    ,   sample_size=3_2    ,   in_channels=4    ,   out_channels=4    ,   down_block_types=("DownBlock2D", "CrossAttnDownBlock2D")    ,   up_block_types=("CrossAttnUpBlock2D", "UpBlock2D")    ,   cross_attention_dim=3_2    ,   )
									snake_case								= DDIMScheduler()
									torch.manual_seed(0       )
									snake_case								= AutoencoderKL(
									    block_out_channels=[3_2, 6_4]    ,   in_channels=3    ,   out_channels=3    ,   down_block_types=["DownEncoderBlock2D", "DownEncoderBlock2D"]    ,   up_block_types=["UpDecoderBlock2D", "UpDecoderBlock2D"]    ,   latent_channels=4    ,   )
									torch.manual_seed(0       )
									snake_case								= CLIPTextConfig(
									    bos_token_id=0    ,   eos_token_id=2    ,   hidden_size=3_2    ,   intermediate_size=3_7    ,   layer_norm_eps=1E-05    ,   num_attention_heads=4    ,   num_hidden_layers=5    ,   pad_token_id=1    ,   vocab_size=1_0_0_0    ,   )
									snake_case								= CLIPTextModel(_A       )
									snake_case								= CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip"       )

									snake_case								= {
									    "unet": unet,
									    "scheduler": scheduler,
									    "vae": vae,
									    "text_encoder": text_encoder,
									    "tokenizer": tokenizer,
									    "safety_checker": None,
									    "feature_extractor": None,
									}
									return components





					def 		UpperCAmelCase(self				:   Optional[Any]    ,   _A				:   Optional[Any]    ,   _A				:   str=0       )						->						Dict:
									snake_case								= torch.manual_seed(_A       )
									snake_case								= {
									    "prompt": "a photo of the dolomites",
									    "generator": generator,
									    # Setting height and width to None to prevent OOMs on CPU.
									    "height": None,
									    "width": None,
									    "num_inference_steps": 1,
									    "guidance_scale": 6.0,
									    "output_type": "numpy",
									}
									return inputs





					def 		UpperCAmelCase(self				:   List[str]       )						->						List[str]:
									snake_case								= "cpu"  # ensure determinism for the device-dependent torch.Generator
									snake_case								= self.get_dummy_components()
									snake_case								= StableDiffusionPanoramaPipeline(**_A       )
									snake_case								= sd_pipe.to(_A       )
									sd_pipe.set_progress_bar_config(disable=_A       )

									snake_case								= self.get_dummy_inputs(_A       )
									snake_case								= sd_pipe(**_A       ).images
									snake_case								= image[0, -3:, -3:, -1]
									assert image.shape == (1, 6_4, 6_4, 3)

									snake_case								= np.array([0.61_86, 0.53_74, 0.49_15, 0.41_35, 0.41_14, 0.45_63, 0.51_28, 0.49_77, 0.47_57]       )

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





					def 		UpperCAmelCase(self				:   str       )						->						Dict:
									super().test_inference_batch_consistent(batch_sizes=[1, 2]       )





					def 		UpperCAmelCase(self				:   str       )						->						Any:
									super().test_inference_batch_single_identical(batch_size=2    ,   expected_max_diff=3.25E-3       )





					def 		UpperCAmelCase(self				:   Dict       )						->						Any:
									snake_case								= "cpu"  # ensure determinism for the device-dependent torch.Generator
									snake_case								= self.get_dummy_components()
									snake_case								= StableDiffusionPanoramaPipeline(**_A       )
									snake_case								= sd_pipe.to(_A       )
									sd_pipe.set_progress_bar_config(disable=_A       )

									snake_case								= self.get_dummy_inputs(_A       )
									snake_case								= "french fries"
									snake_case								= sd_pipe(**_A    ,   negative_prompt=_A       )
									snake_case								= output.images
									snake_case								= image[0, -3:, -3:, -1]

									assert image.shape == (1, 6_4, 6_4, 3)

									snake_case								= np.array([0.61_87, 0.53_75, 0.49_15, 0.41_36, 0.41_14, 0.45_63, 0.51_28, 0.49_76, 0.47_57]       )

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





					def 		UpperCAmelCase(self				:   Tuple       )						->						str:
									snake_case								= "cpu"  # ensure determinism for the device-dependent torch.Generator
									snake_case								= self.get_dummy_components()
									snake_case								= StableDiffusionPanoramaPipeline(**_A       )
									snake_case								= sd_pipe.to(_A       )
									sd_pipe.set_progress_bar_config(disable=_A       )

									snake_case								= self.get_dummy_inputs(_A       )
									snake_case								= sd_pipe(**_A    ,   view_batch_size=2       )
									snake_case								= output.images
									snake_case								= image[0, -3:, -3:, -1]

									assert image.shape == (1, 6_4, 6_4, 3)

									snake_case								= np.array([0.61_87, 0.53_75, 0.49_15, 0.41_36, 0.41_14, 0.45_63, 0.51_28, 0.49_76, 0.47_57]       )

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





					def 		UpperCAmelCase(self				:   int       )						->						List[Any]:
									snake_case								= "cpu"  # ensure determinism for the device-dependent torch.Generator
									snake_case								= self.get_dummy_components()
									snake_case								= EulerAncestralDiscreteScheduler(
									    beta_start=0.0_00_85    ,   beta_end=0.0_12    ,   beta_schedule="scaled_linear"       )
									snake_case								= StableDiffusionPanoramaPipeline(**_A       )
									snake_case								= sd_pipe.to(_A       )
									sd_pipe.set_progress_bar_config(disable=_A       )

									snake_case								= self.get_dummy_inputs(_A       )
									snake_case								= sd_pipe(**_A       ).images
									snake_case								= image[0, -3:, -3:, -1]

									assert image.shape == (1, 6_4, 6_4, 3)

									snake_case								= np.array([0.40_24, 0.65_10, 0.49_01, 0.53_78, 0.58_13, 0.56_22, 0.47_95, 0.44_67, 0.49_52]       )

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





					def 		UpperCAmelCase(self				:   Tuple       )						->						Optional[Any]:
									snake_case								= "cpu"  # ensure determinism for the device-dependent torch.Generator
									snake_case								= self.get_dummy_components()
									snake_case								= PNDMScheduler(
									    beta_start=0.0_00_85    ,   beta_end=0.0_12    ,   beta_schedule="scaled_linear"    ,   skip_prk_steps=_A       )
									snake_case								= StableDiffusionPanoramaPipeline(**_A       )
									snake_case								= sd_pipe.to(_A       )
									sd_pipe.set_progress_bar_config(disable=_A       )

									snake_case								= self.get_dummy_inputs(_A       )
									snake_case								= sd_pipe(**_A       ).images
									snake_case								= image[0, -3:, -3:, -1]

									assert image.shape == (1, 6_4, 6_4, 3)

									snake_case								= np.array([0.63_91, 0.62_91, 0.48_61, 0.51_34, 0.55_52, 0.45_78, 0.50_32, 0.50_23, 0.45_39]       )

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







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





					def 		UpperCAmelCase(self				:   Any       )						->						Optional[Any]:
									super().tearDown()
									gc.collect()
									torch.cuda.empty_cache()





					def 		UpperCAmelCase(self				:   List[Any]    ,   _A				:   Any=0       )						->						Optional[int]:
									snake_case								= torch.manual_seed(_A       )
									snake_case								= {
									    "prompt": "a photo of the dolomites",
									    "generator": generator,
									    "num_inference_steps": 3,
									    "guidance_scale": 7.5,
									    "output_type": "numpy",
									}
									return inputs





					def 		UpperCAmelCase(self				:   Tuple       )						->						List[Any]:
									snake_case								= "stabilityai/stable-diffusion-2-base"
									snake_case								= DDIMScheduler.from_pretrained(_A    ,   subfolder="scheduler"       )
									snake_case								= StableDiffusionPanoramaPipeline.from_pretrained(_A    ,   scheduler=_A    ,   safety_checker=_A       )
									pipe.to(_A       )
									pipe.set_progress_bar_config(disable=_A       )
									pipe.enable_attention_slicing()

									snake_case								= self.get_inputs()
									snake_case								= pipe(**_A       ).images
									snake_case								= image[0, -3:, -3:, -1].flatten()

									assert image.shape == (1, 5_1_2, 2_0_4_8, 3)

									snake_case								= np.array(
									    [
									        0.36_96_83_92,
									        0.27_02_53_72,
									        0.32_44_67_66,
									        0.28_37_93_87,
									        0.36_36_32_74,
									        0.30_73_33_47,
									        0.27_10_00_27,
									        0.27_05_41_25,
									        0.25_53_60_96,
									    ]       )

									assert np.abs(expected_slice - image_slice       ).max() < 1E-2





					def 		UpperCAmelCase(self				:   int       )						->						Any:
									snake_case								= StableDiffusionPanoramaPipeline.from_pretrained(
									    "stabilityai/stable-diffusion-2-base"    ,   safety_checker=_A       )
									snake_case								= LMSDiscreteScheduler.from_config(pipe.scheduler.config       )
									pipe.to(_A       )
									pipe.set_progress_bar_config(disable=_A       )
									pipe.enable_attention_slicing()

									snake_case								= self.get_inputs()
									snake_case								= pipe(**_A       ).images
									snake_case								= image[0, -3:, -3:, -1].flatten()

									assert image.shape == (1, 5_1_2, 2_0_4_8, 3)

									snake_case								= np.array(
									    [
									        [
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									        ]
									    ]       )

									assert np.abs(expected_slice - image_slice       ).max() < 1E-3





					def 		UpperCAmelCase(self				:   Tuple       )						->						Optional[Any]:
									snake_case								= 0

									def callback_fn(_A				:   int    ,   _A				:   int    ,   _A				:   torch.FloatTensor       ) -> None:
													snake_case								= True
													nonlocal number_of_steps
													number_of_steps += 1
													if step == 1:
																	snake_case								= latents.detach().cpu().numpy()
																	assert latents.shape == (1, 4, 6_4, 2_5_6)
																	snake_case								= latents[0, -3:, -3:, -1]

																	snake_case								= np.array(
																	    [
																	        0.18_68_18_69,
																	        0.33_90_78_16,
																	        0.5_36_12_76,
																	        0.14_43_28_65,
																	        -0.02_85_66_11,
																	        -0.73_94_11_23,
																	        0.23_39_79_87,
																	        0.47_32_26_82,
																	        -0.37_82_31_64,
																	    ]       )
																	assert np.abs(latents_slice.flatten() - expected_slice       ).max() < 5E-2
													elif step == 2:
																	snake_case								= latents.detach().cpu().numpy()
																	assert latents.shape == (1, 4, 6_4, 2_5_6)
																	snake_case								= latents[0, -3:, -3:, -1]

																	snake_case								= np.array(
																	    [
																	        0.18_53_96_45,
																	        0.33_98_72_48,
																	        0.5_37_85_59,
																	        0.14_43_71_42,
																	        -0.02_45_52_61,
																	        -0.7_33_83_17,
																	        0.23_99_07_55,
																	        0.47_35_62_72,
																	        -0.3_78_65_05,
																	    ]       )

																	assert np.abs(latents_slice.flatten() - expected_slice       ).max() < 5E-2

									snake_case								= False

									snake_case								= "stabilityai/stable-diffusion-2-base"
									snake_case								= DDIMScheduler.from_pretrained(_A    ,   subfolder="scheduler"       )
									snake_case								= StableDiffusionPanoramaPipeline.from_pretrained(_A    ,   scheduler=_A    ,   safety_checker=_A       )
									snake_case								= pipe.to(_A       )
									pipe.set_progress_bar_config(disable=_A       )
									pipe.enable_attention_slicing()

									snake_case								= self.get_inputs()
									pipe(**_A    ,   callback=_A    ,   callback_steps=1       )
									assert callback_fn.has_been_called
									assert number_of_steps == 3





					def 		UpperCAmelCase(self				:   Dict       )						->						str:
									torch.cuda.empty_cache()
									torch.cuda.reset_max_memory_allocated()
									torch.cuda.reset_peak_memory_stats()

									snake_case								= "stabilityai/stable-diffusion-2-base"
									snake_case								= DDIMScheduler.from_pretrained(_A    ,   subfolder="scheduler"       )
									snake_case								= StableDiffusionPanoramaPipeline.from_pretrained(_A    ,   scheduler=_A    ,   safety_checker=_A       )
									snake_case								= pipe.to(_A       )
									pipe.set_progress_bar_config(disable=_A       )
									pipe.enable_attention_slicing(1       )
									pipe.enable_sequential_cpu_offload()

									snake_case								= self.get_inputs()
									snake_case								= pipe(**_A       )

									snake_case								= torch.cuda.max_memory_allocated()
									# make sure that less than 5.2 GB is allocated
									assert mem_bytes < 5.5 * 1_0**9



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


_A   =			logging.get_logger(__name__)

_A   =			{"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

_A   =			{
    "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"
        ),
    },
}

_A   =			{
    "bert-base-uncased": 5_12,
    "bert-large-uncased": 5_12,
    "bert-base-cased": 5_12,
    "bert-large-cased": 5_12,
    "bert-base-multilingual-uncased": 5_12,
    "bert-base-multilingual-cased": 5_12,
    "bert-base-chinese": 5_12,
    "bert-base-german-cased": 5_12,
    "bert-large-uncased-whole-word-masking": 5_12,
    "bert-large-cased-whole-word-masking": 5_12,
    "bert-large-uncased-whole-word-masking-finetuned-squad": 5_12,
    "bert-large-cased-whole-word-masking-finetuned-squad": 5_12,
    "bert-base-cased-finetuned-mrpc": 5_12,
    "bert-base-german-dbmdz-cased": 5_12,
    "bert-base-german-dbmdz-uncased": 5_12,
    "TurkuNLP/bert-base-finnish-cased-v1": 5_12,
    "TurkuNLP/bert-base-finnish-uncased-v1": 5_12,
    "wietsedv/bert-base-dutch-cased": 5_12,
}

_A   =			{
    "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 					lowerCamelCase		(  A_  ):
     UpperCAmelCase__    :							Optional[Any]									=		VOCAB_FILES_NAMES
     UpperCAmelCase__    :							Union[str, Any]									=		PRETRAINED_VOCAB_FILES_MAP
     UpperCAmelCase__    :							Union[str, Any]									=		PRETRAINED_INIT_CONFIGURATION
     UpperCAmelCase__    :							Any									=		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     UpperCAmelCase__    :							int									=		BertTokenizer





     def __init__(self				:   Union[str, Any]    ,   _A				:   Union[str, Any]=None    ,   _A				:   Optional[int]=None    ,   _A				:   List[str]=True    ,   _A				:   List[Any]="[UNK]"    ,   _A				:   Union[str, Any]="[SEP]"    ,   _A				:   List[Any]="[PAD]"    ,   _A				:   List[Any]="[CLS]"    ,   _A				:   Union[str, Any]="[MASK]"    ,   _A				:   int=True    ,   _A				:   Tuple=None    ,   **_A				:   Optional[int]    ,   )						->						int:
         super().__init__(
             _A    ,   tokenizer_file=_A    ,   do_lower_case=_A    ,   unk_token=_A    ,   sep_token=_A    ,   pad_token=_A    ,   cls_token=_A    ,   mask_token=_A    ,   tokenize_chinese_chars=_A    ,   strip_accents=_A    ,   **_A    ,   )

         snake_case								= json.loads(self.backend_tokenizer.normalizer.__getstate__()       )
         if (
             normalizer_state.get("lowercase"    ,   _A       ) != do_lower_case
             or normalizer_state.get("strip_accents"    ,   _A       ) != strip_accents
             or normalizer_state.get("handle_chinese_chars"    ,   _A       ) != tokenize_chinese_chars
         ):
             snake_case								= getattr(_A    ,   normalizer_state.pop("type"       )       )
             snake_case								= do_lower_case
             snake_case								= strip_accents
             snake_case								= tokenize_chinese_chars
             snake_case								= normalizer_class(**_A       )

         snake_case								= do_lower_case





     def 		UpperCAmelCase(self				:   str    ,   _A				:   Union[str, Any]    ,   _A				:   int=None       )						->						Any:
         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 		UpperCAmelCase(self				:   Optional[Any]    ,   _A				:   List[int]    ,   _A				:   Optional[List[int]] = None       )						->						List[int]:
         snake_case								= [self.sep_token_id]
         snake_case								= [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 		UpperCAmelCase(self				:   Union[str, Any]    ,   _A				:   str    ,   _A				:   Optional[str] = None       )						->						Tuple[str]:
         snake_case								= self._tokenizer.model.save(_A    ,   name=_A       )
         return tuple(_A       )

