code: def __init__(self, tokenizer, label_ids, args):
      super(PromptBartModel, self).__init__()
      self.use_prompt = args.use_prompt
      self.prompt_len = args.prompt_len
      self.prompt_dim = args.prompt_dim
      self.learn_weights = args.learn_weights
      self.device = "cuda" if torch.cuda.is_available else "cpu"
      bart_name = args.bart_name
  
      self.bart_config = BartConfig.from_pretrained(bart_name)
      self.bart_config.use_prompt = args.use_prompt
      self.bart_config.preseqlen = args.prompt_len
      bart_config = self.bart_config
      bart_model = BartModel.from_pretrained(
          bart_name, config=bart_config
      )
      num_tokens, _ = bart_model.encoder.embed_tokens.weight.shape
      bart_model.resize_token_embeddings(
          len(tokenizer.unique_no_split_tokens) + num_tokens
      )
      bart_model = avg_token_embeddings(
          tokenizer, bart_model, bart_name, num_tokens
      )
  
      self.prompt_encoder = PromptBartEncoder(bart_model.encoder)
      self.prompt_decoder = PromptBartDecoder(
          bart_model.decoder,
          tokenizer.pad_token_id,
          label_ids,
          self.use_prompt,
          self.prompt_len,
          self.learn_weights,
      )
  
      self.prompt_inputs = torch.arange(self.prompt_len).long()
      self.encoder_prompt_embed = nn.Embedding(
          self.prompt_len, bart_config.d_model
      )
      self.encoder_mlp = nn.Sequential(
          nn.Linear(bart_config.d_model, self.prompt_dim),
          nn.Tanh(),
          nn.Linear(
              self.prompt_dim,
              bart_config.decoder_layers * 2 * bart_config.d_model,
          ),
      )
  
      self.decoder_prompt_embed = nn.Embedding(
          self.prompt_len, bart_config.d_model
      )
      self.decoder_mlp = nn.Sequential(
          nn.Linear(bart_config.d_model, self.prompt_dim),
          nn.Tanh(),
          nn.Linear(
              self.prompt_dim,
              bart_config.decoder_layers * 2 * bart_config.d_model,
          ),
      )
  
      self.prompt_cross_embed = nn.Embedding(
          self.prompt_len, bart_config.d_model
      )
      self.cross_mlp = nn.Sequential(
          nn.Linear(bart_config.d_model, self.prompt_dim),
          nn.Tanh(),
          nn.Linear(
              self.prompt_dim,
              bart_config.decoder_layers * 2 * bart_config.d_model,
          ),
      )
  
      self.dropout = nn.Dropout(0.0)
  
imports: import torch
  from torch import nn
  from torch.nn import functional
  from transformers.models.bart.configuration_bart import BartConfig
  from .modeling_bart import BartModel
  from ..utils.util import avg_token_embeddings, seq_to_mask, get_model_device
  from functools import partial
  from typing import Union
label_desc: Use image node_id 1 to create a new PromptBartModel object from inherited base classes: nn with example: obj = PromptBartModel(tokenizer, label_ids, args)