





'''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,
    EulerAncestralDiscreteScheduler,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionInstructPixaPixPipeline,
    UNetaDConditionModel,
)
from diffusers.image_processor import VaeImageProcessor
from diffusers.utils import floats_tensor, load_image, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import (
    IMAGE_TO_IMAGE_IMAGE_PARAMS,
    TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_VARIATION_PARAMS,
)
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()







class __a			( _snake_case, _snake_case, _snake_case, unittest.TestCase      ):
   __UpperCamelCase :			str						   =						StableDiffusionInstructPixaPixPipeline
   __UpperCamelCase :			Optional[int]						   =						TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {'height', 'width', 'cross_attention_kwargs'}
   __UpperCamelCase :			Any						   =						TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS
   __UpperCamelCase :			List[str]						   =						IMAGE_TO_IMAGE_IMAGE_PARAMS
   __UpperCamelCase :			Dict						   =						IMAGE_TO_IMAGE_IMAGE_PARAMS





   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

      torch.manual_seed(0     )
      __SCREAMING_SNAKE_CASE   				=							UNetaDConditionModel(
          block_out_channels=(32, 64)					,layers_per_block=2					,sample_size=32					,in_channels=8					,out_channels=4					,down_block_types=("""DownBlock2D""", """CrossAttnDownBlock2D""")					,up_block_types=("""CrossAttnUpBlock2D""", """UpBlock2D""")					,cross_attention_dim=32					,)
      __SCREAMING_SNAKE_CASE   				=							PNDMScheduler(skip_prk_steps=lowerCamelCase     )
      torch.manual_seed(0     )
      __SCREAMING_SNAKE_CASE   				=							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					,)
      torch.manual_seed(0     )
      __SCREAMING_SNAKE_CASE   				=							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					,)
      __SCREAMING_SNAKE_CASE   				=							CLIPTextModel(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""     )

      __SCREAMING_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					:      int					,lowerCamelCase					:      Optional[int]					,lowerCamelCase					:      Optional[Any]=0     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							floats_tensor((1, 3, 32, 32)					,rng=random.Random(lowerCamelCase     )     ).to(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							image.cpu().permute(0					,2					,3					,1     )[0]
      __SCREAMING_SNAKE_CASE   				=							Image.fromarray(np.uinta(lowerCamelCase     )     ).convert("""RGB"""     )
      if str(lowerCamelCase     ).startswith("""mps"""     ):
         __SCREAMING_SNAKE_CASE   				=							torch.manual_seed(lowerCamelCase     )
      else:
         __SCREAMING_SNAKE_CASE   				=							torch.Generator(device=lowerCamelCase     ).manual_seed(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							{
          """prompt""": """A painting of a squirrel eating a burger""",
          """image""": image,
          """generator""": generator,
          """num_inference_steps""": 2,
          """guidance_scale""": 6.0,
          """image_guidance_scale""": 1,
          """output_type""": """numpy""",
      }
      return inputs





   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							"""cpu"""  # ensure determinism for the device-dependent torch.Generator
      __SCREAMING_SNAKE_CASE   				=							self.get_dummy_components()
      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline(**lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							sd_pipe.to(lowerCamelCase     )
      sd_pipe.set_progress_bar_config(disable=lowerCamelCase     )

      __SCREAMING_SNAKE_CASE   				=							self.get_dummy_inputs(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							sd_pipe(**lowerCamelCase     ).images
      __SCREAMING_SNAKE_CASE   				=							image[0, -3:, -3:, -1]
      assert image.shape == (1, 32, 32, 3)
      __SCREAMING_SNAKE_CASE   				=							np.array([0.7_526, 0.3_750, 0.4_547, 0.6_117, 0.5_866, 0.5_016, 0.4_327, 0.5_642, 0.4_815]     )

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





   def   UpperCAmelCase__  (       self					:      int     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							"""cpu"""  # ensure determinism for the device-dependent torch.Generator
      __SCREAMING_SNAKE_CASE   				=							self.get_dummy_components()
      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline(**lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							sd_pipe.to(lowerCamelCase     )
      sd_pipe.set_progress_bar_config(disable=lowerCamelCase     )

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

      assert image.shape == (1, 32, 32, 3)
      __SCREAMING_SNAKE_CASE   				=							np.array([0.7_511, 0.3_642, 0.4_553, 0.6_236, 0.5_797, 0.5_013, 0.4_343, 0.5_611, 0.4_831]     )

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





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							"""cpu"""  # ensure determinism for the device-dependent torch.Generator
      __SCREAMING_SNAKE_CASE   				=							self.get_dummy_components()
      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline(**lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							sd_pipe.to(lowerCamelCase     )
      sd_pipe.set_progress_bar_config(disable=lowerCamelCase     )

      __SCREAMING_SNAKE_CASE   				=							self.get_dummy_inputs(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							[inputs["""prompt"""]] * 2

      __SCREAMING_SNAKE_CASE   				=							np.array(inputs["""image"""]     ).astype(np.floataa     ) / 255.0
      __SCREAMING_SNAKE_CASE   				=							torch.from_numpy(lowerCamelCase     ).unsqueeze(0     ).to(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							image / 2 + 0.5
      __SCREAMING_SNAKE_CASE   				=							image.permute(0					,3					,1					,2     )
      __SCREAMING_SNAKE_CASE   				=							image.repeat(2					,1					,1					,1     )

      __SCREAMING_SNAKE_CASE   				=							sd_pipe(**lowerCamelCase     ).images
      __SCREAMING_SNAKE_CASE   				=							image[-1, -3:, -3:, -1]

      assert image.shape == (2, 32, 32, 3)
      __SCREAMING_SNAKE_CASE   				=							np.array([0.5_812, 0.5_748, 0.5_222, 0.5_908, 0.5_695, 0.7_174, 0.6_804, 0.5_523, 0.5_579]     )

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





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							"""cpu"""  # ensure determinism for the device-dependent torch.Generator
      __SCREAMING_SNAKE_CASE   				=							self.get_dummy_components()
      __SCREAMING_SNAKE_CASE   				=							EulerAncestralDiscreteScheduler(
          beta_start=0.00_085					,beta_end=0.012					,beta_schedule="""scaled_linear"""     )
      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline(**lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							sd_pipe.to(lowerCamelCase     )
      sd_pipe.set_progress_bar_config(disable=lowerCamelCase     )

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

      __SCREAMING_SNAKE_CASE   				=							[round(lowerCamelCase					,4     ) for x in image_slice.flatten().tolist()]
      print(""",""".join([str(lowerCamelCase     ) for x in slice]     )     )

      assert image.shape == (1, 32, 32, 3)
      __SCREAMING_SNAKE_CASE   				=							np.array([0.7_417, 0.3_842, 0.4_732, 0.5_776, 0.5_891, 0.5_139, 0.4_052, 0.5_673, 0.4_986]     )

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





   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

      super().test_inference_batch_single_identical(expected_max_diff=3E-3     )





   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							self.get_dummy_components()
      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline(**lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							VaeImageProcessor(do_resize=lowerCamelCase					,do_normalize=lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							pipe.to(lowerCamelCase     )
      pipe.set_progress_bar_config(disable=lowerCamelCase     )

      __SCREAMING_SNAKE_CASE   				=							pipe(**self.get_dummy_inputs_by_type(lowerCamelCase					,input_image_type="""pt"""     )     )[0]

      __SCREAMING_SNAKE_CASE   				=							components["""vae"""]
      __SCREAMING_SNAKE_CASE   				=							self.get_dummy_inputs_by_type(lowerCamelCase					,input_image_type="""pt"""     )

      for image_param in self.image_latents_params:
         if image_param in inputs.keys():
            __SCREAMING_SNAKE_CASE   				=							vae.encode(inputs[image_param]     ).latent_dist.mode()

      __SCREAMING_SNAKE_CASE   				=							pipe(**lowerCamelCase     )[0]

      __SCREAMING_SNAKE_CASE   				=							np.abs(out - out_latents_inputs     ).max()
      self.assertLess(lowerCamelCase					,1E-4					,"""passing latents as image input generate different result from passing image"""     )







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





   def   UpperCAmelCase__  (       self					:      Dict     ):

      '''simple docstring'''

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





   def   UpperCAmelCase__  (       self					:      int					,lowerCamelCase					:      int=0     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							torch.manual_seed(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							load_image(
          """https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_pix2pix/example.jpg"""     )
      __SCREAMING_SNAKE_CASE   				=							{
          """prompt""": """turn him into a cyborg""",
          """image""": image,
          """generator""": generator,
          """num_inference_steps""": 3,
          """guidance_scale""": 7.5,
          """image_guidance_scale""": 1.0,
          """output_type""": """numpy""",
      }
      return inputs





   def   UpperCAmelCase__  (       self					:      Tuple     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline.from_pretrained(
          """timbrooks/instruct-pix2pix"""					,safety_checker=lowerCamelCase     )
      pipe.to(lowerCamelCase     )
      pipe.set_progress_bar_config(disable=lowerCamelCase     )
      pipe.enable_attention_slicing()

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

      assert image.shape == (1, 512, 512, 3)
      __SCREAMING_SNAKE_CASE   				=							np.array([0.5_902, 0.6_015, 0.6_027, 0.5_983, 0.6_092, 0.6_061, 0.5_765, 0.5_785, 0.5_555]     )

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





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline.from_pretrained(
          """timbrooks/instruct-pix2pix"""					,safety_checker=lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							LMSDiscreteScheduler.from_config(pipe.scheduler.config     )
      pipe.to(lowerCamelCase     )
      pipe.set_progress_bar_config(disable=lowerCamelCase     )
      pipe.enable_attention_slicing()

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

      assert image.shape == (1, 512, 512, 3)
      __SCREAMING_SNAKE_CASE   				=							np.array([0.6_578, 0.6_817, 0.6_972, 0.6_761, 0.6_856, 0.6_916, 0.6_428, 0.6_516, 0.6_301]     )

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





   def   UpperCAmelCase__  (       self					:      Union[str, Any]     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline.from_pretrained(
          """timbrooks/instruct-pix2pix"""					,safety_checker=lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							DDIMScheduler.from_config(pipe.scheduler.config     )
      pipe.to(lowerCamelCase     )
      pipe.set_progress_bar_config(disable=lowerCamelCase     )
      pipe.enable_attention_slicing()

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

      assert image.shape == (1, 512, 512, 3)
      __SCREAMING_SNAKE_CASE   				=							np.array([0.3_828, 0.3_834, 0.3_818, 0.3_792, 0.3_865, 0.3_752, 0.3_792, 0.3_847, 0.3_753]     )

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





   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							0

      def callback_fn(lowerCamelCase					:      int					,lowerCamelCase					:      int					,lowerCamelCase					:      torch.FloatTensor     ) -> None:
         __SCREAMING_SNAKE_CASE   				=							True
         nonlocal number_of_steps
         number_of_steps += 1
         if step == 1:
            __SCREAMING_SNAKE_CASE   				=							latents.detach().cpu().numpy()
            assert latents.shape == (1, 4, 64, 64)
            __SCREAMING_SNAKE_CASE   				=							latents[0, -3:, -3:, -1]
            __SCREAMING_SNAKE_CASE   				=							np.array([-0.2_463, -0.4_644, -0.9_756, 1.5_176, 1.4_414, 0.7_866, 0.9_897, 0.8_521, 0.7_983]     )

            assert np.abs(latents_slice.flatten() - expected_slice     ).max() < 5E-2
         elif step == 2:
            __SCREAMING_SNAKE_CASE   				=							latents.detach().cpu().numpy()
            assert latents.shape == (1, 4, 64, 64)
            __SCREAMING_SNAKE_CASE   				=							latents[0, -3:, -3:, -1]
            __SCREAMING_SNAKE_CASE   				=							np.array([-0.2_644, -0.4_626, -0.9_653, 1.5_176, 1.4_551, 0.7_686, 0.9_805, 0.8_452, 0.8_115]     )

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

      __SCREAMING_SNAKE_CASE   				=							False

      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline.from_pretrained(
          """timbrooks/instruct-pix2pix"""					,safety_checker=lowerCamelCase					,torch_dtype=torch.floataa     )
      __SCREAMING_SNAKE_CASE   				=							pipe.to(lowerCamelCase     )
      pipe.set_progress_bar_config(disable=lowerCamelCase     )
      pipe.enable_attention_slicing()

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





   def   UpperCAmelCase__  (       self					:      str     ):

      '''simple docstring'''

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

      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline.from_pretrained(
          """timbrooks/instruct-pix2pix"""					,safety_checker=lowerCamelCase					,torch_dtype=torch.floataa     )
      __SCREAMING_SNAKE_CASE   				=							pipe.to(lowerCamelCase     )
      pipe.set_progress_bar_config(disable=lowerCamelCase     )
      pipe.enable_attention_slicing(1     )
      pipe.enable_sequential_cpu_offload()

      __SCREAMING_SNAKE_CASE   				=							self.get_inputs()
      __SCREAMING_SNAKE_CASE   				=							pipe(**lowerCamelCase     )

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





   def   UpperCAmelCase__  (       self					:      str     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							self.get_inputs()
      # resize to resolution that is divisible by 8 but not 16 or 32
      __SCREAMING_SNAKE_CASE   				=							inputs["""image"""].resize((504, 504)     )

      __SCREAMING_SNAKE_CASE   				=							"""timbrooks/instruct-pix2pix"""
      __SCREAMING_SNAKE_CASE   				=							StableDiffusionInstructPixaPixPipeline.from_pretrained(
          lowerCamelCase					,safety_checker=lowerCamelCase					,)
      pipe.to(lowerCamelCase     )
      pipe.set_progress_bar_config(disable=lowerCamelCase     )
      pipe.enable_attention_slicing()

      __SCREAMING_SNAKE_CASE   				=							pipe(**lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							output.images[0]

      __SCREAMING_SNAKE_CASE   				=							image[255:258, 383:386, -1]

      assert image.shape == (504, 504, 3)
      __SCREAMING_SNAKE_CASE   				=							np.array([0.2_726, 0.2_529, 0.2_664, 0.2_655, 0.2_641, 0.2_642, 0.2_591, 0.2_649, 0.2_590]     )

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










import unittest

from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer
from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin


a__   :					List[Any] 						=      get_tests_dir("fixtures/test_sentencepiece.model")



@require_sentencepiece
class    UpperCAmelCase__(				lowerCamelCase  ,				unittest.TestCase						):

   '''simple docstring'''




   A     :	Tuple												=     XLMProphetNetTokenizer
   A     :	List[str]												=     False
   A     :	Union[str, Any]												=     True


   def       UpperCAmelCase		(    self	:      Any)						->					int:




         """simple docstring"""

         super().setUp()

         # We have a SentencePiece fixture for testing
         lowercase__  =	XLMProphetNetTokenizer(lowerCAmelCase      ,					keep_accents=lowerCAmelCase)
         tokenizer.save_pretrained(self.tmpdirname)


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




         """simple docstring"""

         lowercase__  =	'[PAD]'
         lowercase__  =	0

         self.assertEqual(self.get_tokenizer()._convert_token_to_id(lowerCAmelCase)      ,					lowerCAmelCase)
         self.assertEqual(self.get_tokenizer()._convert_id_to_token(lowerCAmelCase)      ,					lowerCAmelCase)


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




         """simple docstring"""

         lowercase__  =	list(self.get_tokenizer().get_vocab().keys())

         self.assertEqual(vocab_keys[0]      ,					'[PAD]')
         self.assertEqual(vocab_keys[1]      ,					'[CLS]')
         self.assertEqual(vocab_keys[-1]      ,					'j')
         self.assertEqual(len(lowerCAmelCase)      ,					10_12)


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




         """simple docstring"""

         self.assertEqual(self.get_tokenizer().vocab_size      ,					10_12)


   def       UpperCAmelCase		(    self	:      Tuple)						->					Optional[int]:




         """simple docstring"""

         lowercase__  =	XLMProphetNetTokenizer(lowerCAmelCase      ,					keep_accents=lowerCAmelCase)

         lowercase__  =	tokenizer.tokenize('This is a test')
         self.assertListEqual(lowerCAmelCase      ,					['▁This', '▁is', '▁a', '▁t', 'est'])

         self.assertListEqual(
             tokenizer.convert_tokens_to_ids(lowerCAmelCase)      ,					[value + tokenizer.fairseq_offset for value in [2_85, 46, 10, 1_70, 3_82]]      ,					)

         lowercase__  =	tokenizer.tokenize('I was born in 92000, and this is falsé.')
         self.assertListEqual(
             lowerCAmelCase      ,					[
                 SPIECE_UNDERLINE + 'I',
                 SPIECE_UNDERLINE + 'was',
                 SPIECE_UNDERLINE + 'b',
                 'or',
                 'n',
                 SPIECE_UNDERLINE + 'in',
                 SPIECE_UNDERLINE + '',
                 '9',
                 '2',
                 '0',
                 '0',
                 '0',
                 ',',
                 SPIECE_UNDERLINE + 'and',
                 SPIECE_UNDERLINE + 'this',
                 SPIECE_UNDERLINE + 'is',
                 SPIECE_UNDERLINE + 'f',
                 'al',
                 's',
                 'é',
                 '.',
             ]      ,					)
         lowercase__  =	tokenizer.convert_tokens_to_ids(lowerCAmelCase)
         self.assertListEqual(
             lowerCAmelCase      ,					[
                 value + tokenizer.fairseq_offset
                 for value in [8, 21, 84, 55, 24, 19, 7, -9, 6_02, 3_47, 3_47, 3_47, 3, 12, 66, 46, 72, 80, 6, -9, 4]
             ]      ,					)

         lowercase__  =	tokenizer.convert_ids_to_tokens(lowerCAmelCase)
         self.assertListEqual(
             lowerCAmelCase      ,					[
                 SPIECE_UNDERLINE + 'I',
                 SPIECE_UNDERLINE + 'was',
                 SPIECE_UNDERLINE + 'b',
                 'or',
                 'n',
                 SPIECE_UNDERLINE + 'in',
                 SPIECE_UNDERLINE + '',
                 '[UNK]',
                 '2',
                 '0',
                 '0',
                 '0',
                 ',',
                 SPIECE_UNDERLINE + 'and',
                 SPIECE_UNDERLINE + 'this',
                 SPIECE_UNDERLINE + 'is',
                 SPIECE_UNDERLINE + 'f',
                 'al',
                 's',
                 '[UNK]',
                 '.',
             ]      ,					)


   @cached_property
   def       UpperCAmelCase		(    self	:      str)						->					List[Any]:




         """simple docstring"""

         return XLMProphetNetTokenizer.from_pretrained('microsoft/xprophetnet-large-wiki100-cased')


   @slow
   def       UpperCAmelCase		(    self	:      List[Any])						->					List[str]:




         """simple docstring"""

         lowercase__  =	'Hello World!'
         lowercase__  =	[3_53_89, 66_72, 49, 2]
         self.assertListEqual(lowerCAmelCase      ,					self.big_tokenizer.encode(lowerCAmelCase))



   @slow
   def       UpperCAmelCase		(    self	:      Tuple)						->					str:




         """simple docstring"""

         lowercase__  =	{'input_ids': [[1_10_73, 8_27_83, 18, 26, 8_27_83, 5_49, 5_15_40, 2_48, 1_72_09, 13_01, 2_17, 20, 21_51_86, 13_25, 1_47, 1_72_09, 13_01, 2_17, 20, 5_63_70, 53, 12_20_20, 20, 1_64_77, 27, 8_73_55, 45_48, 20, 47_28, 7_83_92, 17, 15_99_69, 18, 26, 2_44_91, 6_29, 15, 5_38, 2_27_04, 54_39, 15, 27_88, 2_44_91, 98_85, 15, 4_35_34, 6_05, 15, 8_14, 1_84_03, 3_32_00, 29, 15, 4_35_34, 2_44_58, 1_24_10, 1_11, 2_49_66, 8_36_69, 96_37, 14_40_68, 26, 8_50, 2_23_46, 27, 1_47, 2_49_66, 8_36_69, 8_34_90, 26, 3_91_13, 7_35, 27, 6_89, 6_56, 28_00, 13_39, 46_00, 53, 12_20_20, 11_57_85, 34, 8_16, 13_39, 4_68_87, 18, 1_47, 5_39_05, 19_51, 4_22_38, 4_11_70, 1_77_32, 8_34, 4_36, 15, 2_75_23, 9_87_33, 2_17, 1_47, 55_42, 49_81, 9_30, 1_73_47, 16, 2], [2_00_91, 6_29, 94, 8_27_86, 58, 4_90, 20, 15_28, 84, 5_39_05, 3_44, 8_05_92, 11_01_28, 1_88_22, 52_67, 13_06, 62, 15_25_37, 3_08, 79_97, 4_01, 12_44_27, 5_49, 3_54_42, 2_25, 1_09, 1_50_55, 2_57_48, 1_47, 71_19, 4_37_12, 34, 7_67, 13_53_66, 18, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [5_92, 6_37_84, 11_94_66, 17, 14_78_08, 8_82_14, 18, 6_56, 81, 32, 32_96, 1_02_80, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], 'attention_mask': [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]}  # noqa: E501
         # fmt: on

         self.tokenizer_integration_test_util(
             expected_encoding=lowerCAmelCase      ,					model_name='microsoft/xprophetnet-large-wiki100-cased'      ,					revision='1acad1643ddd54a44df6a1b797ada8373685d90e'      ,					)
