code: 
  
  
  import argparse
  
  import torch
  from torch import nn
  
  from transformers import PLBartConfig, PLBartForConditionalGeneration, PLBartForSequenceClassification
  def 							_UpperCAmelCase       (UpperCamelCase__  :						Any		):
         _A   : Optional[Any]       					=				[
             "encoder.version",
             "decoder.version",
             "model.encoder.version",
             "model.decoder.version",
             "_float_tensor",
             "decoder.output_projection.weight",
         ]
         for k in ignore_keys:
                state_dict.pop(UpperCamelCase__       ,							UpperCamelCase__		)
  def 							_UpperCAmelCase       (UpperCamelCase__  :						Dict		):
         _A					,    _A   : Tuple       					=				emb.weight.shape
         _A   : Optional[Any]       					=				nn.Linear(UpperCamelCase__       ,							UpperCamelCase__       ,							bias=UpperCamelCase__		)
         _A   : int       					=				emb.weight.data
         return lin_layer
  def 							_UpperCAmelCase       (UpperCamelCase__  :						List[Any]       ,							UpperCamelCase__  :						List[str]="uclanlp/plbart-base"       ,							UpperCamelCase__  :						List[Any]=False       ,							UpperCamelCase__  :						Dict=False		):
         _A   : str       					=				torch.load(UpperCamelCase__       ,							map_location="cpu"		)["model"]
         remove_ignore_keys_(UpperCamelCase__		)
         _A   : Dict       					=				state_dict["encoder.embed_tokens.weight"].shape[0]
  
         _A   : Dict       					=				PLBartConfig.from_pretrained(UpperCamelCase__       ,							vocab_size=UpperCamelCase__		)
  
         _A   : List[Any]       					=				state_dict["decoder.embed_tokens.weight"]
         if not classification:
                _A   : Any       					=				PLBartForConditionalGeneration(UpperCamelCase__		)
                model.model.load_state_dict(UpperCamelCase__		)
                if finetuned:
                       _A   : List[str]       					=				make_linear_from_emb(model.model.shared		)
  
         else:
                _A   : Dict       					=				{}
                for key, value in state_dict.copy().items():
                       if key.startswith("classification_heads.sentence_classification_head"		):
                              _A   : Tuple       					=				value
                              state_dict.pop(UpperCamelCase__		)
                _A   : List[Any]       					=				PLBartForSequenceClassification(UpperCamelCase__		)
                model.model.load_state_dict(UpperCamelCase__		)
                model.classification_head.load_state_dict(UpperCamelCase__		)
  
         return model
  
  
  if __name__ == "__main__":
      lowerCAmelCase__   	=				argparse.ArgumentParser()
      # Required parameters
      parser.add_argument('fairseq_path', type=str, help='model.pt on local filesystem.')
      parser.add_argument('pytorch_dump_folder_path', default=None, type=str, help='Path to the output PyTorch model.')
      parser.add_argument(
          '--hf_config',
          default='uclanlp/plbart-base',
          type=str,
          help='Which huggingface architecture to use: plbart-base',
      )
      parser.add_argument('--finetuned', action='store_true', help='whether the model is a fine-tuned checkpoint')
      parser.add_argument(
          '--classification', action='store_true', help='whether the model is a classification checkpoint'
      )
      lowerCAmelCase__   	=				parser.parse_args()
      lowerCAmelCase__   	=				convert_fairseq_plbart_checkpoint_from_disk(
          args.fairseq_path,
          hf_config_path=args.hf_config,
          finetuned=args.finetuned,
          classification=args.classification,
      )
      model.save_pretrained(args.pytorch_dump_folder_path)
  
style_context: 
  
  
  lowerCAmelCase__   	=				'\n# Transformers installation\n! pip install transformers datasets evaluate\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n'
  
  lowerCAmelCase__   	=				[{'type': 'code', 'content': INSTALL_CONTENT}]
  lowerCAmelCase__   	=				{
      '{processor_class}': 'FakeProcessorClass',
      '{model_class}': 'FakeModelClass',
      '{object_class}': 'FakeObjectClass',
  }
  