

'''simple docstring'''



import argparse

import torch

from transformers import HubertConfig, HubertForSequenceClassification, WavaVecaFeatureExtractor, logging


logging.set_verbosity_info()
UpperCAmelCase				: List[str]         =  logging.get_logger(__name__)

UpperCAmelCase				: str         =  ['UtteranceLevel']







@torch.no_grad()
def      a__ (						a__   ,					a__   ,					a__   ,					a__		):




     """simple docstring"""


     __SCREAMING_SNAKE_CASE						     =   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}'		)

     __SCREAMING_SNAKE_CASE						     =   checkpoint["""Downstream"""]

     __SCREAMING_SNAKE_CASE						     =   HubertConfig.from_pretrained(a__		)
     __SCREAMING_SNAKE_CASE						     =   HubertForSequenceClassification.from_pretrained(a__   ,					config=a__		)
     __SCREAMING_SNAKE_CASE						     =   WavaVecaFeatureExtractor.from_pretrained(
         a__   ,					return_attention_mask=a__   ,					do_normalize=a__		)

     if hf_congfig.use_weighted_layer_sum:
          __SCREAMING_SNAKE_CASE						     =   checkpoint["""Featurizer"""]["""weights"""]

     __SCREAMING_SNAKE_CASE						     =   downstream_dict["""projector.weight"""]
     __SCREAMING_SNAKE_CASE						     =   downstream_dict["""projector.bias"""]
     __SCREAMING_SNAKE_CASE						     =   downstream_dict["""model.post_net.linear.weight"""]
     __SCREAMING_SNAKE_CASE						     =   downstream_dict["""model.post_net.linear.bias"""]

     hf_feature_extractor.save_pretrained(a__		)
     hf_model.save_pretrained(a__		)


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









'''simple docstring'''



def      a__ (						):




     """simple docstring"""


     __SCREAMING_SNAKE_CASE						     =   1

     while True:
          if (
              sorted(str(a__		)		)
              == sorted(str(2 * i		)		)
              == sorted(str(3 * i		)		)
              == sorted(str(4 * i		)		)
              == sorted(str(5 * i		)		)
              == sorted(str(6 * i		)		)
          ):
               return i

          i += 1


if __name__ == "__main__":
  print(solution())






