



_lowerCAmelCase    : List[Any]							=							range(2, 20 + 1)
_lowerCAmelCase    : Dict							=							[10**k for k in range(ks[-1] + 1)]
_lowerCAmelCase    : dict[int, dict[int, list[list[int]]]]							=							{}

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						Any						,  SCREAMING_SNAKE_CASE__     :						Dict						,  SCREAMING_SNAKE_CASE__     :						Optional[Any]						,  SCREAMING_SNAKE_CASE__     :						Dict    )  ->       Any:





     '''simple docstring'''

     _UpperCAmelCase      :     int        =   sum(a_i[j] for j in range(SCREAMING_SNAKE_CASE__						,  len(SCREAMING_SNAKE_CASE__    )    )    )
     _UpperCAmelCase      :     Union[str, Any]        =   sum(a_i[j] * base[j] for j in range(min(len(SCREAMING_SNAKE_CASE__    )						,  SCREAMING_SNAKE_CASE__    )    )    )

     _UpperCAmelCase      :     Tuple        =   0, 0
     _UpperCAmelCase      :     Any        =   n - i

     _UpperCAmelCase      :     Optional[Any]        =   memo.get(SCREAMING_SNAKE_CASE__    )

     if sub_memo is not None:
          _UpperCAmelCase      :     int        =   sub_memo.get(SCREAMING_SNAKE_CASE__    )

          if jumps is not None and len(SCREAMING_SNAKE_CASE__    ) > 0:
               # find and make the largest jump without going over
               _UpperCAmelCase      :     Optional[Any]        =   -1
               for _k in range(len(SCREAMING_SNAKE_CASE__    ) - 1						,  -1						,  -1    ):
                    if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
                         _UpperCAmelCase      :     List[str]        =   _k
                         break

               if max_jump >= 0:
                    _UpperCAmelCase      :     Dict        =   jumps[max_jump]
                    # since the difference between jumps is cached, add c
                    _UpperCAmelCase      :     List[Any]        =   diff + c
                    for j in range(min(SCREAMING_SNAKE_CASE__						,  len(SCREAMING_SNAKE_CASE__    )    )    ):
                         _UpperCAmelCase      :     Any        =   divmod(SCREAMING_SNAKE_CASE__						,  10    )
                    if new_c > 0:
                         add(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )

          else:
               _UpperCAmelCase      :     str        =   []
     else:
          _UpperCAmelCase      :     int        =   {c: []}
          _UpperCAmelCase      :     Dict        =   sub_memo

     if dn >= max_dn or c + diff >= base[k]:
          return diff, dn

     if k > ks[0]:
          while True:
               # keep doing smaller jumps
               _UpperCAmelCase      :     Optional[Any]        =   next_term(SCREAMING_SNAKE_CASE__						,  k - 1						,  i + dn						,  SCREAMING_SNAKE_CASE__    )
               diff += _diff
               dn += terms_jumped

               if dn >= max_dn or c + diff >= base[k]:
                    break
     else:
          # would be too small a jump, just compute sequential terms instead
          _UpperCAmelCase      :     int        =   compute(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  i + dn						,  SCREAMING_SNAKE_CASE__    )
          diff += _diff
          dn += terms_jumped

     _UpperCAmelCase      :     Dict        =   sub_memo[c]

     # keep jumps sorted by # of terms skipped
     _UpperCAmelCase      :     List[Any]        =   0
     while j < len(SCREAMING_SNAKE_CASE__    ):
          if jumps[j][1] > dn:
               break
          j += 1

     # cache the jump for this value digitsum(b) and c
     sub_memo[c].insert(SCREAMING_SNAKE_CASE__						,  (diff, dn, k)    )
     return (diff, dn)

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						int						,  SCREAMING_SNAKE_CASE__     :						Optional[int]						,  SCREAMING_SNAKE_CASE__     :						Dict						,  SCREAMING_SNAKE_CASE__     :						int    )  ->       List[Any]:





     '''simple docstring'''

     if i >= n:
          return 0, i
     if k > len(SCREAMING_SNAKE_CASE__    ):
          a_i.extend([0 for _ in range(k - len(SCREAMING_SNAKE_CASE__    )    )]    )

     # note: a_i -> b * 10^k + c
     # ds_b -> digitsum(b)
     # ds_c -> digitsum(c)
     _UpperCAmelCase      :     Any        =   i
     _UpperCAmelCase      :     Optional[Any]        =   0, 0, 0
     for j in range(len(SCREAMING_SNAKE_CASE__    )    ):
          if j >= k:
               ds_b += a_i[j]
          else:
               ds_c += a_i[j]

     while i < n:
          i += 1
          _UpperCAmelCase      :     Dict        =   ds_c + ds_b
          diff += addend
          _UpperCAmelCase      :     Tuple        =   0
          for j in range(SCREAMING_SNAKE_CASE__    ):
               _UpperCAmelCase      :     Any        =   a_i[j] + addend
               _UpperCAmelCase      :     List[str]        =   divmod(SCREAMING_SNAKE_CASE__						,  10    )

               ds_c += a_i[j]

          if addend > 0:
               break

     if addend > 0:
          add(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__    )
     return diff, i - start_i

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						List[Any]						,  SCREAMING_SNAKE_CASE__     :						Dict						,  SCREAMING_SNAKE_CASE__     :						Tuple    )  ->       Union[str, Any]:





     '''simple docstring'''

     for j in range(SCREAMING_SNAKE_CASE__						,  len(SCREAMING_SNAKE_CASE__    )    ):
          _UpperCAmelCase      :     Dict        =   digits[j] + addend
          if s >= 10:
               _UpperCAmelCase      :     int        =   divmod(SCREAMING_SNAKE_CASE__						,  10    )
               _UpperCAmelCase      :     Union[str, Any]        =   addend // 10 + quotient
          else:
               _UpperCAmelCase      :     Optional[int]        =   s
               _UpperCAmelCase      :     Optional[int]        =   addend // 10

          if addend == 0:
               break

     while addend > 0:
          _UpperCAmelCase      :     Dict        =   divmod(SCREAMING_SNAKE_CASE__						,  10    )
          digits.append(SCREAMING_SNAKE_CASE__    )

