


'''simple docstring'''







import gc
import unittest

import numpy as np
import torch
from torch.backends.cuda import sdp_kernel

from diffusers import (
    CMStochasticIterativeScheduler,
    ConsistencyModelPipeline,
    UNetaDModel,
)
from diffusers.utils import randn_tensor, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_a, require_torch_gpu

from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GENERATION_PARAMS
from ..test_pipelines_common import PipelineTesterMixin


enable_full_determinism()


class  lowerCAmelCase_						(       snake_case__		,    unittest.TestCase      ):





  """simple docstring"""



  a_       :Optional[int]												=ConsistencyModelPipeline
  a_       :List[Any]												=UNCONDITIONAL_IMAGE_GENERATION_PARAMS
  a_       :Optional[int]												=UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS

  # Override required_optional_params to remove num_images_per_prompt
  a_       :Optional[Any]												=frozenset(
      [
          """num_inference_steps""",
          """generator""",
          """latents""",
          """output_type""",
          """return_dict""",
          """callback""",
          """callback_steps""",
      ]      )

  @property
  def __a						(					self     :							Dict						):





       '''simple docstring'''

       __a       =   UNetaDModel.from_pretrained(
           """diffusers/consistency-models-test"""				,							subfolder="""test_unet"""				,							)
       return unet

  @property
  def __a						(					self     :							Tuple						):





       '''simple docstring'''

       __a       =   UNetaDModel.from_pretrained(
           """diffusers/consistency-models-test"""				,							subfolder="""test_unet_class_cond"""				,							)
       return unet

  def __a						(					self     :							str				,							SCREAMING_SNAKE_CASE__     :							int=False						):





       '''simple docstring'''

       if class_cond:
            __a       =   self.dummy_cond_unet
       else:
            __a       =   self.dummy_uncond_unet

       # Default to CM multistep sampler
       __a       =   CMStochasticIterativeScheduler(
           num_train_timesteps=4_0				,							sigma_min=0.0_0_2				,							sigma_max=8_0.0				,							)

       __a       =   {
           """unet""": unet,
           """scheduler""": scheduler,
       }

       return components

  def __a						(					self     :							Union[str, Any]				,							SCREAMING_SNAKE_CASE__     :							Dict				,							SCREAMING_SNAKE_CASE__     :							int=0						):





       '''simple docstring'''

       if str(SCREAMING_SNAKE_CASE__						).startswith("""mps"""						):
            __a       =   torch.manual_seed(SCREAMING_SNAKE_CASE__						)
       else:
            __a       =   torch.Generator(device=SCREAMING_SNAKE_CASE__						).manual_seed(SCREAMING_SNAKE_CASE__						)

       __a       =   {
           """batch_size""": 1,
           """num_inference_steps""": None,
           """timesteps""": [2_2, 0],
           """generator""": generator,
           """output_type""": """np""",
       }

       return inputs

  def __a						(					self     :							str						):





       '''simple docstring'''

       __a       =   """cpu"""  # ensure determinism for the device-dependent torch.Generator
       __a       =   self.get_dummy_components()
       __a       =   ConsistencyModelPipeline(**SCREAMING_SNAKE_CASE__						)
       __a       =   pipe.to(SCREAMING_SNAKE_CASE__						)
       pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__						)

       __a       =   self.get_dummy_inputs(SCREAMING_SNAKE_CASE__						)
       __a       =   pipe(**SCREAMING_SNAKE_CASE__						).images
       assert image.shape == (1, 3_2, 3_2, 3)

       __a       =   image[0, -3:, -3:, -1]
       __a       =   np.array([0.3_5_7_2, 0.6_2_7_3, 0.4_0_3_1, 0.3_9_6_1, 0.4_3_2_1, 0.5_7_3_0, 0.5_2_6_6, 0.4_7_8_0, 0.5_0_0_4]						)

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

  def __a						(					self     :							int						):





       '''simple docstring'''

       __a       =   """cpu"""  # ensure determinism for the device-dependent torch.Generator
       __a       =   self.get_dummy_components(class_cond=SCREAMING_SNAKE_CASE__						)
       __a       =   ConsistencyModelPipeline(**SCREAMING_SNAKE_CASE__						)
       __a       =   pipe.to(SCREAMING_SNAKE_CASE__						)
       pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__						)

       __a       =   self.get_dummy_inputs(SCREAMING_SNAKE_CASE__						)
       __a       =   0
       __a       =   pipe(**SCREAMING_SNAKE_CASE__						).images
       assert image.shape == (1, 3_2, 3_2, 3)

       __a       =   image[0, -3:, -3:, -1]
       __a       =   np.array([0.3_5_7_2, 0.6_2_7_3, 0.4_0_3_1, 0.3_9_6_1, 0.4_3_2_1, 0.5_7_3_0, 0.5_2_6_6, 0.4_7_8_0, 0.5_0_0_4]						)

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

  def __a						(					self     :							str						):





       '''simple docstring'''

       __a       =   """cpu"""  # ensure determinism for the device-dependent torch.Generator
       __a       =   self.get_dummy_components()
       __a       =   ConsistencyModelPipeline(**SCREAMING_SNAKE_CASE__						)
       __a       =   pipe.to(SCREAMING_SNAKE_CASE__						)
       pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__						)

       __a       =   self.get_dummy_inputs(SCREAMING_SNAKE_CASE__						)
       __a       =   1
       __a       =   None
       __a       =   pipe(**SCREAMING_SNAKE_CASE__						).images
       assert image.shape == (1, 3_2, 3_2, 3)

       __a       =   image[0, -3:, -3:, -1]
       __a       =   np.array([0.5_0_0_4, 0.5_0_0_4, 0.4_9_9_4, 0.5_0_0_8, 0.4_9_7_6, 0.5_0_1_8, 0.4_9_9_0, 0.4_9_8_2, 0.4_9_8_7]						)

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


  def __a						(					self     :							List[Any]						):





       '''simple docstring'''

       __a       =   """cpu"""  # ensure determinism for the device-dependent torch.Generator
       __a       =   self.get_dummy_components(class_cond=SCREAMING_SNAKE_CASE__						)
       __a       =   ConsistencyModelPipeline(**SCREAMING_SNAKE_CASE__						)
       __a       =   pipe.to(SCREAMING_SNAKE_CASE__						)
       pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__						)

       __a       =   self.get_dummy_inputs(SCREAMING_SNAKE_CASE__						)
       __a       =   1
       __a       =   None
       __a       =   0
       __a       =   pipe(**SCREAMING_SNAKE_CASE__						).images
       assert image.shape == (1, 3_2, 3_2, 3)

       __a       =   image[0, -3:, -3:, -1]
       __a       =   np.array([0.5_0_0_4, 0.5_0_0_4, 0.4_9_9_4, 0.5_0_0_8, 0.4_9_7_6, 0.5_0_1_8, 0.4_9_9_0, 0.4_9_8_2, 0.4_9_8_7]						)

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





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





  """simple docstring"""



  def __a						(					self     :							int						):





       '''simple docstring'''

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

  def __a						(					self     :							Union[str, Any]				,							SCREAMING_SNAKE_CASE__     :							Dict=0				,							SCREAMING_SNAKE_CASE__     :							str=False				,							SCREAMING_SNAKE_CASE__     :							int="cpu"				,							SCREAMING_SNAKE_CASE__     :							Union[str, Any]=torch.floataa				,							SCREAMING_SNAKE_CASE__     :							Union[str, Any]=(1, 3, 6_4, 6_4)						):





       '''simple docstring'''

       __a       =   torch.manual_seed(SCREAMING_SNAKE_CASE__						)

       __a       =   {
           """num_inference_steps""": None,
           """timesteps""": [2_2, 0],
           """class_labels""": 0,
           """generator""": generator,
           """output_type""": """np""",
       }

       if get_fixed_latents:
            __a       =   self.get_fixed_latents(seed=SCREAMING_SNAKE_CASE__				,							device=SCREAMING_SNAKE_CASE__				,							dtype=SCREAMING_SNAKE_CASE__				,							shape=SCREAMING_SNAKE_CASE__						)
            __a       =   latents

       return inputs

  def __a						(					self     :							Optional[int]				,							SCREAMING_SNAKE_CASE__     :							str=0				,							SCREAMING_SNAKE_CASE__     :							List[str]="cpu"				,							SCREAMING_SNAKE_CASE__     :							List[str]=torch.floataa				,							SCREAMING_SNAKE_CASE__     :							List[str]=(1, 3, 6_4, 6_4)						):





       '''simple docstring'''

       if type(SCREAMING_SNAKE_CASE__						) == str:
            __a       =   torch.device(SCREAMING_SNAKE_CASE__						)
       __a       =   torch.Generator(device=SCREAMING_SNAKE_CASE__						).manual_seed(SCREAMING_SNAKE_CASE__						)
       __a       =   randn_tensor(SCREAMING_SNAKE_CASE__				,							generator=SCREAMING_SNAKE_CASE__				,							device=SCREAMING_SNAKE_CASE__				,							dtype=SCREAMING_SNAKE_CASE__						)
       return latents

  def __a						(					self     :							str						):





       '''simple docstring'''

       __a       =   UNetaDModel.from_pretrained("""diffusers/consistency_models"""				,							subfolder="""diffusers_cd_imagenet64_l2"""						)
       __a       =   CMStochasticIterativeScheduler(
           num_train_timesteps=4_0				,							sigma_min=0.0_0_2				,							sigma_max=8_0.0				,							)
       __a       =   ConsistencyModelPipeline(unet=SCREAMING_SNAKE_CASE__				,							scheduler=SCREAMING_SNAKE_CASE__						)
       pipe.to(torch_device=SCREAMING_SNAKE_CASE__						)
       pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__						)

       __a       =   self.get_inputs()
       __a       =   pipe(**SCREAMING_SNAKE_CASE__						).images
       assert image.shape == (1, 6_4, 6_4, 3)

       __a       =   image[0, -3:, -3:, -1]

       __a       =   np.array([0.0_8_8_8, 0.0_8_8_1, 0.0_6_6_6, 0.0_4_7_9, 0.0_2_9_2, 0.0_1_9_5, 0.0_2_0_1, 0.0_1_6_3, 0.0_2_5_4]						)

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

  def __a						(					self     :							List[Any]						):





       '''simple docstring'''

       __a       =   UNetaDModel.from_pretrained("""diffusers/consistency_models"""				,							subfolder="""diffusers_cd_imagenet64_l2"""						)
       __a       =   CMStochasticIterativeScheduler(
           num_train_timesteps=4_0				,							sigma_min=0.0_0_2				,							sigma_max=8_0.0				,							)
       __a       =   ConsistencyModelPipeline(unet=SCREAMING_SNAKE_CASE__				,							scheduler=SCREAMING_SNAKE_CASE__						)
       pipe.to(torch_device=SCREAMING_SNAKE_CASE__						)
       pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__						)

       __a       =   self.get_inputs()
       __a       =   1
       __a       =   None
       __a       =   pipe(**SCREAMING_SNAKE_CASE__						).images
       assert image.shape == (1, 6_4, 6_4, 3)

       __a       =   image[0, -3:, -3:, -1]

       __a       =   np.array([0.0_3_4_0, 0.0_1_5_2, 0.0_0_6_3, 0.0_2_6_7, 0.0_2_2_1, 0.0_1_0_7, 0.0_4_1_6, 0.0_1_8_6, 0.0_2_1_7]						)

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

  @require_torch_a
  def __a						(					self     :							Tuple						):





       '''simple docstring'''

       __a       =   UNetaDModel.from_pretrained("""diffusers/consistency_models"""				,							subfolder="""diffusers_cd_imagenet64_l2"""						)
       __a       =   CMStochasticIterativeScheduler(
           num_train_timesteps=4_0				,							sigma_min=0.0_0_2				,							sigma_max=8_0.0				,							)
       __a       =   ConsistencyModelPipeline(unet=SCREAMING_SNAKE_CASE__				,							scheduler=SCREAMING_SNAKE_CASE__						)
       pipe.to(torch_device=SCREAMING_SNAKE_CASE__				,							torch_dtype=torch.floataa						)
       pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__						)

       __a       =   self.get_inputs(get_fixed_latents=SCREAMING_SNAKE_CASE__				,							device=SCREAMING_SNAKE_CASE__						)
       # Ensure usage of flash attention in torch 2.0
       with sdp_kernel(enable_flash=SCREAMING_SNAKE_CASE__				,							enable_math=SCREAMING_SNAKE_CASE__				,							enable_mem_efficient=SCREAMING_SNAKE_CASE__						):
            __a       =   pipe(**SCREAMING_SNAKE_CASE__						).images
       assert image.shape == (1, 6_4, 6_4, 3)

       __a       =   image[0, -3:, -3:, -1]

       __a       =   np.array([0.1_8_7_5, 0.1_4_2_8, 0.1_2_8_9, 0.2_1_5_1, 0.2_0_9_2, 0.1_4_7_7, 0.1_8_7_7, 0.1_6_4_1, 0.1_3_5_3]						)

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


  @require_torch_a
  def __a						(					self     :							Optional[Any]						):





       '''simple docstring'''

       __a       =   UNetaDModel.from_pretrained("""diffusers/consistency_models"""				,							subfolder="""diffusers_cd_imagenet64_l2"""						)
       __a       =   CMStochasticIterativeScheduler(
           num_train_timesteps=4_0				,							sigma_min=0.0_0_2				,							sigma_max=8_0.0				,							)
       __a       =   ConsistencyModelPipeline(unet=SCREAMING_SNAKE_CASE__				,							scheduler=SCREAMING_SNAKE_CASE__						)
       pipe.to(torch_device=SCREAMING_SNAKE_CASE__				,							torch_dtype=torch.floataa						)
       pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE__						)

       __a       =   self.get_inputs(get_fixed_latents=SCREAMING_SNAKE_CASE__				,							device=SCREAMING_SNAKE_CASE__						)
       __a       =   1
       __a       =   None
       # Ensure usage of flash attention in torch 2.0
       with sdp_kernel(enable_flash=SCREAMING_SNAKE_CASE__				,							enable_math=SCREAMING_SNAKE_CASE__				,							enable_mem_efficient=SCREAMING_SNAKE_CASE__						):
            __a       =   pipe(**SCREAMING_SNAKE_CASE__						).images
       assert image.shape == (1, 6_4, 6_4, 3)

       __a       =   image[0, -3:, -3:, -1]

       __a       =   np.array([0.1_6_6_3, 0.1_9_4_8, 0.2_2_7_5, 0.1_6_8_0, 0.1_2_0_4, 0.1_2_4_5, 0.1_8_5_8, 0.1_3_3_8, 0.2_0_9_5]						)

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










