





"""simple docstring"""



import gc
import random
import tempfile
import unittest

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

from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel
from diffusers.pipelines.stable_diffusion_safe import StableDiffusionPipelineSafe as StableDiffusionPipeline
from diffusers.utils import floats_tensor, nightly, torch_device
from diffusers.utils.testing_utils import require_torch_gpu






class 		__snake_case (		unittest.TestCase					):





 """simple docstring"""


 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




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

 @property
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Tuple									=					1
     __A   :						Optional[Any]									=					3
     __A   :						Union[str, Any]									=					(32, 32)

     __A   :						Tuple									=					floats_tensor((batch_size, num_channels) + sizes ,						rng=random.Random(0  )  ).to(_SCREAMING_SNAKE_CASE  )
     return image

 @property
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     torch.manual_seed(0  )
     __A   :						Tuple									=					UNetaDConditionModel(
         block_out_channels=(32, 64) ,						layers_per_block=2 ,						sample_size=32 ,						in_channels=4 ,						out_channels=4 ,						down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''') ,						up_block_types=('''CrossAttnUpBlock2D''', '''UpBlock2D''') ,						cross_attention_dim=32 ,						)
     return model

 @property
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




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

 @property
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     torch.manual_seed(0  )
     __A   :						Dict									=					CLIPTextConfig(
         bos_token_id=0 ,						eos_token_id=2 ,						hidden_size=32 ,						intermediate_size=37 ,						layer_norm_eps=1e-0_5 ,						num_attention_heads=4 ,						num_hidden_layers=5 ,						pad_token_id=1 ,						vocab_size=1000 ,						)
     return CLIPTextModel(_SCREAMING_SNAKE_CASE  )

 @property
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     def extract(*__lowerCamelCase ,						**__lowerCamelCase  ):






         class 		__snake_case :





          """simple docstring"""


          def __init__(   self  ):



              '''simple docstring'''




              __A   :						List[Any]									=					torch.ones([0]  )







          def  UpperCamelCase__(   self ,						__lowerCamelCase  ):



              '''simple docstring'''




              self.pixel_values.to(_SCREAMING_SNAKE_CASE  )
              return self






         return Out()

     return extract

 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Optional[Any]									=					"""cpu"""  # ensure determinism for the device-dependent torch.Generator
     __A   :						Dict									=					self.dummy_cond_unet
     __A   :						Union[str, Any]									=					DDIMScheduler(
         beta_start=0.0_0_0_8_5 ,						beta_end=0.0_1_2 ,						beta_schedule='''scaled_linear''' ,						clip_sample=_SCREAMING_SNAKE_CASE ,						set_alpha_to_one=_SCREAMING_SNAKE_CASE ,						)

     __A   :						Optional[int]									=					self.dummy_vae
     __A   :						Any									=					self.dummy_text_encoder
     __A   :						Dict									=					CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''  )

     # make sure here that pndm scheduler skips prk
     __A   :						Any									=					StableDiffusionPipeline(
         unet=_SCREAMING_SNAKE_CASE ,						scheduler=_SCREAMING_SNAKE_CASE ,						vae=_SCREAMING_SNAKE_CASE ,						text_encoder=_SCREAMING_SNAKE_CASE ,						tokenizer=_SCREAMING_SNAKE_CASE ,						safety_checker=_SCREAMING_SNAKE_CASE ,						feature_extractor=self.dummy_extractor ,						)
     __A   :						Tuple									=					sd_pipe.to(_SCREAMING_SNAKE_CASE  )
     sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE  )

     __A   :						str									=					"""A painting of a squirrel eating a burger"""

     __A   :						Union[str, Any]									=					torch.Generator(device=_SCREAMING_SNAKE_CASE  ).manual_seed(0  )
     __A   :						Tuple									=					sd_pipe([prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=6.0 ,						num_inference_steps=2 ,						output_type='''np'''  )
     __A   :						Any									=					output.images

     __A   :						Union[str, Any]									=					torch.Generator(device=_SCREAMING_SNAKE_CASE  ).manual_seed(0  )
     __A   :						List[Any]									=					sd_pipe(
         [prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=6.0 ,						num_inference_steps=2 ,						output_type='''np''' ,						return_dict=_SCREAMING_SNAKE_CASE ,						)[0]

     __A   :						Optional[int]									=					image[0, -3:, -3:, -1]
     __A   :						Optional[Any]									=					image_from_tuple[0, -3:, -3:, -1]

     assert image.shape == (1, 64, 64, 3)
     __A   :						Optional[Any]									=					np.array([0.5_7_5_6, 0.6_1_1_8, 0.5_0_0_5, 0.5_0_4_1, 0.5_4_7_1, 0.4_7_2_6, 0.4_9_7_6, 0.4_8_6_5, 0.4_8_6_4]  )

     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  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Tuple									=					"""cpu"""  # ensure determinism for the device-dependent torch.Generator
     __A   :						List[Any]									=					self.dummy_cond_unet
     __A   :						List[str]									=					PNDMScheduler(skip_prk_steps=_SCREAMING_SNAKE_CASE  )
     __A   :						Dict									=					self.dummy_vae
     __A   :						str									=					self.dummy_text_encoder
     __A   :						List[Any]									=					CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''  )

     # make sure here that pndm scheduler skips prk
     __A   :						Any									=					StableDiffusionPipeline(
         unet=_SCREAMING_SNAKE_CASE ,						scheduler=_SCREAMING_SNAKE_CASE ,						vae=_SCREAMING_SNAKE_CASE ,						text_encoder=_SCREAMING_SNAKE_CASE ,						tokenizer=_SCREAMING_SNAKE_CASE ,						safety_checker=_SCREAMING_SNAKE_CASE ,						feature_extractor=self.dummy_extractor ,						)
     __A   :						List[str]									=					sd_pipe.to(_SCREAMING_SNAKE_CASE  )
     sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE  )

     __A   :						Dict									=					"""A painting of a squirrel eating a burger"""
     __A   :						List[Any]									=					torch.Generator(device=_SCREAMING_SNAKE_CASE  ).manual_seed(0  )
     __A   :						str									=					sd_pipe([prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=6.0 ,						num_inference_steps=2 ,						output_type='''np'''  )

     __A   :						List[str]									=					output.images

     __A   :						Optional[int]									=					torch.Generator(device=_SCREAMING_SNAKE_CASE  ).manual_seed(0  )
     __A   :						Tuple									=					sd_pipe(
         [prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=6.0 ,						num_inference_steps=2 ,						output_type='''np''' ,						return_dict=_SCREAMING_SNAKE_CASE ,						)[0]

     __A   :						Dict									=					image[0, -3:, -3:, -1]
     __A   :						Union[str, Any]									=					image_from_tuple[0, -3:, -3:, -1]

     assert image.shape == (1, 64, 64, 3)
     __A   :						Optional[Any]									=					np.array([0.5_1_2_5, 0.5_7_1_6, 0.4_8_2_8, 0.5_0_6_0, 0.5_6_5_0, 0.4_7_6_8, 0.5_1_8_5, 0.4_8_9_5, 0.4_9_9_3]  )

     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  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Dict									=					StableDiffusionPipeline.from_pretrained(
         '''hf-internal-testing/tiny-stable-diffusion-lms-pipe''' ,						safety_checker=_SCREAMING_SNAKE_CASE  )
     assert isinstance(_SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE  )
     assert isinstance(pipe.scheduler ,						_SCREAMING_SNAKE_CASE  )
     assert pipe.safety_checker is None

     __A   :						Dict									=					pipe('''example prompt''' ,						num_inference_steps=2  ).images[0]
     assert image is not None

     # check that there's no error when saving a pipeline with one of the models being None
     with tempfile.TemporaryDirectory() as tmpdirname:
         pipe.save_pretrained(_SCREAMING_SNAKE_CASE  )
         __A   :						Any									=					StableDiffusionPipeline.from_pretrained(_SCREAMING_SNAKE_CASE  )

     # sanity check that the pipeline still works
     assert pipe.safety_checker is None
     __A   :						Optional[Any]									=					pipe('''example prompt''' ,						num_inference_steps=2  ).images[0]
     assert image is not None







 @unittest.skipIf(torch_device != '''cuda''' ,						'''This test requires a GPU'''  )
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Optional[int]									=					self.dummy_cond_unet
     __A   :						Any									=					PNDMScheduler(skip_prk_steps=_SCREAMING_SNAKE_CASE  )
     __A   :						int									=					self.dummy_vae
     __A   :						Optional[Any]									=					self.dummy_text_encoder
     __A   :						int									=					CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''  )

     # put models in fp16
     __A   :						Optional[int]									=					unet.half()
     __A   :						str									=					vae.half()
     __A   :						Optional[int]									=					bert.half()

     # make sure here that pndm scheduler skips prk
     __A   :						Tuple									=					StableDiffusionPipeline(
         unet=_SCREAMING_SNAKE_CASE ,						scheduler=_SCREAMING_SNAKE_CASE ,						vae=_SCREAMING_SNAKE_CASE ,						text_encoder=_SCREAMING_SNAKE_CASE ,						tokenizer=_SCREAMING_SNAKE_CASE ,						safety_checker=_SCREAMING_SNAKE_CASE ,						feature_extractor=self.dummy_extractor ,						)
     __A   :						Optional[Any]									=					sd_pipe.to(_SCREAMING_SNAKE_CASE  )
     sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE  )

     __A   :						str									=					"""A painting of a squirrel eating a burger"""
     __A   :						Union[str, Any]									=					sd_pipe([prompt] ,						num_inference_steps=2 ,						output_type='''np'''  ).images

     assert image.shape == (1, 64, 64, 3)






@nightly
@require_torch_gpu
class 		__snake_case (		unittest.TestCase					):





 """simple docstring"""


 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




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

 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Union[str, Any]									=					StableDiffusionPipeline.from_pretrained('''runwayml/stable-diffusion-v1-5''' ,						safety_checker=_SCREAMING_SNAKE_CASE  )
     __A   :						int									=					LMSDiscreteScheduler.from_config(sd_pipe.scheduler.config  )
     __A   :						str									=					sd_pipe.to(_SCREAMING_SNAKE_CASE  )
     sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE  )

     __A   :						Tuple									=					(
         """portrait of girl with smokey eyes makeup in abandoned hotel, grange clothes, redshift, wide high angle"""
         """ coloured polaroid photograph with flash, kodak film, hyper real, stunning moody cinematography, with"""
         """ anamorphic lenses, by maripol, fallen angels by wong kar - wai, style of suspiria and neon demon and"""
         """ children from bahnhof zoo, detailed """
     )
     __A   :						Union[str, Any]									=					40_0366_0346
     __A   :						Tuple									=					7

     # without safety guidance (sld_guidance_scale = 0)
     __A   :						int									=					torch.manual_seed(_SCREAMING_SNAKE_CASE  )
     __A   :						str									=					sd_pipe(
         [prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=_SCREAMING_SNAKE_CASE ,						num_inference_steps=50 ,						output_type='''np''' ,						width=512 ,						height=512 ,						sld_guidance_scale=0 ,						)

     __A   :						List[Any]									=					output.images
     __A   :						Any									=					image[0, -3:, -3:, -1]
     __A   :						Optional[Any]									=					[0.2_2_7_8, 0.2_2_3_1, 0.2_2_4_9, 0.2_3_3_3, 0.2_3_0_3, 0.1_8_8_5, 0.2_2_7_3, 0.2_1_4_4, 0.2_1_7_6]

     assert image.shape == (1, 512, 512, 3)

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

     # without safety guidance (strong configuration)
     __A   :						List[str]									=					torch.manual_seed(_SCREAMING_SNAKE_CASE  )
     __A   :						str									=					sd_pipe(
         [prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=_SCREAMING_SNAKE_CASE ,						num_inference_steps=50 ,						output_type='''np''' ,						width=512 ,						height=512 ,						sld_guidance_scale=2000 ,						sld_warmup_steps=7 ,						sld_threshold=0.0_2_5 ,						sld_momentum_scale=0.5 ,						sld_mom_beta=0.7 ,						)

     __A   :						Dict									=					output.images
     __A   :						str									=					image[0, -3:, -3:, -1]
     __A   :						Dict									=					[0.2_3_8_3, 0.2_2_7_6, 0.2_3_6, 0.2_1_9_2, 0.2_1_8_6, 0.2_0_5_3, 0.1_9_7_1, 0.1_9_0_1, 0.1_7_1_9]

     assert image.shape == (1, 512, 512, 3)

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

 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						int									=					StableDiffusionPipeline.from_pretrained('''runwayml/stable-diffusion-v1-5''' ,						safety_checker=_SCREAMING_SNAKE_CASE  )
     __A   :						List[str]									=					LMSDiscreteScheduler.from_config(sd_pipe.scheduler.config  )
     __A   :						Dict									=					sd_pipe.to(_SCREAMING_SNAKE_CASE  )
     sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE  )

     __A   :						str									=					"""padme amidala taking a bath artwork, safe for work, no nudity"""
     __A   :						str									=					27_3497_1755
     __A   :						List[str]									=					7

     __A   :						int									=					torch.manual_seed(_SCREAMING_SNAKE_CASE  )
     __A   :						Union[str, Any]									=					sd_pipe(
         [prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=_SCREAMING_SNAKE_CASE ,						num_inference_steps=50 ,						output_type='''np''' ,						width=512 ,						height=512 ,						sld_guidance_scale=0 ,						)

     __A   :						Tuple									=					output.images
     __A   :						List[Any]									=					image[0, -3:, -3:, -1]
     __A   :						str									=					[0.3_5_0_2, 0.3_6_2_2, 0.3_3_9_6, 0.3_6_4_2, 0.3_4_7_8, 0.3_3_1_8, 0.3_5, 0.3_3_4_8, 0.3_2_9_7]

     assert image.shape == (1, 512, 512, 3)

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

     __A   :						Tuple									=					torch.manual_seed(_SCREAMING_SNAKE_CASE  )
     __A   :						Optional[int]									=					sd_pipe(
         [prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=_SCREAMING_SNAKE_CASE ,						num_inference_steps=50 ,						output_type='''np''' ,						width=512 ,						height=512 ,						sld_guidance_scale=2000 ,						sld_warmup_steps=7 ,						sld_threshold=0.0_2_5 ,						sld_momentum_scale=0.5 ,						sld_mom_beta=0.7 ,						)

     __A   :						int									=					output.images
     __A   :						int									=					image[0, -3:, -3:, -1]
     __A   :						str									=					[0.5_5_3_1, 0.5_2_0_6, 0.4_8_9_5, 0.5_1_5_6, 0.5_1_8_2, 0.4_7_5_1, 0.4_8_0_2, 0.4_8_0_3, 0.4_4_4_3]

     assert image.shape == (1, 512, 512, 3)

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







 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Union[str, Any]									=					StableDiffusionPipeline.from_pretrained('''runwayml/stable-diffusion-v1-5'''  )
     __A   :						List[str]									=					sd_pipe.to(_SCREAMING_SNAKE_CASE  )
     sd_pipe.set_progress_bar_config(disable=_SCREAMING_SNAKE_CASE  )

     __A   :						Union[str, Any]									=					(
         """the four horsewomen of the apocalypse, painting by tom of finland, gaston bussiere, craig mullins, j. c."""
         """ leyendecker"""
     )
     __A   :						List[Any]									=					10_4435_5234
     __A   :						str									=					12

     __A   :						List[str]									=					torch.manual_seed(_SCREAMING_SNAKE_CASE  )
     __A   :						Optional[Any]									=					sd_pipe(
         [prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=_SCREAMING_SNAKE_CASE ,						num_inference_steps=50 ,						output_type='''np''' ,						width=512 ,						height=512 ,						sld_guidance_scale=0 ,						)

     __A   :						Dict									=					output.images
     __A   :						int									=					image[0, -3:, -3:, -1]
     __A   :						Optional[Any]									=					np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]  )

     assert image.shape == (1, 512, 512, 3)

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

     __A   :						Optional[Any]									=					torch.manual_seed(_SCREAMING_SNAKE_CASE  )
     __A   :						Optional[Any]									=					sd_pipe(
         [prompt] ,						generator=_SCREAMING_SNAKE_CASE ,						guidance_scale=_SCREAMING_SNAKE_CASE ,						num_inference_steps=50 ,						output_type='''np''' ,						width=512 ,						height=512 ,						sld_guidance_scale=2000 ,						sld_warmup_steps=7 ,						sld_threshold=0.0_2_5 ,						sld_momentum_scale=0.5 ,						sld_mom_beta=0.7 ,						)

     __A   :						List[str]									=					output.images
     __A   :						Optional[Any]									=					image[0, -3:, -3:, -1]
     __A   :						List[Any]									=					np.array([0.5_8_1_8, 0.6_2_8_5, 0.6_8_3_5, 0.6_0_1_9, 0.6_2_5, 0.6_7_5_4, 0.6_0_9_6, 0.6_3_3_4, 0.6_5_6_1]  )
     assert image.shape == (1, 512, 512, 3)

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











"""simple docstring"""



import json
import os
import unittest

from transformers import MgpstrTokenizer
from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers

from ...test_tokenization_common import TokenizerTesterMixin






@require_tokenizers
class 		__snake_case (		SCREAMING_SNAKE_CASE__							,							unittest.TestCase					):





 """simple docstring"""


 _lowerCamelCase				=					MgpstrTokenizer
 _lowerCamelCase				=					False
 _lowerCamelCase				=					{}
 _lowerCamelCase				=					False

 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     super().setUp()

     # fmt: off
     __A   :						int									=					['''[GO]''', '''[s]''', '''0''', '''1''', '''2''', '''3''', '''4''', '''5''', '''6''', '''7''', '''8''', '''9''', '''a''', '''b''', '''c''', '''d''', '''e''', '''f''', '''g''', '''h''', '''i''', '''j''', '''k''', '''l''', '''m''', '''n''', '''o''', '''p''', '''q''', '''r''', '''s''', '''t''', '''u''', '''v''', '''w''', '''x''', '''y''', '''z''']
     # fmt: on
     __A   :						Dict									=					dict(zip(__lowerCamelCase ,						range(len(__lowerCamelCase  )  )  )  )

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

 def  UpperCamelCase__(   self ,						**__lowerCamelCase  ):



     '''simple docstring'''




     return MgpstrTokenizer.from_pretrained(self.tmpdirname ,						**__lowerCamelCase  )

 def  UpperCamelCase__(   self ,						__lowerCamelCase  ):



     '''simple docstring'''




     __A   :						List[str]									=					'''tester'''
     __A   :						Dict									=					'''tester'''
     return input_text, output_text

 @unittest.skip('''MGP-STR always lower cases letters.'''  )
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     pass

 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						List[Any]									=					self.get_tokenizers(do_lower_case=__lowerCamelCase  )
     for tokenizer in tokenizers:
         with self.subTest(F"""{tokenizer.__class__.__name__}"""  ):
             __A   :						Union[str, Any]									=					'''[SPECIAL_TOKEN]'''

             tokenizer.add_special_tokens({'''cls_token''': special_token}  )
             __A   :						Optional[Any]									=					tokenizer.encode([special_token] ,						add_special_tokens=__lowerCamelCase  )
             self.assertEqual(len(__lowerCamelCase  ) ,						1  )

             __A   :						List[Any]									=					tokenizer.decode(__lowerCamelCase ,						skip_special_tokens=__lowerCamelCase  )
             self.assertTrue(special_token not in decoded  )

 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     __A   :						Tuple									=					self.get_tokenizers()
     for tokenizer in tokenizers:
         with self.subTest(F"""{tokenizer.__class__.__name__}"""  ):
             __A			,	__A   :						str									=					self.get_input_output_texts(__lowerCamelCase  )

             __A   :						Union[str, Any]									=					tokenizer.tokenize(__lowerCamelCase  )
             __A   :						Union[str, Any]									=					tokenizer.convert_tokens_to_ids(__lowerCamelCase  )
             __A   :						Union[str, Any]									=					tokenizer.encode(__lowerCamelCase ,						add_special_tokens=__lowerCamelCase  )
             self.assertListEqual(__lowerCamelCase ,						__lowerCamelCase  )

             __A   :						Optional[Any]									=					tokenizer.convert_ids_to_tokens(__lowerCamelCase  )
             self.assertNotEqual(len(__lowerCamelCase  ) ,						0  )
             __A   :						Union[str, Any]									=					tokenizer.decode(__lowerCamelCase  )
             self.assertIsInstance(__lowerCamelCase ,						__lowerCamelCase  )

             self.assertEqual(text_a.replace(''' ''' ,						''''''  ) ,						__lowerCamelCase  )

 @unittest.skip('''MGP-STR tokenizer only handles one sequence.'''  )
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     pass







 @unittest.skip('''inputs cannot be pretokenized in MgpstrTokenizer'''  )
 def  UpperCamelCase__(   self  ):



     '''simple docstring'''




     pass




