
import argparse

import torch

from transformers import HubertConfig, HubertForSequenceClassification, WavaVecaFeatureExtractor, logging


logging.set_verbosity_info()
__lowerCAmelCase   :     Optional[Any]      =						logging.get_logger(__name__)

__lowerCAmelCase   :     Dict      =						["UtteranceLevel"]


@torch.no_grad()
def       UpperCAmelCase_					(  __lowerCAmelCase		,   __lowerCAmelCase		,   __lowerCAmelCase		,   __lowerCAmelCase		)	->  Optional[Any]:
    __lowercase						:     List[str]		      =    torch.load(_lowerCAmelCase		,   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						:     Union[str, Any]		      =    checkpoint['''Downstream''']

    __lowercase						:     List[Any]		      =    HubertConfig.from_pretrained(_lowerCAmelCase		)
    __lowercase						:     Optional[int]		      =    HubertForSequenceClassification.from_pretrained(_lowerCAmelCase		,   config=_lowerCAmelCase		)
    __lowercase						:     int		      =    WavaVecaFeatureExtractor.from_pretrained(
        _lowerCAmelCase		,   return_attention_mask=_lowerCAmelCase		,   do_normalize=_lowerCAmelCase		)

    if hf_congfig.use_weighted_layer_sum:
        __lowercase						:     int		      =    checkpoint['''Featurizer''']['''weights''']

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

    hf_feature_extractor.save_pretrained(_lowerCAmelCase		)
    hf_model.save_pretrained(_lowerCAmelCase		)


if __name__ == "__main__":
 __lowerCAmelCase   :     Union[str, Any]      =						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.")
 __lowerCAmelCase   :     Dict      =						parser.parse_args()
 convert_saprl_checkpoint(args.base_model_name, args.config_path, args.checkpoint_path, args.model_dump_path)




from __future__ import annotations

import math
from itertools import permutations


def       UpperCAmelCase_					(  __lowerCAmelCase		)	->  bool:

    if 1 < number < 4:
        # 2 and 3 are primes
        return True
    elif number < 2 or number % 2 == 0 or number % 3 == 0:
        # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
        return False

    # All primes number are in format of 6k +/- 1
    for i in range(5		,   int(math.sqrt(__lowerCAmelCase		) + 1		)		,   6		):
        if number % i == 0 or number % (i + 2) == 0:
            return False
    return True


def       UpperCAmelCase_					(  __lowerCAmelCase = 7		)	->  int:
    __lowercase						:     Union[str, Any]		      =    ''''''.join(str(__lowerCAmelCase		) for i in range(1		,   n + 1		)		)
    __lowercase						:     Dict		      =    [int(''''''.join(__lowerCAmelCase		)		) for i in permutations(__lowerCAmelCase		,   __lowerCAmelCase		)]
    __lowercase						:     int		      =    [num for num in perm_list if is_prime(__lowerCAmelCase		)]
    return max(__lowerCAmelCase		) if pandigitals else 0


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


