
'''simple docstring'''
from ..utils import DummyObject, requires_backends







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     str					, **lowerCamelCase      :     str							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Union[str, Any]					, *lowerCamelCase      :     int					, **lowerCamelCase      :     Dict							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[Any]					, *lowerCamelCase      :     Optional[Any]					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     int					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     Dict							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     Any					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Optional[int]					, *lowerCamelCase      :     Optional[Any]					, **lowerCamelCase      :     Any							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     List[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Union[str, Any]					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     Tuple							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     str					, *lowerCamelCase      :     int					, **lowerCamelCase      :     List[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Union[str, Any]					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     Tuple							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     Optional[Any]					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Optional[int]					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     Union[str, Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[Any]					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[Any]					, *lowerCamelCase      :     Dict					, **lowerCamelCase      :     Dict							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     str					, *lowerCamelCase      :     Dict					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[str]					, *lowerCamelCase      :     str					, **lowerCamelCase      :     str							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[str]					, *lowerCamelCase      :     Optional[Any]					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Tuple					, *lowerCamelCase      :     Optional[int]					, **lowerCamelCase      :     Tuple							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Tuple					, *lowerCamelCase      :     Optional[int]					, **lowerCamelCase      :     List[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Union[str, Any]					, *lowerCamelCase      :     int					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Optional[Any]					, *lowerCamelCase      :     int					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     str					, *lowerCamelCase      :     int					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Dict					, *lowerCamelCase      :     str					, **lowerCamelCase      :     Optional[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Union[str, Any]					, *lowerCamelCase      :     Any					, **lowerCamelCase      :     Any							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Any					, *lowerCamelCase      :     Optional[Any]					, **lowerCamelCase      :     Tuple							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Any					, *lowerCamelCase      :     Dict					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[str]					, *lowerCamelCase      :     Optional[int]					, **lowerCamelCase      :     Any							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     str					, **lowerCamelCase      :     Optional[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Optional[Any]					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Tuple					, *lowerCamelCase      :     int					, **lowerCamelCase      :     Optional[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[Any]					, *lowerCamelCase      :     Optional[Any]					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Tuple					, *lowerCamelCase      :     Dict					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Any					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Optional[int]					, *lowerCamelCase      :     Dict					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Tuple					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[Any]					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     List[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Union[str, Any]					, *lowerCamelCase      :     Any					, **lowerCamelCase      :     Tuple							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     Union[str, Any]					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     str					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     Optional[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Any					, *lowerCamelCase      :     Dict					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[Any]					, *lowerCamelCase      :     Optional[Any]					, **lowerCamelCase      :     Union[str, Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Optional[Any]					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     Optional[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Dict					, *lowerCamelCase      :     Union[str, Any]					, **lowerCamelCase      :     str							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     str					, *lowerCamelCase      :     Dict					, **lowerCamelCase      :     List[str]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Tuple					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     Union[str, Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     str					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Union[str, Any]					, *lowerCamelCase      :     int					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Dict					, *lowerCamelCase      :     Dict					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Tuple					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     str					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Dict					, *lowerCamelCase      :     str					, **lowerCamelCase      :     Union[str, Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     List[str]					, *lowerCamelCase      :     str					, **lowerCamelCase      :     Optional[int]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Union[str, Any]					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     Any							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     str					, *lowerCamelCase      :     Optional[int]					, **lowerCamelCase      :     Tuple							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     int					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     int							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Optional[Any]					, *lowerCamelCase      :     List[str]					, **lowerCamelCase      :     Dict							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)







class 			__A					(			metaclass=A__      ):
 lowerCamelCase												=['''tokenizers''']
 def __init__( self      :     Tuple					, *lowerCamelCase      :     List[Any]					, **lowerCamelCase      :     Optional[Any]							):



   """simple docstring"""





   requires_backends(self					, ["""tokenizers"""]							)










'''simple docstring'''


import argparse

import torch

from transformers import HubertConfig, HubertForSequenceClassification, WavaVecaFeatureExtractor, logging


logging.set_verbosity_info()
_lowerCamelCase					:						Dict					     =							logging.get_logger(__name__)

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




@torch.no_grad()
def  __a			(  UpperCAmelCase							,      UpperCAmelCase							,      UpperCAmelCase							,      UpperCAmelCase     )   ->Union[str, Any]:



	"""simple docstring"""







	A					=   torch.load(UpperCAmelCase							,      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					=   checkpoint["""Downstream"""]

	A					=   HubertConfig.from_pretrained(UpperCAmelCase     )
	A					=   HubertForSequenceClassification.from_pretrained(UpperCAmelCase							,      config=UpperCAmelCase     )
	A					=   WavaVecaFeatureExtractor.from_pretrained(
	    UpperCAmelCase							,      return_attention_mask=UpperCAmelCase							,      do_normalize=UpperCAmelCase     )

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

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

	hf_feature_extractor.save_pretrained(UpperCAmelCase     )
	hf_model.save_pretrained(UpperCAmelCase     )


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

