code: def test_mask_to_index():
      assert (
          str(MaskToIndex()) == "MaskToIndex(attrs=None, replace=False)"
      )
  
      train_mask = torch.tensor([True, True, True, False, False])
      test_mask = torch.tensor([False, False, False, True, True])
      data = Data(train_mask=train_mask, test_mask=test_mask)
  
      out = MaskToIndex(replace=True)(data)
      assert len(out) == len(data)
      assert out.train_index.tolist() == [0, 1, 2]
      assert out.test_index.tolist() == [3, 4]
  
      out = MaskToIndex(replace=False)(data)
      assert len(out) == len(data) + 2
  
      out = MaskToIndex(attrs="train_mask")(data)
      assert len(out) == len(data) + 1
      assert "train_mask" in out
      assert "train_index" in out
      assert "test_mask" in out
      assert "test_index" not in out
  
imports: import torch
  from torch_geometric.data import Data, HeteroData
  from torch_geometric.transforms import IndexToMask, MaskToIndex
label_desc: Use image node_id 2 for calling a global function with example usage: test_mask_to_index() without return types