





UpperCAmelCase						:       Tuple        =					{
    '''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						:       Union[str, Any]        =					{1_45: 1_45}

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







def 			_SCREAMING_SNAKE_CASE    (       a  )				->				int:
					if n in CACHE_SUM_DIGIT_FACTORIALS:
										return CACHE_SUM_DIGIT_FACTORIALS[n]
					__A     :						List[str]          =    sum(DIGIT_FACTORIALS[let] for let in str(a  )  )
					__A     :						Optional[int]          =    ret
					return ret







def 			_SCREAMING_SNAKE_CASE    (       a ,						a = None  )				->				int:
					__A     :						Optional[Any]          =    previous or set()
					if n in CHAIN_LENGTH_CACHE:
										return CHAIN_LENGTH_CACHE[n]
					__A     :						Union[str, Any]          =    sum_digit_factorials(a  )
					if next_number in previous:
										__A     :						Union[str, Any]          =    0
										return 0
					else:
										previous.add(a  )
										__A     :						Optional[int]          =    1 + chain_length(a ,						a  )
										__A     :						Dict          =    ret
										return ret







def 			_SCREAMING_SNAKE_CASE    (       a = 60 ,						a = 1_00_00_00  )				->				int:
					return sum(1 for i in range(1 ,						a  ) if chain_length(a  ) == num_terms  )


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











import argparse

import torch

from transformers import HubertConfig, HubertForSequenceClassification, WavaVecaFeatureExtractor, logging


logging.set_verbosity_info()
UpperCAmelCase						:       Tuple        =					logging.get_logger(__name__)

UpperCAmelCase						:       List[Any]        =					['''UtteranceLevel''']







@torch.no_grad()
def 			_SCREAMING_SNAKE_CASE    (       a ,						a ,						a ,						a  )				->				List[str]:
					__A     :						Any          =    torch.load(a ,						map_location='cpu'  )
					if checkpoint["Config"]["downstream_expert"]["modelrc"]["select"] not in SUPPORTED_MODELS:
										raise NotImplementedError(F"""The supported s3prl models are {SUPPORTED_MODELS}"""  )

					__A     :						Dict          =    checkpoint['Downstream']

					__A     :						Optional[Any]          =    HubertConfig.from_pretrained(a  )
					__A     :						Tuple          =    HubertForSequenceClassification.from_pretrained(a ,						config=a  )
					__A     :						str          =    WavaVecaFeatureExtractor.from_pretrained(
					    a ,						return_attention_mask=a ,						do_normalize=a  )

					if hf_congfig.use_weighted_layer_sum:
										__A     :						Optional[Any]          =    checkpoint['Featurizer']['weights']

					__A     :						Dict          =    downstream_dict['projector.weight']
					__A     :						int          =    downstream_dict['projector.bias']
					__A     :						List[Any]          =    downstream_dict['model.post_net.linear.weight']
					__A     :						int          =    downstream_dict['model.post_net.linear.bias']

					hf_feature_extractor.save_pretrained(a  )
					hf_model.save_pretrained(a  )


if __name__ == "__main__":
				UpperCAmelCase						:       Dict        =					argparse.ArgumentParser()
				parser.add_argument(
				    '''--base_model_name''', default=None, type=str, help='''Name of the huggingface pretrained base model.'''
				)
				parser.add_argument('''--config_path''', default=None, type=str, help='''Path to the huggingface classifier config.''')
				parser.add_argument('''--checkpoint_path''', default=None, type=str, help='''Path to the s3prl checkpoint.''')
				parser.add_argument('''--model_dump_path''', default=None, type=str, help='''Path to the final converted model.''')
				UpperCAmelCase						:       Dict        =					parser.parse_args()
				convert_saprl_checkpoint(args.base_model_name, args.config_path, args.checkpoint_path, args.model_dump_path)




