






import os
from glob import glob

import imageio
import torch
import torchvision
import wandb
from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan
from loaders import load_vqgan
from PIL import Image
from torch import nn

from transformers import CLIPModel, CLIPTokenizerFast
from utils import get_device, get_timestamp, show_pil
class      UpperCamelCase :







		"""simple docstring"""



		def __init__(  self		:       int						,_SCREAMING_SNAKE_CASE		:       str = "cpu"						,_SCREAMING_SNAKE_CASE		:       str = "openai/clip-vit-large-patch14"		)    ->   None:


						'''simple docstring'''
						A	 =      device
						A	 =      CLIPTokenizerFast.from_pretrained(_SCREAMING_SNAKE_CASE		)
						A	 =      [0.48145466, 0.4578275, 0.40821073]
						A	 =      [0.26862954, 0.26130258, 0.27577711]
						A	 =      torchvision.transforms.Normalize(self.image_mean						,self.image_std		)
						A	 =      torchvision.transforms.Resize(2_2_4		)
						A	 =      torchvision.transforms.CenterCrop(2_2_4		)
		def       A(  self		:       Tuple						,_SCREAMING_SNAKE_CASE		:       Optional[Any]		)    ->   List[str]:


						'''simple docstring'''
						A	 =      self.resize(_SCREAMING_SNAKE_CASE		)
						A	 =      self.center_crop(_SCREAMING_SNAKE_CASE		)
						A	 =      self.normalize(_SCREAMING_SNAKE_CASE		)
						return images







		def __call__(  self		:       Any						,_SCREAMING_SNAKE_CASE		:       Dict=None						,_SCREAMING_SNAKE_CASE		:       Any=None						,**_SCREAMING_SNAKE_CASE		:       int		)    ->   Any:


						'''simple docstring'''
						A	 =      self.tokenizer(text=_SCREAMING_SNAKE_CASE						,**_SCREAMING_SNAKE_CASE		)
						A	 =      self.preprocess_img(_SCREAMING_SNAKE_CASE		)
						A	 =      {key: value.to(self.device		) for (key, value) in encoding.items()}
						return encoding


