class_docstr: Average policy for bag-level relation extraction.
docstr: Args:
      sentence_encoder: encoder for sentences
      num_class: number of classes
      id2rel: dictionary of id -> relation name mapping
docstr_tok: ["Args",":","sentence_encoder",":","encoder","for","sentences","num_class",":","number","of","classes","id2rel",":","dictionary","of","id","-",">","relation","name","mapping"]
code: def __init__(self, sentence_encoder, num_class, rel2id):
      """
      Args:
          sentence_encoder: encoder for sentences
          num_class: number of classes
          id2rel: dictionary of id -> relation name mapping
      """
      super().__init__()
      self.sentence_encoder = sentence_encoder
      self.num_class = num_class
      self.fc = nn.Linear(self.sentence_encoder.hidden_size, num_class)
      self.softmax = nn.Softmax(-1)
      self.rel2id = rel2id
      self.id2rel = {}
      self.drop = nn.Dropout()
      for rel, id in rel2id.items():
          self.id2rel[id] = rel
  
file_path: OpenNRE/opennre/model/bag_average.py
imports: import torch
  from torch import nn, optim
  from .base_model import BagRE
label_desc: Use image node_id 1 to create a new BagAverage object from inherited base classes: BagRE with example: obj = BagAverage(sentence_encoder, num_class, rel2id)