

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


a_    :						Any    		=      logging.get_logger(__name__)

a_    :						Any    		=      {
    "naver-clova-ix/donut-base": "https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json",
    # See all Donut models at https://huggingface.co/models?filter=donut-swin
}




class      UpperCamelCase (     SCREAMING_SNAKE_CASE   ):
    __UpperCamelCase         ="donut-swin"

    __UpperCamelCase         ={
        "num_attention_heads": "num_heads",
        "num_hidden_layers": "num_layers",
    }

    def __init__(			self :      Any							,    snake_case__ :      Dict=2_2_4							,    snake_case__ :      Tuple=4							,    snake_case__ :      Optional[Any]=3							,    snake_case__ :      Union[str, Any]=9_6							,    snake_case__ :      List[Any]=[2, 2, 6, 2]							,    snake_case__ :      Optional[Any]=[3, 6, 1_2, 2_4]							,    snake_case__ :      str=7							,    snake_case__ :      Optional[Any]=4.0							,    snake_case__ :      Union[str, Any]=True							,    snake_case__ :      int=0.0							,    snake_case__ :      Optional[int]=0.0							,    snake_case__ :      List[str]=0.1							,    snake_case__ :      Dict="gelu"							,    snake_case__ :      int=False							,    snake_case__ :      List[Any]=0.02							,    snake_case__ :      Tuple=1E-5							,    **snake_case__ :      Dict							,    ):

     """simple docstring"""






     super().__init__(**snake_case__    )

     SCREAMING_SNAKE_CASE								=			image_size
     SCREAMING_SNAKE_CASE								=			patch_size
     SCREAMING_SNAKE_CASE								=			num_channels
     SCREAMING_SNAKE_CASE								=			embed_dim
     SCREAMING_SNAKE_CASE								=			depths
     SCREAMING_SNAKE_CASE								=			len(snake_case__    )
     SCREAMING_SNAKE_CASE								=			num_heads
     SCREAMING_SNAKE_CASE								=			window_size
     SCREAMING_SNAKE_CASE								=			mlp_ratio
     SCREAMING_SNAKE_CASE								=			qkv_bias
     SCREAMING_SNAKE_CASE								=			hidden_dropout_prob
     SCREAMING_SNAKE_CASE								=			attention_probs_dropout_prob
     SCREAMING_SNAKE_CASE								=			drop_path_rate
     SCREAMING_SNAKE_CASE								=			hidden_act
     SCREAMING_SNAKE_CASE								=			use_absolute_embeddings
     SCREAMING_SNAKE_CASE								=			layer_norm_eps
     SCREAMING_SNAKE_CASE								=			initializer_range
     # we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
     # this indicates the channel dimension after the last stage of the model
     SCREAMING_SNAKE_CASE								=			int(embed_dim * 2 ** (len(snake_case__    ) - 1)    )




def        __lowerCAmelCase    (       _UpperCamelCase		:  int	)		->							int:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE								=			abs(_UpperCamelCase	)
 SCREAMING_SNAKE_CASE								=			0
 while n > 0:
  res += n % 10
  n //= 10
 return res


def        __lowerCAmelCase    (       _UpperCamelCase		:  int	)		->							int:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE								=			abs(_UpperCamelCase	)
 return n if n < 10 else n % 10 + sum_of_digits(n // 10	)


def        __lowerCAmelCase    (       _UpperCamelCase		:  int	)		->							int:
 '''simple docstring'''


 return sum(int(_UpperCamelCase	) for c in str(abs(_UpperCamelCase	)	)	)


def        __lowerCAmelCase    (       )		->							None:
 '''simple docstring'''


 from collections.abc import Callable
 from timeit import timeit

 def benchmark_a_function(_UpperCamelCase		:  Callable		,							_UpperCamelCase		:  int	) -> None:
  SCREAMING_SNAKE_CASE								=			f"""{func.__name__}({value})"""
  SCREAMING_SNAKE_CASE								=			timeit(f"""__main__.{call}"""		,							setup='import __main__'	)
  print(f"""{call:56} = {func(_UpperCamelCase	)} -- {timing:.4f} seconds"""	)

 for value in (26_21_44, 11_25_89_99_06_84_26_24, 1_26_76_50_60_02_28_22_94_01_49_67_03_20_53_76):
  for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
   benchmark_a_function(_UpperCamelCase		,							_UpperCamelCase	)
  print()


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      benchmark()