'''simple docstring'''







import json
import os
import unittest

from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast
from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, require_torch
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin


@require_tokenizers
class  lowerCAmelCase_						(       snake_case__		,    unittest.TestCase      ):





  """simple docstring"""



  a_       :Union[str, Any]												=LEDTokenizer
  a_       :List[Any]												=LEDTokenizerFast
  a_       :Union[str, Any]												=True

  def __a						(					self     :							Dict						):





       '''simple docstring'''

       super().setUp()
       __a       =   [
           """l""",
           """o""",
           """w""",
           """e""",
           """r""",
           """s""",
           """t""",
           """i""",
           """d""",
           """n""",
           """\u0120""",
           """\u0120l""",
           """\u0120n""",
           """\u0120lo""",
           """\u0120low""",
           """er""",
           """\u0120lowest""",
           """\u0120newer""",
           """\u0120wider""",
           """<unk>""",
       ]
       __a       =   dict(zip(SCREAMING_SNAKE_CASE__				,							range(len(SCREAMING_SNAKE_CASE__						)						)						)						)
       __a       =   ["""#version: 0.2""", """\u0120 l""", """\u0120l o""", """\u0120lo w""", """e r""", """"""]
       __a       =   {"""unk_token""": """<unk>"""}

       __a       =   os.path.join(self.tmpdirname				,							VOCAB_FILES_NAMES["""vocab_file"""]						)
       __a       =   os.path.join(self.tmpdirname				,							VOCAB_FILES_NAMES["""merges_file"""]						)
       with open(self.vocab_file				,							"""w"""				,							encoding="""utf-8"""						) as fp:
            fp.write(json.dumps(SCREAMING_SNAKE_CASE__						) + """\n"""						)
       with open(self.merges_file				,							"""w"""				,							encoding="""utf-8"""						) as fp:
            fp.write("""\n""".join(SCREAMING_SNAKE_CASE__						)						)

  def __a						(					self     :							Optional[Any]				,							**SCREAMING_SNAKE_CASE__     :							Optional[Any]						):





       '''simple docstring'''

       kwargs.update(self.special_tokens_map						)
       return self.tokenizer_class.from_pretrained(self.tmpdirname				,							**SCREAMING_SNAKE_CASE__						)

  def __a						(					self     :							int				,							**SCREAMING_SNAKE_CASE__     :							Optional[int]						):





       '''simple docstring'''

       kwargs.update(self.special_tokens_map						)
       return self.rust_tokenizer_class.from_pretrained(self.tmpdirname				,							**SCREAMING_SNAKE_CASE__						)

  def __a						(					self     :							str				,							SCREAMING_SNAKE_CASE__     :							int						):





       '''simple docstring'''

       return "lower newer", "lower newer"

  @cached_property
  def __a						(					self     :							Dict						):





       '''simple docstring'''

       return LEDTokenizer.from_pretrained("""allenai/led-base-16384"""						)

  @cached_property
  def __a						(					self     :							Union[str, Any]						):





       '''simple docstring'''

       return LEDTokenizerFast.from_pretrained("""allenai/led-base-16384"""						)

  @require_torch
  def __a						(					self     :							Tuple						):





       '''simple docstring'''

       __a       =   ["""A long paragraph for summarization.""", """Another paragraph for summarization."""]
       __a       =   [0, 2_5_0, 2_5_1, 1_7_8_1_8, 1_3, 3_9_1_8_6, 1_9_3_8, 4, 2]

       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
            __a       =   tokenizer(SCREAMING_SNAKE_CASE__				,							max_length=len(SCREAMING_SNAKE_CASE__						)				,							padding=SCREAMING_SNAKE_CASE__				,							return_tensors="""pt"""						)
            self.assertIsInstance(SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__						)

            self.assertEqual((2, 9)				,							batch.input_ids.shape						)
            self.assertEqual((2, 9)				,							batch.attention_mask.shape						)
            __a       =   batch.input_ids.tolist()[0]
            self.assertListEqual(SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__						)

  @require_torch
  def __a						(					self     :							Dict						):





       '''simple docstring'''

       __a       =   ["""A long paragraph for summarization.""", """Another paragraph for summarization."""]
       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
            __a       =   tokenizer(SCREAMING_SNAKE_CASE__				,							padding=SCREAMING_SNAKE_CASE__				,							return_tensors="""pt"""						)
            self.assertIn("""input_ids"""				,							SCREAMING_SNAKE_CASE__						)
            self.assertIn("""attention_mask"""				,							SCREAMING_SNAKE_CASE__						)
            self.assertNotIn("""labels"""				,							SCREAMING_SNAKE_CASE__						)
            self.assertNotIn("""decoder_attention_mask"""				,							SCREAMING_SNAKE_CASE__						)

  @require_torch
  def __a						(					self     :							Union[str, Any]						):





       '''simple docstring'''

       __a       =   [
           """Summary of the text.""",
           """Another summary.""",
       ]
       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
            __a       =   tokenizer(text_target=SCREAMING_SNAKE_CASE__				,							max_length=3_2				,							padding="""max_length"""				,							return_tensors="""pt"""						)
            self.assertEqual(3_2				,							targets["""input_ids"""].shape[1]						)

  @require_torch
  def __a						(					self     :							Any						):





       '''simple docstring'''

       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
            __a       =   tokenizer(
                ["""I am a small frog""" * 1_0_2_4, """I am a small frog"""]				,							padding=SCREAMING_SNAKE_CASE__				,							truncation=SCREAMING_SNAKE_CASE__				,							return_tensors="""pt"""						)
            self.assertIsInstance(SCREAMING_SNAKE_CASE__				,							SCREAMING_SNAKE_CASE__						)
            self.assertEqual(batch.input_ids.shape				,							(2, 5_1_2_2)						)

  @require_torch
  def __a						(					self     :							Tuple						):





       '''simple docstring'''

       __a       =   ["""A long paragraph for summarization."""]
       __a       =   [
           """Summary of the text.""",
       ]
       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
            __a       =   tokenizer(SCREAMING_SNAKE_CASE__				,							return_tensors="""pt"""						)
            __a       =   tokenizer(text_target=SCREAMING_SNAKE_CASE__				,							return_tensors="""pt"""						)
            __a       =   inputs["""input_ids"""]
            __a       =   targets["""input_ids"""]
            self.assertTrue((input_ids[:, 0] == tokenizer.bos_token_id).all().item()						)
            self.assertTrue((labels[:, 0] == tokenizer.bos_token_id).all().item()						)
            self.assertTrue((input_ids[:, -1] == tokenizer.eos_token_id).all().item()						)
            self.assertTrue((labels[:, -1] == tokenizer.eos_token_id).all().item()						)

  @require_torch
  def __a						(					self     :							Dict						):





       '''simple docstring'''

       for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
            __a       =   ["""Summary of the text.""", """Another summary."""]
            __a       =   [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, -1]]

            __a       =   tokenizer(SCREAMING_SNAKE_CASE__				,							padding=SCREAMING_SNAKE_CASE__						)
            __a       =   [[0] * len(SCREAMING_SNAKE_CASE__						) for x in encoded_output["""input_ids"""]]
            __a       =   tokenizer.pad(SCREAMING_SNAKE_CASE__						)
            self.assertSequenceEqual(outputs["""global_attention_mask"""]				,							SCREAMING_SNAKE_CASE__						)

  def __a						(					self     :							List[Any]						):





       '''simple docstring'''

       pass


  def __a						(					self     :							Any						):





       '''simple docstring'''

       for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
            with self.subTest(f'''{tokenizer.__class__.__name__} ({pretrained_name})'''						):
                 __a       =   self.rust_tokenizer_class.from_pretrained(SCREAMING_SNAKE_CASE__				,							**SCREAMING_SNAKE_CASE__						)
                 __a       =   self.tokenizer_class.from_pretrained(SCREAMING_SNAKE_CASE__				,							**SCREAMING_SNAKE_CASE__						)
                 __a       =   """A, <mask> AllenNLP sentence."""
                 __a       =   tokenizer_r.encode_plus(SCREAMING_SNAKE_CASE__				,							add_special_tokens=SCREAMING_SNAKE_CASE__				,							return_token_type_ids=SCREAMING_SNAKE_CASE__						)
                 __a       =   tokenizer_p.encode_plus(SCREAMING_SNAKE_CASE__				,							add_special_tokens=SCREAMING_SNAKE_CASE__				,							return_token_type_ids=SCREAMING_SNAKE_CASE__						)
                 self.assertEqual(sum(tokens_r["""token_type_ids"""]						)				,							sum(tokens_p["""token_type_ids"""]						)						)
                 self.assertEqual(
                     sum(tokens_r["""attention_mask"""]						) / len(tokens_r["""attention_mask"""]						)				,							sum(tokens_p["""attention_mask"""]						) / len(tokens_p["""attention_mask"""]						)				,							)

                 __a       =   tokenizer_r.convert_ids_to_tokens(tokens_r["""input_ids"""]						)
                 __a       =   tokenizer_p.convert_ids_to_tokens(tokens_p["""input_ids"""]						)
                 self.assertSequenceEqual(tokens_p["""input_ids"""]				,							[0, 2_5_0, 6, 5_0_2_6_4, 3_8_2_3, 4_8_7, 2_1_9_9_2, 3_6_4_5, 4, 2]						)
                 self.assertSequenceEqual(tokens_r["""input_ids"""]				,							[0, 2_5_0, 6, 5_0_2_6_4, 3_8_2_3, 4_8_7, 2_1_9_9_2, 3_6_4_5, 4, 2]						)

                 self.assertSequenceEqual(
                     SCREAMING_SNAKE_CASE__				,							["""<s>""", """A""", """,""", """<mask>""", """ĠAllen""", """N""", """LP""", """Ġsentence""", """.""", """</s>"""]						)
                 self.assertSequenceEqual(
                     SCREAMING_SNAKE_CASE__				,							["""<s>""", """A""", """,""", """<mask>""", """ĠAllen""", """N""", """LP""", """Ġsentence""", """.""", """</s>"""]						)






