class_docstr: A negative sampler used to generate negative samples and return
  a mix of positive and negative samples.
  
  Functional name: :obj:`sample_negative`.
  
  Parameters
  ----------
  datapipe : DataPipe
      The datapipe.
  negative_ratio : int
      The proportion of negative samples to positive samples.
docstr: Generate a mix of positive and negative samples.
  
  Parameters
  ----------
  minibatch : MiniBatch
      An instance of 'MiniBatch' class requires the 'node_pairs' field.
      This function is responsible for generating negative edges
      corresponding to the positive edges defined by the 'node_pairs'. In
      cases where negative edges already exist, this function will
      overwrite them.
  
  Returns
  -------
  MiniBatch
      An instance of 'MiniBatch' encompasses both positive and negative
      samples.
docstr_tok: ["Generate","a","mix","of","positive","and","negative","samples",".","Parameters","--","--","--","--","--","minibatch",":","MiniBatch","An","instance","of","'MiniBatch","'","class","requires","the","'node_pairs","'","field",".","This","function","is","responsible","for","generating","negative","edges","corresponding","to","the","positive","edges","defined","by","the","'node_pairs","'",".","In","cases","where","negative","edges","already","exist",",","this","function","will","overwrite","them",".","Returns","--","--","--","-","MiniBatch","An","instance","of","'MiniBatch","'","encompasses","both","positive","and","negative","samples","."]
code: def _sample(self, minibatch):
      """
      Generate a mix of positive and negative samples.
  
      Parameters
      ----------
      minibatch : MiniBatch
          An instance of 'MiniBatch' class requires the 'node_pairs' field.
          This function is responsible for generating negative edges
          corresponding to the positive edges defined by the 'node_pairs'. In
          cases where negative edges already exist, this function will
          overwrite them.
  
      Returns
      -------
      MiniBatch
          An instance of 'MiniBatch' encompasses both positive and negative
          samples.
      """
      node_pairs = minibatch.node_pairs
      assert node_pairs is not None
      if isinstance(node_pairs, Mapping):
          minibatch.negative_srcs, minibatch.negative_dsts = {}, {}
          for etype, pos_pairs in node_pairs.items():
              self._collate(
                  minibatch,
                  self._sample_with_etype(pos_pairs, etype),
                  etype,
              )
      else:
          self._collate(minibatch, self._sample_with_etype(node_pairs))
      return minibatch
  
file_path: dgl/python/dgl/graphbolt/negative_sampler.py
imports: from _collections_abc import Mapping
  from torch.utils.data import functional_datapipe
  from .minibatch_transformer import MiniBatchTransformer
label_desc: Use image node_id 2 for calling the NegativeSampler obj's underlying member method code with example usage: obj._sample(minibatch) and returns: minibatch