



from ...configuration_utils import PretrainedConfig
from ...utils import logging


__snake_case     :str			       =logging.get_logger(__name__)

__snake_case     :Tuple			       ={
    'facebook/s2t-wav2vec2-large-en-de': (
        'https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json'
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}



class        lowerCAmelCase__					(  _lowerCamelCase       ):
				A_   :     Tuple								=     'speech_to_text_2'
				A_   :     Union[str, Any]								=     ['past_key_values']
				A_   :     Dict								=     {'num_attention_heads': 'decoder_attention_heads', 'hidden_size': 'd_model'}


				def __init__(							self      :  int						, __UpperCamelCase      :  Union[str, Any]=10_000						, __UpperCamelCase      :  List[Any]=6						, __UpperCamelCase      :  Any=2_048						, __UpperCamelCase      :  Optional[Any]=4						, __UpperCamelCase      :  Optional[Any]=0.0						, __UpperCamelCase      :  Any=True						, __UpperCamelCase      :  List[str]="relu"						, __UpperCamelCase      :  Optional[Any]=256						, __UpperCamelCase      :  Optional[Any]=0.1						, __UpperCamelCase      :  Dict=0.0						, __UpperCamelCase      :  int=0.0						, __UpperCamelCase      :  List[Any]=0.0_2						, __UpperCamelCase      :  List[Any]=2						, __UpperCamelCase      :  Optional[Any]=True						, __UpperCamelCase      :  Optional[Any]=1						, __UpperCamelCase      :  List[str]=0						, __UpperCamelCase      :  Tuple=2						, __UpperCamelCase      :  Dict=1_024						, **__UpperCamelCase      :  Any						, )		->     List[Any]:
											A      						=    vocab_size
											A      						=    d_model
											A      						=    decoder_ffn_dim
											A      						=    decoder_layers
											A      						=    decoder_attention_heads
											A      						=    dropout
											A      						=    attention_dropout
											A      						=    activation_dropout
											A      						=    activation_function
											A      						=    init_std
											A      						=    decoder_layerdrop
											A      						=    use_cache
											A      						=    decoder_layers
											A      						=    scale_embedding  # scale factor will be sqrt(d_model) if True
											A      						=    max_target_positions

											super().__init__(
											    pad_token_id=__UpperCamelCase						, bos_token_id=__UpperCamelCase						, eos_token_id=__UpperCamelCase						, decoder_start_token_id=__UpperCamelCase						, **__UpperCamelCase						, )




import logging
import os

from .state import PartialState
class    __UpperCamelCase			(       logging.LoggerAdapter				):

 """simple docstring"""



 @staticmethod
 def 						_UpperCAmelCase       (	SCREAMING_SNAKE_CASE      ) ->			Optional[Any]:
  a__												= PartialState()
  return not main_process_only or (main_process_only and state.is_main_process)



 def 						_UpperCAmelCase       (	self		,				SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      ) ->			Optional[int]:
  if PartialState._shared_state == {}:
   raise RuntimeError(
       '''You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility.'''      )
  a__												= kwargs.pop('''main_process_only'''		,				SCREAMING_SNAKE_CASE      )
  a__												= kwargs.pop('''in_order'''		,				SCREAMING_SNAKE_CASE      )

  if self.isEnabledFor(SCREAMING_SNAKE_CASE      ):
   if self._should_log(SCREAMING_SNAKE_CASE      ):
    a__							,			a__												= self.process(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE      )
    self.logger.log(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )

   elif in_order:
    a__												= PartialState()
    for i in range(state.num_processes      ):
     if i == state.process_index:
      a__							,			a__												= self.process(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE      )
      self.logger.log(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )
     state.wait_for_everyone()






def     __a					(		__UpperCAmelCase							,  __UpperCAmelCase = None       ):
 if log_level is None:
  a__												= os.environ.get('''ACCELERATE_LOG_LEVEL'''							,  __UpperCAmelCase       )
 a__												= logging.getLogger(__UpperCAmelCase       )
 if log_level is not None:
  logger.setLevel(log_level.upper()       )
  logger.root.setLevel(log_level.upper()       )
 return MultiProcessAdapter(__UpperCAmelCase							,  {}       )





