code: 
  
  
  
  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  __a  (					lowerCAmelCase_     :      Optional[Any]    ,lowerCAmelCase_     :      Optional[Any]    ,lowerCAmelCase_     :      Union[str, Any]    ,lowerCAmelCase_     :      Tuple       )   ->				int:
  
  
  
  
  
  
  						'''simple docstring'''
  
  
  
  						UpperCAmelCase_=     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}"""       )
  
  						UpperCAmelCase_=     checkpoint["""Downstream"""]
  
  						UpperCAmelCase_=     HubertConfig.from_pretrained(lowerCAmelCase_       )
  						UpperCAmelCase_=     HubertForSequenceClassification.from_pretrained(lowerCAmelCase_    ,config=lowerCAmelCase_       )
  						UpperCAmelCase_=     WavaVecaFeatureExtractor.from_pretrained(
  						    lowerCAmelCase_    ,return_attention_mask=lowerCAmelCase_    ,do_normalize=lowerCAmelCase_       )
  
  						if hf_congfig.use_weighted_layer_sum:
  												UpperCAmelCase_=     checkpoint["""Featurizer"""]["""weights"""]
  
  						UpperCAmelCase_=     downstream_dict["""projector.weight"""]
  						UpperCAmelCase_=     downstream_dict["""projector.bias"""]
  						UpperCAmelCase_=     downstream_dict["""model.post_net.linear.weight"""]
  						UpperCAmelCase_=     downstream_dict["""model.post_net.linear.bias"""]
  
  						hf_feature_extractor.save_pretrained(lowerCAmelCase_       )
  						hf_model.save_pretrained(lowerCAmelCase_       )
  
  
  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)
  
  
  
  
  
style_context: 
  
  
  
  from ...configuration_utils import PretrainedConfig
  from ...utils import logging
  
  
  __A       					=		logging.get_logger(__name__)
  
  __A       					=		{
      '''ZinengTang/tvlt-base''': '''https://huggingface.co/ZinengTang/tvlt-base/blob/main/config.json''',
  }
  
  
  
  
  
  
  class 	lowercase		(				snake_case__):
  
  
  
  
  
  
  	"""simple docstring"""
  
  
  	a__   :      Tuple	     =							"tvlt"
  
  
  
  
  	def __init__(			self			:		List[str]		,						__UpperCAmelCase			:		List[str]=224		,						__UpperCAmelCase			:		List[str]=2_048		,						__UpperCAmelCase			:		Tuple=128		,						__UpperCAmelCase			:		Union[str, Any]=[16, 16]		,						__UpperCAmelCase			:		str=[16, 16]		,						__UpperCAmelCase			:		str=3		,						__UpperCAmelCase			:		List[str]=1		,						__UpperCAmelCase			:		Tuple=8		,						__UpperCAmelCase			:		Optional[Any]=768		,						__UpperCAmelCase			:		List[Any]=12		,						__UpperCAmelCase			:		Tuple=12		,						__UpperCAmelCase			:		List[str]=3_072		,						__UpperCAmelCase			:		List[Any]="gelu"		,						__UpperCAmelCase			:		str=0.0		,						__UpperCAmelCase			:		str=0.0		,						__UpperCAmelCase			:		List[Any]=0.02		,						__UpperCAmelCase			:		Optional[int]=1E-6		,						__UpperCAmelCase			:		Tuple=True		,						__UpperCAmelCase			:		List[Any]=False		,						__UpperCAmelCase			:		Union[str, Any]=16		,						__UpperCAmelCase			:		Any=512		,						__UpperCAmelCase			:		Optional[Any]=8		,						__UpperCAmelCase			:		Dict=2_048		,						__UpperCAmelCase			:		Dict=0.75		,						__UpperCAmelCase			:		Union[str, Any]=0.15		,						__UpperCAmelCase			:		Any="frame-level"		,						__UpperCAmelCase			:		int=True		,						__UpperCAmelCase			:		List[Any]=True		,						__UpperCAmelCase			:		Union[str, Any]="classification"		,						**__UpperCAmelCase			:		Any		,						)    ->				Tuple:
  							super().__init__(**__UpperCAmelCase  )
  
  							if audio_mask_type not in ("frame-level", "patch_level"):
  													raise ValueError(
  													    """audio_mask_type must be one of two acceptable strategies - {'frame_level', 'patch-level') """
  													    F"""got {audio_mask_type}"""  )
  
  							UpperCAmelCase_=     image_size
  							UpperCAmelCase_=     spectrogram_length
  							UpperCAmelCase_=     frequency_length
  							UpperCAmelCase_=     image_patch_size
  							UpperCAmelCase_=     audio_patch_size
  							UpperCAmelCase_=     num_image_channels
  							UpperCAmelCase_=     num_audio_channels
  							UpperCAmelCase_=     num_frames
  
  							UpperCAmelCase_=     hidden_size
  							UpperCAmelCase_=     num_hidden_layers
  							UpperCAmelCase_=     num_attention_heads
  							UpperCAmelCase_=     intermediate_size
  							UpperCAmelCase_=     hidden_act
  							UpperCAmelCase_=     hidden_dropout_prob
  							UpperCAmelCase_=     attention_probs_dropout_prob
  							UpperCAmelCase_=     initializer_range
  							UpperCAmelCase_=     layer_norm_eps
  							UpperCAmelCase_=     qkv_bias
  							UpperCAmelCase_=     use_mean_pooling
  
  							UpperCAmelCase_=     decoder_num_attention_heads
  							UpperCAmelCase_=     decoder_hidden_size
  							UpperCAmelCase_=     decoder_num_hidden_layers
  							UpperCAmelCase_=     decoder_intermediate_size
  							UpperCAmelCase_=     pixel_mask_ratio
  							UpperCAmelCase_=     audio_mask_ratio
  							UpperCAmelCase_=     audio_mask_type
  
  							UpperCAmelCase_=     task_matching
  							UpperCAmelCase_=     task_mae
  							UpperCAmelCase_=     loss_type
  
  
  
  
  