def 						__snake_case						(				SCREAMING_SNAKE_CASE__     :						int = 10**15    )  ->       int:





     '''simple docstring'''

     _UpperCAmelCase      :     Any        =   [1]
     _UpperCAmelCase      :     str        =   1
     _UpperCAmelCase      :     int        =   0
     while True:
          _UpperCAmelCase      :     Tuple        =   next_term(SCREAMING_SNAKE_CASE__						,  20						,  i + dn						,  SCREAMING_SNAKE_CASE__    )
          dn += terms_jumped
          if dn == n - i:
               break

     _UpperCAmelCase      :     int        =   0
     for j in range(len(SCREAMING_SNAKE_CASE__    )    ):
          a_n += digits[j] * 10**j
     return a_n


if __name__ == "__main__":
 print(F"{solution() = }")





"""simple docstring"""




import importlib
import inspect
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
_lowerCAmelCase    : Dict							=							"src/transformers"


# This is to make sure the transformers module imported is the one in the repo.
_lowerCAmelCase    : List[Any]							=							importlib.util.spec_from_file_location(
    "transformers",
    os.path.join(PATH_TO_TRANSFORMERS, "__init__.py"),
    submodule_search_locations=[PATH_TO_TRANSFORMERS],
)
_lowerCAmelCase    : Tuple							=							spec.loader.load_module()

_lowerCAmelCase    : Tuple							=							transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
_lowerCAmelCase    : Optional[int]							=							re.compile("\[(.+?)\]\((https://huggingface\.co/.+?)\)")


_lowerCAmelCase    : Optional[int]							=							{
    "CLIPConfigMixin",
    "DecisionTransformerConfigMixin",
    "EncoderDecoderConfigMixin",
    "RagConfigMixin",
    "SpeechEncoderDecoderConfigMixin",
    "VisionEncoderDecoderConfigMixin",
    "VisionTextDualEncoderConfigMixin",
}

def 						__snake_case						(				)  ->       Dict:





     '''simple docstring'''

     _UpperCAmelCase      :     List[str]        =   []

     for config_class in list(CONFIG_MAPPING.values()    ):
          _UpperCAmelCase      :     Union[str, Any]        =   False

          # source code of `config_class`
          _UpperCAmelCase      :     Optional[int]        =   inspect.getsource(SCREAMING_SNAKE_CASE__    )
          _UpperCAmelCase      :     List[Any]        =   _re_checkpoint.findall(SCREAMING_SNAKE_CASE__    )

          for checkpoint in checkpoints:
               # Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
               # For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
               _UpperCAmelCase    ,	_UpperCAmelCase      :     List[Any]        =   checkpoint

               # verify the checkpoint name corresponds to the checkpoint link
               _UpperCAmelCase      :     Optional[Any]        =   f'https://huggingface.co/{ckpt_name}'
               if ckpt_link == ckpt_link_from_name:
                    _UpperCAmelCase      :     Optional[Any]        =   True
                    break

          _UpperCAmelCase      :     int        =   config_class.__name__
          if not checkpoint_found and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
               configs_without_checkpoint.append(SCREAMING_SNAKE_CASE__    )

     if len(SCREAMING_SNAKE_CASE__    ) > 0:
          _UpperCAmelCase      :     List[str]        =   "\n".join(sorted(SCREAMING_SNAKE_CASE__    )    )
          raise ValueError(f'The following configurations don\'t contain any valid checkpoint:\n{message}'    )


if __name__ == "__main__":
 check_config_docstrings_have_checkpoints()
