






from ..utils import DummyObject, requires_backends





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Tuple    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Any    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  str    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  int    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Dict    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Tuple    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Any    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Tuple    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Any    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Tuple    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  str    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  str    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Optional[Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Any    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  int    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Dict    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  int    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Optional[Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  str    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Any    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Dict    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Tuple    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Any    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Any    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  int    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  str    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Optional[int]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Dict    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  int    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Tuple    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Optional[int]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Optional[int]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Dict    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Optional[Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Dict    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Union[str, Any]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  Tuple    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)





class 						_A( metaclass=A__       ):


				"""simple docstring"""


				UpperCamelCase   :  List[str]    =     ['''tokenizers''']



				def __init__(      self					, *_A					, **_A					):
									requires_backends(self					, ['tokenizers']					)











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)




