code: 
  
  
  
  
  
  import os
  import unittest
  
  from transformers import RealmTokenizerFast
  from transformers.models.bert.tokenization_bert import (
      VOCAB_FILES_NAMES,
      BasicTokenizer,
      WordpieceTokenizer,
      _is_control,
      _is_punctuation,
      _is_whitespace,
  )
  from transformers.models.realm.tokenization_realm import RealmTokenizer
  from transformers.testing_utils import require_tokenizers, slow
  
  from ...test_tokenization_common import TokenizerTesterMixin, filter_non_english
  
  
  
  
  
  
  @require_tokenizers
  class 	UpperCamelCase_     (     snake_case__     ,    unittest.TestCase       ):
  					_a			:	int							=				RealmTokenizer
  					_a			:	Dict							=				RealmTokenizerFast
  					_a			:	Optional[Any]							=				True
  					_a			:	Union[str, Any]							=				True
  					_a			:	Union[str, Any]							=				filter_non_english
  
  
  
  					def      __a    (		self    :    Optional[int]	):
  							super().setUp()
  
  							lowerCamelCase_  :    Optional[Any]   	=			[
  							    '[UNK]',
  							    '[CLS]',
  							    '[SEP]',
  							    '[PAD]',
  							    '[MASK]',
  							    'want',
  							    '##want',
  							    '##ed',
  							    'wa',
  							    'un',
  							    'runn',
  							    '##ing',
  							    ',',
  							    'low',
  							    'lowest',
  							]
  							lowerCamelCase_  :    List[Any]   	=			os.path.join(self.tmpdirname					,			VOCAB_FILES_NAMES['vocab_file']	)
  							with open(self.vocab_file					,			'w'					,			encoding='utf-8'	) as vocab_writer:
  									vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]	)	)
  
  
  
  					def      __a    (		self    :    str					,			lowerCamelCase    :    str	):
  							lowerCamelCase_  :    Optional[int]   	=			'UNwant\u00E9d,running'
  							lowerCamelCase_  :    List[str]   	=			'unwanted, running'
  							return input_text, output_text
  
  
  
  					def      __a    (		self    :    Any	):
  							lowerCamelCase_  :    Optional[Any]   	=			self.tokenizer_class(self.vocab_file	)
  
  							lowerCamelCase_  :    Dict   	=			tokenizer.tokenize('UNwant\u00E9d,running'	)
  							self.assertListEqual(lowerCamelCase					,			['un', '##want', '##ed', ',', 'runn', '##ing']	)
  							self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCamelCase	)					,			[9, 6, 7, 12, 10, 11]	)
  
  
  
  					def      __a    (		self    :    Tuple	):
  							if not self.test_rust_tokenizer:
  									return
  
  							lowerCamelCase_  :    int   	=			self.get_tokenizer()
  							lowerCamelCase_  :    Optional[Any]   	=			self.get_rust_tokenizer()
  
  							lowerCamelCase_  :    Optional[Any]   	=			'UNwant\u00E9d,running'
  
  							lowerCamelCase_  :    Optional[int]   	=			tokenizer.tokenize(lowerCamelCase	)
  							lowerCamelCase_  :    Optional[int]   	=			rust_tokenizer.tokenize(lowerCamelCase	)
  							self.assertListEqual(lowerCamelCase					,			lowerCamelCase	)
  
  							lowerCamelCase_  :    Dict   	=			tokenizer.encode(lowerCamelCase					,			add_special_tokens=lowerCamelCase	)
  							lowerCamelCase_  :    List[Any]   	=			rust_tokenizer.encode(lowerCamelCase					,			add_special_tokens=lowerCamelCase	)
  							self.assertListEqual(lowerCamelCase					,			lowerCamelCase	)
  
  							lowerCamelCase_  :    Tuple   	=			self.get_rust_tokenizer()
  							lowerCamelCase_  :    Optional[int]   	=			tokenizer.encode(lowerCamelCase	)
  							lowerCamelCase_  :    Tuple   	=			rust_tokenizer.encode(lowerCamelCase	)
  							self.assertListEqual(lowerCamelCase					,			lowerCamelCase	)
  
  							# With lower casing
  							lowerCamelCase_  :    List[str]   	=			self.get_tokenizer(do_lower_case=lowerCamelCase	)
  							lowerCamelCase_  :    List[str]   	=			self.get_rust_tokenizer(do_lower_case=lowerCamelCase	)
  
  							lowerCamelCase_  :    str   	=			'UNwant\u00E9d,running'
  
  							lowerCamelCase_  :    int   	=			tokenizer.tokenize(lowerCamelCase	)
  							lowerCamelCase_  :    int   	=			rust_tokenizer.tokenize(lowerCamelCase	)
  							self.assertListEqual(lowerCamelCase					,			lowerCamelCase	)
  
  							lowerCamelCase_  :    Tuple   	=			tokenizer.encode(lowerCamelCase					,			add_special_tokens=lowerCamelCase	)
  							lowerCamelCase_  :    Tuple   	=			rust_tokenizer.encode(lowerCamelCase					,			add_special_tokens=lowerCamelCase	)
  							self.assertListEqual(lowerCamelCase					,			lowerCamelCase	)
  
  							lowerCamelCase_  :    Optional[int]   	=			self.get_rust_tokenizer()
  							lowerCamelCase_  :    Union[str, Any]   	=			tokenizer.encode(lowerCamelCase	)
  							lowerCamelCase_  :    Tuple   	=			rust_tokenizer.encode(lowerCamelCase	)
  							self.assertListEqual(lowerCamelCase					,			lowerCamelCase	)
  
  
  
  					def      __a    (		self    :    List[Any]	):
  							lowerCamelCase_  :    Tuple   	=			BasicTokenizer()
  
  							self.assertListEqual(tokenizer.tokenize('ah\u535A\u63A8zz'	)					,			['ah', '\u535A', '\u63A8', 'zz']	)
  
  
  
  					def      __a    (		self    :    List[str]	):
  							lowerCamelCase_  :    str   	=			BasicTokenizer(do_lower_case=lowerCamelCase	)
  
  							self.assertListEqual(
  							    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU?  '	)					,			['hello', '!', 'how', 'are', 'you', '?']	)
  							self.assertListEqual(tokenizer.tokenize('H\u00E9llo'	)					,			['hello']	)
  
  
  
  					def      __a    (		self    :    Optional[int]	):
  							lowerCamelCase_  :    Optional[int]   	=			BasicTokenizer(do_lower_case=lowerCamelCase					,			strip_accents=lowerCamelCase	)
  
  							self.assertListEqual(
  							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '	)					,			['hällo', '!', 'how', 'are', 'you', '?']	)
  							self.assertListEqual(tokenizer.tokenize('H\u00E9llo'	)					,			['h\u00E9llo']	)
  
  
  
  					def      __a    (		self    :    Dict	):
  							lowerCamelCase_  :    str   	=			BasicTokenizer(do_lower_case=lowerCamelCase					,			strip_accents=lowerCamelCase	)
  
  							self.assertListEqual(
  							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '	)					,			['hallo', '!', 'how', 'are', 'you', '?']	)
  							self.assertListEqual(tokenizer.tokenize('H\u00E9llo'	)					,			['hello']	)
  
  
  
  					def      __a    (		self    :    int	):
  							lowerCamelCase_  :    List[Any]   	=			BasicTokenizer(do_lower_case=lowerCamelCase	)
  
  							self.assertListEqual(
  							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '	)					,			['hallo', '!', 'how', 'are', 'you', '?']	)
  							self.assertListEqual(tokenizer.tokenize('H\u00E9llo'	)					,			['hello']	)
  
  
  
  					def      __a    (		self    :    Optional[Any]	):
  							lowerCamelCase_  :    Dict   	=			BasicTokenizer(do_lower_case=lowerCamelCase	)
  
  							self.assertListEqual(
  							    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU?  '	)					,			['HeLLo', '!', 'how', 'Are', 'yoU', '?']	)
  
  
  
  					def      __a    (		self    :    Optional[Any]	):
  							lowerCamelCase_  :    List[str]   	=			BasicTokenizer(do_lower_case=lowerCamelCase					,			strip_accents=lowerCamelCase	)
  
  							self.assertListEqual(
  							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '	)					,			['HäLLo', '!', 'how', 'Are', 'yoU', '?']	)
  
  
  
  					def      __a    (		self    :    str	):
  							lowerCamelCase_  :    Optional[Any]   	=			BasicTokenizer(do_lower_case=lowerCamelCase					,			strip_accents=lowerCamelCase	)
  
  							self.assertListEqual(
  							    tokenizer.tokenize(' \tHäLLo!how  \n Are yoU?  '	)					,			['HaLLo', '!', 'how', 'Are', 'yoU', '?']	)
  
  
  
  					def      __a    (		self    :    Dict	):
  							lowerCamelCase_  :    List[Any]   	=			BasicTokenizer(do_lower_case=lowerCamelCase					,			never_split=['[UNK]']	)
  
  							self.assertListEqual(
  							    tokenizer.tokenize(' \tHeLLo!how  \n Are yoU? [UNK]'	)					,			['HeLLo', '!', 'how', 'Are', 'yoU', '?', '[UNK]']	)
  
  
  
  					def      __a    (		self    :    Any	):
  							lowerCamelCase_  :    Optional[Any]   	=			['[UNK]', '[CLS]', '[SEP]', 'want', '##want', '##ed', 'wa', 'un', 'runn', '##ing']
  
  							lowerCamelCase_  :    Union[str, Any]   	=			{}
  							for i, token in enumerate(lowerCamelCase	):
  									lowerCamelCase_  :    List[str]   	=			i
  							lowerCamelCase_  :    Optional[int]   	=			WordpieceTokenizer(vocab=lowerCamelCase					,			unk_token='[UNK]'	)
  
  							self.assertListEqual(tokenizer.tokenize(''	)					,			[]	)
  
  							self.assertListEqual(tokenizer.tokenize('unwanted running'	)					,			['un', '##want', '##ed', 'runn', '##ing']	)
  
  							self.assertListEqual(tokenizer.tokenize('unwantedX running'	)					,			['[UNK]', 'runn', '##ing']	)
  
  
  
  					def      __a    (		self    :    int	):
  							self.assertTrue(_is_whitespace(' '	)	)
  							self.assertTrue(_is_whitespace('\t'	)	)
  							self.assertTrue(_is_whitespace('\r'	)	)
  							self.assertTrue(_is_whitespace('\n'	)	)
  							self.assertTrue(_is_whitespace('\u00A0'	)	)
  
  							self.assertFalse(_is_whitespace('A'	)	)
  							self.assertFalse(_is_whitespace('-'	)	)
  
  
  
  					def      __a    (		self    :    int	):
  							self.assertTrue(_is_control('\u0005'	)	)
  
  							self.assertFalse(_is_control('A'	)	)
  							self.assertFalse(_is_control(' '	)	)
  							self.assertFalse(_is_control('\t'	)	)
  							self.assertFalse(_is_control('\r'	)	)
  
  
  
  					def      __a    (		self    :    Any	):
  							self.assertTrue(_is_punctuation('-'	)	)
  							self.assertTrue(_is_punctuation('$'	)	)
  							self.assertTrue(_is_punctuation('`'	)	)
  							self.assertTrue(_is_punctuation('.'	)	)
  
  							self.assertFalse(_is_punctuation('A'	)	)
  							self.assertFalse(_is_punctuation(' '	)	)
  
  
  
  					def      __a    (		self    :    Optional[Any]	):
  							lowerCamelCase_  :    Tuple   	=			self.get_tokenizer()
  
  							# Example taken from the issue https://github.com/huggingface/tokenizers/issues/340
  							self.assertListEqual([tokenizer.tokenize(lowerCamelCase	) for t in ['Test', '\xad', 'test']]					,			[['[UNK]'], [], ['[UNK]']]	)
  
  							if self.test_rust_tokenizer:
  									lowerCamelCase_  :    List[Any]   	=			self.get_rust_tokenizer()
  									self.assertListEqual(
  									    [rust_tokenizer.tokenize(lowerCamelCase	) for t in ['Test', '\xad', 'test']]					,			[['[UNK]'], [], ['[UNK]']]	)
  
  
  
  					@slow
  					def      __a    (		self    :    List[str]	):
  							lowerCamelCase_  :    List[str]   	=			self.tokenizer_class.from_pretrained('bert-base-uncased'	)
  
  							lowerCamelCase_  :    Optional[Any]   	=			tokenizer.encode('sequence builders'					,			add_special_tokens=lowerCamelCase	)
  							lowerCamelCase_  :    Optional[Any]   	=			tokenizer.encode('multi-sequence build'					,			add_special_tokens=lowerCamelCase	)
  
  							lowerCamelCase_  :    str   	=			tokenizer.build_inputs_with_special_tokens(lowerCamelCase	)
  							lowerCamelCase_  :    str   	=			tokenizer.build_inputs_with_special_tokens(lowerCamelCase					,			lowerCamelCase	)
  
  							assert encoded_sentence == [1_01] + text + [1_02]
  							assert encoded_pair == [1_01] + text + [1_02] + text_a + [1_02]
  
  
  
  					def      __a    (		self    :    Tuple	):
  							for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
  									with self.subTest(F"{tokenizer.__class__.__name__} ({pretrained_name})"	):
  											lowerCamelCase_  :    List[Any]   	=			self.rust_tokenizer_class.from_pretrained(lowerCamelCase					,			**lowerCamelCase	)
  
  											lowerCamelCase_  :    int   	=			F"A, naïve {tokenizer_r.mask_token} AllenNLP sentence."
  											lowerCamelCase_  :    str   	=			tokenizer_r.encode_plus(
  											    lowerCamelCase					,			return_attention_mask=lowerCamelCase					,			return_token_type_ids=lowerCamelCase					,			return_offsets_mapping=lowerCamelCase					,			add_special_tokens=lowerCamelCase					,			)
  
  											lowerCamelCase_  :    Union[str, Any]   	=			tokenizer_r.do_lower_case if hasattr(lowerCamelCase					,			'do_lower_case'	) else False
  											lowerCamelCase_  :    Optional[int]   	=			(
  											    [
  											        ((0, 0), tokenizer_r.cls_token),
  											        ((0, 1), 'A'),
  											        ((1, 2), ','),
  											        ((3, 5), 'na'),
  											        ((5, 6), '##ï'),
  											        ((6, 8), '##ve'),
  											        ((9, 15), tokenizer_r.mask_token),
  											        ((16, 21), 'Allen'),
  											        ((21, 23), '##NL'),
  											        ((23, 24), '##P'),
  											        ((25, 33), 'sentence'),
  											        ((33, 34), '.'),
  											        ((0, 0), tokenizer_r.sep_token),
  											    ]
  											    if not do_lower_case
  											    else [
  											        ((0, 0), tokenizer_r.cls_token),
  											        ((0, 1), 'a'),
  											        ((1, 2), ','),
  											        ((3, 8), 'naive'),
  											        ((9, 15), tokenizer_r.mask_token),
  											        ((16, 21), 'allen'),
  											        ((21, 23), '##nl'),
  											        ((23, 24), '##p'),
  											        ((25, 33), 'sentence'),
  											        ((33, 34), '.'),
  											        ((0, 0), tokenizer_r.sep_token),
  											    ]
  											)
  
  											self.assertEqual(
  											    [e[1] for e in expected_results]					,			tokenizer_r.convert_ids_to_tokens(tokens['input_ids']	)	)
  											self.assertEqual([e[0] for e in expected_results]					,			tokens['offset_mapping']	)
  
  
  
  
  
  					@slow
  					def      __a    (		self    :    Tuple	):
  							for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
  									with self.subTest(F"{tokenizer.__class__.__name__} ({pretrained_name})"	):
  											lowerCamelCase_  :    List[str]   	=			self.rust_tokenizer_class.from_pretrained(lowerCamelCase					,			**lowerCamelCase	)
  											lowerCamelCase_  :    Dict   	=			self.tokenizer_class.from_pretrained(lowerCamelCase					,			**lowerCamelCase	)
  											lowerCamelCase_  :    List[Any]   	=			[['Hello world!', 'Nice to meet you!'], ['The cute cat.', 'The adorable dog.']]
  
  											lowerCamelCase_  :    Optional[Any]   	=			tokenizer_r.batch_encode_candidates(lowerCamelCase					,			max_length=10					,			return_tensors='np'	)
  											lowerCamelCase_  :    int   	=			tokenizer_p.batch_encode_candidates(lowerCamelCase					,			max_length=10					,			return_tensors='np'	)
  
  											lowerCamelCase_  :    str   	=			(2, 2, 10)
  
  											self.assertEqual(encoded_sentence_r['input_ids'].shape					,			lowerCamelCase	)
  											self.assertEqual(encoded_sentence_r['attention_mask'].shape					,			lowerCamelCase	)
  											self.assertEqual(encoded_sentence_r['token_type_ids'].shape					,			lowerCamelCase	)
  
  											self.assertEqual(encoded_sentence_p['input_ids'].shape					,			lowerCamelCase	)
  											self.assertEqual(encoded_sentence_p['attention_mask'].shape					,			lowerCamelCase	)
  											self.assertEqual(encoded_sentence_p['token_type_ids'].shape					,			lowerCamelCase	)
  
style_context: 
  
  
  
  
  
  import gc
  import unittest
  
  import numpy as np
  import torch
  
  from diffusers import DDPMScheduler, MidiProcessor, SpectrogramDiffusionPipeline
  from diffusers.pipelines.spectrogram_diffusion import SpectrogramContEncoder, SpectrogramNotesEncoder, TaFilmDecoder
  from diffusers.utils import require_torch_gpu, skip_mps, slow, torch_device
  from diffusers.utils.testing_utils import enable_full_determinism, require_note_seq, require_onnxruntime
  
  from ..pipeline_params import TOKENS_TO_AUDIO_GENERATION_BATCH_PARAMS, TOKENS_TO_AUDIO_GENERATION_PARAMS
  from ..test_pipelines_common import PipelineTesterMixin
  
  
  enable_full_determinism()
  
  
  _lowercase		:     Optional[Any] 					="""./tests/fixtures/elise_format0.mid"""
  
  
  
  
  
  
  @unittest.skip('The note-seq package currently throws an error on import'       )
  class 	UpperCamelCase_     (     snake_case__     ,    unittest.TestCase       ):
  					_a			:	int							=				SpectrogramDiffusionPipeline
  					_a			:	Dict							=				PipelineTesterMixin.required_optional_params - {
  					    'callback',
  					    'latents',
  					    'callback_steps',
  					    'output_type',
  					    'num_images_per_prompt',
  					}
  					_a			:	str							=				False
  					_a			:	Union[str, Any]							=				False
  					_a			:	Optional[int]							=				TOKENS_TO_AUDIO_GENERATION_PARAMS
  					_a			:	Optional[Any]							=				TOKENS_TO_AUDIO_GENERATION_BATCH_PARAMS
  
  
  
  					def      __a    (		self    :    Dict	):
  							torch.manual_seed(0	)
  							lowerCamelCase_  :    List[str]   	=			SpectrogramNotesEncoder(
  							    max_length=20_48					,			vocab_size=15_36					,			d_model=7_68					,			dropout_rate=0.1					,			num_layers=1					,			num_heads=1					,			d_kv=4					,			d_ff=20_48					,			feed_forward_proj='gated-gelu'					,			)
  
  							lowerCamelCase_  :    Union[str, Any]   	=			SpectrogramContEncoder(
  							    input_dims=1_28					,			targets_context_length=2_56					,			d_model=7_68					,			dropout_rate=0.1					,			num_layers=1					,			num_heads=1					,			d_kv=4					,			d_ff=20_48					,			feed_forward_proj='gated-gelu'					,			)
  
  							lowerCamelCase_  :    Union[str, Any]   	=			TaFilmDecoder(
  							    input_dims=1_28					,			targets_length=2_56					,			max_decoder_noise_time=20_000.0					,			d_model=7_68					,			num_layers=1					,			num_heads=1					,			d_kv=4					,			d_ff=20_48					,			dropout_rate=0.1					,			)
  
  							lowerCamelCase_  :    Any   	=			DDPMScheduler()
  
  							lowerCamelCase_  :    str   	=			{
  							    'notes_encoder': notes_encoder.eval(),
  							    'continuous_encoder': continuous_encoder.eval(),
  							    'decoder': decoder.eval(),
  							    'scheduler': scheduler,
  							    'melgan': None,
  							}
  							return components
  
  
  
  					def      __a    (		self    :    Any					,			lowerCamelCase    :    Any					,			lowerCamelCase    :    int=0	):
  							if str(lowerCamelCase	).startswith('mps'	):
  									lowerCamelCase_  :    Optional[int]   	=			torch.manual_seed(lowerCamelCase	)
  							else:
  									lowerCamelCase_  :    Dict   	=			torch.Generator(device=lowerCamelCase	).manual_seed(lowerCamelCase	)
  							lowerCamelCase_  :    str   	=			{
  							    'input_tokens': [
  							        [11_34, 90, 11_35, 11_33, 10_80, 1_12, 11_32, 10_80, 11_33, 10_79, 1_33, 11_32, 10_79, 11_33, 1] + [0] * 20_33
  							    ],
  							    'generator': generator,
  							    'num_inference_steps': 4,
  							    'output_type': 'mel',
  							}
  							return inputs
  
  
  
  					def      __a    (		self    :    Dict	):
  							lowerCamelCase_  :    str   	=			'cpu'  # ensure determinism for the device-dependent torch.Generator
  							lowerCamelCase_  :    Dict   	=			self.get_dummy_components()
  							lowerCamelCase_  :    Tuple   	=			SpectrogramDiffusionPipeline(**lowerCamelCase	)
  							lowerCamelCase_  :    List[str]   	=			pipe.to(lowerCamelCase	)
  							pipe.set_progress_bar_config(disable=lowerCamelCase	)
  
  							lowerCamelCase_  :    Optional[Any]   	=			self.get_dummy_inputs(lowerCamelCase	)
  							lowerCamelCase_  :    str   	=			pipe(**lowerCamelCase	)
  							lowerCamelCase_  :    Tuple   	=			output.audios
  
  							lowerCamelCase_  :    Tuple   	=			mel[0, -3:, -3:]
  
  							assert mel_slice.shape == (3, 3)
  							lowerCamelCase_  :    List[str]   	=			np.array(
  							    [-11.512_925, -4.788_215, -0.46_172_905, -2.051_715, -10.539_147, -10.970_963, -9.091_634, 4.0, 4.0]	)
  							assert np.abs(mel_slice.flatten() - expected_slice	).max() < 1E-2
  
  
  
  					@skip_mps
  					def      __a    (		self    :    Any	):
  							return super().test_save_load_local()
  
  
  
  					@skip_mps
  					def      __a    (		self    :    Tuple	):
  							return super().test_dict_tuple_outputs_equivalent()
  
  
  
  					@skip_mps
  					def      __a    (		self    :    Dict	):
  							return super().test_save_load_optional_components()
  
  
  
  					@skip_mps
  					def      __a    (		self    :    str	):
  							return super().test_attention_slicing_forward_pass()
  
  
  
  					def      __a    (		self    :    Any	):
  							pass
  
  
  
  					def      __a    (		self    :    Optional[int]	):
  							pass
  
  
  
  
  
  					@skip_mps
  					def      __a    (		self    :    Optional[Any]	):
  							return super().test_progress_bar()
  
  
  
  
  
  
  @slow
  @require_torch_gpu
  @require_onnxruntime
  @require_note_seq
  class 	UpperCamelCase_     (     unittest.TestCase       ):
  
  
  
  					def      __a    (		self    :    Optional[int]	):
  							# clean up the VRAM after each test
  							super().tearDown()
  							gc.collect()
  							torch.cuda.empty_cache()
  
  
  
  					def      __a    (		self    :    str	):
  							# TODO - test that pipeline can decode tokens in a callback
  							# so that music can be played live
  							lowerCamelCase_  :    Optional[Any]   	=			torch_device
  
  							lowerCamelCase_  :    Union[str, Any]   	=			SpectrogramDiffusionPipeline.from_pretrained('google/music-spectrogram-diffusion'	)
  							lowerCamelCase_  :    str   	=			pipe.melgan
  							lowerCamelCase_  :    Optional[int]   	=			None
  
  							lowerCamelCase_  :    str   	=			pipe.to(lowerCamelCase	)
  							pipe.set_progress_bar_config(disable=lowerCamelCase	)
  
  							def callback(lowerCamelCase    :    int					,			lowerCamelCase    :    int	):
  									# decode mel to audio
  									lowerCamelCase_  :    Union[str, Any]   	=			melgan(input_features=mel_output.astype(np.floataa	)	)[0]
  									assert len(audio[0]	) == 8_19_20 * (step + 1)
  									# simulate that audio is played
  									return audio
  
  							lowerCamelCase_  :    Any   	=			MidiProcessor()
  							lowerCamelCase_  :    str   	=			processor(lowerCamelCase	)
  
  							lowerCamelCase_  :    str   	=			input_tokens[:3]
  							lowerCamelCase_  :    Dict   	=			torch.manual_seed(0	)
  							pipe(lowerCamelCase					,			num_inference_steps=5					,			generator=lowerCamelCase					,			callback=lowerCamelCase					,			output_type='mel'	)
  
  
  
  					def      __a    (		self    :    str	):
  							lowerCamelCase_  :    List[str]   	=			torch_device
  
  							lowerCamelCase_  :    List[str]   	=			SpectrogramDiffusionPipeline.from_pretrained('google/music-spectrogram-diffusion'	)
  							lowerCamelCase_  :    Union[str, Any]   	=			pipe.to(lowerCamelCase	)
  							pipe.set_progress_bar_config(disable=lowerCamelCase	)
  							lowerCamelCase_  :    int   	=			MidiProcessor()
  
  							lowerCamelCase_  :    Dict   	=			processor(lowerCamelCase	)
  							# just run two denoising loops
  							lowerCamelCase_  :    Optional[Any]   	=			input_tokens[:2]
  
  							lowerCamelCase_  :    List[Any]   	=			torch.manual_seed(0	)
  							lowerCamelCase_  :    str   	=			pipe(lowerCamelCase					,			num_inference_steps=2					,			generator=lowerCamelCase	)
  
  							lowerCamelCase_  :    Dict   	=			output.audios[0]
  
  							assert abs(np.abs(lowerCamelCase	).sum() - 3_612.841	) < 1E-1
  
  
  
  
  
  					def      __a    (		self    :    List[Any]	):
  							lowerCamelCase_  :    int   	=			torch_device
  
  							lowerCamelCase_  :    str   	=			SpectrogramDiffusionPipeline.from_pretrained('google/music-spectrogram-diffusion'	)
  							lowerCamelCase_  :    Optional[int]   	=			pipe.to(lowerCamelCase	)
  							pipe.set_progress_bar_config(disable=lowerCamelCase	)
  
  							lowerCamelCase_  :    Tuple   	=			MidiProcessor()
  
  							lowerCamelCase_  :    int   	=			processor(lowerCamelCase	)
  
  							# just run 4 denoising loops
  							lowerCamelCase_  :    Optional[Any]   	=			input_tokens[:4]
  
  							lowerCamelCase_  :    List[Any]   	=			torch.manual_seed(0	)
  							lowerCamelCase_  :    int   	=			pipe(lowerCamelCase					,			num_inference_steps=1_00					,			generator=lowerCamelCase	)
  
  							lowerCamelCase_  :    List[Any]   	=			output.audios[0]
  							assert abs(np.abs(lowerCamelCase	).sum() - 9_389.1_111	) < 5E-2
  