



from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast
from ...utils import logging


if TYPE_CHECKING:
  from ...feature_extraction_utils import FeatureExtractionMixin
  from ...tokenization_utils_base import PreTrainedTokenizerBase
  from ...utils import TensorType

a__    =	logging.get_logger(__name__)

a__    =	{
    """openai/whisper-base""": """https://huggingface.co/openai/whisper-base/resolve/main/config.json""",
}

# fmt: off
a__    =	[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 3_57, 3_66, 4_38, 5_32, 6_85,
    7_05, 7_96, 9_30, 10_58, 12_20, 12_67, 12_79, 13_03, 13_43, 13_77,
    13_91, 16_35, 17_82, 18_75, 21_62, 23_61, 24_88, 34_67, 40_08, 42_11,
    46_00, 48_08, 52_99, 58_55, 63_29, 72_03, 96_09, 99_59, 1_05_63, 1_07_86,
    1_14_20, 1_17_09, 1_19_07, 1_31_63, 1_36_97, 1_37_00, 1_48_08, 1_53_06, 1_64_10, 1_67_91,
    1_79_92, 1_92_03, 1_95_10, 2_07_24, 2_23_05, 2_29_35, 2_70_07, 3_01_09, 3_04_20, 3_34_09,
    3_49_49, 4_02_83, 4_04_93, 4_05_49, 4_72_82, 4_91_46, 5_02_57, 5_03_59, 5_03_60, 5_03_61
]
a__    =	[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 3_59, 5_03, 5_22, 5_42, 8_73,
    8_93, 9_02, 9_18, 9_22, 9_31, 13_50, 18_53, 19_82, 24_60, 26_27,
    32_46, 32_53, 32_68, 35_36, 38_46, 39_61, 41_83, 46_67, 65_85, 66_47,
    72_73, 90_61, 93_83, 1_04_28, 1_09_29, 1_19_38, 1_20_33, 1_23_31, 1_25_62, 1_37_93,
    1_41_57, 1_46_35, 1_52_65, 1_56_18, 1_65_53, 1_66_04, 1_83_62, 1_89_56, 2_00_75, 2_16_75,
    2_25_20, 2_61_30, 2_61_61, 2_64_35, 2_82_79, 2_94_64, 3_16_50, 3_23_02, 3_24_70, 3_68_65,
    4_28_63, 4_74_25, 4_98_70, 5_02_54, 5_02_58, 5_03_60, 5_03_61, 5_03_62
]







