class_docstr: A data object describing a hypergraph.
  
  The data object can hold node-level, link-level and graph-level attributes.
  This object differs from a standard :obj:`~torch_geometric.data.Data`
  object by having hyperedges, i.e. edges that connect more
  than two nodes. For example, in the hypergraph scenario
  :math:`\mathcal{G} = (\mathcal{V}, \mathcal{E})` with
  :math:`\mathcal{V} = \{ 0, 1, 2, 3, 4 \}` and
  :math:`\mathcal{E} = \{ \{ 0, 1, 2 \}, \{ 1, 2, 3, 4 \} \}`, the
  hyperedge index :obj:`edge_index` is represented as:
  
  .. code-block:: python
  
      # hyper graph with two hyperedges
      # connecting 3 and 4 nodes, respectively
      edge_index = torch.tensor([
          [0, 1, 2, 1, 2, 3, 4],
          [0, 0, 0, 1, 1, 1, 1],
      ])
  
  Args:
      x (torch.Tensor, optional): Node feature matrix with shape
          :obj:`[num_nodes, num_node_features]`. (default: :obj:`None`)
      edge_index (LongTensor, optional): Hyperedge tensor
          with shape :obj:`[2, num_edges*num_nodes_per_edge]`.
          Where `edge_index[1]` denotes the hyperedge index and
          `edge_index[0]` denotes the node indicies that are connected
          by the hyperedge. (default: :obj:`None`)
          (default: :obj:`None`)
      edge_attr (torch.Tensor, optional): Edge feature matrix with shape
          :obj:`[num_edges, num_edge_features]`.
          (default: :obj:`None`)
      y (torch.Tensor, optional): Graph-level or node-level ground-truth
          labels with arbitrary shape. (default: :obj:`None`)
      pos (torch.Tensor, optional): Node position matrix with shape
          :obj:`[num_nodes, num_dimensions]`. (default: :obj:`None`)
      **kwargs (optional): Additional attributes.
class_docstr_tok: ["A","data","object","describing","a","hypergraph",".","The","data","object","can","hold","node-level",",","link-level","and","graph-level","attributes",".","This","object","differs","from","a","standard",":","obj",":","`","~torch_geometric.data.Data","`","object","by","having","hyperedges",",","i.e",".","edges","that","connect","more","than","two","nodes",".","For","example",",","in","the","hypergraph","scenario",":","math",":","`","\\mathcal","{","G","}","=","(","\\mathcal","{","V","}",",","\\mathcal","{","E","}",")","`","with",":","math",":","`","\\mathcal","{","V","}","=","\\","{","0",",","1",",","2",",","3",",","4","\\","}","`","and",":","math",":","`","\\mathcal","{","E","}","=","\\","{","\\","{","0",",","1",",","2","\\","}",",","\\","{","1",",","2",",","3",",","4","\\","}","\\","}","`",",","the","hyperedge","index",":","obj",":","`","edge_index","`","is","represented","as",":","..","code-block",":",":","python","#","hyper","graph","with","two","hyperedges","#","connecting","3","and","4","nodes",",","respectively","edge_index","=","torch.tensor","(","[","[","0",",","1",",","2",",","1",",","2",",","3",",","4","]",",","[","0",",","0",",","0",",","1",",","1",",","1",",","1","]",",","]",")","Args",":","x","(","torch.Tensor",",","optional",")",":","Node","feature","matrix","with","shape",":","obj",":","`","[","num_nodes",",","num_node_features","]","`",".","(","default",":",":","obj",":","`","None","`",")","edge_index","(","LongTensor",",","optional",")",":","Hyperedge","tensor","with","shape",":","obj",":","`","[","2",",","num_edges","*","num_nodes_per_edge","]","`",".","Where","`","edge_index","[","1","]","`","denotes","the","hyperedge","index","and","`","edge_index","[","0","]","`","denotes","the","node","indicies","that","are","connected","by","the","hyperedge",".","(","default",":",":","obj",":","`","None","`",")","(","default",":",":","obj",":","`","None","`",")","edge_attr","(","torch.Tensor",",","optional",")",":","Edge","feature","matrix","with","shape",":","obj",":","`","[","num_edges",",","num_edge_features","]","`",".","(","default",":",":","obj",":","`","None","`",")","y","(","torch.Tensor",",","optional",")",":","Graph-level","or","node-level","ground-truth","labels","with","arbitrary","shape",".","(","default",":",":","obj",":","`","None","`",")","pos","(","torch.Tensor",",","optional",")",":","Node","position","matrix","with","shape",":","obj",":","`","[","num_nodes",",","num_dimensions","]","`",".","(","default",":",":","obj",":","`","None","`",")","*","*","kwargs","(","optional",")",":","Additional","attributes","."]
docstr: Returns the induced subgraph given by the node indices
  :obj:`subset`.
  
  .. note::
  
      If only a subset of a hyperedge's nodes are to be
      selected in the subgraph, the hyperedge will remain in the
      subgraph, but only the selected nodes will be connected by
      the hyperedge. Hyperedges that only connects one node in the
      subgraph will be removed.
  
  Examples:
      >>> x = torch.randn(4, 16)
      >>> edge_index = torch.tensor([
      ...     [0, 1, 0, 2, 1, 1, 2, 4],
      ...     [0, 0, 1, 1, 1, 2, 2, 2]
      >>> ])
      >>> data = HyperGraphData(x = x, edge_index = edge_index)
      >>> subset = torch.tensor([1, 2, 4])
      >>> subgraph = data.subgraph(subset)
      >>> subgraph.edge_index
      tensor([[2, 1, 1, 2, 4],
      [0, 0, 1, 1, 1]])
  
  Args:
      subset (LongTensor or BoolTensor): The nodes to keep.
