code: def bipartite_subgraph(
      subset: Union[PairTensor, Tuple[List[int], List[int]]],
      edge_index: Tensor,
      edge_attr: OptTensor = None,
      relabel_nodes: bool = False,
      size: Optional[Tuple[int, int]] = None,
      return_edge_mask: bool = False,
  ) -> Union[
      Tuple[Tensor, OptTensor], Tuple[Tensor, OptTensor, OptTensor]
  ]:
      r"""Returns the induced subgraph of the bipartite graph
      :obj:`(edge_index, edge_attr)` containing the nodes in :obj:`subset`.
  
      Args:
          subset (Tuple[Tensor, Tensor] or tuple([int],[int])): The nodes
              to keep.
          edge_index (LongTensor): The edge indices.
          edge_attr (Tensor, optional): Edge weights or multi-dimensional
              edge features. (default: :obj:`None`)
          relabel_nodes (bool, optional): If set to :obj:`True`, the resulting
              :obj:`edge_index` will be relabeled to hold consecutive indices
              starting from zero. (default: :obj:`False`)
          size (tuple, optional): The number of nodes.
              (default: :obj:`None`)
          return_edge_mask (bool, optional): If set to :obj:`True`, will return
              the edge mask to filter out additional edge features.
              (default: :obj:`False`)
  
      :rtype: (:class:`LongTensor`, :class:`Tensor`)
  
      Examples:
          >>> edge_index = torch.tensor([[0, 5, 2, 3, 3, 4, 4, 3, 5, 5, 6],
          ...                            [0, 0, 3, 2, 0, 0, 2, 1, 2, 3, 1]])
          >>> edge_attr = torch.tensor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
          >>> subset = (torch.tensor([2, 3, 5]), torch.tensor([2, 3]))
          >>> bipartite_subgraph(subset, edge_index, edge_attr)
          (tensor([[2, 3, 5, 5],
                  [3, 2, 2, 3]]),
          tensor([ 3,  4,  9, 10]))
  
          >>> bipartite_subgraph(subset, edge_index, edge_attr,
          ...                    return_edge_mask=True)
          (tensor([[2, 3, 5, 5],
                  [3, 2, 2, 3]]),
          tensor([ 3,  4,  9, 10]),
          tensor([False, False,  True,  True, False, False, False, False,
                  True,  True,  False]))
      """
      device = edge_index.device
  
      src_subset, dst_subset = subset
      if not isinstance(src_subset, Tensor):
          src_subset = torch.tensor(
              src_subset, dtype=torch.long, device=device
          )
      if not isinstance(dst_subset, Tensor):
          dst_subset = torch.tensor(
              dst_subset, dtype=torch.long, device=device
          )
  
      if src_subset.dtype != torch.bool:
          src_size = (
              int(edge_index[0].max()) + 1 if size is None else size[0]
          )
          src_node_mask = index_to_mask(src_subset, size=src_size)
      else:
          src_size = src_subset.size(0)
          src_node_mask = src_subset
          src_subset = src_subset.nonzero().view(-1)
  
      if dst_subset.dtype != torch.bool:
          dst_size = (
              int(edge_index[1].max()) + 1 if size is None else size[1]
          )
          dst_node_mask = index_to_mask(dst_subset, size=dst_size)
      else:
          dst_size = dst_subset.size(0)
          dst_node_mask = dst_subset
          dst_subset = dst_subset.nonzero().view(-1)
  
      edge_mask = (
          src_node_mask[edge_index[0]] & dst_node_mask[edge_index[1]]
      )
      edge_index = edge_index[:, edge_mask]
      edge_attr = (
          edge_attr[edge_mask] if edge_attr is not None else None
      )
  
      if relabel_nodes:
          src_index, _ = map_index(
              edge_index[0],
              src_subset,
              max_index=src_size,
              inclusive=True,
          )
          dst_index, _ = map_index(
              edge_index[1],
              dst_subset,
              max_index=dst_size,
              inclusive=True,
          )
          edge_index = torch.stack([src_index, dst_index], dim=0)
  
      if return_edge_mask:
          return edge_index, edge_attr, edge_mask
      else:
          return edge_index, edge_attr
  
file_path: pytorch_geometric/torch_geometric/utils/_subgraph.py
imports: from typing import List, Literal, Optional, Tuple, Union, overload
  import torch
  from torch import Tensor
  from torch_geometric.typing import OptTensor, PairTensor
  from torch_geometric.utils import scatter
  from torch_geometric.utils.map import map_index
  from torch_geometric.utils.mask import index_to_mask
  from torch_geometric.utils.num_nodes import maybe_num_nodes
label_desc: Use image node_id 6 for calling a global function with example usage: bipartite_subgraph(subset, edge_index, edge_attr, relabel_nodes, size, return_edge_mask) and returns: edge_index,  edge_attr,  edge_mask, edge_index,  edge_attr