





from typing import List, Optional, Union

import torch

from ...models import UNetaDConditionModel, VQModel
from ...pipelines import DiffusionPipeline
from ...pipelines.pipeline_utils import ImagePipelineOutput
from ...schedulers import DDPMScheduler
from ...utils import (
    is_accelerate_available,
    is_accelerate_version,
    logging,
    randn_tensor,
    replace_example_docstring,
)


_UpperCAmelCase				:       Any	   =				logging.get_logger(__name__)  # pylint: disable=invalid-name

_UpperCAmelCase				:       Tuple	   =				"""
    Examples:
        ```py
        >>> from diffusers import KandinskyV22Pipeline, KandinskyV22PriorPipeline
        >>> import torch

        >>> pipe_prior = KandinskyV22PriorPipeline.from_pretrained(\"kandinsky-community/kandinsky-2-2-prior\")
        >>> pipe_prior.to(\"cuda\")
        >>> prompt = \"red cat, 4k photo\"
        >>> out = pipe_prior(prompt)
        >>> image_emb = out.image_embeds
        >>> zero_image_emb = out.negative_image_embeds
        >>> pipe = KandinskyV22Pipeline.from_pretrained(\"kandinsky-community/kandinsky-2-2-decoder\")
        >>> pipe.to(\"cuda\")
        >>> image = pipe(
        ...     image_embeds=image_emb,
        ...     negative_image_embeds=zero_image_emb,
        ...     height=768,
        ...     width=768,
        ...     num_inference_steps=50,
        ... ).images
        >>> image[0].save(\"cat.png\")
        ```
"""


def        SCREAMING_SNAKE_CASE      (       _UpperCAmelCase						,	_UpperCAmelCase						,	_UpperCAmelCase=8 )			->     Dict:
    lowerCamelCase__    :      Tuple					 =		height // scale_factor**2
    if height % scale_factor**2 != 0:
        new_height += 1
    lowerCamelCase__    :      Dict					 =		width // scale_factor**2
    if width % scale_factor**2 != 0:
        new_width += 1
    return new_height * scale_factor, new_width * scale_factor


