code: def __init__(
      self,
      decoder,
      pad_token_id,
      label_ids,
      use_prompt=False,
      prompt_len=10,
      learn_weights=False,
  ):
      super(PromptBartDecoder, self).__init__()
      self.bart_decoder = decoder
      self.pad_token_id = pad_token_id
      self.use_prompt = use_prompt
      self.prompt_len = prompt_len
      self.learn_weights = learn_weights
      self.label_ids = label_ids
  
      print(label_ids)
      if self.learn_weights:  # set learnable averge weights
          self.averge_weights = nn.ParameterList(parameters=None)
          for id in label_ids:
              if len(id) > 1:
                  self.averge_weights.append(
                      nn.Parameter(
                          torch.FloatTensor(len(id)).uniform_(1.0, 2.5)
                      )
                  )
          print(self.averge_weights)
          mapping = [0, 2]
          if self.pad_token_id == 0:
              mapping = [101, 102]
          for id in label_ids:
              mapping += id[:1]
          mapping = torch.LongTensor(mapping)
      else:
          mapping = torch.LongTensor([0, 2] + label_ids)
          if self.pad_token_id == 0:
              mapping = torch.LongTensor([101, 102] + label_ids)
          self.label_start_id = min(label_ids)
          self.label_end_id = max(label_ids) + 1
  
      self.register_buffer("mapping", mapping)
      self.src_start_index = len(mapping)
  
      hidden_size = decoder.embed_tokens.weight.size(1)
      self.bart_mlp = nn.Sequential(
          nn.Linear(hidden_size, hidden_size),
          nn.Dropout(0.3),
          nn.ReLU(),
          nn.Linear(hidden_size, hidden_size),
      )
      self.dropout_layer = nn.Dropout(0.3)
  
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 PromptBartDecoder object from inherited base classes: nn with example: obj = PromptBartDecoder(decoder, pad_token_id, label_ids, use_prompt, prompt_len, learn_weights)