code: def erdos_renyi_graph(
      num_nodes: int,
      edge_prob: float,
      directed: bool = False,
  ) -> torch.Tensor:
      r"""Returns the :obj:`edge_index` of a random Erdos-Renyi graph.
  
      Args:
          num_nodes (int): The number of nodes.
          edge_prob (float): Probability of an edge.
          directed (bool, optional): If set to :obj:`True`, will return a
              directed graph. (default: :obj:`False`)
  
      Examples:
          >>> erdos_renyi_graph(5, 0.2, directed=False)
          tensor([[0, 1, 1, 4],
                  [1, 0, 4, 1]])
  
          >>> erdos_renyi_graph(5, 0.2, directed=True)
          tensor([[0, 1, 3, 3, 4, 4],
                  [4, 3, 1, 2, 1, 3]])
      """
      if directed:
          idx = torch.arange((num_nodes - 1) * num_nodes)
          idx = idx.view(num_nodes - 1, num_nodes)
          idx = idx + torch.arange(1, num_nodes).view(-1, 1)
          idx = idx.view(-1)
      else:
          warnings.filterwarnings(
              "ignore", ".*pass the indexing argument.*"
          )
          idx = torch.combinations(torch.arange(num_nodes), r=2)
  
      # Filter edges.
      mask = torch.rand(idx.size(0)) < edge_prob
      idx = idx[mask]
  
      if directed:
          row = idx.div(num_nodes, rounding_mode="floor")
          col = idx % num_nodes
          edge_index = torch.stack([row, col], dim=0)
      else:
          edge_index = to_undirected(idx.t(), num_nodes=num_nodes)
  
      return edge_index
  
imports: import warnings
  from typing import List, Union
  import numpy
  import torch
  from torch_geometric.utils import remove_self_loops, to_undirected
label_desc: Use image node_id 1 for calling a global function with example usage: erdos_renyi_graph(num_nodes, edge_prob, directed) and returns: edge_index