class    lowerCAmelCase							(					__UpperCamelCase			):
 def __init__(      self  :      Tuple			,     UpperCAmelCase  :      UNetaDConditionModel			,     UpperCAmelCase  :      DDPMScheduler			,     UpperCAmelCase  :      VQModel			,     )			->	str:
     super().__init__()

     self.register_modules(
         unet=UpperCAmelCase			,     scheduler=UpperCAmelCase			,     movq=UpperCAmelCase			,     )
     lowerCamelCase__    :      Optional[Any]					 =		2 ** (len(self.movq.config.block_out_channels	) - 1)
 def      A_	(      self  :      int			,     UpperCAmelCase  :      Optional[int]			,     UpperCAmelCase  :      Optional[int]			,     UpperCAmelCase  :      List[Any]			,     UpperCAmelCase  :      List[str]			,     UpperCAmelCase  :      int			,     UpperCAmelCase  :      Tuple	)			->	List[str]:
     if latents is None:
         lowerCamelCase__    :      Dict					 =		randn_tensor(UpperCAmelCase			,     generator=UpperCAmelCase			,     device=UpperCAmelCase			,     dtype=UpperCAmelCase	)
     else:
         if latents.shape != shape:
             raise ValueError(F"""Unexpected latents shape, got {latents.shape}, expected {shape}"""	)
         lowerCamelCase__    :      str					 =		latents.to(UpperCAmelCase	)

     lowerCamelCase__    :      List[Any]					 =		latents * scheduler.init_noise_sigma
     return latents
 def      A_	(      self  :      Tuple			,     UpperCAmelCase  :      Tuple=0	)			->	List[Any]:
     if is_accelerate_available():
         from accelerate import cpu_offload
     else:
         raise ImportError('Please install accelerate via `pip install accelerate`'	)

     lowerCamelCase__    :      Any					 =		torch.device(F"""cuda:{gpu_id}"""	)

     lowerCamelCase__    :      List[Any]					 =		[
         self.unet,
         self.movq,
     ]
     for cpu_offloaded_model in models:
         if cpu_offloaded_model is not None:
             cpu_offload(UpperCAmelCase			,     UpperCAmelCase	)
 def      A_	(      self  :      Optional[Any]			,     UpperCAmelCase  :      int=0	)			->	List[Any]:
     if is_accelerate_available() and is_accelerate_version('>='			,     '0.17.0.dev0'	):
         from accelerate import cpu_offload_with_hook
     else:
         raise ImportError('`enable_model_cpu_offload` requires `accelerate v0.17.0` or higher.'	)

     lowerCamelCase__    :      Union[str, Any]					 =		torch.device(F"""cuda:{gpu_id}"""	)

     if self.device.type != "cpu":
         self.to('cpu'			,     silence_dtype_warnings=UpperCAmelCase	)
         torch.cuda.empty_cache()  # otherwise we don't see the memory savings (but they probably exist)

     lowerCamelCase__    :      Union[str, Any]					 =		None
     for cpu_offloaded_model in [self.unet, self.movq]:
         lowerCamelCase__ ,							lowerCamelCase__    :      str					 =		cpu_offload_with_hook(UpperCAmelCase			,     UpperCAmelCase			,     prev_module_hook=UpperCAmelCase	)

     # We'll offload the last model manually.
     lowerCamelCase__    :      Optional[int]					 =		hook
 @property
 # Copied from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline._execution_device
 def      A_	(      self  :      List[str]	)			->	Any:
     if not hasattr(self.unet			,     '_hf_hook'	):
         return self.device
     for module in self.unet.modules():
         if (
             hasattr(UpperCAmelCase			,     '_hf_hook'	)
             and hasattr(module._hf_hook			,     'execution_device'	)
             and module._hf_hook.execution_device is not None
         ):
             return torch.device(module._hf_hook.execution_device	)
     return self.device







 @torch.no_grad()
 @replace_example_docstring(UpperCAmelCase	)
 def __call__(      self  :      str			,     UpperCAmelCase  :      Union[torch.FloatTensor, List[torch.FloatTensor]]			,     UpperCAmelCase  :      Union[torch.FloatTensor, List[torch.FloatTensor]]			,     UpperCAmelCase  :      int = 512			,     UpperCAmelCase  :      int = 512			,     UpperCAmelCase  :      int = 100			,     UpperCAmelCase  :      float = 4.0			,     UpperCAmelCase  :      int = 1			,     UpperCAmelCase  :      Optional[Union[torch.Generator, List[torch.Generator]]] = None			,     UpperCAmelCase  :      Optional[torch.FloatTensor] = None			,     UpperCAmelCase  :      Optional[str] = "pil"			,     UpperCAmelCase  :      bool = True			,     )			->	Optional[int]:
     lowerCamelCase__    :      Any					 =		self._execution_device

     lowerCamelCase__    :      Dict					 =		guidance_scale > 1.0

     if isinstance(UpperCAmelCase			,     UpperCAmelCase	):
         lowerCamelCase__    :      Optional[int]					 =		torch.cat(UpperCAmelCase			,     dim=0	)
     lowerCamelCase__    :      int					 =		image_embeds.shape[0] * num_images_per_prompt
     if isinstance(UpperCAmelCase			,     UpperCAmelCase	):
         lowerCamelCase__    :      int					 =		torch.cat(UpperCAmelCase			,     dim=0	)

     if do_classifier_free_guidance:
         lowerCamelCase__    :      int					 =		image_embeds.repeat_interleave(UpperCAmelCase			,     dim=0	)
         lowerCamelCase__    :      Tuple					 =		negative_image_embeds.repeat_interleave(UpperCAmelCase			,     dim=0	)

     lowerCamelCase__    :      Optional[int]					 =		torch.cat([negative_image_embeds, image_embeds]			,     dim=0	).to(dtype=self.unet.dtype			,     device=UpperCAmelCase	)

     self.scheduler.set_timesteps(UpperCAmelCase			,     device=UpperCAmelCase	)
     lowerCamelCase__    :      Dict					 =		self.scheduler.timesteps

     lowerCamelCase__    :      Dict					 =		self.unet.config.in_channels

     lowerCamelCase__ ,							lowerCamelCase__    :      Optional[Any]					 =		downscale_height_and_width(UpperCAmelCase			,     UpperCAmelCase			,     self.movq_scale_factor	)

     # create initial latent
     lowerCamelCase__    :      Union[str, Any]					 =		self.prepare_latents(
         (batch_size, num_channels_latents, height, width)			,     image_embeds.dtype			,     UpperCAmelCase			,     UpperCAmelCase			,     UpperCAmelCase			,     self.scheduler			,     )

     for i, t in enumerate(self.progress_bar(UpperCAmelCase	)	):
         # expand the latents if we are doing classifier free guidance
         lowerCamelCase__    :      List[str]					 =		torch.cat([latents] * 2	) if do_classifier_free_guidance else latents

         lowerCamelCase__    :      str					 =		{'image_embeds': image_embeds}
         lowerCamelCase__    :      int					 =		self.unet(
             sample=UpperCAmelCase			,     timestep=UpperCAmelCase			,     encoder_hidden_states=UpperCAmelCase			,     added_cond_kwargs=UpperCAmelCase			,     return_dict=UpperCAmelCase			,     )[0]

         if do_classifier_free_guidance:
             lowerCamelCase__ ,							lowerCamelCase__    :      Any					 =		noise_pred.split(latents.shape[1]			,     dim=1	)
             lowerCamelCase__ ,							lowerCamelCase__    :      List[Any]					 =		noise_pred.chunk(2	)
             lowerCamelCase__ ,							lowerCamelCase__    :      Optional[int]					 =		variance_pred.chunk(2	)
             lowerCamelCase__    :      str					 =		noise_pred_uncond + guidance_scale * (noise_pred_text - noise_pred_uncond)
             lowerCamelCase__    :      List[Any]					 =		torch.cat([noise_pred, variance_pred_text]			,     dim=1	)

         if not (
             hasattr(self.scheduler.config			,     'variance_type'	)
             and self.scheduler.config.variance_type in ["learned", "learned_range"]
         ):
             lowerCamelCase__ ,							lowerCamelCase__    :      List[Any]					 =		noise_pred.split(latents.shape[1]			,     dim=1	)

         # compute the previous noisy sample x_t -> x_t-1
         lowerCamelCase__    :      Optional[int]					 =		self.scheduler.step(
             UpperCAmelCase			,     UpperCAmelCase			,     UpperCAmelCase			,     generator=UpperCAmelCase			,     )[0]
     # post-processing
     lowerCamelCase__    :      Dict					 =		self.movq.decode(UpperCAmelCase			,     force_not_quantize=UpperCAmelCase	)['sample']

     if output_type not in ["pt", "np", "pil"]:
         raise ValueError(F"""Only the output types `pt`, `pil` and `np` are supported not output_type={output_type}"""	)

     if output_type in ["np", "pil"]:
         lowerCamelCase__    :      Optional[int]					 =		image * 0.5 + 0.5
         lowerCamelCase__    :      Optional[int]					 =		image.clamp(0			,     1	)
         lowerCamelCase__    :      List[str]					 =		image.cpu().permute(0			,     2			,     3			,     1	).float().numpy()

     if output_type == "pil":
         lowerCamelCase__    :      Dict					 =		self.numpy_to_pil(UpperCAmelCase	)

     if not return_dict:
         return (image,)

     return ImagePipelineOutput(images=UpperCAmelCase	)









