


import copy
import re
class 			SCREAMING_SNAKE_CASE__  :
      snake_case__    :					Optional[int]					       =						'''hp'''
      snake_case__    :					int					       =						{}
      snake_case__    :					Dict					       =						None
      @classmethod
      def 	SCREAMING_SNAKE_CASE							(	cls    :	Optional[Any]					,							SCREAMING_SNAKE_CASE__    :	List[str]					,							SCREAMING_SNAKE_CASE__    :	Optional[int]					)		->      Any:
             a_ :		str							=  prefix
             a_ :		Optional[int]							=  defaults
             cls.build_naming_info()
      @staticmethod
      def 	SCREAMING_SNAKE_CASE							(	SCREAMING_SNAKE_CASE__    :	Union[str, Any]					,							SCREAMING_SNAKE_CASE__    :	Dict					)		->      Union[str, Any]:
             if len(SCREAMING_SNAKE_CASE__					) == 0:
                    return ""
             a_ :		Optional[int]							=  None
             if any(char.isdigit() for char in word					):
                    raise Exception(F"""Parameters should not contain numbers: '{word}' contains a number"""					)
             if word in info["short_word"]:
                    return info["short_word"][word]
             for prefix_len in range(1					,							len(SCREAMING_SNAKE_CASE__					) + 1					):
                    a_ :		int							=  word[:prefix_len]
                    if prefix in info["reverse_short_word"]:
                           continue
                    else:
                           a_ :		Optional[Any]							=  prefix
                           break

             if short_word is None:
                    # Paranoid fallback
                    def int_to_alphabetic(SCREAMING_SNAKE_CASE__    :	Tuple					):
                           a_ :		Dict							=  ''
                           while integer != 0:
                                  a_ :		str							=  chr(ord('A'					) + integer % 1_0					) + s
                                  integer //= 1_0
                           return s

                    a_ :		str							=  0
                    while True:
                           a_ :		Optional[Any]							=  word + '#' + int_to_alphabetic(SCREAMING_SNAKE_CASE__					)
                           if sword in info["reverse_short_word"]:
                                  continue
                           else:
                                  a_ :		Tuple							=  sword
                                  break

             a_ :		List[Any]							=  short_word
             a_ :		List[Any]							=  word
             return short_word
      @staticmethod
      def 	SCREAMING_SNAKE_CASE							(	SCREAMING_SNAKE_CASE__    :	Optional[int]					,							SCREAMING_SNAKE_CASE__    :	List[str]					)		->      Optional[Any]:
             a_ :		Dict							=  param_name.split('_'					)

             a_ :		List[str]							=  [TrialShortNamer.shortname_for_word(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					) for word in words]

             # We try to create a separatorless short name, but if there is a collision we have to fallback
             # to a separated short name
             a_ :		List[str]							=  ['', '_']

             for separator in separators:
                    a_ :		Optional[Any]							=  separator.join(SCREAMING_SNAKE_CASE__					)
                    if shortname not in info["reverse_short_param"]:
                           a_ :		Union[str, Any]							=  shortname
                           a_ :		int							=  param_name
                           return shortname

             return param_name
      @staticmethod
      def 	SCREAMING_SNAKE_CASE							(	SCREAMING_SNAKE_CASE__    :	int					,							SCREAMING_SNAKE_CASE__    :	List[Any]					)		->      int:
             a_ :		Optional[Any]							=  TrialShortNamer.shortname_for_key(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					)
             a_ :		Tuple							=  short_name
             a_ :		int							=  param_name
      @classmethod
      def 	SCREAMING_SNAKE_CASE							(	cls    :	List[str]					)		->      Any:
             if cls.NAMING_INFO is not None:
                    return

             a_ :		int							=  {
                 'short_word': {},
                 'reverse_short_word': {},
                 'short_param': {},
                 'reverse_short_param': {},
             }

             a_ :		Optional[Any]							=  list(cls.DEFAULTS.keys()					)

             for k in field_keys:
                    cls.add_new_param_name(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					)

             a_ :		Any							=  info
      @classmethod
      def 	SCREAMING_SNAKE_CASE							(	cls    :	List[Any]					,							SCREAMING_SNAKE_CASE__    :	int					)		->      Dict:
             cls.build_naming_info()
             assert cls.PREFIX is not None
             a_ :		List[Any]							=  [copy.copy(cls.PREFIX					)]

             for k, v in params.items():
                    if k not in cls.DEFAULTS:
                           raise Exception(F"""You should provide a default value for the param name {k} with value {v}"""					)
                    if v == cls.DEFAULTS[k]:
                           # The default value is not added to the name
                           continue

                    a_ :		Dict							=  cls.NAMING_INFO['short_param'][k]

                    if isinstance(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					):
                           a_ :		Tuple							=  1 if v else 0

                    a_ :		List[Any]							=  '' if isinstance(SCREAMING_SNAKE_CASE__					,							(int, float)					) else '-'
                    a_ :		List[str]							=  F"""{key}{sep}{v}"""
                    name.append(SCREAMING_SNAKE_CASE__					)

             return "_".join(SCREAMING_SNAKE_CASE__					)

      @classmethod
      def 	SCREAMING_SNAKE_CASE							(	cls    :	Optional[Any]					,							SCREAMING_SNAKE_CASE__    :	Tuple					)		->      Optional[int]:
             a_ :		List[str]							=  repr[len(cls.PREFIX					) + 1 :]
             if repr == "":
                    a_ :		Any							=  []
             else:
                    a_ :		Tuple							=  repr.split('_'					)

             a_ :		Optional[Any]							=  {}

             for value in values:
                    if "-" in value:
                           a_ :		str							=  value.split('-'					)
                    else:
                           a_ :		Optional[Any]							=  re.sub('[0-9.]'					,							''					,							SCREAMING_SNAKE_CASE__					)
                           a_ :		Union[str, Any]							=  float(re.sub('[^0-9.]'					,							''					,							SCREAMING_SNAKE_CASE__					)					)

                    a_ :		List[Any]							=  cls.NAMING_INFO['reverse_short_param'][p_k]

                    a_ :		Any							=  p_v

             for k in cls.DEFAULTS:
                    if k not in parameters:
                           a_ :		Optional[Any]							=  cls.DEFAULTS[k]

             return parameters






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase_				:			Union[str, Any]   =	{
    'configuration_whisper': ['WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WhisperConfig', 'WhisperOnnxConfig'],
    'feature_extraction_whisper': ['WhisperFeatureExtractor'],
    'processing_whisper': ['WhisperProcessor'],
    'tokenization_whisper': ['WhisperTokenizer'],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_				:			Optional[Any]   =	['WhisperTokenizerFast']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_				:			int   =	[
       'WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST',
       'WhisperForConditionalGeneration',
       'WhisperModel',
       'WhisperPreTrainedModel',
       'WhisperForAudioClassification',
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_				:			int   =	[
       'TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST',
       'TFWhisperForConditionalGeneration',
       'TFWhisperModel',
       'TFWhisperPreTrainedModel',
   ]

try:
   if not is_flax_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_				:			Any   =	[
       'FlaxWhisperForConditionalGeneration',
       'FlaxWhisperModel',
       'FlaxWhisperPreTrainedModel',
       'FlaxWhisperForAudioClassification',
   ]


if TYPE_CHECKING:
   from .configuration_whisper import WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP, WhisperConfig, WhisperOnnxConfig
   from .feature_extraction_whisper import WhisperFeatureExtractor
   from .processing_whisper import WhisperProcessor
   from .tokenization_whisper import WhisperTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_whisper_fast import WhisperTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_whisper import (
          WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
          WhisperForAudioClassification,
          WhisperForConditionalGeneration,
          WhisperModel,
          WhisperPreTrainedModel,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_whisper import (
          TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFWhisperForConditionalGeneration,
          TFWhisperModel,
          TFWhisperPreTrainedModel,
      )

   try:
      if not is_flax_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_flax_whisper import (
          FlaxWhisperForAudioClassification,
          FlaxWhisperForConditionalGeneration,
          FlaxWhisperModel,
          FlaxWhisperPreTrainedModel,
      )

else:
   import sys

   UpperCAmelCase_				:			int   =	_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)


