class_docstr: The negative sampling configuration of a
  :class:`~torch_geometric.sampler.BaseSampler` when calling
  :meth:`~torch_geometric.sampler.BaseSampler.sample_from_edges`.
  
  Args:
      mode (str): The negative sampling mode
          (:obj:`"binary"` or :obj:`"triplet"`).
          If set to :obj:`"binary"`, will randomly sample negative links
          from the graph.
          If set to :obj:`"triplet"`, will randomly sample negative
          destination nodes for each positive source node.
      amount (int or float, optional): The ratio of sampled negative edges to
          the number of positive edges. (default: :obj:`1`)
      weight (torch.Tensor, optional): A node-level vector determining the
          sampling of nodes. Does not necessariyl need to sum up to one.
          If not given, negative nodes will be sampled uniformly.
          (default: :obj:`None`)
docstr: Generates :obj:`num_samples` negative samples.
docstr_tok: ["Generates",":","obj",":","`","num_samples","`","negative","samples","."]
code: def sample(
      self, num_samples: int, num_nodes: Optional[int] = None
  ) -> Tensor:
      r"""Generates :obj:`num_samples` negative samples."""
      if self.weight is None:
          if num_nodes is None:
              raise ValueError(
                  f"Cannot sample negatives in '{self.__class__.__name__}' "
                  f"without passing the 'num_nodes' argument"
              )
          return torch.randint(num_nodes, (num_samples,))
  
      if num_nodes is not None and self.weight.numel() != num_nodes:
          raise ValueError(
              f"The 'weight' attribute in '{self.__class__.__name__}' "
              f"needs to match the number of nodes {num_nodes} "
              f"(got {self.weight.numel()})"
          )
      return torch.multinomial(
          self.weight, num_samples, replacement=True
      )
  
imports: import copy
  import math
  import warnings
  from abc import ABC
  from collections import defaultdict
  from dataclasses import dataclass
  from enum import Enum
  from typing import Any, Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from torch_geometric.data import Data, FeatureStore, GraphStore, HeteroData
  from torch_geometric.sampler.utils import to_bidirectional
  from torch_geometric.typing import EdgeType, EdgeTypeStr, NodeType, OptTensor
  from torch_geometric.utils.mixin import CastMixin
label_desc: Use image node_id 4 for calling the NegativeSampling obj's underlying member method code with example usage: obj.sample(num_samples, num_nodes) and returns: torch, torch