code: def test_trim_to_layer_hetero():
      x = {"v": torch.arange(4)}
      edge_index = {
          ("v", "to", "v"): torch.tensor([[1, 2, 3], [0, 1, 2]])
      }
      edge_weight = {("v", "to", "v"): torch.arange(3)}
  
      num_sampled_nodes_per_hop = {"v": [1, 1, 1, 1]}
      num_sampled_edges_per_hop = {("v", "to", "v"): [1, 1, 1]}
  
      x, edge_index, edge_weight = trim_to_layer(
          layer=1,
          num_sampled_nodes_per_hop=num_sampled_nodes_per_hop,
          num_sampled_edges_per_hop=num_sampled_edges_per_hop,
          x=x,
          edge_index=edge_index,
          edge_attr=edge_weight,
      )
      assert torch.equal(x["v"], torch.arange(3))
      assert edge_index["v", "to", "v"].tolist() == [[1, 2], [0, 1]]
      assert torch.equal(edge_weight["v", "to", "v"], torch.arange(2))
  
imports: from typing import List, Optional
  import torch
  from torch import Tensor
  import torch_geometric.typing
  from torch_geometric.data import Data
  from torch_geometric.loader import NeighborLoader
  from torch_geometric.nn import GraphConv
  from torch_geometric.testing import withPackage
  from torch_geometric.typing import SparseTensor
  from torch_geometric.utils import trim_to_layer
  from torch_geometric.utils._trim_to_layer import trim_sparse_tensor
label_desc: Use image node_id 3 for calling a global function with example usage: test_trim_to_layer_hetero() without return types