code: def test_hetero_data_functions():
      data = HeteroData()
      with pytest.raises(
          KeyError, match="did not find any occurrences of it"
      ):
          data.collect("x")
      data["paper"].x = x_paper
      data["author"].x = x_author
      data["paper", "paper"].edge_index = edge_index_paper_paper
      data["paper", "author"].edge_index = edge_index_paper_author
      data["author", "paper"].edge_index = edge_index_author_paper
      data["paper", "paper"].edge_attr = edge_attr_paper_paper
      assert len(data) == 3
      assert sorted(data.keys()) == ["edge_attr", "edge_index", "x"]
      assert (
          "x" in data and "edge_index" in data and "edge_attr" in data
      )
      assert data.num_nodes == 15
      assert data.num_edges == 110
  
      assert data.node_attrs() == ["x"]
      assert sorted(data.edge_attrs()) == ["edge_attr", "edge_index"]
  
      assert data.num_node_features == {"paper": 16, "author": 32}
      assert data.num_edge_features == {
          ("paper", "to", "paper"): 8,
          ("paper", "to", "author"): 0,
          ("author", "to", "paper"): 0,
      }
  
      node_types, edge_types = data.metadata()
      assert node_types == ["paper", "author"]
      assert edge_types == [
          ("paper", "to", "paper"),
          ("paper", "to", "author"),
          ("author", "to", "paper"),
      ]
  
      x_dict = data.collect("x")
      assert len(x_dict) == 2
      assert x_dict["paper"].tolist() == x_paper.tolist()
      assert x_dict["author"].tolist() == x_author.tolist()
      assert x_dict == data.x_dict
  
      data.y = 0
      assert data["y"] == 0 and data.y == 0
      assert len(data) == 4
      assert sorted(data.keys()) == [
          "edge_attr",
          "edge_index",
          "x",
          "y",
      ]
  
      del data["paper", "author"]
      node_types, edge_types = data.metadata()
      assert node_types == ["paper", "author"]
      assert edge_types == [
          ("paper", "to", "paper"),
          ("author", "to", "paper"),
      ]
  
      assert len(data.to_dict()) == 5
      assert len(data.to_namedtuple()) == 5
      assert data.to_namedtuple().y == 0
      assert len(data.to_namedtuple().paper) == 1
  
imports: import copy
  import pytest
  import torch
  from torch_geometric.data import HeteroData
  from torch_geometric.data.storage import EdgeStorage
  from torch_geometric.testing import get_random_edge_index, get_random_tensor_frame, withPackage
  from torch_geometric.typing import TensorFrame
label_desc: Use image node_id 3 for calling a global function with example usage: test_hetero_data_functions() without return types