code: def test_sample_neighbors_exclude_edges_heteroG(dtype, fused):
      if fused and (
          F._default_context_str == "gpu" or F.backend_name != "pytorch"
      ):
          pytest.skip(
              "Fused sampling support CPU with backend PyTorch."
          )
      d_i_d_u_nodes = F.zerocopy_from_numpy(
          np.unique(np.random.randint(300, size=100, dtype=dtype))
      )
      d_i_d_v_nodes = F.zerocopy_from_numpy(
          np.random.randint(25, size=d_i_d_u_nodes.shape, dtype=dtype)
      )
      d_i_g_u_nodes = F.zerocopy_from_numpy(
          np.unique(np.random.randint(300, size=100, dtype=dtype))
      )
      d_i_g_v_nodes = F.zerocopy_from_numpy(
          np.random.randint(25, size=d_i_g_u_nodes.shape, dtype=dtype)
      )
      d_t_d_u_nodes = F.zerocopy_from_numpy(
          np.unique(np.random.randint(300, size=100, dtype=dtype))
      )
      d_t_d_v_nodes = F.zerocopy_from_numpy(
          np.random.randint(25, size=d_t_d_u_nodes.shape, dtype=dtype)
      )
  
      g = dgl.heterograph(
          {
              ("drug", "interacts", "drug"): (
                  d_i_d_u_nodes,
                  d_i_d_v_nodes,
              ),
              ("drug", "interacts", "gene"): (
                  d_i_g_u_nodes,
                  d_i_g_v_nodes,
              ),
              ("drug", "treats", "disease"): (
                  d_t_d_u_nodes,
                  d_t_d_v_nodes,
              ),
          }
      ).to(F.ctx())
  
      (U, V, EID) = (0, 1, 2)
  
      nd_b_idx = np.random.randint(low=1, high=24, dtype=dtype)
      nd_e_idx = np.random.randint(low=25, high=49, dtype=dtype)
      did_b_idx = np.random.randint(low=1, high=24, dtype=dtype)
      did_e_idx = np.random.randint(low=25, high=49, dtype=dtype)
      sampled_amount = np.random.randint(low=1, high=10, dtype=dtype)
  
      drug_i_drug_edges = g.all_edges(
          form="all", etype=("drug", "interacts", "drug")
      )
      excluded_d_i_d_edges = drug_i_drug_edges[EID][did_b_idx:did_e_idx]
      sampled_drug_node = drug_i_drug_edges[V][nd_b_idx:nd_e_idx]
      did_excluded_nodes_U = drug_i_drug_edges[U][did_b_idx:did_e_idx]
      did_excluded_nodes_V = drug_i_drug_edges[V][did_b_idx:did_e_idx]
  
      nd_b_idx = np.random.randint(low=1, high=24, dtype=dtype)
      nd_e_idx = np.random.randint(low=25, high=49, dtype=dtype)
      dig_b_idx = np.random.randint(low=1, high=24, dtype=dtype)
      dig_e_idx = np.random.randint(low=25, high=49, dtype=dtype)
      drug_i_gene_edges = g.all_edges(
          form="all", etype=("drug", "interacts", "gene")
      )
      excluded_d_i_g_edges = drug_i_gene_edges[EID][dig_b_idx:dig_e_idx]
      dig_excluded_nodes_U = drug_i_gene_edges[U][dig_b_idx:dig_e_idx]
      dig_excluded_nodes_V = drug_i_gene_edges[V][dig_b_idx:dig_e_idx]
      sampled_gene_node = drug_i_gene_edges[V][nd_b_idx:nd_e_idx]
  
      nd_b_idx = np.random.randint(low=1, high=24, dtype=dtype)
      nd_e_idx = np.random.randint(low=25, high=49, dtype=dtype)
      dtd_b_idx = np.random.randint(low=1, high=24, dtype=dtype)
      dtd_e_idx = np.random.randint(low=25, high=49, dtype=dtype)
      drug_t_dis_edges = g.all_edges(
          form="all", etype=("drug", "treats", "disease")
      )
      excluded_d_t_d_edges = drug_t_dis_edges[EID][dtd_b_idx:dtd_e_idx]
      dtd_excluded_nodes_U = drug_t_dis_edges[U][dtd_b_idx:dtd_e_idx]
      dtd_excluded_nodes_V = drug_t_dis_edges[V][dtd_b_idx:dtd_e_idx]
      sampled_disease_node = drug_t_dis_edges[V][nd_b_idx:nd_e_idx]
      excluded_edges = {
          ("drug", "interacts", "drug"): excluded_d_i_d_edges,
          ("drug", "interacts", "gene"): excluded_d_i_g_edges,
          ("drug", "treats", "disease"): excluded_d_t_d_edges,
      }
  
      sg = sample_neighbors_fusing_mode[fused](
          g,
          {
              "drug": sampled_drug_node,
              "gene": sampled_gene_node,
              "disease": sampled_disease_node,
          },
          sampled_amount,
          exclude_edges=excluded_edges,
      )
  
      if fused:
  
          def contain_edge(g, sg, etype, u, v):
              # set of subgraph graph edges deduced from original graph
              org_edges = set(
                  map(
                      tuple,
                      np.stack(
                          g.find_edges(
                              sg.edges[etype].data[dgl.EID], etype
                          ),
                          axis=1,
                      ),
                  )
              )
              # set of excluded edges
              excluded_edges = set(map(tuple, np.stack((u, v), axis=1)))
  
              diff_set = org_edges - excluded_edges
  
              return len(diff_set) != len(org_edges)
  
          assert not contain_edge(
              g,
              sg,
              ("drug", "interacts", "drug"),
              did_excluded_nodes_U,
              did_excluded_nodes_V,
          )
          assert not contain_edge(
              g,
              sg,
              ("drug", "interacts", "gene"),
              dig_excluded_nodes_U,
              dig_excluded_nodes_V,
          )
          assert not contain_edge(
              g,
              sg,
              ("drug", "treats", "disease"),
              dtd_excluded_nodes_U,
              dtd_excluded_nodes_V,
          )
      else:
          assert not np.any(
              F.asnumpy(
                  sg.has_edges_between(
                      did_excluded_nodes_U,
                      did_excluded_nodes_V,
                      etype=("drug", "interacts", "drug"),
                  )
              )
          )
          assert not np.any(
              F.asnumpy(
                  sg.has_edges_between(
                      dig_excluded_nodes_U,
                      dig_excluded_nodes_V,
                      etype=("drug", "interacts", "gene"),
                  )
              )
          )
          assert not np.any(
              F.asnumpy(
                  sg.has_edges_between(
                      dtd_excluded_nodes_U,
                      dtd_excluded_nodes_V,
                      etype=("drug", "treats", "disease"),
                  )
              )
          )
  
imports: import unittest
  import warnings
  import backend
  import dgl
  import numpy
  import pytest
label_desc: Use image node_id 29 for calling a global function with example usage: test_sample_neighbors_exclude_edges_heteroG(dtype, fused) and returns: unknown