






"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCamelCase			=      {"configuration_t5": ["T5_PRETRAINED_CONFIG_ARCHIVE_MAP", "T5Config", "T5OnnxConfig"]}

try:
		if not is_sentencepiece_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		UpperCamelCase			=      ["T5Tokenizer"]

try:
		if not is_tokenizers_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		UpperCamelCase			=      ["T5TokenizerFast"]

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		UpperCamelCase			=      [
		    "T5_PRETRAINED_MODEL_ARCHIVE_LIST",
		    "T5EncoderModel",
		    "T5ForConditionalGeneration",
		    "T5Model",
		    "T5PreTrainedModel",
		    "load_tf_weights_in_t5",
		    "T5ForQuestionAnswering",
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		UpperCamelCase			=      [
		    "TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST",
		    "TFT5EncoderModel",
		    "TFT5ForConditionalGeneration",
		    "TFT5Model",
		    "TFT5PreTrainedModel",
		]

try:
		if not is_flax_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		UpperCamelCase			=      [
		    "FlaxT5EncoderModel",
		    "FlaxT5ForConditionalGeneration",
		    "FlaxT5Model",
		    "FlaxT5PreTrainedModel",
		]


if TYPE_CHECKING:
		from .configuration_ta import T5_PRETRAINED_CONFIG_ARCHIVE_MAP, TaConfig, TaOnnxConfig

		try:
				if not is_sentencepiece_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_ta import TaTokenizer

		try:
				if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_ta_fast import TaTokenizerFast

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_ta import (
				    T5_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TaEncoderModel,
				    TaForConditionalGeneration,
				    TaForQuestionAnswering,
				    TaModel,
				    TaPreTrainedModel,
				    load_tf_weights_in_ta,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_ta import (
				    TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFTaEncoderModel,
				    TFTaForConditionalGeneration,
				    TFTaModel,
				    TFTaPreTrainedModel,
				)

		try:
				if not is_flax_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_flax_ta import (
				    FlaxTaEncoderModel,
				    FlaxTaForConditionalGeneration,
				    FlaxTaModel,
				    FlaxTaPreTrainedModel,
				)


else:
		import sys

		UpperCamelCase			=      _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)














"""simple docstring"""





UpperCamelCase			=      {
    """0""": 1,
    """1""": 1,
    """2""": 2,
    """3""": 6,
    """4""": 24,
    """5""": 1_20,
    """6""": 7_20,
    """7""": 50_40,
    """8""": 4_03_20,
    """9""": 36_28_80,
}

UpperCamelCase			=      {1_45: 1_45}

UpperCamelCase			=      {
    1_45: 0,
    1_69: 3,
    3_63_01: 3,
    14_54: 3,
    8_71: 2,
    4_53_61: 2,
    8_72: 2,
}






def     A(  snake_case_		):
       """simple docstring"""





       if n in CACHE_SUM_DIGIT_FACTORIALS:
              return CACHE_SUM_DIGIT_FACTORIALS[n]
       lowercase__:    Any        =      sum(DIGIT_FACTORIALS[let] for let in str(snake_case_		)		)
       lowercase__:    Optional[Any]        =      ret
       return ret






def     A(  snake_case_						,       snake_case_ = None		):
       """simple docstring"""





       lowercase__:    Optional[int]        =      previous or set()
       if n in CHAIN_LENGTH_CACHE:
              return CHAIN_LENGTH_CACHE[n]
       lowercase__:    Tuple        =      sum_digit_factorials(snake_case_		)
       if next_number in previous:
              lowercase__:    List[Any]        =      0
              return 0
       else:
              previous.add(snake_case_		)
              lowercase__:    Optional[int]        =      1 + chain_length(snake_case_						,       snake_case_		)
              lowercase__:    Any        =      ret
              return ret






def     A(  snake_case_ = 60						,       snake_case_ = 1000000		):
       """simple docstring"""





       return sum(1 for i in range(1						,       snake_case_		) if chain_length(snake_case_		) == num_terms		)


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






