code: def test_data_subgraph():
      x = torch.arange(5)
      y = torch.tensor([0.0])
      edge_index = torch.tensor(
          [[0, 1, 1, 2, 2, 3, 3, 4], [1, 0, 2, 1, 3, 2, 4, 3]]
      )
      edge_weight = torch.arange(edge_index.size(1))
  
      data = Data(
          x=x,
          y=y,
          edge_index=edge_index,
          edge_weight=edge_weight,
          num_nodes=5,
      )
  
      out = data.subgraph(torch.tensor([1, 2, 3]))
      assert len(out) == 5
      assert torch.equal(out.x, torch.arange(1, 4))
      assert torch.equal(out.y, data.y)
      assert out.edge_index.tolist() == [[0, 1, 1, 2], [1, 0, 2, 1]]
      assert torch.equal(
          out.edge_weight, edge_weight[torch.arange(2, 6)]
      )
      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() == [[1, 2, 2, 0], [2, 1, 0, 2]]
      assert torch.equal(
          out.edge_weight, edge_weight[torch.arange(2, 6)]
      )
      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], [1, 0]]
      assert torch.equal(
          out.edge_weight, edge_weight[torch.arange(6, 8)]
      )
      assert out.num_nodes == 2
  
      out = data.edge_subgraph(torch.tensor([1, 2, 3]))
      assert len(out) == 5
      assert out.num_nodes == data.num_nodes
      assert torch.equal(out.x, data.x)
      assert torch.equal(out.y, data.y)
      assert out.edge_index.tolist() == [[1, 1, 2], [0, 2, 1]]
      assert torch.equal(
          out.edge_weight, edge_weight[torch.tensor([1, 2, 3])]
      )
  
      out = data.edge_subgraph(
          torch.tensor(
              [False, True, True, True, False, False, False, False]
          )
      )
      assert len(out) == 5
      assert out.num_nodes == data.num_nodes
      assert torch.equal(out.x, data.x)
      assert torch.equal(out.y, data.y)
      assert out.edge_index.tolist() == [[1, 1, 2], [0, 2, 1]]
      assert torch.equal(
          out.edge_weight, edge_weight[torch.tensor([1, 2, 3])]
      )
  
imports: import copy
  import pytest
  import torch
  import torch.multiprocessing
  import torch_geometric
  from torch_geometric.data import Data
  from torch_geometric.data.storage import AttrType
  from torch_geometric.testing import get_random_tensor_frame, withPackage
label_desc: Use image node_id 4 for calling a global function with example usage: test_data_subgraph() without return types