code: 
  
  
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  import tempfile
  import unittest
  
  from diffusers import (
      DDIMScheduler,
      DDPMScheduler,
      DPMSolverMultistepScheduler,
      EulerAncestralDiscreteScheduler,
      EulerDiscreteScheduler,
      PNDMScheduler,
      logging,
  )
  from diffusers.configuration_utils import ConfigMixin, register_to_config
  from diffusers.utils.testing_utils import CaptureLogger
  
  class 					snake_case_							(       lowerCAmelCase_      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						'config.json'
  
     @register_to_config
     def __init__(    self:	int   ,       snake_case__:	Union[str, Any]=2   ,       snake_case__:	Optional[Any]=5   ,       snake_case__:	int=(2, 5)   ,       snake_case__:	Any="for diffusion"   ,       snake_case__:	List[Any]=[1, 3]   ,       )  ->		int:
  
  
         """simple docstring"""
  
  
  
         pass
  
  
  
  
  
  
  class 					snake_case_							(       lowerCAmelCase_      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						'config.json'
  
     @register_to_config
     def __init__(    self:	Any   ,       snake_case__:	Optional[int]=2   ,       snake_case__:	int=5   ,       snake_case__:	Optional[Any]=(2, 5)   ,       snake_case__:	Union[str, Any]="for diffusion"   ,       snake_case__:	Tuple=[1, 3]   ,       )  ->		Union[str, Any]:
  
  
         """simple docstring"""
  
  
  
         pass
  
  
  
  
  
  
  class 					snake_case_							(       lowerCAmelCase_      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						'config.json'
  
     @register_to_config
     def __init__(    self:	int   ,       snake_case__:	str=2   ,       snake_case__:	Optional[Any]=5   ,       snake_case__:	List[str]=(2, 5)   ,       snake_case__:	Dict="for diffusion"   ,       snake_case__:	Optional[int]=[1, 3]   ,       snake_case__:	Union[str, Any]=[1, 3]   ,       )  ->		Any:
  
  
         """simple docstring"""
  
  
  
         pass
  
  
  
  
  
  
  class 					snake_case_							(       lowerCAmelCase_      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     __lowerCAmelCase      =						'config.json'
  
     @register_to_config
     def __init__(    self:	str   ,       snake_case__:	Tuple=2   ,       snake_case__:	Tuple=5   ,       snake_case__:	Optional[Any]=(2, 5)   ,       snake_case__:	Optional[int]="for diffusion"   ,       snake_case__:	Optional[Any]=[1, 5]   ,       snake_case__:	Tuple=[5, 4]   ,       )  ->		Dict:
  
  
         """simple docstring"""
  
  
  
         pass
  
  
  
  
  
  
  class 					snake_case_							(       unittest.TestCase      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[int]	)  ->		List[str]:
  
  
         """simple docstring"""
  
  
  
         with self.assertRaises(lowerCamelCase_	):
             ConfigMixin.load_config('dummy_path'	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Tuple	)  ->		List[str]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	SampleObject()
         _lowercase     =	obj.config
         assert config["a"] == 2
         assert config["b"] == 5
         assert config["c"] == (2, 5)
         assert config["d"] == "for diffusion"
         assert config["e"] == [1, 3]
  
         # init ignore private arguments
         _lowercase     =	SampleObject(_name_or_path='lalala'	)
         _lowercase     =	obj.config
         assert config["a"] == 2
         assert config["b"] == 5
         assert config["c"] == (2, 5)
         assert config["d"] == "for diffusion"
         assert config["e"] == [1, 3]
  
         # can override default
         _lowercase     =	SampleObject(c=6	)
         _lowercase     =	obj.config
         assert config["a"] == 2
         assert config["b"] == 5
         assert config["c"] == 6
         assert config["d"] == "for diffusion"
         assert config["e"] == [1, 3]
  
         # can use positional arguments.
         _lowercase     =	SampleObject(1   ,       c=6	)
         _lowercase     =	obj.config
         assert config["a"] == 1
         assert config["b"] == 5
         assert config["c"] == 6
         assert config["d"] == "for diffusion"
         assert config["e"] == [1, 3]
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Dict	)  ->		Any:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	SampleObject()
         _lowercase     =	obj.config
  
         assert config["a"] == 2
         assert config["b"] == 5
         assert config["c"] == (2, 5)
         assert config["d"] == "for diffusion"
         assert config["e"] == [1, 3]
  
         with tempfile.TemporaryDirectory() as tmpdirname:
             obj.save_config(lowerCamelCase_	)
             _lowercase     =	SampleObject.from_config(SampleObject.load_config(lowerCamelCase_	)	)
             _lowercase     =	new_obj.config
  
         # unfreeze configs
         _lowercase     =	dict(lowerCamelCase_	)
         _lowercase     =	dict(lowerCamelCase_	)
  
         assert config.pop('c'	) == (2, 5)  # instantiated as tuple
         assert new_config.pop('c'	) == [2, 5]  # saved & loaded as list because of json
         config.pop('_use_default_values'	)
         assert config == new_config
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	int	)  ->		Any:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	logging.get_logger('diffusers.configuration_utils'	)
         # 30 for warning
         logger.setLevel(30	)
  
         with CaptureLogger(lowerCamelCase_	) as cap_logger:
             _lowercase     =	DDIMScheduler.from_pretrained(
                 'hf-internal-testing/tiny-stable-diffusion-torch'   ,       subfolder='scheduler'	)
  
         assert ddim.__class__ == DDIMScheduler
         # no warning should be thrown
         assert cap_logger.out == ""
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[Any]	)  ->		Dict:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	logging.get_logger('diffusers.configuration_utils'	)
         # 30 for warning
         logger.setLevel(30	)
  
         with CaptureLogger(lowerCamelCase_	) as cap_logger:
             _lowercase     =	EulerDiscreteScheduler.from_pretrained(
                 'hf-internal-testing/tiny-stable-diffusion-torch'   ,       subfolder='scheduler'	)
  
         assert euler.__class__ == EulerDiscreteScheduler
         # no warning should be thrown
         assert cap_logger.out == ""
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	int	)  ->		Tuple:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	logging.get_logger('diffusers.configuration_utils'	)
         # 30 for warning
         logger.setLevel(30	)
  
         with CaptureLogger(lowerCamelCase_	) as cap_logger:
             _lowercase     =	EulerAncestralDiscreteScheduler.from_pretrained(
                 'hf-internal-testing/tiny-stable-diffusion-torch'   ,       subfolder='scheduler'	)
  
         assert euler.__class__ == EulerAncestralDiscreteScheduler
         # no warning should be thrown
         assert cap_logger.out == ""
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	List[Any]	)  ->		List[Any]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	logging.get_logger('diffusers.configuration_utils'	)
         # 30 for warning
         logger.setLevel(30	)
  
         with CaptureLogger(lowerCamelCase_	) as cap_logger:
             _lowercase     =	PNDMScheduler.from_pretrained(
                 'hf-internal-testing/tiny-stable-diffusion-torch'   ,       subfolder='scheduler'	)
  
         assert pndm.__class__ == PNDMScheduler
         # no warning should be thrown
         assert cap_logger.out == ""
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Any	)  ->		Dict:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	logging.get_logger('diffusers.configuration_utils'	)
         # 30 for warning
         logger.setLevel(30	)
  
         with CaptureLogger(lowerCamelCase_	) as cap_logger:
             _lowercase     =	DDPMScheduler.from_pretrained(
                 'hf-internal-testing/tiny-stable-diffusion-torch'   ,       subfolder='scheduler'   ,       prediction_type='sample'   ,       beta_end=8   ,       )
  
         with CaptureLogger(lowerCamelCase_	) as cap_logger_a:
             _lowercase     =	DDPMScheduler.from_pretrained('google/ddpm-celebahq-256'   ,       beta_start=88	)
  
         assert ddpm.__class__ == DDPMScheduler
         assert ddpm.config.prediction_type == "sample"
         assert ddpm.config.beta_end == 8
         assert ddpm_a.config.beta_start == 88
  
         # no warning should be thrown
         assert cap_logger.out == ""
         assert cap_logger_a.out == ""
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Dict	)  ->		Optional[Any]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	logging.get_logger('diffusers.configuration_utils'	)
         # 30 for warning
         logger.setLevel(30	)
  
         with CaptureLogger(lowerCamelCase_	) as cap_logger:
             _lowercase     =	DPMSolverMultistepScheduler.from_pretrained(
                 'hf-internal-testing/tiny-stable-diffusion-torch'   ,       subfolder='scheduler'	)
  
         assert dpm.__class__ == DPMSolverMultistepScheduler
         # no warning should be thrown
         assert cap_logger.out == ""
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Dict	)  ->		int:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	SampleObject()
  
         _lowercase     =	{k: v for k, v in config.config.items() if not k.startswith('_'	)}
  
         # make sure that default config has all keys in `_use_default_values`
         assert set(config_dict.keys()	) == set(config.config._use_default_values	)
  
         with tempfile.TemporaryDirectory() as tmpdirname:
             config.save_config(lowerCamelCase_	)
  
             # now loading it with SampleObject2 should put f into `_use_default_values`
             _lowercase     =	SampleObjecta.from_config(lowerCamelCase_	)
  
             assert "f" in config._use_default_values
             assert config.f == [1, 3]
  
         # now loading the config, should **NOT** use [1, 3] for `f`, but the default [1, 4] value
         # **BECAUSE** it is part of `config._use_default_values`
         _lowercase     =	SampleObjecta.from_config(config.config	)
         assert new_config.f == [5, 4]
  
         config.config._use_default_values.pop()
         _lowercase     =	SampleObjecta.from_config(config.config	)
         assert new_config_a.f == [1, 3]
  
         # Nevertheless "e" should still be correctly loaded to [1, 3] from SampleObject2 instead of defaulting to [1, 5]
         assert new_config_a.e == [1, 3]
  