class      UpperCamelCase (				nn.Module ):







		"""simple docstring"""



		def __init__(  self		:       Any						,_SCREAMING_SNAKE_CASE		:       Optional[int]=1_0						,_SCREAMING_SNAKE_CASE		:       Tuple=0.01						,_SCREAMING_SNAKE_CASE		:       int=None						,_SCREAMING_SNAKE_CASE		:       Union[str, Any]=None						,_SCREAMING_SNAKE_CASE		:       Tuple=None						,_SCREAMING_SNAKE_CASE		:       int=None						,_SCREAMING_SNAKE_CASE		:       Optional[int]=None						,_SCREAMING_SNAKE_CASE		:       Tuple=None						,_SCREAMING_SNAKE_CASE		:       str=False						,_SCREAMING_SNAKE_CASE		:       Union[str, Any]=True						,_SCREAMING_SNAKE_CASE		:       Any="image"						,_SCREAMING_SNAKE_CASE		:       Optional[Any]=True						,_SCREAMING_SNAKE_CASE		:       Dict=False						,_SCREAMING_SNAKE_CASE		:       Dict=False						,_SCREAMING_SNAKE_CASE		:       List[str]=False						,)    ->   None:


						'''simple docstring'''
						super().__init__()
						A	 =      None
						A	 =      device if device else get_device()
						if vqgan:
										A	 =      vqgan
						else:
										A	 =      load_vqgan(self.device						,conf_path=_SCREAMING_SNAKE_CASE						,ckpt_path=_SCREAMING_SNAKE_CASE		)
						self.vqgan.eval()
						if clip:
										A	 =      clip
						else:
										A	 =      CLIPModel.from_pretrained('openai/clip-vit-base-patch32'		)
						self.clip.to(self.device		)
						A	 =      ProcessorGradientFlow(device=self.device		)

						A	 =      iterations
						A	 =      lr
						A	 =      log
						A	 =      make_grid
						A	 =      return_val
						A	 =      quantize
						A	 =      self.vqgan.decoder.z_shape
		def       A(  self		:       str						,_SCREAMING_SNAKE_CASE		:       str=None						,_SCREAMING_SNAKE_CASE		:       Tuple=None						,_SCREAMING_SNAKE_CASE		:       Dict=5						,_SCREAMING_SNAKE_CASE		:       str=True		)    ->   Union[str, Any]:


						'''simple docstring'''
						A	 =      []
						if output_path is None:
										A	 =      './animation.gif'
						if input_path is None:
										A	 =      self.save_path
						A	 =      sorted(glob(input_path + '/*'		)		)
						if not len(_SCREAMING_SNAKE_CASE		):
										raise ValueError(
										    'No images found in save path, aborting (did you pass save_intermediate=True to the generate'
										    ' function?)'		)
						if len(_SCREAMING_SNAKE_CASE		) == 1:
										print('Only one image found in save path, (did you pass save_intermediate=True to the generate function?)'		)
						A	 =      total_duration / len(_SCREAMING_SNAKE_CASE		)
						A	 =      [frame_duration] * len(_SCREAMING_SNAKE_CASE		)
						if extend_frames:
										A	 =      1.5
										A	 =      3
						for file_name in paths:
										if file_name.endswith('.png'		):
														images.append(imageio.imread(_SCREAMING_SNAKE_CASE		)		)
						imageio.mimsave(_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE						,duration=_SCREAMING_SNAKE_CASE		)
						print(f'gif saved to {output_path}'		)
		def       A(  self		:       Tuple						,_SCREAMING_SNAKE_CASE		:       List[str]=None						,_SCREAMING_SNAKE_CASE		:       int=None		)    ->   Optional[Any]:


						'''simple docstring'''
						if not (path or img):
										raise ValueError('Input either path or tensor'		)
						if img is not None:
										raise NotImplementedError
						A	 =      preprocess(Image.open(_SCREAMING_SNAKE_CASE		)						,target_image_size=2_5_6		).to(self.device		)
						A	 =      preprocess_vqgan(_SCREAMING_SNAKE_CASE		)
						A ,		*A	 =      self.vqgan.encode(_SCREAMING_SNAKE_CASE		)
						return z
		def       A(  self		:       List[str]						,_SCREAMING_SNAKE_CASE		:       List[str]		)    ->   int:


						'''simple docstring'''
						A	 =      self.latent.detach().requires_grad_()
						A	 =      base_latent + transform_vector
						if self.quantize:
										A ,		*A	 =      self.vqgan.quantize(_SCREAMING_SNAKE_CASE		)
						else:
										A	 =      trans_latent
						return self.vqgan.decode(_SCREAMING_SNAKE_CASE		)
		def       A(  self		:       Any						,_SCREAMING_SNAKE_CASE		:       int						,_SCREAMING_SNAKE_CASE		:       int						,_SCREAMING_SNAKE_CASE		:       int=None		)    ->   int:


						'''simple docstring'''
						A	 =      self.clip_preprocessor(text=_SCREAMING_SNAKE_CASE						,images=_SCREAMING_SNAKE_CASE						,return_tensors='pt'						,padding=_SCREAMING_SNAKE_CASE		)
						A	 =      self.clip(**_SCREAMING_SNAKE_CASE		)
						A	 =      clip_outputs.logits_per_image
						if weights is not None:
										A	 =      similarity_logits * weights
						return similarity_logits.sum()
		def       A(  self		:       Tuple						,_SCREAMING_SNAKE_CASE		:       Tuple						,_SCREAMING_SNAKE_CASE		:       Optional[Any]						,_SCREAMING_SNAKE_CASE		:       Union[str, Any]		)    ->   Optional[Any]:


						'''simple docstring'''
						A	 =      self._get_clip_similarity(pos_prompts['prompts']						,_SCREAMING_SNAKE_CASE						,weights=(1 / pos_prompts['weights'])		)
						if neg_prompts:
										A	 =      self._get_clip_similarity(neg_prompts['prompts']						,_SCREAMING_SNAKE_CASE						,weights=neg_prompts['weights']		)
						else:
										A	 =      torch.tensor([1]						,device=self.device		)
						A	 =      -torch.log(_SCREAMING_SNAKE_CASE		) + torch.log(_SCREAMING_SNAKE_CASE		)
						return loss
		def       A(  self		:       Dict						,_SCREAMING_SNAKE_CASE		:       List[str]						,_SCREAMING_SNAKE_CASE		:       Union[str, Any]						,_SCREAMING_SNAKE_CASE		:       Tuple		)    ->   Dict:


						'''simple docstring'''
						A	 =      torch.randn_like(self.latent						,requires_grad=_SCREAMING_SNAKE_CASE						,device=self.device		)
						A	 =      torch.optim.Adam([vector]						,lr=self.lr		)

						for i in range(self.iterations		):
										optim.zero_grad()
										A	 =      self._add_vector(_SCREAMING_SNAKE_CASE		)
										A	 =      loop_post_process(_SCREAMING_SNAKE_CASE		)
										A	 =      self._get_CLIP_loss(_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE		)
										print('CLIP loss'						,_SCREAMING_SNAKE_CASE		)
										if self.log:
														wandb.log({'CLIP Loss': clip_loss}		)
										clip_loss.backward(retain_graph=_SCREAMING_SNAKE_CASE		)
										optim.step()
										if self.return_val == "image":
														yield custom_to_pil(transformed_img[0]		)
										else:
														yield vector
		def       A(  self		:       str						,_SCREAMING_SNAKE_CASE		:       str						,_SCREAMING_SNAKE_CASE		:       Optional[int]						,_SCREAMING_SNAKE_CASE		:       Optional[int]		)    ->   List[str]:


						'''simple docstring'''
						wandb.init(reinit=_SCREAMING_SNAKE_CASE						,project='face-editor'		)
						wandb.config.update({'Positive Prompts': positive_prompts}		)
						wandb.config.update({'Negative Prompts': negative_prompts}		)
						wandb.config.update({'lr': self.lr, 'iterations': self.iterations}		)
						if image_path:
										A	 =      Image.open(_SCREAMING_SNAKE_CASE		)
										A	 =      image.resize((2_5_6, 2_5_6)		)
										wandb.log('Original Image'						,wandb.Image(_SCREAMING_SNAKE_CASE		)		)
		def       A(  self		:       List[str]						,_SCREAMING_SNAKE_CASE		:       Tuple		)    ->   Union[str, Any]:


						'''simple docstring'''
						if not prompts:
										return []
						A	 =      []
						A	 =      []
						if isinstance(_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE		):
										A	 =      [prompt.strip() for prompt in prompts.split('|'		)]
						for prompt in prompts:
										if isinstance(_SCREAMING_SNAKE_CASE						,(tuple, list)		):
														A	 =      prompt[0]
														A	 =      float(prompt[1]		)
										elif ":" in prompt:
														A ,		A	 =      prompt.split(':'		)
														A	 =      float(_SCREAMING_SNAKE_CASE		)
										else:
														A	 =      prompt
														A	 =      1.0
										processed_prompts.append(_SCREAMING_SNAKE_CASE		)
										weights.append(_SCREAMING_SNAKE_CASE		)
						return {
						    "prompts": processed_prompts,
						    "weights": torch.tensor(_SCREAMING_SNAKE_CASE						,device=self.device		),
						}







		def       A(  self		:       List[Any]						,_SCREAMING_SNAKE_CASE		:       Any						,_SCREAMING_SNAKE_CASE		:       List[Any]=None						,_SCREAMING_SNAKE_CASE		:       Any=None						,_SCREAMING_SNAKE_CASE		:       Dict=True						,_SCREAMING_SNAKE_CASE		:       List[str]=False						,_SCREAMING_SNAKE_CASE		:       Tuple=True						,_SCREAMING_SNAKE_CASE		:       Any=True						,_SCREAMING_SNAKE_CASE		:       Optional[Any]=None						,)    ->   Union[str, Any]:


						'''simple docstring'''
						if image_path:
										A	 =      self._get_latent(_SCREAMING_SNAKE_CASE		)
						else:
										A	 =      torch.randn(self.latent_dim						,device=self.device		)
						if self.log:
										self._init_logging(_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE		)

						assert pos_prompts, "You must provide at least one positive prompt."
						A	 =      self.process_prompts(_SCREAMING_SNAKE_CASE		)
						A	 =      self.process_prompts(_SCREAMING_SNAKE_CASE		)
						if save_final and save_path is None:
										A	 =      os.path.join('./outputs/'						,'_'.join(pos_prompts['prompts']		)		)
						if not os.path.exists(_SCREAMING_SNAKE_CASE		):
										os.makedirs(_SCREAMING_SNAKE_CASE		)
						else:
										A	 =      save_path + '_' + get_timestamp()
										os.makedirs(_SCREAMING_SNAKE_CASE		)
						A	 =      save_path

						A	 =      self.vqgan.decode(self.latent		)[0]
						if show_intermediate:
										print('Original Image'		)
										show_pil(custom_to_pil(_SCREAMING_SNAKE_CASE		)		)

						A	 =      loop_post_process(_SCREAMING_SNAKE_CASE		)
						for iter, transformed_img in enumerate(self._optimize_CLIP(_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE						,_SCREAMING_SNAKE_CASE		)		):
										if show_intermediate:
														show_pil(_SCREAMING_SNAKE_CASE		)
										if save_intermediate:
														transformed_img.save(os.path.join(self.save_path						,f'iter_{iter:03d}.png'		)		)
										if self.log:
														wandb.log({'Image': wandb.Image(_SCREAMING_SNAKE_CASE		)}		)
						if show_final:
										show_pil(_SCREAMING_SNAKE_CASE		)
						if save_final:
										transformed_img.save(os.path.join(self.save_path						,f'iter_{iter:03d}_final.png'		)		)













