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 = [
          head + self.entity_dict[head_type][0],
          relation,
          tail + self.entity_dict[tail_type][0],
      ]
  
      subsampling_weight = (
          self.count[(head, relation, head_type)]
          + self.count[(tail, -relation - 1, tail_type)]
      )
      subsampling_weight = torch.sqrt(
          1 / torch.Tensor([subsampling_weight])
      )
  
      if self.mode == "head-batch":
          negative_sample = torch.randint(
              self.entity_dict[head_type][0],
              self.entity_dict[head_type][1],
              (self.negative_sample_size,),
          )
      elif self.mode == "tail-batch":
          negative_sample = torch.randint(
              self.entity_dict[tail_type][0],
              self.entity_dict[tail_type][1],
              (self.negative_sample_size,),
          )
      else:
          raise
      positive_sample = torch.LongTensor(positive_sample)
  
      return (
          positive_sample,
          negative_sample,
          subsampling_weight,
          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 TrainDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: positive_sample,  negative_sample,  subsampling_weight,  self