style_context: 
  
  
  
  
  
  
  import json
  import os
  import shutil
  import tempfile
  import unittest
  
  from transformers import is_speech_available, is_torch_available
  from transformers.models.speechta import SpeechTaTokenizer
  from transformers.testing_utils import get_tests_dir, require_torch
  from transformers.utils import FEATURE_EXTRACTOR_NAME
  
  
  if is_speech_available() and is_torch_available():
     from transformers import SpeechTaFeatureExtractor, SpeechTaProcessor
  
     from .test_feature_extraction_speechta import floats_list
  
  
  lowerCamelCase										=  get_tests_dir('''fixtures/test_sentencepiece_bpe_char.model''')
  
  @require_torch
  class 					snake_case_							(       unittest.TestCase      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	List[str]	)  ->		Union[str, Any]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	tempfile.mkdtemp()
  
         _lowercase     =	SpeechTaTokenizer(snake_case__	)
         tokenizer.save_pretrained(self.tmpdirname	)
  
         _lowercase     =	{
             'feature_size': 1,
             'padding_value': 0.0,
             'sampling_rate': 16_000,
             'do_normalize': False,
             'num_mel_bins': 80,
             'hop_length': 16,
             'win_length': 64,
             'win_function': 'hann_window',
             'fmin': 80,
             'fmax': 7_600,
             'mel_floor': 1E-10,
             'reduction_factor': 2,
             'return_attention_mask': True,
         }
  
         _lowercase     =	os.path.join(self.tmpdirname   ,       snake_case__	)
         with open(self.feature_extraction_file   ,       'w'   ,       encoding='utf-8'	) as fp:
             fp.write(json.dumps(snake_case__	) + '\n'	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Union[str, Any]   ,       **snake_case__:	Union[str, Any]	)  ->		Union[str, Any]:
  
  
         """simple docstring"""
  
  
  
         return SpeechTaTokenizer.from_pretrained(self.tmpdirname   ,       **snake_case__	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[int]   ,       **snake_case__:	str	)  ->		int:
  
  
         """simple docstring"""
  
  
  
         return SpeechTaFeatureExtractor.from_pretrained(self.tmpdirname   ,       **snake_case__	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[Any]	)  ->		Optional[int]:
  
  
         """simple docstring"""
  
  
  
         shutil.rmtree(self.tmpdirname	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	int	)  ->		List[str]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.get_tokenizer()
         _lowercase     =	self.get_feature_extractor()
  
         _lowercase     =	SpeechTaProcessor(tokenizer=snake_case__   ,       feature_extractor=snake_case__	)
  
         processor.save_pretrained(self.tmpdirname	)
         _lowercase     =	SpeechTaProcessor.from_pretrained(self.tmpdirname	)
  
         self.assertEqual(processor.tokenizer.get_vocab()   ,       tokenizer.get_vocab()	)
         self.assertIsInstance(processor.tokenizer   ,       snake_case__	)
  
         self.assertEqual(processor.feature_extractor.to_json_string()   ,       feature_extractor.to_json_string()	)
         self.assertIsInstance(processor.feature_extractor   ,       snake_case__	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	int	)  ->		Any:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	SpeechTaProcessor(tokenizer=self.get_tokenizer()   ,       feature_extractor=self.get_feature_extractor()	)
         processor.save_pretrained(self.tmpdirname	)
  
         _lowercase     =	self.get_tokenizer(bos_token='(BOS)'   ,       eos_token='(EOS)'	)
         _lowercase     =	self.get_feature_extractor(do_normalize=snake_case__   ,       padding_value=1.0	)
  
         _lowercase     =	SpeechTaProcessor.from_pretrained(
             self.tmpdirname   ,       bos_token='(BOS)'   ,       eos_token='(EOS)'   ,       do_normalize=snake_case__   ,       padding_value=1.0	)
  
         self.assertEqual(processor.tokenizer.get_vocab()   ,       tokenizer_add_kwargs.get_vocab()	)
         self.assertIsInstance(processor.tokenizer   ,       snake_case__	)
  
         self.assertEqual(processor.feature_extractor.to_json_string()   ,       feature_extractor_add_kwargs.to_json_string()	)
         self.assertIsInstance(processor.feature_extractor   ,       snake_case__	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Union[str, Any]	)  ->		int:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.get_feature_extractor()
         _lowercase     =	self.get_tokenizer()
  
         _lowercase     =	SpeechTaProcessor(tokenizer=snake_case__   ,       feature_extractor=snake_case__	)
  
         _lowercase     =	floats_list((3, 1_000)	)
  
         _lowercase     =	feature_extractor(audio=snake_case__   ,       return_tensors='np'	)
         _lowercase     =	processor(audio=snake_case__   ,       return_tensors='np'	)
  
         for key in input_feat_extract.keys():
             self.assertAlmostEqual(input_feat_extract[key].sum()   ,       input_processor[key].sum()   ,       delta=1E-2	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Tuple	)  ->		List[str]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.get_feature_extractor()
         _lowercase     =	self.get_tokenizer()
  
         _lowercase     =	SpeechTaProcessor(tokenizer=snake_case__   ,       feature_extractor=snake_case__	)
  
         _lowercase     =	floats_list((3, 1_000)	)
  
         _lowercase     =	feature_extractor(audio_target=snake_case__   ,       return_tensors='np'	)
         _lowercase     =	processor(audio_target=snake_case__   ,       return_tensors='np'	)
  
         for key in input_feat_extract.keys():
             self.assertAlmostEqual(input_feat_extract[key].sum()   ,       input_processor[key].sum()   ,       delta=1E-2	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Dict	)  ->		Dict:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.get_feature_extractor()
         _lowercase     =	self.get_tokenizer()
  
         _lowercase     =	SpeechTaProcessor(tokenizer=snake_case__   ,       feature_extractor=snake_case__	)
  
         _lowercase     =	'This is a test string'
  
         _lowercase     =	processor(text=snake_case__	)
         _lowercase     =	tokenizer(snake_case__	)
  
         for key in encoded_tok.keys():
             self.assertListEqual(encoded_tok[key]   ,       encoded_processor[key]	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[int]	)  ->		int:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.get_feature_extractor()
         _lowercase     =	self.get_tokenizer()
  
         _lowercase     =	SpeechTaProcessor(tokenizer=snake_case__   ,       feature_extractor=snake_case__	)
  
         _lowercase     =	'This is a test string'
  
         _lowercase     =	processor(text_target=snake_case__	)
         _lowercase     =	tokenizer(snake_case__	)
  
         for key in encoded_tok.keys():
             self.assertListEqual(encoded_tok[key]   ,       encoded_processor[key]	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Dict	)  ->		int:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.get_feature_extractor()
         _lowercase     =	self.get_tokenizer()
  
         _lowercase     =	SpeechTaProcessor(tokenizer=snake_case__   ,       feature_extractor=snake_case__	)
  
         _lowercase     =	[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]
  
         _lowercase     =	processor.batch_decode(snake_case__	)
         _lowercase     =	tokenizer.batch_decode(snake_case__	)
  
         self.assertListEqual(snake_case__   ,       snake_case__	)
  
     def 			SCREAMING_SNAKE_CASE__				(    self:	Optional[Any]	)  ->		List[Any]:
  
  
         """simple docstring"""
  
  
  
         _lowercase     =	self.get_feature_extractor()
         _lowercase     =	self.get_tokenizer()
  
         _lowercase     =	SpeechTaProcessor(tokenizer=snake_case__   ,       feature_extractor=snake_case__	)
  
         self.assertListEqual(
             processor.model_input_names   ,       feature_extractor.model_input_names   ,       msg='`processor` and `feature_extractor` model input names do not match'   ,       )
  