code: def test_subgraph_mask(idtype):
      g = create_test_heterograph(idtype)
      g_graph = g["follows"]
      g_bipartite = g["plays"]
  
      x = F.randn((3, 5))
      y = F.randn((2, 4))
      g.nodes["user"].data["h"] = x
      g.edges["follows"].data["h"] = y
  
      def _check_subgraph(g, sg):
          assert sg.idtype == g.idtype
          assert sg.device == g.device
          assert sg.ntypes == g.ntypes
          assert sg.etypes == g.etypes
          assert sg.canonical_etypes == g.canonical_etypes
          assert F.array_equal(
              F.tensor(sg.nodes["user"].data[dgl.NID]),
              F.tensor([1, 2], idtype),
          )
          assert F.array_equal(
              F.tensor(sg.nodes["game"].data[dgl.NID]),
              F.tensor([0], idtype),
          )
          assert F.array_equal(
              F.tensor(sg.edges["follows"].data[dgl.EID]),
              F.tensor([1], idtype),
          )
          assert F.array_equal(
              F.tensor(sg.edges["plays"].data[dgl.EID]),
              F.tensor([1], idtype),
          )
          assert F.array_equal(
              F.tensor(sg.edges["wishes"].data[dgl.EID]),
              F.tensor([1], idtype),
          )
          assert sg.num_nodes("developer") == 0
          assert sg.num_edges("develops") == 0
          assert F.array_equal(
              sg.nodes["user"].data["h"], g.nodes["user"].data["h"][1:3]
          )
          assert F.array_equal(
              sg.edges["follows"].data["h"],
              g.edges["follows"].data["h"][1:2],
          )
  
      sg1 = g.subgraph(
          {
              "user": F.tensor([False, True, True], dtype=F.bool),
              "game": F.tensor(
                  [True, False, False, False], dtype=F.bool
              ),
          }
      )
      _check_subgraph(g, sg1)
      sg2 = g.edge_subgraph(
          {
              "follows": F.tensor([False, True], dtype=F.bool),
              "plays": F.tensor(
                  [False, True, False, False], dtype=F.bool
              ),
              "wishes": F.tensor([False, True], dtype=F.bool),
          }
      )
      _check_subgraph(g, sg2)
  
imports: import unittest
  import backend
  import dgl
  import networkx
  import numpy
  import pytest
  import scipy.sparse
  from utils import parametrize_idtype
label_desc: Use image node_id 7 for calling a global function with example usage: test_subgraph_mask(idtype) without return types