docstr_tok: ["Returns","the","induced","subgraph","given","by","the","node","indices",":","obj",":","`","subset","`",".","..","note",":",":","If","only","a","subset","of","a","hyperedge","'s","nodes","are","to","be","selected","in","the","subgraph",",","the","hyperedge","will","remain","in","the","subgraph",",","but","only","the","selected","nodes","will","be","connected","by","the","hyperedge",".","Hyperedges","that","only","connects","one","node","in","the","subgraph","will","be","removed",".","Examples",":",">",">",">","x","=","torch.randn","(","4",",","16",")",">",">",">","edge_index","=","torch.tensor","(","[","...","[","0",",","1",",","0",",","2",",","1",",","1",",","2",",","4","]",",","...","[","0",",","0",",","1",",","1",",","1",",","2",",","2",",","2","]",">",">",">","]",")",">",">",">","data","=","HyperGraphData","(","x","=","x",",","edge_index","=","edge_index",")",">",">",">","subset","=","torch.tensor","(","[","1",",","2",",","4","]",")",">",">",">","subgraph","=","data.subgraph","(","subset",")",">",">",">","subgraph.edge_index","tensor","(","[","[","2",",","1",",","1",",","2",",","4","]",",","[","0",",","0",",","1",",","1",",","1","]","]",")","Args",":","subset","(","LongTensor","or","BoolTensor",")",":","The","nodes","to","keep","."]
code: def subgraph(self, subset: Tensor) -> "HyperGraphData":
      r"""Returns the induced subgraph given by the node indices
      :obj:`subset`.
  
      .. note::
  
          If only a subset of a hyperedge's nodes are to be
          selected in the subgraph, the hyperedge will remain in the
          subgraph, but only the selected nodes will be connected by
          the hyperedge. Hyperedges that only connects one node in the
          subgraph will be removed.
  
      Examples:
          >>> x = torch.randn(4, 16)
          >>> edge_index = torch.tensor([
          ...     [0, 1, 0, 2, 1, 1, 2, 4],
          ...     [0, 0, 1, 1, 1, 2, 2, 2]
          >>> ])
          >>> data = HyperGraphData(x = x, edge_index = edge_index)
          >>> subset = torch.tensor([1, 2, 4])
          >>> subgraph = data.subgraph(subset)
          >>> subgraph.edge_index
          tensor([[2, 1, 1, 2, 4],
          [0, 0, 1, 1, 1]])
  
      Args:
          subset (LongTensor or BoolTensor): The nodes to keep.
      """
      assert self.edge_index is not None
      out = hyper_subgraph(
          subset,
          self.edge_index,
          relabel_nodes=True,
          num_nodes=self.num_nodes,
          return_edge_mask=True,
      )
      edge_index, _, edge_mask = out
  
      data = copy.copy(self)
  
      for key, value in self.items():
          if key == "edge_index":
              data.edge_index = edge_index
          elif key == "num_nodes":
              if subset.dtype == torch.bool:
                  data.num_nodes = int(subset.sum())
              else:
                  data.num_nodes = subset.size(0)
          elif self.is_node_attr(key):
              cat_dim = self.__cat_dim__(key, value)
              data[key] = select(value, subset, dim=cat_dim)
          elif self.is_edge_attr(key):
              cat_dim = self.__cat_dim__(key, value)
              data[key] = select(value, edge_mask, dim=cat_dim)
  
      return data
  
imports: import copy
  import warnings
  from typing import Any, List, Optional
  import torch
  from torch import Tensor
  from typing_extensions import Self
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.typing import EdgeType, NodeType, OptTensor
  from torch_geometric.utils import select
  from torch_geometric.utils._subgraph import hyper_subgraph
label_desc: Use image node_id 7 for calling the HyperGraphData obj's underlying member method code with example usage: obj.subgraph(subset) and returns: data