



"""simple docstring"""






from typing import TYPE_CHECKING

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


__UpperCAmelCase      :      Optional[int]   					=					{
    'configuration_segformer': ['SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SegformerConfig', 'SegformerOnnxConfig']
}

try:
    if not is_vision_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCAmelCase      :      int   					=					['SegformerFeatureExtractor']
    __UpperCAmelCase      :      Dict   					=					['SegformerImageProcessor']

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCAmelCase      :      Optional[Any]   					=					[
        'SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
        'SegformerDecodeHead',
        'SegformerForImageClassification',
        'SegformerForSemanticSegmentation',
        'SegformerLayer',
        'SegformerModel',
        'SegformerPreTrainedModel',
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCAmelCase      :      Dict   					=					[
        'TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
        'TFSegformerDecodeHead',
        'TFSegformerForImageClassification',
        'TFSegformerForSemanticSegmentation',
        'TFSegformerModel',
        'TFSegformerPreTrainedModel',
    ]


if TYPE_CHECKING:
    from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

    try:
        if not is_vision_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .feature_extraction_segformer import SegformerFeatureExtractor
        from .image_processing_segformer import SegformerImageProcessor

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_segformer import (
            SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
            SegformerDecodeHead,
            SegformerForImageClassification,
            SegformerForSemanticSegmentation,
            SegformerLayer,
            SegformerModel,
            SegformerPreTrainedModel,
        )
    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_segformer import (
            TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFSegformerDecodeHead,
            TFSegformerForImageClassification,
            TFSegformerForSemanticSegmentation,
            TFSegformerModel,
            TFSegformerPreTrainedModel,
        )

else:
    import sys

    __UpperCAmelCase      :      Optional[Any]   					=					_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)






"""simple docstring"""






def      A      (			_A,     _A = 1_000							):




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

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




					"""simple docstring"""
					snake_case_						:int								=						0.0
					for sum_index in range(digit_pos_to_extract + precision							):
										snake_case_						:Optional[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
															snake_case_						:List[Any]								=						pow(
															    16,     digit_pos_to_extract - 1 - sum_index,     _A							)
										else:
															snake_case_						:Optional[Any]								=						pow(16,     digit_pos_to_extract - 1 - sum_index							)
										total += exponential_term / denominator
					return total


if __name__ == "__main__":
				import doctest

				doctest.testmod()

