code: def test_hypergraphdata_subgraph():
      x = torch.arange(5)
      y = torch.tensor([0.0])
      edge_index = torch.tensor(
          [
              [0, 1, 3, 2, 4, 0, 3, 4, 2, 1, 2, 3],
              [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3],
          ]
      )
      edge_attr = torch.rand(4, 2)
      data = HyperGraphData(
          x=x,
          y=y,
          edge_index=edge_index,
          edge_attr=edge_attr,
          num_nodes=5,
      )
  
      out = data.subgraph(torch.tensor([1, 2, 4]))
      assert len(out) == 5
      assert torch.equal(out.x, torch.tensor([1, 2, 4]))
      assert torch.equal(out.y, data.y)
      assert out.edge_index.tolist() == [
          [1, 2, 2, 1, 0, 1],
          [0, 0, 1, 1, 2, 2],
      ]
      assert torch.equal(out.edge_attr, edge_attr[[1, 2, 3]])
      assert out.num_nodes == 3
  
      # Test unordered selection:
      out = data.subgraph(torch.tensor([3, 1, 2]))
      assert len(out) == 5
      assert torch.equal(out.x, torch.tensor([3, 1, 2]))
      assert torch.equal(out.y, data.y)
      assert out.edge_index.tolist() == [
          [0, 2, 0, 2, 1, 2, 0],
          [0, 0, 1, 1, 2, 2, 2],
      ]
      assert torch.equal(out.edge_attr, edge_attr[[1, 2, 3]])
      assert out.num_nodes == 3
  
      out = data.subgraph(
          torch.tensor([False, False, False, True, True])
      )
      assert len(out) == 5
      assert torch.equal(out.x, torch.arange(3, 5))
      assert torch.equal(out.y, data.y)
      assert out.edge_index.tolist() == [[0, 1, 0, 1], [0, 0, 1, 1]]
      assert torch.equal(out.edge_attr, edge_attr[[1, 2]])
      assert out.num_nodes == 2
  
imports: import pytest
  import torch
  import torch_geometric
  from torch_geometric.data.hypergraph_data import HyperGraphData
  from torch_geometric.loader import DataLoader
label_desc: Use image node_id 2 for calling a global function with example usage: test_hypergraphdata_subgraph() without return types