import unittest

from transformers import JukeboxTokenizer
from transformers.testing_utils import require_torch
class      UpperCamelCase (				unittest.TestCase ):







		"""simple docstring"""



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


						'''simple docstring'''
						import torch

						A	 =      JukeboxTokenizer.from_pretrained('openai/jukebox-1b-lyrics'		)
						A	 =      tokenizer(**self.metas		)['input_ids']
						# fmt: off
						A	 =      [
						    torch.tensor([[
						        0, 0, 0, 7_1_6_9, 5_0_7, 9, 7_6, 3_9, 3_1, 4_6, 7_6, 2_7,
						        7_6, 4_6, 4_4, 2_7, 4_8, 3_1, 3_8, 3_8, 3_1, 4_4, 7_6, 3_2,
						        4_4, 4_1, 3_9, 7_6, 2_7, 4_0, 7_6, 2_7, 4_0, 4_6, 3_5, 4_3,
						        4_7, 3_1, 7_6, 3_8, 2_7, 4_0, 3_0, 6_4, 7_8, 7_6, 7_6, 7_6,
						        7_6, 7_6, 7_6, 7_6, 7_6, 2_3, 3_4, 4_1, 7_6, 4_5, 2_7, 3_5,
						        3_0, 7_6, 7_1, 2_0, 4_9, 4_1, 7_6, 4_8, 2_7, 4_5, 4_6, 7_6,
						        2_7, 4_0, 3_0, 7_6, 4_6, 4_4, 4_7, 4_0, 3_7, 3_8, 3_1, 4_5,
						        4_5, 7_6, 3_8, 3_1, 3_3, 4_5, 7_6, 4_1, 3_2, 7_6, 4_5, 4_6,
						        4_1, 4_0, 3_1, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6,
						        1_9, 4_6, 2_7, 4_0, 3_0, 7_6, 3_5, 4_0, 7_6, 4_6, 3_4, 3_1,
						        7_6, 3_0, 3_1, 4_5, 3_1, 4_4, 4_6, 6_3, 7_6, 6_3, 7_6, 6_3,
						        7_6, 6_3, 7_6, 1_4, 3_1, 2_7, 4_4, 7_6, 4_6, 3_4, 3_1, 3_9,
						        6_4, 7_6, 4_1, 4_0, 7_6, 4_6, 3_4, 3_1, 7_6, 4_5, 2_7, 4_0,
						        3_0, 6_4, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 8,
						        2_7, 3_8, 3_2, 7_6, 4_5, 4_7, 4_0, 3_7, 7_6, 2_7, 7_6, 4_5,
						        3_4, 2_7, 4_6, 4_6, 3_1, 4_4, 3_1, 3_0, 7_6, 4_8, 3_5, 4_5,
						        2_7, 3_3, 3_1, 7_6, 3_8, 3_5, 3_1, 4_5, 6_4, 7_6, 4_9, 3_4,
						        4_1, 4_5, 3_1, 7_6, 3_2, 4_4, 4_1, 4_9, 4_0, 6_4, 7_8, 7_6,
						        7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1, 4_0, 3_0, 7_6, 4_9,
						        4_4, 3_5, 4_0, 3_7, 3_8, 3_1, 3_0, 7_6, 3_8, 3_5, 4_2, 6_4,
						        7_6, 2_7, 4_0, 3_0, 7_6, 4_5, 4_0, 3_1, 3_1, 4_4, 7_6, 4_1,
						        3_2, 7_6, 2_9, 4_1, 3_8, 3_0, 7_6, 2_9, 4_1, 3_9, 3_9, 2_7,
						        4_0, 3_0, 6_4, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6,
						        2_0, 3_1, 3_8, 3_8, 7_6, 4_6, 3_4, 2_7, 4_6, 7_6, 3_5, 4_6,
						        4_5, 7_6, 4_5, 2_9, 4_7, 3_8, 4_2, 4_6, 4_1, 4_4, 7_6, 4_9,
						        3_1, 3_8, 3_8, 7_6, 4_6, 3_4, 4_1, 4_5, 3_1, 7_6, 4_2, 2_7,
						        4_5, 4_5, 3_5, 4_1, 4_0, 4_5, 7_6, 4_4, 3_1, 2_7, 3_0, 7_8,
						        7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 2_3, 3_4, 3_5, 2_9,
						        3_4, 7_6, 5_1, 3_1, 4_6, 7_6, 4_5, 4_7, 4_4, 4_8, 3_5, 4_8,
						        3_1, 6_4, 7_6, 4_5, 4_6, 2_7, 3_9, 4_2, 3_1, 3_0, 7_6, 4_1,
						        4_0, 7_6, 4_6, 3_4, 3_1, 4_5, 3_1, 7_6, 3_8, 3_5, 3_2, 3_1,
						        3_8, 3_1, 4_5, 4_5, 7_6, 4_6, 3_4, 3_5, 4_0, 3_3, 4_5, 6_4,
						        7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 2_0, 3_4, 3_1,
						        7_6, 3_4, 2_7, 4_0, 3_0, 7_6, 4_6, 3_4, 2_7, 4_6, 7_6, 3_9,
						        4_1, 2_9, 3_7, 3_1, 3_0, 7_6, 4_6, 3_4, 3_1, 3_9, 6_4, 7_6,
						        2_7, 4_0, 3_0, 7_6, 4_6, 3_4, 3_1, 7_6, 3_4, 3_1, 2_7, 4_4,
						        4_6, 7_6, 4_6, 3_4, 2_7, 4_6, 7_6, 3_2, 3_1, 3_0, 6_6, 7_8,
						        7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1, 4_0, 3_0, 7_6,
						        4_1, 4_0, 7_6, 4_6, 3_4, 3_1, 7_6, 4_2, 3_1, 3_0, 3_1, 4_5,
						        4_6, 2_7, 3_8, 6_4, 7_6, 4_6, 3_4, 3_1, 4_5, 3_1, 7_6, 4_9,
						        4_1, 4_4, 3_0, 4_5, 7_6, 2_7, 4_2, 4_2, 3_1, 2_7, 4_4, 6_5,
						        7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1_3, 5_1, 7_6,
						        4_0, 2_7, 3_9, 3_1, 7_6, 3_5, 4_5, 7_6, 1_5, 5_2, 5_1, 3_9,
						        2_7, 4_0, 3_0, 3_5, 2_7, 4_5, 6_4, 7_6, 1_1, 3_5, 4_0, 3_3,
						        7_6, 4_1, 3_2, 7_6, 1_1, 3_5, 4_0, 3_3, 4_5, 6_6, 7_8, 7_6,
						        7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1_2, 4_1, 4_1, 3_7, 7_6,
						        4_1, 4_0, 7_6, 3_9, 5_1, 7_6, 2_3, 4_1, 4_4, 3_7, 4_5, 6_4,
						        7_6, 5_1, 3_1, 7_6, 1_3, 3_5, 3_3, 3_4, 4_6, 5_1, 6_4, 7_6,
						        2_7, 4_0, 3_0, 7_6, 3_0, 3_1, 4_5, 4_2, 2_7, 3_5, 4_4, 6_7,
						        7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1_4, 4_1, 4_6,
						        3_4, 3_5, 4_0, 3_3, 7_6, 2_8, 3_1, 4_5, 3_5, 3_0, 3_1, 7_6,
						        4_4, 3_1, 3_9, 2_7, 3_5, 4_0, 4_5, 6_3, 7_6, 1_8, 4_1, 4_7,
						        4_0, 3_0, 7_6, 4_6, 3_4, 3_1, 7_6, 3_0, 3_1, 2_9, 2_7, 5_1,
						        7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 1_5, 3_2, 7_6,
						        4_6, 3_4, 2_7, 4_6, 7_6, 2_9, 4_1, 3_8, 4_1, 4_5, 4_5, 2_7,
						        3_8, 7_6, 2_3, 4_4, 3_1, 2_9, 3_7, 6_4, 7_6, 2_8, 4_1, 4_7,
						        4_0, 3_0, 3_8, 3_1, 4_5, 4_5, 7_6, 2_7, 4_0, 3_0, 7_6, 2_8,
						        2_7, 4_4, 3_1, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6,
						        2_0, 3_4, 3_1, 7_6, 3_8, 4_1, 4_0, 3_1, 7_6, 2_7, 4_0, 3_0,
						        7_6, 3_8, 3_1, 4_8, 3_1, 3_8, 7_6, 4_5, 2_7, 4_0, 3_0, 4_5,
						        7_6, 4_5, 4_6, 4_4, 3_1, 4_6, 2_9, 3_4, 7_6, 3_2, 2_7, 4_4,
						        7_6, 2_7, 4_9, 2_7, 5_1, 7_8, 7_6, 7_6, 7_6, 7_6, 7_6, 7_6,
						        7_6, 7_6]]		),
						    torch.tensor([[0, 0, 0, 1_0_6_9, 1_1]]		),
						    torch.tensor([[0, 0, 0, 1_0_6_9, 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]		)		)







		@require_torch
		def       A(  self		:       Tuple		)    ->   List[Any]:


						'''simple docstring'''
						import torch

						A	 =      JukeboxTokenizer.from_pretrained('openai/jukebox-5b-lyrics'		)
						A	 =      tokenizer(**self.metas		)['input_ids']
						# fmt: off
						A	 =      [
						    torch.tensor([[
						        0, 0, 0, 1_0_6_9, 1_1, -1, -1, -1, -1, 9, 7_7, 3_9,
						        3_1, 4_6, 7_7, 2_7, 7_7, 4_6, 4_4, 2_7, 4_8, 3_1, 3_8, 3_8,
						        3_1, 4_4, 7_7, 3_2, 4_4, 4_1, 3_9, 7_7, 2_7, 4_0, 7_7, 2_7,
						        4_0, 4_6, 3_5, 4_3, 4_7, 3_1, 7_7, 3_8, 2_7, 4_0, 3_0, 6_4,
						        7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 2_3, 3_4, 4_1,
						        7_7, 4_5, 2_7, 3_5, 3_0, 7_7, 7_2, 2_0, 4_9, 4_1, 7_7, 4_8,
						        2_7, 4_5, 4_6, 7_7, 2_7, 4_0, 3_0, 7_7, 4_6, 4_4, 4_7, 4_0,
						        3_7, 3_8, 3_1, 4_5, 4_5, 7_7, 3_8, 3_1, 3_3, 4_5, 7_7, 4_1,
						        3_2, 7_7, 4_5, 4_6, 4_1, 4_0, 3_1, 7_9, 7_7, 7_7, 7_7, 7_7,
						        7_7, 7_7, 7_7, 7_7, 1_9, 4_6, 2_7, 4_0, 3_0, 7_7, 3_5, 4_0,
						        7_7, 4_6, 3_4, 3_1, 7_7, 3_0, 3_1, 4_5, 3_1, 4_4, 4_6, 6_3,
						        7_7, 6_3, 7_7, 6_3, 7_7, 6_3, 7_7, 1_4, 3_1, 2_7, 4_4, 7_7,
						        4_6, 3_4, 3_1, 3_9, 6_4, 7_7, 4_1, 4_0, 7_7, 4_6, 3_4, 3_1,
						        7_7, 4_5, 2_7, 4_0, 3_0, 6_4, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7,
						        7_7, 7_7, 7_7, 8, 2_7, 3_8, 3_2, 7_7, 4_5, 4_7, 4_0, 3_7,
						        7_7, 2_7, 7_7, 4_5, 3_4, 2_7, 4_6, 4_6, 3_1, 4_4, 3_1, 3_0,
						        7_7, 4_8, 3_5, 4_5, 2_7, 3_3, 3_1, 7_7, 3_8, 3_5, 3_1, 4_5,
						        6_4, 7_7, 4_9, 3_4, 4_1, 4_5, 3_1, 7_7, 3_2, 4_4, 4_1, 4_9,
						        4_0, 6_4, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 1,
						        4_0, 3_0, 7_7, 4_9, 4_4, 3_5, 4_0, 3_7, 3_8, 3_1, 3_0, 7_7,
						        3_8, 3_5, 4_2, 6_4, 7_7, 2_7, 4_0, 3_0, 7_7, 4_5, 4_0, 3_1,
						        3_1, 4_4, 7_7, 4_1, 3_2, 7_7, 2_9, 4_1, 3_8, 3_0, 7_7, 2_9,
						        4_1, 3_9, 3_9, 2_7, 4_0, 3_0, 6_4, 7_9, 7_7, 7_7, 7_7, 7_7,
						        7_7, 7_7, 7_7, 7_7, 2_0, 3_1, 3_8, 3_8, 7_7, 4_6, 3_4, 2_7,
						        4_6, 7_7, 3_5, 4_6, 4_5, 7_7, 4_5, 2_9, 4_7, 3_8, 4_2, 4_6,
						        4_1, 4_4, 7_7, 4_9, 3_1, 3_8, 3_8, 7_7, 4_6, 3_4, 4_1, 4_5,
						        3_1, 7_7, 4_2, 2_7, 4_5, 4_5, 3_5, 4_1, 4_0, 4_5, 7_7, 4_4,
						        3_1, 2_7, 3_0, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
						        2_3, 3_4, 3_5, 2_9, 3_4, 7_7, 5_1, 3_1, 4_6, 7_7, 4_5, 4_7,
						        4_4, 4_8, 3_5, 4_8, 3_1, 6_4, 7_7, 4_5, 4_6, 2_7, 3_9, 4_2,
						        3_1, 3_0, 7_7, 4_1, 4_0, 7_7, 4_6, 3_4, 3_1, 4_5, 3_1, 7_7,
						        3_8, 3_5, 3_2, 3_1, 3_8, 3_1, 4_5, 4_5, 7_7, 4_6, 3_4, 3_5,
						        4_0, 3_3, 4_5, 6_4, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
						        7_7, 2_0, 3_4, 3_1, 7_7, 3_4, 2_7, 4_0, 3_0, 7_7, 4_6, 3_4,
						        2_7, 4_6, 7_7, 3_9, 4_1, 2_9, 3_7, 3_1, 3_0, 7_7, 4_6, 3_4,
						        3_1, 3_9, 6_4, 7_7, 2_7, 4_0, 3_0, 7_7, 4_6, 3_4, 3_1, 7_7,
						        3_4, 3_1, 2_7, 4_4, 4_6, 7_7, 4_6, 3_4, 2_7, 4_6, 7_7, 3_2,
						        3_1, 3_0, 6_6, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
						        1, 4_0, 3_0, 7_7, 4_1, 4_0, 7_7, 4_6, 3_4, 3_1, 7_7, 4_2,
						        3_1, 3_0, 3_1, 4_5, 4_6, 2_7, 3_8, 6_4, 7_7, 4_6, 3_4, 3_1,
						        4_5, 3_1, 7_7, 4_9, 4_1, 4_4, 3_0, 4_5, 7_7, 2_7, 4_2, 4_2,
						        3_1, 2_7, 4_4, 6_5, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
						        7_7, 1_3, 5_1, 7_7, 4_0, 2_7, 3_9, 3_1, 7_7, 3_5, 4_5, 7_7,
						        1_5, 5_2, 5_1, 3_9, 2_7, 4_0, 3_0, 3_5, 2_7, 4_5, 6_4, 7_7,
						        1_1, 3_5, 4_0, 3_3, 7_7, 4_1, 3_2, 7_7, 1_1, 3_5, 4_0, 3_3,
						        4_5, 6_6, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 1_2,
						        4_1, 4_1, 3_7, 7_7, 4_1, 4_0, 7_7, 3_9, 5_1, 7_7, 2_3, 4_1,
						        4_4, 3_7, 4_5, 6_4, 7_7, 5_1, 3_1, 7_7, 1_3, 3_5, 3_3, 3_4,
						        4_6, 5_1, 6_4, 7_7, 2_7, 4_0, 3_0, 7_7, 3_0, 3_1, 4_5, 4_2,
						        2_7, 3_5, 4_4, 6_7, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
						        7_7, 1_4, 4_1, 4_6, 3_4, 3_5, 4_0, 3_3, 7_7, 2_8, 3_1, 4_5,
						        3_5, 3_0, 3_1, 7_7, 4_4, 3_1, 3_9, 2_7, 3_5, 4_0, 4_5, 6_3,
						        7_7, 1_8, 4_1, 4_7, 4_0, 3_0, 7_7, 4_6, 3_4, 3_1, 7_7, 3_0,
						        3_1, 2_9, 2_7, 5_1, 7_9, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7, 7_7,
						        7_7, 1_5, 3_2, 7_7, 4_6, 3_4, 2_7, 4_6, 7_7, 2_9, 4_1, 3_8,
						        4_1, 4_5, 4_5, 2_7, 3_8, 7_7, 2_3, 4_4, 3_1, 2_9, 3_7, 6_4,
						        7_7, 2_8, 4_1, 4_7, 4_0, 3_0, 3_8, 3_1, 4_5, 4_5, 7_7, 2_7,
						        4_0, 3_0, 7_7, 2_8, 2_7, 4_4, 3_1, 7_9, 7_7, 7_7, 7_7, 7_7,
						        7_7, 7_7, 7_7, 7_7, 2_0, 3_4, 3_1, 7_7, 3_8, 4_1, 4_0, 3_1,
						        7_7, 2_7, 4_0, 3_0, 7_7, 3_8, 3_1, 4_8, 3_1, 3_8, 7_7, 4_5,
						        2_7, 4_0, 3_0, 4_5, 7_7, 4_5, 4_6, 4_4, 3_1, 4_6, 2_9, 3_4,
						        7_7, 3_2, 2_7, 4_4, 7_7, 2_7, 4_9, 2_7, 5_1, 7_9, 7_7, 7_7,
						        7_7, 7_7, 7_7, 7_7, 7_7, 7_7]]		),
						    torch.tensor([[0, 0, 0, 1_0_6_9, 1_1, -1, -1, -1, -1]]		),
						    torch.tensor([[0, 0, 0, 1_0_6_9, 1_1, -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]		)		)





