code: def test_SubgraphSampler_Random_Hetero_Graph(sampler_type, replace):
      _check_sampler_type(sampler_type)
      if F._default_context_str == "gpu" and replace == True:
          pytest.skip(
              "Sampling with replacement not yet supported on GPU."
          )
      num_nodes = 5
      num_edges = 9
      num_ntypes = 3
      num_etypes = 3
      (
          csc_indptr,
          indices,
          node_type_offset,
          type_per_edge,
          node_type_to_id,
          edge_type_to_id,
      ) = gb_test_utils.random_hetero_graph(
          num_nodes, num_edges, num_ntypes, num_etypes
      )
      node_attributes = {}
      edge_attributes = {
          "A1": torch.randn(num_edges),
          "A2": torch.randn(num_edges),
      }
      if sampler_type == SamplerType.Temporal:
          node_attributes["timestamp"] = torch.randint(
              0, 10, (num_nodes,)
          )
          edge_attributes["timestamp"] = torch.randint(
              0, 10, (num_edges,)
          )
      graph = gb.fused_csc_sampling_graph(
          csc_indptr,
          indices,
          node_type_offset=node_type_offset,
          type_per_edge=type_per_edge,
          node_type_to_id=node_type_to_id,
          edge_type_to_id=edge_type_to_id,
          node_attributes=node_attributes,
          edge_attributes=edge_attributes,
      ).to(F.ctx())
      first_items = torch.tensor([0])
      first_names = "seed_nodes"
      second_items = torch.tensor([0])
      second_names = "seed_nodes"
      if sampler_type == SamplerType.Temporal:
          first_items = (first_items, torch.randint(0, 10, (1,)))
          first_names = (first_names, "timestamp")
          second_items = (second_items, torch.randint(0, 10, (1,)))
          second_names = (second_names, "timestamp")
      itemset = gb.ItemSetDict(
          {
              "n2": gb.ItemSet(first_items, names=first_names),
              "n1": gb.ItemSet(second_items, names=second_names),
          }
      )
  
      item_sampler = gb.ItemSampler(itemset, batch_size=2).copy_to(
          F.ctx()
      )
      num_layer = 2
      fanouts = [torch.LongTensor([2]) for _ in range(num_layer)]
      sampler = _get_sampler(sampler_type)
  
      sampler_dp = sampler(
          item_sampler, graph, fanouts, replace=replace
      )
  
      for data in sampler_dp:
          for sampledsubgraph in data.sampled_subgraphs:
              for _, value in sampledsubgraph.sampled_csc.items():
                  assert torch.equal(
                      torch.ge(
                          value.indices,
                          torch.zeros(len(value.indices)).to(F.ctx()),
                      ),
                      torch.ones(len(value.indices)).to(F.ctx()),
                  )
                  assert torch.equal(
                      torch.ge(
                          value.indptr,
                          torch.zeros(len(value.indptr)).to(F.ctx()),
                      ),
                      torch.ones(len(value.indptr)).to(F.ctx()),
                  )
              for (
                  _,
                  value,
              ) in sampledsubgraph.original_column_node_ids.items():
                  assert torch.equal(
                      torch.ge(
                          value, torch.zeros(len(value)).to(F.ctx())
                      ),
                      torch.ones(len(value)).to(F.ctx()),
                  )
              for (
                  _,
                  value,
              ) in sampledsubgraph.original_row_node_ids.items():
                  assert torch.equal(
                      torch.ge(
                          value, torch.zeros(len(value)).to(F.ctx())
                      ),
                      torch.ones(len(value)).to(F.ctx()),
                  )
  
imports: import unittest
  from enum import Enum
  from functools import partial
  import backend
  import dgl
  import dgl.graphbolt
  import pytest
  import torch
  from torchdata.datapipes.iter import Mapper
  from .None import gb_test_utils
label_desc: Use image node_id 16 for calling a global function with example usage: test_SubgraphSampler_Random_Hetero_Graph(sampler_type, replace) without return types