code: def typed_negative_sampling(
      pos_edge_index: torch.Tensor,
      num_nodes: int,
      range_list: torch.Tensor,
  ) -> torch.Tensor:
      r"""
      Typed negative sampling for link prediction. Copy-paste from https://github.com/NYXFLOWER/GripNet.
  
      Args:
          pos_edge_index (torch.Tensor): edge indices in COO format with shape [2, num_edges].
          num_nodes (int): the number of nodes in the graph.
          range_list (torch.Tensor): the range of edge types. [[start_index, end_index], ...]
  
      Returns:
          torch.Tensor: edge indices in COO format with shape [2, num_edges].
      """
  
      tmp = []
      for start, end in range_list:
          tmp.append(
              negative_sampling(pos_edge_index[:, start:end], num_nodes)
          )
      return torch.cat(tmp, dim=1)
  
label_desc: Use image node_id 2 for calling a global function with example usage: typed_negative_sampling(pos_edge_index, num_nodes, range_list) and returns: torch