code: 
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  
  
  import argparse
  
  import torch
  
  from transformers import HubertConfig, HubertForSequenceClassification, WavaVecaFeatureExtractor, logging
  
  
  logging.set_verbosity_info()
  _lowerCamelCase							:		Union[str, Any]  			=						logging.get_logger(__name__)
  
  _lowerCamelCase							:		List[str]  			=						['''UtteranceLevel''']
  
  
  
  
  
  
  @torch.no_grad()
  def 	_lowercase	(			lowercase_		,							lowercase_		,							lowercase_		,							lowercase_						):
  
  
  
  		'''simple docstring'''
  
  
  
  
  
  
  
  		_snake_case			 = 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}'''						)
  
  		_snake_case			 = checkpoint["Downstream"]
  
  		_snake_case			 = HubertConfig.from_pretrained(__lowerCAmelCase						)
  		_snake_case			 = HubertForSequenceClassification.from_pretrained(__lowerCAmelCase		,							config=__lowerCAmelCase						)
  		_snake_case			 = WavaVecaFeatureExtractor.from_pretrained(
  		    __lowerCAmelCase		,							return_attention_mask=__lowerCAmelCase		,							do_normalize=__lowerCAmelCase						)
  
  		if hf_congfig.use_weighted_layer_sum:
  				_snake_case			 = checkpoint["Featurizer"]["weights"]
  
  		_snake_case			 = downstream_dict["projector.weight"]
  		_snake_case			 = downstream_dict["projector.bias"]
  		_snake_case			 = downstream_dict["model.post_net.linear.weight"]
  		_snake_case			 = downstream_dict["model.post_net.linear.bias"]
  
  		hf_feature_extractor.save_pretrained(__lowerCAmelCase						)
  		hf_model.save_pretrained(__lowerCAmelCase						)
  
  
  if __name__ == "__main__":
  						_lowerCamelCase							:		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							:		Any  			=						parser.parse_args()
  						convert_saprl_checkpoint(args.base_model_name, args.config_path, args.checkpoint_path, args.model_dump_path)
  
  
  
  
  
  
style_context: 
  
  
  
  
  '''simple docstring'''
  
  
  
  
  
  
  
  import unittest
  import warnings
  from dataclasses import dataclass
  
  from transformers.convert_slow_tokenizer import SpmConverter
  from transformers.testing_utils import get_tests_dir
  
  
  
  
  
  @dataclass
  class   lowerCamelCase_							:
  
  
  
  
  					'''simple docstring'''
  
  
  
  
  
  
  					lowercase__					=				42
  
  
  
  
  
  class   lowerCamelCase_							( unittest.TestCase							):
  
  
  
  
  					'''simple docstring'''
  
  
  
  
  
  
  					def        __SCREAMING_SNAKE_CASE			(					self				):
  							_snake_case			 = get_tests_dir("fixtures/test_sentencepiece.model"				)
  							_snake_case			 = get_tests_dir("fixtures/test_sentencepiece_with_bytefallback.model"				)
  
  							_snake_case			 = FakeOriginalTokenizer(vocab_file=__UpperCamelCase				)
  
  							with warnings.catch_warnings(record=__UpperCamelCase				) as w:
  									_snake_case			 = SpmConverter(__UpperCamelCase				)
  							self.assertEqual(len(__UpperCamelCase				),						0				)
  
  							_snake_case			 = FakeOriginalTokenizer(vocab_file=__UpperCamelCase				)
  
  							with warnings.catch_warnings(record=__UpperCamelCase				) as w:
  									_snake_case			 = SpmConverter(__UpperCamelCase				)
  							self.assertEqual(len(__UpperCamelCase				),						1				)
  
  							self.assertIn(
  							    "The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option"
  							    " which is not implemented in the fast tokenizers.",						str(w[0].message				),						)
  
  
  
  
  
  