import unittest

from transformers import JukeboxTokenizer
from transformers.testing_utils import require_torch






class _lowerCamelCase(						unittest.TestCase   ):
       lowercase_ :	Dict     =			JukeboxTokenizer
       lowercase_ :	Dict     =			{
           """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 			UpperCamelCase     (					self)       ->   Optional[int]:




           """simple docstring"""

           import torch

           _lowercase       :							str      		=		JukeboxTokenizer.from_pretrained('openai/jukebox-1b-lyrics')
           _lowercase       :							Optional[Any]      		=		tokenizer(**self.metas)['input_ids']
           # fmt: off
           _lowercase       :							Optional[int]      		=		[
               torch.tensor([[
                   0, 0, 0, 71_69, 5_07, 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, 10_69, 11]]),
               torch.tensor([[0, 0, 0, 10_69, 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 			UpperCamelCase     (					self)       ->   int:




           """simple docstring"""

           import torch

           _lowercase       :							List[str]      		=		JukeboxTokenizer.from_pretrained('openai/jukebox-5b-lyrics')
           _lowercase       :							List[str]      		=		tokenizer(**self.metas)['input_ids']
           # fmt: off
           _lowercase       :							Optional[int]      		=		[
               torch.tensor([[
                   0, 0, 0, 10_69, 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, 10_69, 11, -1, -1, -1, -1]]),
               torch.tensor([[0, 0, 0, 10_69, 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]))


