code: def sample(self, pos_samples, num_nodes):
      batch_size = len(pos_samples)
      neg_batch_size = batch_size * self.k
      neg_samples = np.tile(pos_samples, (self.k, 1))
  
      values = np.random.randint(num_nodes, size=neg_batch_size)
      choices = np.random.uniform(size=neg_batch_size)
      subj = choices > 0.5
      obj = choices <= 0.5
      neg_samples[subj, 0] = values[subj]
      neg_samples[obj, 2] = values[obj]
      samples = np.concatenate((pos_samples, neg_samples))
  
      # binary labels indicating positive and negative samples
      labels = np.zeros(batch_size * (self.k + 1), dtype=np.float32)
      labels[:batch_size] = 1
  
      return torch.from_numpy(samples), torch.from_numpy(labels)
  
imports: import dgl
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import tqdm
  from dgl.data.knowledge_graph import FB15k237Dataset
  from dgl.dataloading import GraphDataLoader
  from dgl.nn.pytorch import RelGraphConv
label_desc: Use image node_id 2 for calling the NegativeSampler obj's underlying member method code with example usage: obj.sample(pos_samples, num_nodes) and returns: torch,  torch