code: def test_add_remaining_self_loops():
      assert str(AddRemainingSelfLoops()) == "AddRemainingSelfLoops()"
  
      assert len(AddRemainingSelfLoops()(Data())) == 0
  
      # No self-loops in `edge_index`.
      edge_index = torch.tensor([[0, 1, 1, 2], [1, 0, 2, 1]])
      edge_weight = torch.tensor([1, 2, 3, 4])
      edge_attr = torch.tensor([[1, 2], [3, 4], [5, 6], [7, 8]])
  
      data = Data(edge_index=edge_index, num_nodes=3)
      data = AddRemainingSelfLoops()(data)
      assert len(data) == 2
      assert data.edge_index.tolist() == [
          [0, 1, 1, 2, 0, 1, 2],
          [1, 0, 2, 1, 0, 1, 2],
      ]
      assert data.num_nodes == 3
  
      # Single self-loop in `edge_index`.
      edge_index = torch.tensor([[0, 0, 1, 2], [1, 0, 2, 1]])
      data = Data(edge_index=edge_index, num_nodes=3)
      data = AddRemainingSelfLoops()(data)
      assert len(data) == 2
      assert data.edge_index.tolist() == [
          [0, 1, 2, 0, 1, 2],
          [1, 2, 1, 0, 1, 2],
      ]
      assert data.num_nodes == 3
  
      data = Data(
          edge_index=edge_index, edge_weight=edge_weight, num_nodes=3
      )
      data = AddRemainingSelfLoops(attr="edge_weight", fill_value=5)(
          data
      )
      assert data.edge_index.tolist() == [
          [0, 1, 2, 0, 1, 2],
          [1, 2, 1, 0, 1, 2],
      ]
      assert data.num_nodes == 3
      assert data.edge_weight.tolist() == [1, 3, 4, 2, 5, 5]
  
      data = Data(
          edge_index=edge_index, edge_attr=edge_attr, num_nodes=3
      )
      data = AddRemainingSelfLoops(attr="edge_attr", fill_value="add")(
          data
      )
      assert data.edge_index.tolist() == [
          [0, 1, 2, 0, 1, 2],
          [1, 2, 1, 0, 1, 2],
      ]
      assert data.num_nodes == 3
      assert data.edge_attr.tolist() == [
          [1, 2],
          [5, 6],
          [7, 8],
          [3, 4],
          [8, 10],
          [5, 6],
      ]
  
imports: import torch
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.transforms import AddRemainingSelfLoops
label_desc: Use image node_id 1 for calling a global function with example usage: test_add_remaining_self_loops() without return types