from __future__ import annotations

import copy
import inspect
import json
import math
import os
import tempfile
import unittest
from importlib import import_module

import numpy as np

from transformers import ViTMAEConfig
from transformers.file_utils import cached_property, is_tf_available, is_vision_available
from transformers.testing_utils import require_tf, require_vision, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
     import tensorflow as tf

     from transformers import TFViTMAEForPreTraining, TFViTMAEModel


if is_vision_available():
     from PIL import Image

     from transformers import ViTImageProcessor
class SCREAMING_SNAKE_CASE_		:







   def __init__(     self						:						Optional[int]   ,   lowerCamelCase_						:						Any   ,   lowerCamelCase_						:						Optional[Any]=13   ,   lowerCamelCase_						:						Tuple=30   ,   lowerCamelCase_						:						List[str]=2   ,   lowerCamelCase_						:						Union[str, Any]=3   ,   lowerCamelCase_						:						Optional[int]=True   ,   lowerCamelCase_						:						Optional[Any]=True   ,   lowerCamelCase_						:						Union[str, Any]=32   ,   lowerCamelCase_						:						List[Any]=2   ,   lowerCamelCase_						:						List[Any]=4   ,   lowerCamelCase_						:						Union[str, Any]=37   ,   lowerCamelCase_						:						List[Any]="gelu"   ,   lowerCamelCase_						:						str=0.1   ,   lowerCamelCase_						:						int=0.1   ,   lowerCamelCase_						:						List[Any]=10   ,   lowerCamelCase_						:						str=0.0_2   ,   lowerCamelCase_						:						Optional[Any]=3   ,   lowerCamelCase_						:						List[Any]=0.6   ,   lowerCamelCase_						:						Tuple=None   ,   ):





    """simple docstring"""


    UpperCamelCase			  =      parent
    UpperCamelCase			  =      batch_size
    UpperCamelCase			  =      image_size
    UpperCamelCase			  =      patch_size
    UpperCamelCase			  =      num_channels
    UpperCamelCase			  =      is_training
    UpperCamelCase			  =      use_labels
    UpperCamelCase			  =      hidden_size
    UpperCamelCase			  =      num_hidden_layers
    UpperCamelCase			  =      num_attention_heads
    UpperCamelCase			  =      intermediate_size
    UpperCamelCase			  =      hidden_act
    UpperCamelCase			  =      hidden_dropout_prob
    UpperCamelCase			  =      attention_probs_dropout_prob
    UpperCamelCase			  =      type_sequence_label_size
    UpperCamelCase			  =      initializer_range
    UpperCamelCase			  =      mask_ratio
    UpperCamelCase			  =      scope

    # in ViTMAE, the expected sequence length = (num_patches + 1) * (1 - config.mask_ratio), rounded above
    # (we add 1 for the [CLS] token)
    UpperCamelCase			  =      (image_size // patch_size) ** 2
    UpperCamelCase			  =      int(math.ceil((1 - mask_ratio) * (num_patches + 1)				)				)







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





    """simple docstring"""


    UpperCamelCase			  =      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

    UpperCamelCase			  =      None
    if self.use_labels:
     UpperCamelCase			  =      ids_tensor([self.batch_size]   ,   self.type_sequence_label_size				)

    UpperCamelCase			  =      self.get_config()

    return config, pixel_values, labels







   def 						lowerCamelCase_	(     self						:						Tuple				):





    """simple docstring"""


    return ViTMAEConfig(
        image_size=self.image_size   ,   patch_size=self.patch_size   ,   num_channels=self.num_channels   ,   hidden_size=self.hidden_size   ,   num_hidden_layers=self.num_hidden_layers   ,   num_attention_heads=self.num_attention_heads   ,   intermediate_size=self.intermediate_size   ,   decoder_hidden_size=self.hidden_size   ,   decoder_num_hidden_layers=self.num_hidden_layers   ,   decoder_num_attention_heads=self.num_attention_heads   ,   decoder_intermediate_size=self.intermediate_size   ,   hidden_act=self.hidden_act   ,   hidden_dropout_prob=self.hidden_dropout_prob   ,   attention_probs_dropout_prob=self.attention_probs_dropout_prob   ,   is_decoder=lowerCamelCase_   ,   initializer_range=self.initializer_range   ,   mask_ratio=self.mask_ratio   ,   )







   def 						lowerCamelCase_	(     self						:						List[Any]   ,   lowerCamelCase_						:						Optional[int]   ,   lowerCamelCase_						:						Tuple   ,   lowerCamelCase_						:						int				):





    """simple docstring"""


    UpperCamelCase			  =      TFViTMAEModel(config=lowerCamelCase_				)
    UpperCamelCase			  =      model(lowerCamelCase_   ,   training=lowerCamelCase_				)
    self.parent.assertEqual(result.last_hidden_state.shape   ,   (self.batch_size, self.seq_length, self.hidden_size)				)







   def 						lowerCamelCase_	(     self						:						Any   ,   lowerCamelCase_						:						Optional[Any]   ,   lowerCamelCase_						:						List[str]   ,   lowerCamelCase_						:						Tuple				):





    """simple docstring"""


    UpperCamelCase			  =      TFViTMAEForPreTraining(lowerCamelCase_				)
    UpperCamelCase			  =      model(lowerCamelCase_   ,   training=lowerCamelCase_				)
    # expected sequence length = num_patches
    UpperCamelCase			  =      (self.image_size // self.patch_size) ** 2
    UpperCamelCase			  =      self.patch_size**2 * self.num_channels
    self.parent.assertEqual(result.logits.shape   ,   (self.batch_size, num_patches, expected_num_channels)				)

    # test greyscale images
    UpperCamelCase			  =      1
    UpperCamelCase			  =      TFViTMAEForPreTraining(lowerCamelCase_				)

    UpperCamelCase			  =      floats_tensor([self.batch_size, 1, self.image_size, self.image_size]				)
    UpperCamelCase			  =      model(lowerCamelCase_   ,   training=lowerCamelCase_				)
    UpperCamelCase			  =      self.patch_size**2
    self.parent.assertEqual(result.logits.shape   ,   (self.batch_size, num_patches, expected_num_channels)				)







   def 						lowerCamelCase_	(     self						:						List[Any]				):





    """simple docstring"""


    UpperCamelCase			  =      self.prepare_config_and_inputs()
    ((UpperCamelCase)  ,     (UpperCamelCase)  ,     (UpperCamelCase))			  =      config_and_inputs
    UpperCamelCase			  =      {"""pixel_values""": pixel_values}
    return config, inputs_dict





@require_tf
class SCREAMING_SNAKE_CASE_		(      __lowerCAmelCase  ,     __lowerCAmelCase  ,     unittest.TestCase		):
   __lowerCAmelCase           =				(TFViTMAEModel, TFViTMAEForPreTraining) if is_tf_available() else ()
   __lowerCAmelCase           =				{"""feature-extraction""": TFViTMAEModel} if is_tf_available() else {}

   __lowerCAmelCase           =				False
   __lowerCAmelCase           =				False
   __lowerCAmelCase           =				False
   __lowerCAmelCase           =				False







   def 						lowerCamelCase_	(     self						:						List[str]				):





    """simple docstring"""


    UpperCamelCase			  =      TFViTMAEModelTester(self				)
    UpperCamelCase			  =      ConfigTester(self   ,   config_class=lowerCamelCase_   ,   has_text_modality=lowerCamelCase_   ,   hidden_size=37				)







   def 						lowerCamelCase_	(     self						:						List[str]				):





    """simple docstring"""


    self.config_tester.run_common_tests()







   @unittest.skip(reason="""ViTMAE does not use inputs_embeds"""				)
   def 						lowerCamelCase_	(     self						:						str				):





    """simple docstring"""


    pass







   def 						lowerCamelCase_	(     self						:						Dict				):





    """simple docstring"""


    UpperCamelCase  ,     UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     UpperCamelCase			  =      model_class(lowerCamelCase_				)
     self.assertIsInstance(model.get_input_embeddings()   ,   (tf.keras.layers.Layer)				)
     UpperCamelCase			  =      model.get_output_embeddings()
     self.assertTrue(x is None or isinstance(lowerCamelCase_   ,   tf.keras.layers.Layer				)				)







   def 						lowerCamelCase_	(     self						:						Dict				):





    """simple docstring"""


    UpperCamelCase  ,     UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     UpperCamelCase			  =      model_class(lowerCamelCase_				)
     UpperCamelCase			  =      inspect.signature(model.call				)
     # signature.parameters is an OrderedDict => so arg_names order is deterministic
     UpperCamelCase			  =      [*signature.parameters.keys()]

     UpperCamelCase			  =      ["""pixel_values"""]
     self.assertListEqual(arg_names[:1]   ,   lowerCamelCase_				)







   def 						lowerCamelCase_	(     self						:						List[str]				):





    """simple docstring"""


    UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_model(*lowerCamelCase_				)







   def 						lowerCamelCase_	(     self						:						List[str]				):





    """simple docstring"""


    UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_for_pretraining(*lowerCamelCase_				)







   def 						lowerCamelCase_	(     self						:						Any				):





    """simple docstring"""


    np.random.seed(2				)

    UpperCamelCase  ,     UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs_for_common()

    UpperCamelCase			  =      int((config.image_size // config.patch_size) ** 2				)
    UpperCamelCase			  =      np.random.uniform(size=(self.model_tester.batch_size, num_patches)				)

    for model_class in self.all_model_classes:
     UpperCamelCase			  =      model_class(lowerCamelCase_				)
     UpperCamelCase			  =      self._prepare_for_class(lowerCamelCase_   ,   lowerCamelCase_				)

     UpperCamelCase			  =      model(lowerCamelCase_   ,   noise=lowerCamelCase_				)

     UpperCamelCase			  =      copy.deepcopy(self._prepare_for_class(lowerCamelCase_   ,   lowerCamelCase_				)				)
     UpperCamelCase			  =      model(**lowerCamelCase_   ,   noise=lowerCamelCase_				)
     UpperCamelCase			  =      outputs_dict[0].numpy()
     UpperCamelCase			  =      outputs_keywords[0].numpy()

     self.assertLess(np.sum(np.abs(output_dict - output_keywords				)				)   ,   1E-6				)







   def 						lowerCamelCase_	(     self						:						List[Any]				):





    """simple docstring"""


    np.random.seed(2				)

    UpperCamelCase  ,     UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs_for_common()

    UpperCamelCase			  =      int((config.image_size // config.patch_size) ** 2				)
    UpperCamelCase			  =      np.random.uniform(size=(self.model_tester.batch_size, num_patches)				)

    def prepare_numpy_arrays(lowerCamelCase_						:						Tuple				):
     UpperCamelCase			  =      {}
     for k, v in inputs_dict.items():
      if tf.is_tensor(lowerCamelCase_				):
       UpperCamelCase			  =      v.numpy()
      else:
       UpperCamelCase			  =      np.array(lowerCamelCase_				)

     return inputs_np_dict

    for model_class in self.all_model_classes:
     UpperCamelCase			  =      model_class(lowerCamelCase_				)

     UpperCamelCase			  =      self._prepare_for_class(lowerCamelCase_   ,   lowerCamelCase_				)
     UpperCamelCase			  =      prepare_numpy_arrays(lowerCamelCase_				)

     UpperCamelCase			  =      model(lowerCamelCase_   ,   noise=lowerCamelCase_				)
     UpperCamelCase			  =      model(**lowerCamelCase_   ,   noise=lowerCamelCase_				)
     self.assert_outputs_same(lowerCamelCase_   ,   lowerCamelCase_				)







   def 						lowerCamelCase_	(     self						:						Tuple   ,   lowerCamelCase_						:						Any   ,   lowerCamelCase_						:						Union[str, Any]   ,   lowerCamelCase_						:						Dict				):





    """simple docstring"""


    np.random.seed(2				)

    UpperCamelCase			  =      int((tf_model.config.image_size // tf_model.config.patch_size) ** 2				)
    UpperCamelCase			  =      np.random.uniform(size=(self.model_tester.batch_size, num_patches)				)
    UpperCamelCase			  =      tf.constant(lowerCamelCase_				)

    # Add `noise` argument.
    # PT inputs will be prepared in `super().check_pt_tf_models()` with this added `noise` argument
    UpperCamelCase			  =      tf_noise

    super().check_pt_tf_models(lowerCamelCase_   ,   lowerCamelCase_   ,   lowerCamelCase_				)







   def 						lowerCamelCase_	(     self						:						Any				):





    """simple docstring"""


    np.random.seed(2				)

    UpperCamelCase  ,     UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs_for_common()

    UpperCamelCase			  =      {
        module_member
        for model_class in self.all_model_classes
        for module in (import_module(model_class.__module__				),)
        for module_member_name in dir(lowerCamelCase_				)
        if module_member_name.endswith("""MainLayer"""				)
        # This condition is required, since `modeling_tf_clip.py` has 3 classes whose names end with `MainLayer`.
        and module_member_name[: -len("""MainLayer"""				)] == model_class.__name__[: -len("""Model"""				)]
        for module_member in (getattr(lowerCamelCase_   ,   lowerCamelCase_				),)
        if isinstance(lowerCamelCase_   ,   lowerCamelCase_				)
        and tf.keras.layers.Layer in module_member.__bases__
        and getattr(lowerCamelCase_   ,   """_keras_serializable"""   ,   lowerCamelCase_				)
    }

    UpperCamelCase			  =      int((config.image_size // config.patch_size) ** 2				)
    UpperCamelCase			  =      np.random.uniform(size=(self.model_tester.batch_size, num_patches)				)
    UpperCamelCase			  =      tf.convert_to_tensor(lowerCamelCase_				)
    inputs_dict.update({"""noise""": noise}				)

    for main_layer_class in tf_main_layer_classes:
     UpperCamelCase			  =      main_layer_class(lowerCamelCase_				)

     UpperCamelCase			  =      {
         name: tf.keras.Input(tensor.shape[1:]   ,   dtype=tensor.dtype				) for name, tensor in inputs_dict.items()
     }

     UpperCamelCase			  =      tf.keras.Model(lowerCamelCase_   ,   outputs=main_layer(lowerCamelCase_				)				)
     UpperCamelCase			  =      model(lowerCamelCase_				)

     with tempfile.TemporaryDirectory() as tmpdirname:
      UpperCamelCase			  =      os.path.join(lowerCamelCase_   ,   """keras_model.h5"""				)
      model.save(lowerCamelCase_				)
      UpperCamelCase			  =      tf.keras.models.load_model(
          lowerCamelCase_   ,   custom_objects={main_layer_class.__name__: main_layer_class}				)
      assert isinstance(lowerCamelCase_   ,   tf.keras.Model				)
      UpperCamelCase			  =      model(lowerCamelCase_				)
      self.assert_outputs_same(lowerCamelCase_   ,   lowerCamelCase_				)







   @slow
   def 						lowerCamelCase_	(     self						:						Any				):





    """simple docstring"""


    np.random.seed(2				)

    UpperCamelCase  ,     UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs_for_common()

    UpperCamelCase			  =      int((config.image_size // config.patch_size) ** 2				)
    UpperCamelCase			  =      np.random.uniform(size=(self.model_tester.batch_size, num_patches)				)

    for model_class in self.all_model_classes:
     UpperCamelCase			  =      model_class(lowerCamelCase_				)
     UpperCamelCase			  =      self._prepare_for_class(lowerCamelCase_   ,   lowerCamelCase_				)
     UpperCamelCase			  =      model(lowerCamelCase_   ,   noise=lowerCamelCase_				)

     if model_class.__name__ == "TFViTMAEModel":
      UpperCamelCase			  =      outputs.last_hidden_state.numpy()
      UpperCamelCase			  =      0
     else:
      UpperCamelCase			  =      outputs.logits.numpy()
      UpperCamelCase			  =      0

     with tempfile.TemporaryDirectory() as tmpdirname:
      model.save_pretrained(lowerCamelCase_   ,   saved_model=lowerCamelCase_				)
      UpperCamelCase			  =      model_class.from_pretrained(lowerCamelCase_				)
      UpperCamelCase			  =      model(lowerCamelCase_   ,   noise=lowerCamelCase_				)

      if model_class.__name__ == "TFViTMAEModel":
       UpperCamelCase			  =      after_outputs["""last_hidden_state"""].numpy()
       UpperCamelCase			  =      0
      else:
       UpperCamelCase			  =      after_outputs["""logits"""].numpy()
       UpperCamelCase			  =      0

      UpperCamelCase			  =      np.amax(np.abs(out_a - out_a				)				)
      self.assertLessEqual(lowerCamelCase_   ,   1E-5				)







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





    """simple docstring"""


    np.random.seed(2				)

    UpperCamelCase  ,     UpperCamelCase			  =      self.model_tester.prepare_config_and_inputs_for_common()

    UpperCamelCase			  =      int((config.image_size // config.patch_size) ** 2				)
    UpperCamelCase			  =      np.random.uniform(size=(self.model_tester.batch_size, num_patches)				)

    for model_class in self.all_model_classes:
     UpperCamelCase			  =      model_class(lowerCamelCase_				)
     UpperCamelCase			  =      self._prepare_for_class(lowerCamelCase_   ,   lowerCamelCase_				)

     UpperCamelCase			  =      model(lowerCamelCase_   ,   noise=lowerCamelCase_				)
     UpperCamelCase			  =      model.get_config()
     # make sure that returned config is jsonifiable, which is required by keras
     json.dumps(lowerCamelCase_				)
     UpperCamelCase			  =      model_class.from_config(model.get_config()				)
     # make sure it also accepts a normal config
     UpperCamelCase			  =      model_class.from_config(model.config				)
     UpperCamelCase			  =      new_model(lowerCamelCase_				)  # Build model
     new_model.set_weights(model.get_weights()				)
     UpperCamelCase			  =      new_model(lowerCamelCase_   ,   noise=lowerCamelCase_				)

     self.assert_outputs_same(lowerCamelCase_   ,   lowerCamelCase_				)







   @unittest.skip(
       reason="""ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load
    to get deterministic results."""				)
   def 						lowerCamelCase_	(     self						:						Union[str, Any]				):





    """simple docstring"""


    pass







   @unittest.skip(reason="""ViTMAE returns a random mask + ids_restore in each forward pass. See test_save_load"""				)
   def 						lowerCamelCase_	(     self						:						Optional[int]				):





    """simple docstring"""


    pass







   @slow
   def 						lowerCamelCase_	(     self						:						int				):





    """simple docstring"""


    UpperCamelCase			  =      TFViTMAEModel.from_pretrained("""google/vit-base-patch16-224"""				)
    self.assertIsNotNone(lowerCamelCase_				)





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







 '''simple docstring'''
 UpperCamelCase			  =      Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""       )
 return image


@require_tf
@require_vision
class SCREAMING_SNAKE_CASE_		(      unittest.TestCase		):







   @cached_property
   def 						lowerCamelCase_	(     self						:						str				):





    """simple docstring"""


    return ViTImageProcessor.from_pretrained("""facebook/vit-mae-base"""				) if is_vision_available() else None







   @slow
   def 						lowerCamelCase_	(     self						:						List[Any]				):





    """simple docstring"""


    np.random.seed(2				)

    UpperCamelCase			  =      TFViTMAEForPreTraining.from_pretrained("""facebook/vit-mae-base"""				)

    UpperCamelCase			  =      self.default_image_processor
    UpperCamelCase			  =      prepare_img()
    UpperCamelCase			  =      image_processor(images=lowerCamelCase_   ,   return_tensors="""tf"""				)

    # prepare a noise vector that will be also used for testing the TF model
    # (this way we can ensure that the PT and TF models operate on the same inputs)
    UpperCamelCase			  =      ViTMAEConfig()
    UpperCamelCase			  =      int((vit_mae_config.image_size // vit_mae_config.patch_size) ** 2				)
    UpperCamelCase			  =      np.random.uniform(size=(1, num_patches)				)

    # forward pass
    UpperCamelCase			  =      model(**lowerCamelCase_   ,   noise=lowerCamelCase_				)

    # verify the logits
    UpperCamelCase			  =      tf.convert_to_tensor([1, 196, 768]				)
    self.assertEqual(outputs.logits.shape   ,   lowerCamelCase_				)

    UpperCamelCase			  =      tf.convert_to_tensor(
        [[-0.0_5_4_8, -1.7_0_2_3, -0.9_3_2_5], [0.3_7_2_1, -0.5_6_7_0, -0.2_2_3_3], [0.8_2_3_5, -1.3_8_7_8, -0.3_5_2_4]]				)

    tf.debugging.assert_near(outputs.logits[0, :3, :3]   ,   lowerCamelCase_   ,   atol=1E-4				)

import unittest

from transformers import JukeboxTokenizer
from transformers.testing_utils import require_torch
class SCREAMING_SNAKE_CASE_		(      unittest.TestCase		):
   __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 						lowerCamelCase_	(     self						:						Any				):





    """simple docstring"""


    import torch

    UpperCamelCase			  =      JukeboxTokenizer.from_pretrained("""openai/jukebox-1b-lyrics"""				)
    UpperCamelCase			  =      tokenizer(**self.metas				)["""input_ids"""]
    # fmt: off
    UpperCamelCase			  =      [
        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 						lowerCamelCase_	(     self						:						Dict				):





    """simple docstring"""


    import torch

    UpperCamelCase			  =      JukeboxTokenizer.from_pretrained("""openai/jukebox-5b-lyrics"""				)
    UpperCamelCase			  =      tokenizer(**self.metas				)["""input_ids"""]
    # fmt: off
    UpperCamelCase			  =      [
        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]				)				)