class 		snake_case						(	SCREAMING_SNAKE_CASE_  ):



   '''simple docstring'''






   snake_case_					: Union[str, Any]          =		"""whisper"""
   snake_case_					: str          =		["""past_key_values"""]
   snake_case_					: Union[str, Any]          =		{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}

   def __init__(					self							:			str				,		lowerCAmelCase							:			Tuple=5_1865				,		lowerCAmelCase							:			Union[str, Any]=80				,		lowerCAmelCase							:			Union[str, Any]=6				,		lowerCAmelCase							:			Optional[int]=4				,		lowerCAmelCase							:			Optional[Any]=6				,		lowerCAmelCase							:			str=4				,		lowerCAmelCase							:			Union[str, Any]=1536				,		lowerCAmelCase							:			Any=1536				,		lowerCAmelCase							:			int=0.0				,		lowerCAmelCase							:			Optional[int]=0.0				,		lowerCAmelCase							:			Optional[Any]=5_0257				,		lowerCAmelCase							:			Optional[int]=True				,		lowerCAmelCase							:			Optional[int]=True				,		lowerCAmelCase							:			Optional[Any]="gelu"				,		lowerCAmelCase							:			Any=256				,		lowerCAmelCase							:			Optional[int]=0.0				,		lowerCAmelCase							:			Union[str, Any]=0.0				,		lowerCAmelCase							:			Tuple=0.0				,		lowerCAmelCase							:			Dict=0.02				,		lowerCAmelCase							:			int=False				,		lowerCAmelCase							:			List[str]=1500				,		lowerCAmelCase							:			Optional[Any]=448				,		lowerCAmelCase							:			Dict=5_0256				,		lowerCAmelCase							:			str=5_0256				,		lowerCAmelCase							:			Optional[int]=5_0256				,		lowerCAmelCase							:			Optional[Any]=None				,		lowerCAmelCase							:			Optional[int]=[220, 5_0256]				,		lowerCAmelCase							:			Tuple=False				,		lowerCAmelCase							:			str=256				,		lowerCAmelCase							:			Any=False				,		lowerCAmelCase							:			List[str]=0.05				,		lowerCAmelCase							:			List[Any]=10				,		lowerCAmelCase							:			Dict=2				,		lowerCAmelCase							:			str=0.0				,		lowerCAmelCase							:			Tuple=10				,		lowerCAmelCase							:			Union[str, Any]=0				,		lowerCAmelCase							:			int=7				,		**lowerCAmelCase							:			Union[str, Any]				,		)				->				Dict:

    """simple docstring"""







    _snake_case    :  Dict					=					vocab_size
    _snake_case    :  List[Any]					=					num_mel_bins
    _snake_case    :  Dict					=					d_model
    _snake_case    :  Tuple					=					encoder_layers
    _snake_case    :  List[Any]					=					encoder_attention_heads
    _snake_case    :  List[Any]					=					decoder_layers
    _snake_case    :  Optional[Any]					=					decoder_attention_heads
    _snake_case    :  Dict					=					decoder_ffn_dim
    _snake_case    :  int					=					encoder_ffn_dim
    _snake_case    :  List[str]					=					dropout
    _snake_case    :  str					=					attention_dropout
    _snake_case    :  Optional[Any]					=					activation_dropout
    _snake_case    :  Union[str, Any]					=					activation_function
    _snake_case    :  Optional[Any]					=					init_std
    _snake_case    :  Any					=					encoder_layerdrop
    _snake_case    :  Optional[Any]					=					decoder_layerdrop
    _snake_case    :  Optional[int]					=					use_cache
    _snake_case    :  Optional[int]					=					encoder_layers
    _snake_case    :  Dict					=					scale_embedding  # scale factor will be sqrt(d_model) if True
    _snake_case    :  Union[str, Any]					=					max_source_positions
    _snake_case    :  Any					=					max_target_positions

    # Audio Classification-specific parameters. Feel free to ignore for other classes.
    _snake_case    :  Optional[Any]					=					classifier_proj_size
    _snake_case    :  List[str]					=					use_weighted_layer_sum

    # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
    _snake_case    :  Any					=					apply_spec_augment
    _snake_case    :  int					=					mask_time_prob
    _snake_case    :  Optional[int]					=					mask_time_length
    _snake_case    :  Any					=					mask_time_min_masks
    _snake_case    :  int					=					mask_feature_prob
    _snake_case    :  Union[str, Any]					=					mask_feature_length
    _snake_case    :  Union[str, Any]					=					mask_feature_min_masks

    _snake_case    :  int					=					median_filter_width

    super().__init__(
        pad_token_id=lowerCAmelCase				,		bos_token_id=lowerCAmelCase				,		eos_token_id=lowerCAmelCase				,		is_encoder_decoder=lowerCAmelCase				,		decoder_start_token_id=lowerCAmelCase				,		suppress_tokens=lowerCAmelCase				,		begin_suppress_tokens=lowerCAmelCase				,		**lowerCAmelCase				,		)







