'''simple docstring'''






import tempfile
import unittest

from transformers import TaConfig, is_torch_available
from transformers.testing_utils import (
    require_sentencepiece,
    require_tokenizers,
    require_torch,
    slow,
    torch_device,
)

from ...generation.test_utils import GenerationTesterMixin
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import AutoTokenizer, UMTaForConditionalGeneration, UMTaForQuestionAnswering, UMTaModel




class    a :



  """simple docstring"""







  def __init__(							self   ,    snake_case_   ,    snake_case_=99   ,    snake_case_=13   ,    snake_case_=7   ,    snake_case_=9   ,    snake_case_=True   ,    snake_case_=True   ,    snake_case_=False   ,    snake_case_=32   ,    snake_case_=5   ,    snake_case_=4   ,    snake_case_=37   ,    snake_case_=8   ,    snake_case_=0.1   ,    snake_case_=0.0_0_2   ,    snake_case_=1   ,    snake_case_=0   ,    snake_case_=0   ,    snake_case_=None   ,    snake_case_=None   ,    ):

    '''simple docstring'''







    __UpperCAmelCase:					str		= parent
    __UpperCAmelCase:					Any		= batch_size
    __UpperCAmelCase:					Tuple		= encoder_seq_length
    __UpperCAmelCase:					str		= decoder_seq_length
    # For common tests
    __UpperCAmelCase:					Union[str, Any]		= self.decoder_seq_length
    __UpperCAmelCase:					List[Any]		= is_training
    __UpperCAmelCase:					Tuple		= use_attention_mask
    __UpperCAmelCase:					List[str]		= use_labels
    __UpperCAmelCase:					Tuple		= vocab_size
    __UpperCAmelCase:					Tuple		= hidden_size
    __UpperCAmelCase:					List[Any]		= num_hidden_layers
    __UpperCAmelCase:					Any		= num_attention_heads
    __UpperCAmelCase:					List[Any]		= d_ff
    __UpperCAmelCase:					Optional[int]		= relative_attention_num_buckets
    __UpperCAmelCase:					int		= dropout_rate
    __UpperCAmelCase:					Union[str, Any]		= initializer_factor
    __UpperCAmelCase:					List[str]		= eos_token_id
    __UpperCAmelCase:					Tuple		= pad_token_id
    __UpperCAmelCase:					List[Any]		= decoder_start_token_id
    __UpperCAmelCase:					Optional[int]		= None
    __UpperCAmelCase:					List[str]		= decoder_layers







  def    lowercase_  (							self					):

    '''simple docstring'''







    return TaConfig.from_pretrained("""google/umt5-base"""					)







  def    lowercase_  (							self   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    snake_case_=None   ,    snake_case_=None   ,    snake_case_=None   ,    snake_case_=None   ,    snake_case_=None   ,    ):

    '''simple docstring'''







    if attention_mask is None:
      __UpperCAmelCase:					Optional[Any]		= input_ids.ne(config.pad_token_id					)
    if decoder_attention_mask is None:
      __UpperCAmelCase:					Dict		= decoder_input_ids.ne(config.pad_token_id					)
    if head_mask is None:
      __UpperCAmelCase:					Optional[int]		= torch.ones(config.num_hidden_layers   ,    config.num_attention_heads   ,    device=snake_case_					)
    if decoder_head_mask is None:
      __UpperCAmelCase:					str		= torch.ones(config.num_decoder_layers   ,    config.num_attention_heads   ,    device=snake_case_					)
    if cross_attn_head_mask is None:
      __UpperCAmelCase:					Tuple		= torch.ones(
          config.num_decoder_layers   ,    config.num_attention_heads   ,    device=snake_case_					)
    return {
        "input_ids": input_ids,
        "decoder_input_ids": decoder_input_ids,
        "attention_mask": attention_mask,
        "decoder_attention_mask": decoder_attention_mask,
        "head_mask": head_mask,
        "decoder_head_mask": decoder_head_mask,
        "cross_attn_head_mask": cross_attn_head_mask,
    }







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Tuple		= ids_tensor([self.batch_size, self.encoder_seq_length]   ,    self.vocab_size					)
    __UpperCAmelCase:					Any		= ids_tensor([self.batch_size, self.decoder_seq_length]   ,    self.vocab_size					)

    # we need to clamp the input ids here to avoid having pad token in between
    # this is because for NllbMoe the position_ids are prepared such that
    # all pad tokens have pos id = 2 and rest are between 2..seq_length
    # and the seq_length here is seq_length - num_pad_tokens
    # but when using past, there is no way of knowing if the past input ids had
    # pad tokens in them, which results in incorrect seq_lenth and which in turn results in
    # position_ids being off by num_pad_tokens in past input
    __UpperCAmelCase:					Optional[Any]		= input_ids.clamp(self.pad_token_id + 1					)
    __UpperCAmelCase:					str		= decoder_input_ids.clamp(self.pad_token_id + 1					)

    __UpperCAmelCase:					Any		= self.get_config()
    __UpperCAmelCase:					Dict		= config.num_attention_heads
    __UpperCAmelCase:					Optional[Any]		= self.prepare_inputs_dict(snake_case_   ,    snake_case_   ,    snake_case_					)
    return config, input_dict







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					List[Any]		= self.prepare_config_and_inputs()
    return config, inputs_dict







  def    lowercase_  (							self					):

    '''simple docstring'''







    return TaConfig(
        vocab_size=166   ,    d_model=self.hidden_size   ,    d_ff=self.d_ff   ,    d_kv=self.hidden_size // self.num_attention_heads   ,    num_layers=self.num_hidden_layers   ,    num_decoder_layers=self.decoder_layers   ,    num_heads=self.num_attention_heads   ,    relative_attention_num_buckets=self.relative_attention_num_buckets   ,    dropout_rate=self.dropout_rate   ,    initializer_factor=self.initializer_factor   ,    eos_token_id=self.eos_token_id   ,    bos_token_id=self.pad_token_id   ,    pad_token_id=self.pad_token_id   ,    decoder_start_token_id=self.decoder_start_token_id   ,    )







  def    lowercase_  (							self					):

    '''simple docstring'''







    return TaConfig(
        vocab_size=self.vocab_size   ,    d_model=self.hidden_size   ,    d_ff=self.d_ff   ,    d_kv=self.hidden_size // self.num_attention_heads   ,    num_layers=self.num_hidden_layers   ,    num_decoder_layers=self.decoder_layers   ,    num_heads=self.num_attention_heads   ,    relative_attention_num_buckets=self.relative_attention_num_buckets   ,    dropout_rate=self.dropout_rate   ,    initializer_factor=self.initializer_factor   ,    eos_token_id=self.eos_token_id   ,    bos_token_id=self.pad_token_id   ,    pad_token_id=self.pad_token_id   ,    decoder_start_token_id=self.decoder_start_token_id   ,    )







  def    lowercase_  (							self   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    ):

    '''simple docstring'''







    __UpperCAmelCase:					Dict		= UMTaModel(config=snake_case_					)
    model.to(snake_case_					)
    model.eval()
    __UpperCAmelCase:					List[str]		= model(
        input_ids=snake_case_   ,    decoder_input_ids=snake_case_   ,    attention_mask=snake_case_   ,    decoder_attention_mask=snake_case_   ,    )
    __UpperCAmelCase:					Optional[Any]		= model(input_ids=snake_case_   ,    decoder_input_ids=snake_case_					)
    __UpperCAmelCase:					Dict		= result.last_hidden_state
    __UpperCAmelCase:					Any		= result.past_key_values
    __UpperCAmelCase:					Dict		= result.encoder_last_hidden_state

    self.parent.assertEqual(encoder_output.size()   ,    (self.batch_size, self.encoder_seq_length, self.hidden_size)					)
    self.parent.assertEqual(decoder_output.size()   ,    (self.batch_size, self.decoder_seq_length, self.hidden_size)					)
    # There should be `num_layers` key value embeddings stored in decoder_past
    self.parent.assertEqual(len(snake_case_					)   ,    config.num_layers					)
    # There should be a self attn key, a self attn value, a cross attn key and a cross attn value stored in each decoder_past tuple
    self.parent.assertEqual(len(decoder_past[0]					)   ,    4					)







  def    lowercase_  (							self   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    snake_case_   ,    ):

    '''simple docstring'''







    __UpperCAmelCase:					Tuple		= UMTaModel(config=snake_case_					).get_decoder().to(snake_case_					).eval()
    # first forward pass
    __UpperCAmelCase:					Optional[Any]		= model(snake_case_   ,    use_cache=snake_case_					)
    __UpperCAmelCase:					Any		= model(snake_case_					)
    __UpperCAmelCase:					str		= model(snake_case_   ,    use_cache=snake_case_					)

    self.parent.assertTrue(len(snake_case_					) == len(snake_case_					)					)
    self.parent.assertTrue(len(snake_case_					) == len(snake_case_					) + 1					)

    __UpperCAmelCase:					List[str]		= outputs.to_tuple()

    # create hypothetical next token and extent to next_input_ids
    __UpperCAmelCase:					int		= ids_tensor((self.batch_size, 1)   ,    config.vocab_size					)

    # append to next input_ids and
    __UpperCAmelCase:					Union[str, Any]		= torch.cat([input_ids, next_tokens]   ,    dim=-1					)

    __UpperCAmelCase:					Any		= model(snake_case_					)["""last_hidden_state"""]
    __UpperCAmelCase:					List[Any]		= model(snake_case_   ,    past_key_values=snake_case_					)["""last_hidden_state"""]

    # select random slice
    __UpperCAmelCase:					Tuple		= ids_tensor((1,)   ,    output_from_past.shape[-1]					).item()
    __UpperCAmelCase:					int		= output_from_no_past[:, -1, random_slice_idx].detach()
    __UpperCAmelCase:					str		= output_from_past[:, 0, random_slice_idx].detach()

    # test that outputs are equal for slice
    self.parent.assertTrue(torch.allclose(snake_case_   ,    snake_case_   ,    atol=1e-3					)					)







  def    lowercase_  (							self   ,    snake_case_   ,    snake_case_   ,    ):

    '''simple docstring'''







    __UpperCAmelCase:					str		= UMTaModel(config=snake_case_					).to(snake_case_					).half().eval()
    __UpperCAmelCase:					Union[str, Any]		= model(**snake_case_					)["""last_hidden_state"""]
    self.parent.assertFalse(torch.isnan(snake_case_					).any().item()					)




@require_torch
class    a (       UpperCAmelCase__						,  UpperCAmelCase__						,  UpperCAmelCase__						,  unittest.TestCase				):



  """simple docstring"""
  __lowerCAmelCase				      =					(
      (UMTaModel, UMTaForConditionalGeneration, UMTaForQuestionAnswering) if is_torch_available() else ()
  )
  __lowerCAmelCase				      =					(UMTaForConditionalGeneration,) if is_torch_available() else ()
  __lowerCAmelCase				      =					(
      {
          'conversational': UMTaForConditionalGeneration,
          'feature-extraction': UMTaModel,
          'summarization': UMTaForConditionalGeneration,
          'text2text-generation': UMTaForConditionalGeneration,
          'translation': UMTaForConditionalGeneration,
          'question-answering': UMTaForQuestionAnswering,
      }
      if is_torch_available()
      else {}
  )
  __lowerCAmelCase				      =					True
  __lowerCAmelCase				      =					False
  __lowerCAmelCase				      =					False
  __lowerCAmelCase				      =					True
  __lowerCAmelCase				      =					True
  # The small UMT5 model needs higher percentages for CPU/MP tests
  __lowerCAmelCase				      =					[0.8, 0.9]







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					int		= UMTaModelTester(self					)







  @unittest.skip("""Test has a segmentation fault on torch 1.8.0"""					)
  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Union[str, Any]		= self.model_tester.prepare_config_and_inputs()
    __UpperCAmelCase:					Dict		= UMTaModel(config_and_inputs[0]					).to(snake_case_					)
    with tempfile.TemporaryDirectory() as tmpdirname:
      torch.onnx.export(
          snake_case_   ,    (config_and_inputs[1], config_and_inputs[3], config_and_inputs[2])   ,    F'''{tmpdirname}/t5_test.onnx'''   ,    export_params=snake_case_   ,    opset_version=9   ,    input_names=["""input_ids""", """decoder_input_ids"""]   ,    )







  @unittest.skipIf(torch_device == """cpu"""   ,    """Cant do half precision"""					)
  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					Union[str, Any]		= self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model_fpaa_forward(*snake_case_					)







  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					int		= ["""encoder_attentions""", """decoder_attentions""", """cross_attentions"""]
    __UpperCAmelCase:					List[Any]		= self.model_tester.prepare_config_and_inputs()
    __UpperCAmelCase:					List[str]		= config_and_inputs[0]
    __UpperCAmelCase:					Union[str, Any]		= UMTaForConditionalGeneration(snake_case_					).eval()
    model.to(snake_case_					)

    __UpperCAmelCase:					int		= {
        """head_mask""": torch.zeros(config.num_layers   ,    config.num_heads   ,    device=snake_case_					),
        """decoder_head_mask""": torch.zeros(config.num_decoder_layers   ,    config.num_heads   ,    device=snake_case_					),
        """cross_attn_head_mask""": torch.zeros(config.num_decoder_layers   ,    config.num_heads   ,    device=snake_case_					),
    }

    for attn_name, (name, mask) in zip(snake_case_   ,    head_masking.items()					):
      __UpperCAmelCase:					Union[str, Any]		= {name: mask}
      # Explicitly pass decoder_head_mask as it is required from T5 model when head_mask specified
      if name == "head_mask":
        __UpperCAmelCase:					Dict		= torch.ones(
            config.num_decoder_layers   ,    config.num_heads   ,    device=snake_case_					)

      __UpperCAmelCase:					int		= model.generate(
          config_and_inputs[1]["""input_ids"""]   ,    num_beams=1   ,    max_length=3   ,    output_attentions=snake_case_   ,    return_dict_in_generate=snake_case_   ,    **snake_case_   ,    )
      # We check the state of decoder_attentions and cross_attentions just from the last step
      __UpperCAmelCase:					Tuple		= out[attn_name] if attn_name == attention_names[0] else out[attn_name][-1]
      self.assertEqual(sum([w.sum().item() for w in attn_weights]					)   ,    0.0					)







  @unittest.skip("""Does not work on the tiny model as we keep hitting edge cases."""					)
  def    lowercase_  (							self					):

    '''simple docstring'''







    pass




@require_torch
@require_sentencepiece
@require_tokenizers
class    a (       unittest.TestCase				):



  """simple docstring"""







  @slow
  @unittest.skip(
      """Unless we stop stripping left and right by default for all special tokens, the expected ids obtained here will not match the original ones. Wait for https://github.com/huggingface/transformers/pull/23909 to be merged"""					)
  def    lowercase_  (							self					):

    '''simple docstring'''







    __UpperCAmelCase:					List[str]		= UMTaForConditionalGeneration.from_pretrained("""google/umt5-small"""   ,    return_dict=snake_case_					).to(snake_case_					)
    __UpperCAmelCase:					Optional[int]		= AutoTokenizer.from_pretrained("""google/umt5-small"""   ,    use_fast=snake_case_   ,    legacy=snake_case_					)
    __UpperCAmelCase:					List[str]		= [
        """Bonjour monsieur <extra_id_0> bien <extra_id_1>.""",
        """No se como puedo <extra_id_0>.""",
        """This is the reason why we <extra_id_0> them.""",
        """The <extra_id_0> walks in <extra_id_1>, seats""",
        """A <extra_id_0> walks into a bar and orders a <extra_id_1> with <extra_id_2> pinch of <extra_id_3>.""",
    ]
    __UpperCAmelCase:					int		= tokenizer(snake_case_   ,    return_tensors="""pt"""   ,    padding=snake_case_					).input_ids
    # fmt: off
    __UpperCAmelCase:					Any		= torch.tensor(
        [
            [ 3_8530, 21_0703, 25_6299, 1410, 25_6298, 274, 1, 0,0, 0, 0, 0, 0, 0, 0, 0,0, 0],
            [   826, 321, 671, 2_5922, 25_6299, 274, 1, 0,0, 0, 0, 0, 0, 0, 0, 0,0, 0],
            [  1460, 339, 312, 1_9014, 1_0620, 758, 25_6299, 2355,274, 1, 0, 0, 0, 0, 0, 0,0, 0],
            [   517, 25_6299, 1_4869, 281, 301, 25_6298, 275, 11_9983,1, 0, 0, 0, 0, 0, 0, 0,0, 0],
            [   320, 25_6299, 1_4869, 281, 2234, 289, 2275, 333,6_1391, 289, 25_6298, 543, 25_6297, 16_8714, 329, 25_6296,274, 1],
        ]					)
    # fmt: on
    torch.testing.assert_allclose(snake_case_   ,    snake_case_					)

    __UpperCAmelCase:					Tuple		= model.generate(input_ids.to(snake_case_					)					)
    __UpperCAmelCase:					Dict		= [
        """<pad><extra_id_0> et<extra_id_1> [eod] <extra_id_2><extra_id_55>.. [eod] 💐 💐 💐 💐 💐 💐 💐 💐 💐 💐 💐 <extra_id_56>ajšietosto<extra_id_56>lleux<extra_id_19><extra_id_6>ajšie</s>""",
        """<pad><extra_id_0>.<extra_id_1>.,<0x0A>...spech <0x0A><extra_id_20> <extra_id_21></s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>""",
        """<pad><extra_id_0> are not going to be a part of the world. We are not going to be a part of<extra_id_1> and<extra_id_2><0x0A><extra_id_48>.<extra_id_48></s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>""",
        """<pad><extra_id_0> door<extra_id_1>, the door<extra_id_2> 피해[/</s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>""",
        """<pad><extra_id_0>nyone who<extra_id_1> drink<extra_id_2> a<extra_id_3> alcohol<extra_id_4> A<extra_id_5> A. This<extra_id_6> I<extra_id_7><extra_id_52><extra_id_53></s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>""",
    ]
    __UpperCAmelCase:					Optional[int]		= tokenizer.batch_decode(snake_case_					)
    self.assertEqual(snake_case_   ,    snake_case_					)
'''simple docstring'''






import unittest

from transformers import JukeboxTokenizer
from transformers.testing_utils import require_torch




class    a (       unittest.TestCase				):



  """simple docstring"""
  __lowerCAmelCase				      =					JukeboxTokenizer
  __lowerCAmelCase				      =					{
      """artist""": """Zac Brown Band""",
      """genres""": """Country""",
      """lyrics""": """I met a traveller from an antique land,
        Who said \"Two vast and trunkless legs of stone
        Stand in the desert. . . . Near them, on the sand,
        Half sunk a shattered visage lies, whose frown,
        And wrinkled lip, and sneer of cold command,
        Tell that its sculptor well those passions read
        Which yet survive, stamped on these lifeless things,
        The hand that mocked them, and the heart that fed;
        And on the pedestal, these words appear:
        My name is Ozymandias, King of Kings;
        Look on my Works, ye Mighty, and despair!
        Nothing beside remains. Round the decay
        Of that colossal Wreck, boundless and bare
        The lone and level sands stretch far away
        """,
  }







  @require_torch
  def    lowercase_  (							self					):

    '''simple docstring'''







    import torch

    __UpperCAmelCase:					Dict		= JukeboxTokenizer.from_pretrained("""openai/jukebox-1b-lyrics"""					)
    __UpperCAmelCase:					List[str]		= tokenizer(**self.metas					)["""input_ids"""]
    # fmt: off
    __UpperCAmelCase:					int		= [
        torch.tensor([[
            0, 0, 0, 7169, 507, 9, 76, 39, 31, 46, 76, 27,
            76, 46, 44, 27, 48, 31, 38, 38, 31, 44, 76, 32,
            44, 41, 39, 76, 27, 40, 76, 27, 40, 46, 35, 43,
            47, 31, 76, 38, 27, 40, 30, 64, 78, 76, 76, 76,
            76, 76, 76, 76, 76, 23, 34, 41, 76, 45, 27, 35,
            30, 76, 71, 20, 49, 41, 76, 48, 27, 45, 46, 76,
            27, 40, 30, 76, 46, 44, 47, 40, 37, 38, 31, 45,
            45, 76, 38, 31, 33, 45, 76, 41, 32, 76, 45, 46,
            41, 40, 31, 78, 76, 76, 76, 76, 76, 76, 76, 76,
            19, 46, 27, 40, 30, 76, 35, 40, 76, 46, 34, 31,
            76, 30, 31, 45, 31, 44, 46, 63, 76, 63, 76, 63,
            76, 63, 76, 14, 31, 27, 44, 76, 46, 34, 31, 39,
            64, 76, 41, 40, 76, 46, 34, 31, 76, 45, 27, 40,
            30, 64, 78, 76, 76, 76, 76, 76, 76, 76, 76, 8,
            27, 38, 32, 76, 45, 47, 40, 37, 76, 27, 76, 45,
            34, 27, 46, 46, 31, 44, 31, 30, 76, 48, 35, 45,
            27, 33, 31, 76, 38, 35, 31, 45, 64, 76, 49, 34,
            41, 45, 31, 76, 32, 44, 41, 49, 40, 64, 78, 76,
            76, 76, 76, 76, 76, 76, 76, 1, 40, 30, 76, 49,
            44, 35, 40, 37, 38, 31, 30, 76, 38, 35, 42, 64,
            76, 27, 40, 30, 76, 45, 40, 31, 31, 44, 76, 41,
            32, 76, 29, 41, 38, 30, 76, 29, 41, 39, 39, 27,
            40, 30, 64, 78, 76, 76, 76, 76, 76, 76, 76, 76,
            20, 31, 38, 38, 76, 46, 34, 27, 46, 76, 35, 46,
            45, 76, 45, 29, 47, 38, 42, 46, 41, 44, 76, 49,
            31, 38, 38, 76, 46, 34, 41, 45, 31, 76, 42, 27,
            45, 45, 35, 41, 40, 45, 76, 44, 31, 27, 30, 78,
            76, 76, 76, 76, 76, 76, 76, 76, 23, 34, 35, 29,
            34, 76, 51, 31, 46, 76, 45, 47, 44, 48, 35, 48,
            31, 64, 76, 45, 46, 27, 39, 42, 31, 30, 76, 41,
            40, 76, 46, 34, 31, 45, 31, 76, 38, 35, 32, 31,
            38, 31, 45, 45, 76, 46, 34, 35, 40, 33, 45, 64,
            78, 76, 76, 76, 76, 76, 76, 76, 76, 20, 34, 31,
            76, 34, 27, 40, 30, 76, 46, 34, 27, 46, 76, 39,
            41, 29, 37, 31, 30, 76, 46, 34, 31, 39, 64, 76,
            27, 40, 30, 76, 46, 34, 31, 76, 34, 31, 27, 44,
            46, 76, 46, 34, 27, 46, 76, 32, 31, 30, 66, 78,
            76, 76, 76, 76, 76, 76, 76, 76, 1, 40, 30, 76,
            41, 40, 76, 46, 34, 31, 76, 42, 31, 30, 31, 45,
            46, 27, 38, 64, 76, 46, 34, 31, 45, 31, 76, 49,
            41, 44, 30, 45, 76, 27, 42, 42, 31, 27, 44, 65,
            78, 76, 76, 76, 76, 76, 76, 76, 76, 13, 51, 76,
            40, 27, 39, 31, 76, 35, 45, 76, 15, 52, 51, 39,
            27, 40, 30, 35, 27, 45, 64, 76, 11, 35, 40, 33,
            76, 41, 32, 76, 11, 35, 40, 33, 45, 66, 78, 76,
            76, 76, 76, 76, 76, 76, 76, 12, 41, 41, 37, 76,
            41, 40, 76, 39, 51, 76, 23, 41, 44, 37, 45, 64,
            76, 51, 31, 76, 13, 35, 33, 34, 46, 51, 64, 76,
            27, 40, 30, 76, 30, 31, 45, 42, 27, 35, 44, 67,
            78, 76, 76, 76, 76, 76, 76, 76, 76, 14, 41, 46,
            34, 35, 40, 33, 76, 28, 31, 45, 35, 30, 31, 76,
            44, 31, 39, 27, 35, 40, 45, 63, 76, 18, 41, 47,
            40, 30, 76, 46, 34, 31, 76, 30, 31, 29, 27, 51,
            78, 76, 76, 76, 76, 76, 76, 76, 76, 15, 32, 76,
            46, 34, 27, 46, 76, 29, 41, 38, 41, 45, 45, 27,
            38, 76, 23, 44, 31, 29, 37, 64, 76, 28, 41, 47,
            40, 30, 38, 31, 45, 45, 76, 27, 40, 30, 76, 28,
            27, 44, 31, 78, 76, 76, 76, 76, 76, 76, 76, 76,
            20, 34, 31, 76, 38, 41, 40, 31, 76, 27, 40, 30,
            76, 38, 31, 48, 31, 38, 76, 45, 27, 40, 30, 45,
            76, 45, 46, 44, 31, 46, 29, 34, 76, 32, 27, 44,
            76, 27, 49, 27, 51, 78, 76, 76, 76, 76, 76, 76,
            76, 76]]					),
        torch.tensor([[0, 0, 0, 1069, 11]]					),
        torch.tensor([[0, 0, 0, 1069, 11]]					),
    ]
    # fmt: on
    self.assertTrue(torch.allclose(tokens[0]   ,    EXPECTED_OUTPUT[0]					)					)
    self.assertTrue(torch.allclose(tokens[1]   ,    EXPECTED_OUTPUT[1]					)					)
    self.assertTrue(torch.allclose(tokens[2]   ,    EXPECTED_OUTPUT[2]					)					)







  @require_torch
  def    lowercase_  (							self					):

    '''simple docstring'''







    import torch

    __UpperCAmelCase:					Any		= JukeboxTokenizer.from_pretrained("""openai/jukebox-5b-lyrics"""					)
    __UpperCAmelCase:					Tuple		= tokenizer(**self.metas					)["""input_ids"""]
    # fmt: off
    __UpperCAmelCase:					int		= [
        torch.tensor([[
            0, 0, 0, 1069, 11, -1, -1, -1, -1, 9, 77, 39,
            31, 46, 77, 27, 77, 46, 44, 27, 48, 31, 38, 38,
            31, 44, 77, 32, 44, 41, 39, 77, 27, 40, 77, 27,
            40, 46, 35, 43, 47, 31, 77, 38, 27, 40, 30, 64,
            79, 77, 77, 77, 77, 77, 77, 77, 77, 23, 34, 41,
            77, 45, 27, 35, 30, 77, 72, 20, 49, 41, 77, 48,
            27, 45, 46, 77, 27, 40, 30, 77, 46, 44, 47, 40,
            37, 38, 31, 45, 45, 77, 38, 31, 33, 45, 77, 41,
            32, 77, 45, 46, 41, 40, 31, 79, 77, 77, 77, 77,
            77, 77, 77, 77, 19, 46, 27, 40, 30, 77, 35, 40,
            77, 46, 34, 31, 77, 30, 31, 45, 31, 44, 46, 63,
            77, 63, 77, 63, 77, 63, 77, 14, 31, 27, 44, 77,
            46, 34, 31, 39, 64, 77, 41, 40, 77, 46, 34, 31,
            77, 45, 27, 40, 30, 64, 79, 77, 77, 77, 77, 77,
            77, 77, 77, 8, 27, 38, 32, 77, 45, 47, 40, 37,
            77, 27, 77, 45, 34, 27, 46, 46, 31, 44, 31, 30,
            77, 48, 35, 45, 27, 33, 31, 77, 38, 35, 31, 45,
            64, 77, 49, 34, 41, 45, 31, 77, 32, 44, 41, 49,
            40, 64, 79, 77, 77, 77, 77, 77, 77, 77, 77, 1,
            40, 30, 77, 49, 44, 35, 40, 37, 38, 31, 30, 77,
            38, 35, 42, 64, 77, 27, 40, 30, 77, 45, 40, 31,
            31, 44, 77, 41, 32, 77, 29, 41, 38, 30, 77, 29,
            41, 39, 39, 27, 40, 30, 64, 79, 77, 77, 77, 77,
            77, 77, 77, 77, 20, 31, 38, 38, 77, 46, 34, 27,
            46, 77, 35, 46, 45, 77, 45, 29, 47, 38, 42, 46,
            41, 44, 77, 49, 31, 38, 38, 77, 46, 34, 41, 45,
            31, 77, 42, 27, 45, 45, 35, 41, 40, 45, 77, 44,
            31, 27, 30, 79, 77, 77, 77, 77, 77, 77, 77, 77,
            23, 34, 35, 29, 34, 77, 51, 31, 46, 77, 45, 47,
            44, 48, 35, 48, 31, 64, 77, 45, 46, 27, 39, 42,
            31, 30, 77, 41, 40, 77, 46, 34, 31, 45, 31, 77,
            38, 35, 32, 31, 38, 31, 45, 45, 77, 46, 34, 35,
            40, 33, 45, 64, 79, 77, 77, 77, 77, 77, 77, 77,
            77, 20, 34, 31, 77, 34, 27, 40, 30, 77, 46, 34,
            27, 46, 77, 39, 41, 29, 37, 31, 30, 77, 46, 34,
            31, 39, 64, 77, 27, 40, 30, 77, 46, 34, 31, 77,
            34, 31, 27, 44, 46, 77, 46, 34, 27, 46, 77, 32,
            31, 30, 66, 79, 77, 77, 77, 77, 77, 77, 77, 77,
            1, 40, 30, 77, 41, 40, 77, 46, 34, 31, 77, 42,
            31, 30, 31, 45, 46, 27, 38, 64, 77, 46, 34, 31,
            45, 31, 77, 49, 41, 44, 30, 45, 77, 27, 42, 42,
            31, 27, 44, 65, 79, 77, 77, 77, 77, 77, 77, 77,
            77, 13, 51, 77, 40, 27, 39, 31, 77, 35, 45, 77,
            15, 52, 51, 39, 27, 40, 30, 35, 27, 45, 64, 77,
            11, 35, 40, 33, 77, 41, 32, 77, 11, 35, 40, 33,
            45, 66, 79, 77, 77, 77, 77, 77, 77, 77, 77, 12,
            41, 41, 37, 77, 41, 40, 77, 39, 51, 77, 23, 41,
            44, 37, 45, 64, 77, 51, 31, 77, 13, 35, 33, 34,
            46, 51, 64, 77, 27, 40, 30, 77, 30, 31, 45, 42,
            27, 35, 44, 67, 79, 77, 77, 77, 77, 77, 77, 77,
            77, 14, 41, 46, 34, 35, 40, 33, 77, 28, 31, 45,
            35, 30, 31, 77, 44, 31, 39, 27, 35, 40, 45, 63,
            77, 18, 41, 47, 40, 30, 77, 46, 34, 31, 77, 30,
            31, 29, 27, 51, 79, 77, 77, 77, 77, 77, 77, 77,
            77, 15, 32, 77, 46, 34, 27, 46, 77, 29, 41, 38,
            41, 45, 45, 27, 38, 77, 23, 44, 31, 29, 37, 64,
            77, 28, 41, 47, 40, 30, 38, 31, 45, 45, 77, 27,
            40, 30, 77, 28, 27, 44, 31, 79, 77, 77, 77, 77,
            77, 77, 77, 77, 20, 34, 31, 77, 38, 41, 40, 31,
            77, 27, 40, 30, 77, 38, 31, 48, 31, 38, 77, 45,
            27, 40, 30, 45, 77, 45, 46, 44, 31, 46, 29, 34,
            77, 32, 27, 44, 77, 27, 49, 27, 51, 79, 77, 77,
            77, 77, 77, 77, 77, 77]]					),
        torch.tensor([[0, 0, 0, 1069, 11, -1, -1, -1, -1]]					),
        torch.tensor([[0, 0, 0, 1069, 11, -1, -1, -1, -1]]					),
    ]
    # fmt: on
    self.assertTrue(torch.allclose(tokens[0]   ,    EXPECTED_OUTPUT[0]					)					)
    self.assertTrue(torch.allclose(tokens[1]   ,    EXPECTED_OUTPUT[1]					)					)
    self.assertTrue(torch.allclose(tokens[2]   ,    EXPECTED_OUTPUT[2]					)					)