




def 							__SCREAMING_SNAKE_CASE						(    snake_case_			,					snake_case_ = 1000		):

						'''simple docstring'''


						if (not isinstance(snake_case_			,					snake_case_		)) or (digit_position <= 0):
												raise ValueError("Digit position must be a positive integer"		)
						elif (not isinstance(snake_case_			,					snake_case_		)) 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
						_UpperCAmelCase									=  (
						    4 * _subsum(snake_case_			,					1			,					snake_case_		)
						    - 2 * _subsum(snake_case_			,					4			,					snake_case_		)
						    - _subsum(snake_case_			,					5			,					snake_case_		)
						    - _subsum(snake_case_			,					6			,					snake_case_		)
						)

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


def 							__SCREAMING_SNAKE_CASE						(    snake_case_			,					snake_case_			,					snake_case_		):

						'''simple docstring'''


						_UpperCAmelCase									=  0.0
						for sum_index in range(digit_pos_to_extract + precision		):
												_UpperCAmelCase									=  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
																		_UpperCAmelCase									=  pow(
																		    16			,					digit_pos_to_extract - 1 - sum_index			,					snake_case_		)
												else:
																		_UpperCAmelCase									=  pow(16			,					digit_pos_to_extract - 1 - sum_index		)
												total += exponential_term / denominator
						return total


if __name__ == "__main__":
				import doctest

				doctest.testmod()










from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


lowercase_			:       List[str]						       =				{
    'configuration_rwkv': ['RWKV_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RwkvConfig', 'RwkvOnnxConfig'],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowercase_			:       Any						       =				[
				    'RWKV_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'RwkvForCausalLM',
				    'RwkvModel',
				    'RwkvPreTrainedModel',
				]


if TYPE_CHECKING:
				from .configuration_rwkv import RWKV_PRETRAINED_CONFIG_ARCHIVE_MAP, RwkvConfig, RwkvOnnxConfig

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_rwkv import (
								    RWKV_PRETRAINED_MODEL_ARCHIVE_LIST,
								    RwkvForCausalLM,
								    RwkvModel,
								    RwkvPreTrainedModel,
								)
else:
				import sys

				lowercase_			:       Union[str, Any]						       =				_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