class 		snake_case						(	SCREAMING_SNAKE_CASE_  ):



   '''simple docstring'''






   @property
   def      UpperCamelCase_  (					self							:			Dict)				->				Mapping[str, Mapping[int, str]]:

    """simple docstring"""







    _snake_case    :  str					=					OrderedDict(
        [
            ("""input_features""", {0: """batch""", 1: """feature_size""", 2: """encoder_sequence"""}),
        ])
    if self.use_past:
     _snake_case    :  List[str]					=					{0: """batch"""}
    else:
     _snake_case    :  Any					=					{0: """batch""", 1: """decoder_sequence"""}

    if self.use_past:
     self.fill_with_past_key_values_(lowerCAmelCase				,		direction="""inputs""")

    return common_inputs

   def      UpperCamelCase_  (					self							:			Optional[int]				,		lowerCAmelCase							:			Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]				,		lowerCAmelCase							:			int = -1				,		lowerCAmelCase							:			int = -1				,		lowerCAmelCase							:			bool = False				,		lowerCAmelCase							:			Optional["TensorType"] = None				,		lowerCAmelCase							:			int = 2_2050				,		lowerCAmelCase							:			float = 5.0				,		lowerCAmelCase							:			int = 220				,		)				->				Mapping[str, Any]:

    """simple docstring"""







    _snake_case    :  Optional[Any]					=					OrderedDict()
    _snake_case    :  str					=					OnnxConfig.generate_dummy_inputs(
        self				,		preprocessor=preprocessor.feature_extractor				,		batch_size=lowerCAmelCase				,		framework=lowerCAmelCase				,		sampling_rate=lowerCAmelCase				,		time_duration=lowerCAmelCase				,		frequency=lowerCAmelCase				,		)
    _snake_case    :  Optional[Any]					=					encoder_inputs["""input_features"""].shape[2]
    _snake_case    :  str					=					encoder_sequence_length // 2 if self.use_past else seq_length

    _snake_case    :  str					=					super().generate_dummy_inputs(
        preprocessor.tokenizer				,		lowerCAmelCase				,		lowerCAmelCase				,		lowerCAmelCase				,		lowerCAmelCase)

    _snake_case    :  Optional[int]					=					encoder_inputs.pop("""input_features""")
    _snake_case    :  List[Any]					=					decoder_inputs.pop("""decoder_input_ids""")

    if "past_key_values" in decoder_inputs:
     _snake_case    :  Any					=					decoder_inputs.pop("""past_key_values""")

    return dummy_inputs


   @property
   def      UpperCamelCase_  (					self							:			Optional[Any])				->				float:

    """simple docstring"""







    return 1E-3





import argparse
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_dummies.py
a__    =	"""src/diffusers"""

# Matches is_xxx_available()
a__    =	re.compile(R"""is\_([a-z_]*)_available\(\)""")
# Matches from xxx import bla
a__    =	re.compile(R"""\s+from\s+\S*\s+import\s+([^\(\s].*)\n""")


a__    =	"""
{0} = None
"""

a__    =	"""
class {0}(metaclass=DummyObject):
    _backends = {1}

    def __init__(self, *args, **kwargs):
        requires_backends(self, {1})

    @classmethod
    def from_config(cls, *args, **kwargs):
        requires_backends(cls, {1})

    @classmethod
    def from_pretrained(cls, *args, **kwargs):
        requires_backends(cls, {1})
"""


a__    =	"""
def {0}(*args, **kwargs):
    requires_backends({0}, {1})
"""



def       lowercase       (   SCREAMING_SNAKE_CASE__       :	Tuple				)  ->     Optional[Any]:
 _snake_case    :  str					=					_re_backend.findall(SCREAMING_SNAKE_CASE__				)
 if len(SCREAMING_SNAKE_CASE__				) == 0:
  return None

 return "_and_".join(SCREAMING_SNAKE_CASE__				)



def       lowercase       (   )  ->     Optional[Any]:
 with open(os.path.join(SCREAMING_SNAKE_CASE__				,       """__init__.py"""				)				,       """r"""				,       encoding="""utf-8"""				,       newline="""\n"""				) as f:
  _snake_case    :  Dict					=					f.readlines()

 # Get to the point we do the actual imports for type checking
 _snake_case    :  Optional[int]					=					0
 _snake_case    :  Union[str, Any]					=					{}
 # Go through the end of the file
 while line_index < len(SCREAMING_SNAKE_CASE__				):
  # If the line contains is_backend_available, we grab all objects associated with the `else` block
  _snake_case    :  int					=					find_backend(lines[line_index]				)
  if backend is not None:
   while not lines[line_index].startswith("""else:"""				):
    line_index += 1
   line_index += 1
   _snake_case    :  str					=					[]
   # Until we unindent, add backend objects to the list
   while line_index < len(SCREAMING_SNAKE_CASE__				) and len(lines[line_index]				) > 1:
    _snake_case    :  int					=					lines[line_index]
    _snake_case    :  str					=					_re_single_line_import.search(SCREAMING_SNAKE_CASE__				)
    if single_line_import_search is not None:
     objects.extend(single_line_import_search.groups()[0].split(""", """				)				)
    elif line.startswith(""" """ * 8				):
     objects.append(line[8:-2]				)
    line_index += 1

   if len(SCREAMING_SNAKE_CASE__				) > 0:
    _snake_case    :  Optional[int]					=					objects
  else:
   line_index += 1

 return backend_specific_objects



