code: def __getitem__(self, batch_num):
      start = self.batch_size * batch_num
      end = start + self.batch_size
  
      indices = self.indices[start:end]
  
      s_iloc = self.source_ilocs[indices]
      r_iloc = self.rel_ilocs[indices]
      o_iloc = self.target_ilocs[indices]
      positive_count = len(s_iloc)
      targets = None
  
      if self.negative_samples is not None:
          s_iloc = np.tile(s_iloc, 1 + self.negative_samples)
          r_iloc = np.tile(r_iloc, 1 + self.negative_samples)
          o_iloc = np.tile(o_iloc, 1 + self.negative_samples)
  
          negative_count = self.negative_samples * positive_count
          assert len(s_iloc) == positive_count + negative_count
  
          rng = self._batch_sampler[batch_num]
  
          # FIXME (#882): this sampling may be able to be optimised to a slice-write
          change_source = rng.random(size=negative_count) < 0.5
          source_changes = change_source.sum()
  
          new_nodes = rng.randint(
              self.max_node_iloc, size=negative_count
          )
  
          s_iloc[positive_count:][change_source] = new_nodes[
              :source_changes
          ]
          o_iloc[positive_count:][~change_source] = new_nodes[
              source_changes:
          ]
  
          if self.sample_strategy == "uniform":
              targets = np.repeat(
                  np.array([1, 0], dtype=np.float32),
                  [positive_count, negative_count],
              )
          elif self.sample_strategy == "self-adversarial":
              # the negative samples are labelled with an arbitrary within-batch integer <= 0, based on
              # which positive edge they came from.
              targets = np.tile(
                  np.arange(0, -positive_count, -1),
                  1 + self.negative_samples,
              )
              # the positive examples are labelled with 1
              targets[:positive_count] = 1
          else:
              raise ValueError(
                  f"unknown sample_strategy: {sample_strategy!r}"
              )
  
          assert len(targets) == len(s_iloc)
  
      assert len(s_iloc) == len(r_iloc) == len(o_iloc)
  
      if targets is None:
          return ((s_iloc, r_iloc, o_iloc),)
  
      return (s_iloc, r_iloc, o_iloc), targets
  
file_path: stellargraph/stellargraph/mapper/knowledge_graph.py
imports: import threading
  import numpy
  import pandas
  from tensorflow.keras.utils import Sequence
  from ..globalvar import SOURCE, TARGET, TYPE_ATTR_NAME
  from ..random import random_state, SeededPerBatch
  from .base import Generator
  from ..core.validation import comma_sep, require_integer_in_range
label_desc: Use image node_id 3 for calling the KGTripleSequence obj's underlying member method code with example usage: obj.__getitem__(batch_num) and returns: s_iloc,  r_iloc,  o_iloc,  targets, s_iloc,  r_iloc,  o_iloc