


_A							     =       {
    '0': 1,
    '1': 1,
    '2': 2,
    '3': 6,
    '4': 24,
    '5': 120,
    '6': 720,
    '7': 5040,
    '8': 4_0320,
    '9': 36_2880,
}

_A							     =       {145: 145}

_A							     =       {
    145: 0,
    169: 3,
    3_6301: 3,
    1454: 3,
    871: 2,
    4_5361: 2,
    872: 2,
}

def 			__SCREAMING_SNAKE_CASE		(		UpperCamelCase		:      List[Any]	)     ->	int:



	"""simple docstring"""






	if n in CACHE_SUM_DIGIT_FACTORIALS:
		return CACHE_SUM_DIGIT_FACTORIALS[n]
	a_     			=   sum(DIGIT_FACTORIALS[let] for let in str(SCREAMING_SNAKE_CASE_	)	)
	a_     			=   ret
	return ret

def 			__SCREAMING_SNAKE_CASE		(		UpperCamelCase		:      Any     ,					UpperCamelCase		:      Tuple = None	)     ->	Any:



	"""simple docstring"""






	a_     			=   previous or set()
	if n in CHAIN_LENGTH_CACHE:
		return CHAIN_LENGTH_CACHE[n]
	a_     			=   sum_digit_factorials(SCREAMING_SNAKE_CASE_	)
	if next_number in previous:
		a_     			=   0
		return 0
	else:
		previous.add(SCREAMING_SNAKE_CASE_	)
		a_     			=   1 + chain_length(SCREAMING_SNAKE_CASE_     ,					SCREAMING_SNAKE_CASE_	)
		a_     			=   ret
		return ret

def 			__SCREAMING_SNAKE_CASE		(		UpperCamelCase		:      List[Any] = 60     ,					UpperCamelCase		:      Optional[Any] = 100_0000	)     ->	List[Any]:



	"""simple docstring"""






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


if __name__ == "__main__":
			print(f'{solution() = }')
'''simple docstring'''




import argparse

import torch

from transformers import HubertConfig, HubertForSequenceClassification, WavaVecaFeatureExtractor, logging


logging.set_verbosity_info()
_A										= logging.get_logger(__name__)

_A										= ['UtteranceLevel']

@torch.no_grad()
def _UpperCamelCase (							SCREAMING_SNAKE_CASE_	,							SCREAMING_SNAKE_CASE_	,							SCREAMING_SNAKE_CASE_	,							SCREAMING_SNAKE_CASE_				):
     lowercase_       :							List[str]  					=       torch.load(SCREAMING_SNAKE_CASE_	,							map_location='cpu'				)
     if checkpoint["Config"]["downstream_expert"]["modelrc"]["select"] not in SUPPORTED_MODELS:
          raise NotImplementedError(f'''The supported s3prl models are {SUPPORTED_MODELS}'''				)

     lowercase_       :							Dict  					=       checkpoint['Downstream']

     lowercase_       :							List[Any]  					=       HubertConfig.from_pretrained(SCREAMING_SNAKE_CASE_				)
     lowercase_       :							List[Any]  					=       HubertForSequenceClassification.from_pretrained(SCREAMING_SNAKE_CASE_	,							config=SCREAMING_SNAKE_CASE_				)
     lowercase_       :							List[str]  					=       WavaVecaFeatureExtractor.from_pretrained(
         SCREAMING_SNAKE_CASE_	,							return_attention_mask=SCREAMING_SNAKE_CASE_	,							do_normalize=SCREAMING_SNAKE_CASE_				)

     if hf_congfig.use_weighted_layer_sum:
          lowercase_       :							List[str]  					=       checkpoint['Featurizer']['weights']

     lowercase_       :							Tuple  					=       downstream_dict['projector.weight']
     lowercase_       :							List[Any]  					=       downstream_dict['projector.bias']
     lowercase_       :							List[Any]  					=       downstream_dict['model.post_net.linear.weight']
     lowercase_       :							str  					=       downstream_dict['model.post_net.linear.bias']

     hf_feature_extractor.save_pretrained(SCREAMING_SNAKE_CASE_				)
     hf_model.save_pretrained(SCREAMING_SNAKE_CASE_				)


if __name__ == "__main__":
 _A										= 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.')
 _A										= parser.parse_args()
 convert_saprl_checkpoint(args.base_model_name, args.config_path, args.checkpoint_path, args.model_dump_path)




