code: def __getitem__(self, idx):
      head, relation, tail = (
          self.triples["head"][idx],
          self.triples["relation"][idx],
          self.triples["tail"][idx],
      )
      head_type, tail_type = (
          self.triples["head_type"][idx],
          self.triples["tail_type"][idx],
      )
      positive_sample = torch.LongTensor(
          (
              head + self.entity_dict[head_type][0],
              relation,
              tail + self.entity_dict[tail_type][0],
          )
      )
  
      if self.mode == "head-batch":
          if not self.random_sampling:
              negative_sample = torch.cat(
                  [
                      torch.LongTensor(
                          [head + self.entity_dict[head_type][0]]
                      ),
                      torch.from_numpy(
                          self.triples["head_neg"][idx]
                          + self.entity_dict[head_type][0]
                      ),
                  ]
              )
          else:
              negative_sample = torch.cat(
                  [
                      torch.LongTensor(
                          [head + self.entity_dict[head_type][0]]
                      ),
                      torch.randint(
                          self.entity_dict[head_type][0],
                          self.entity_dict[head_type][1],
                          size=(self.neg_size,),
                      ),
                  ]
              )
      elif self.mode == "tail-batch":
          if not self.random_sampling:
              negative_sample = torch.cat(
                  [
                      torch.LongTensor(
                          [tail + self.entity_dict[tail_type][0]]
                      ),
                      torch.from_numpy(
                          self.triples["tail_neg"][idx]
                          + self.entity_dict[tail_type][0]
                      ),
                  ]
              )
          else:
              negative_sample = torch.cat(
                  [
                      torch.LongTensor(
                          [tail + self.entity_dict[tail_type][0]]
                      ),
                      torch.randint(
                          self.entity_dict[tail_type][0],
                          self.entity_dict[tail_type][1],
                          size=(self.neg_size,),
                      ),
                  ]
              )
  
      return positive_sample, negative_sample, self.mode
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import torch
  from torch.utils.data import Dataset
label_desc: Use image node_id 3 for calling the TestDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: positive_sample,  negative_sample,  self