def       lowercase       (   SCREAMING_SNAKE_CASE__       :	Union[str, Any]				,       SCREAMING_SNAKE_CASE__       :	Tuple				)  ->     Dict:
 if name.isupper():
  return DUMMY_CONSTANT.format(SCREAMING_SNAKE_CASE__				)
 elif name.islower():
  return DUMMY_FUNCTION.format(SCREAMING_SNAKE_CASE__				,       SCREAMING_SNAKE_CASE__				)
 else:
  return DUMMY_CLASS.format(SCREAMING_SNAKE_CASE__				,       SCREAMING_SNAKE_CASE__				)



def       lowercase       (   SCREAMING_SNAKE_CASE__       :	Dict=None				)  ->     List[Any]:
 if backend_specific_objects is None:
  _snake_case    :  Dict					=					read_init()
 # For special correspondence backend to module name as used in the function requires_modulename
 _snake_case    :  Union[str, Any]					=					{}

 for backend, objects in backend_specific_objects.items():
  _snake_case    :  List[Any]					=					"""[""" + """, """.join(F'''"{b}"''' for b in backend.split("""_and_"""				)				) + """]"""
  _snake_case    :  Any					=					"""# This file is autogenerated by the command `make fix-copies`, do not edit.\n"""
  dummy_file += "from ..utils import DummyObject, requires_backends\n\n"
  dummy_file += "\n".join([create_dummy_object(SCREAMING_SNAKE_CASE__				,       SCREAMING_SNAKE_CASE__				) for o in objects]				)
  _snake_case    :  Any					=					dummy_file

 return dummy_files



def       lowercase       (   SCREAMING_SNAKE_CASE__       :	Tuple=False				)  ->     Optional[int]:
 _snake_case    :  str					=					create_dummy_files()
 # For special correspondence backend to shortcut as used in utils/dummy_xxx_objects.py
 _snake_case    :  List[Any]					=					{"""torch""": """pt"""}

 # Locate actual dummy modules and read their content.
 _snake_case    :  Dict					=					os.path.join(SCREAMING_SNAKE_CASE__				,       """utils"""				)
 _snake_case    :  int					=					{
     backend: os.path.join(SCREAMING_SNAKE_CASE__				,       F'''dummy_{short_names.get(SCREAMING_SNAKE_CASE__				,       SCREAMING_SNAKE_CASE__				)}_objects.py'''				)
     for backend in dummy_files.keys()
 }

 _snake_case    :  int					=					{}
 for backend, file_path in dummy_file_paths.items():
  if os.path.isfile(SCREAMING_SNAKE_CASE__				):
   with open(SCREAMING_SNAKE_CASE__				,       """r"""				,       encoding="""utf-8"""				,       newline="""\n"""				) as f:
    _snake_case    :  Union[str, Any]					=					f.read()
  else:
   _snake_case    :  str					=					""""""

 for backend in dummy_files.keys():
  if dummy_files[backend] != actual_dummies[backend]:
   if overwrite:
    print(
        F'''Updating diffusers.utils.dummy_{short_names.get(SCREAMING_SNAKE_CASE__				,       SCREAMING_SNAKE_CASE__				)}_objects.py as the main '''
        """__init__ has new objects."""				)
    with open(dummy_file_paths[backend]				,       """w"""				,       encoding="""utf-8"""				,       newline="""\n"""				) as f:
     f.write(dummy_files[backend]				)
   else:
    raise ValueError(
        """The main __init__ has objects that are not present in """
        F'''diffusers.utils.dummy_{short_names.get(SCREAMING_SNAKE_CASE__				,       SCREAMING_SNAKE_CASE__				)}_objects.py. Run `make fix-copies` '''
        """to fix this."""				)


if __name__ == "__main__":
  a__    =	argparse.ArgumentParser()
  parser.add_argument("""--fix_and_overwrite""", action="""store_true""", help="""Whether to fix inconsistencies.""")
  a__    =	parser.parse_args()

  check_dummies(args.fix_and_overwrite)
