



def 						_lowerCAmelCase    (					__lowerCamelCase :  int		,						__lowerCamelCase :  int = 1000  ):



 """simple docstring"""





 if (not isinstance(__lowerCamelCase		,						__lowerCamelCase  )) or (digit_position <= 0):
  raise ValueError("Digit position must be a positive integer"  )
 elif (not isinstance(__lowerCamelCase		,						__lowerCamelCase  )) or (precision < 0):
  raise ValueError("Precision must be a nonnegative integer"  )

 # compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
 # accurate
 __SCREAMING_SNAKE_CASE							:     Union[str, Any]							=						(
     4 * _subsum(__lowerCamelCase		,						1		,						__lowerCamelCase  )
     - 2 * _subsum(__lowerCamelCase		,						4		,						__lowerCamelCase  )
     - _subsum(__lowerCamelCase		,						5		,						__lowerCamelCase  )
     - _subsum(__lowerCamelCase		,						6		,						__lowerCamelCase  )
 )

 # return the first hex digit of the fractional part of the result
 return hex(int((sum_result % 1) * 16  )  )[2:]






def 						_lowerCAmelCase    (					__lowerCamelCase :  int		,						__lowerCamelCase :  int		,						__lowerCamelCase :  int  ):



 """simple docstring"""





 __SCREAMING_SNAKE_CASE							:     Optional[Any]							=						0.0
 for sum_index in range(digit_pos_to_extract + precision  ):
  __SCREAMING_SNAKE_CASE							:     Union[str, Any]							=						8 * sum_index + denominator_addend
  if sum_index < digit_pos_to_extract:
   # if the exponential term is an integer and we mod it by the denominator
   # before dividing, only the integer part of the sum will change;
   # the fractional part will not
   __SCREAMING_SNAKE_CASE							:     str							=						pow(
       16		,						digit_pos_to_extract - 1 - sum_index		,						__lowerCamelCase  )
  else:
   __SCREAMING_SNAKE_CASE							:     List[str]							=						pow(16		,						digit_pos_to_extract - 1 - sum_index  )
  total += exponential_term / denominator
 return total


if __name__ == "__main__":
      import doctest

      doctest.testmod()











import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


UpperCAmelCase :				Union[str, Any]							=logging.get_logger(__name__)


class    _lowercase (a_   ):
				'''simple docstring'''







				lowercase__     =    """speech-encoder-decoder"""
				lowercase__     =    True

				def __init__(			self  ,			**snake_case__     ):

									'''simple docstring'''


									super().__init__(**snake_case__     )
									if "encoder" not in kwargs or "decoder" not in kwargs:
														raise ValueError(
														    F"""A configuraton of type {self.model_type} cannot be instantiated because not both `encoder` and"""
														    F""" `decoder` sub-configurations are passed, but only {kwargs}"""     )

									UpperCamelCase_			= kwargs.pop("encoder"     )
									UpperCamelCase_			= encoder_config.pop("model_type"     )
									UpperCamelCase_			= kwargs.pop("decoder"     )
									UpperCamelCase_			= decoder_config.pop("model_type"     )

									UpperCamelCase_			= AutoConfig.for_model(snake_case__  ,			**snake_case__     )
									UpperCamelCase_			= AutoConfig.for_model(snake_case__  ,			**snake_case__     )
									UpperCamelCase_			= True

				@classmethod
				def    _lowerCamelCase       (			cls  ,			snake_case__  ,			snake_case__  ,			**snake_case__     ):

									'''simple docstring'''


									logger.info("Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"     )
									UpperCamelCase_			= True
									UpperCamelCase_			= True

									return cls(encoder=encoder_config.to_dict()  ,			decoder=decoder_config.to_dict()  ,			**snake_case__     )

				def    _lowerCamelCase       (			self     ):

									'''simple docstring'''


									UpperCamelCase_			= copy.deepcopy(self.__dict__     )
									UpperCamelCase_			= self.encoder.to_dict()
									UpperCamelCase_			= self.decoder.to_dict()
									UpperCamelCase_			= self.__class__.model_type
									return output
