code: def get_tensor(
      self,
      ent_vocab,
      rel_vocab,
      text_vocab,
      ent_text_vocab,
      title_vocab,
  ):
      if hasattr(self, "_cached_tensor"):
          return self._cached_tensor
      else:
          title_data = ["<BOS>"] + self.raw_title + ["<EOS>"]
          title = [title_vocab(x) for x in title_data]
          ent_text = [
              [ent_text_vocab(y) for y in x] for x in self.raw_ent_text
          ]
          ent_type = [
              text_vocab(x) for x in self.raw_ent_type
          ]  # for inference
          rel_data = ["--root--"] + sum(
              [[x[1], x[1] + "_INV"] for x in self.raw_rel], []
          )
          rel = [rel_vocab(x) for x in rel_data]
  
          text_data = ["<BOS>"] + self.raw_text + ["<EOS>"]
          text = [text_vocab(x) for x in text_data]
          tgt_text = []
          # the input text and decoding target are different since the consideration of the copy mechanism.
          for i, str1 in enumerate(text_data):
              if str1[0] == "<" and str1[-1] == ">" and "_" in str1:
                  a, b = str1[1:-1].split("_")
                  text[i] = text_vocab("<" + a + ">")
                  tgt_text.append(len(text_vocab) + int(b))
              else:
                  tgt_text.append(text[i])
          self._cached_tensor = {
              "title": torch.LongTensor(title),
              "ent_text": [torch.LongTensor(x) for x in ent_text],
              "ent_type": torch.LongTensor(ent_type),
              "rel": torch.LongTensor(rel),
              "text": torch.LongTensor(text[:-1]),
              "tgt_text": torch.LongTensor(tgt_text[1:]),
              "graph": self.graph,
              "raw_ent_text": self.raw_ent_text,
          }
          return self._cached_tensor
  
imports: import json
  import pickle
  import random
  import dgl
  import numpy
  import torch
label_desc: Use image node_id 6 for calling the Example obj's underlying member method code with example usage: obj.get_tensor(ent_vocab, rel_vocab, text_vocab, ent_text_vocab, title_vocab) and returns: self, self