code: def structured_negative_sampling_feasible(
      edge_index: Tensor,
      num_nodes: Optional[int] = None,
      contains_neg_self_loops: bool = True,
  ) -> bool:
      r"""Returns :obj:`True` if
      :meth:`~torch_geometric.utils.structured_negative_sampling` is feasible
      on the graph given by :obj:`edge_index`.
      :meth:`~torch_geometric.utils.structured_negative_sampling` is infeasible
      if atleast one node is connected to all other nodes.
  
      Args:
          edge_index (LongTensor): The edge indices.
          num_nodes (int, optional): The number of nodes, *i.e.*
              :obj:`max_val + 1` of :attr:`edge_index`. (default: :obj:`None`)
          contains_neg_self_loops (bool, optional): If set to
              :obj:`False`, sampled negative edges will not contain self loops.
              (default: :obj:`True`)
  
      :rtype: bool
  
      Examples:
          >>> edge_index = torch.LongTensor([[0, 0, 1, 1, 2, 2, 2],
          ...                                [1, 2, 0, 2, 0, 1, 1]])
          >>> structured_negative_sampling_feasible(edge_index, 3, False)
          False
  
          >>> structured_negative_sampling_feasible(edge_index, 3, True)
          True
      """
      num_nodes = maybe_num_nodes(edge_index, num_nodes)
      max_num_neighbors = num_nodes
  
      edge_index = coalesce(edge_index, num_nodes=num_nodes)
  
      if not contains_neg_self_loops:
          edge_index, _ = remove_self_loops(edge_index)
          max_num_neighbors -= 1  # Reduce number of valid neighbors
  
      deg = degree(edge_index[0], num_nodes)
      # True if there exists no node that is connected to all other nodes.
      return bool(torch.all(deg < max_num_neighbors))
  
file_path: pytorch_geometric/torch_geometric/utils/_negative_sampling.py
imports: import random
  from typing import Optional, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  from torch_geometric.utils import coalesce, cumsum, degree, remove_self_loops
  from torch_geometric.utils.num_nodes import maybe_num_nodes
label_desc: Use image node_id 4 for calling a global function with example usage: structured_negative_sampling_feasible(edge_index, num_nodes, contains_neg__loops) and returns: bool