code: def check_metis_partition_with_constraint(g):
      ntypes = np.zeros((g.num_nodes(),), dtype=np.int32)
      ntypes[0 : int(g.num_nodes() / 4)] = 1
      ntypes[int(g.num_nodes() * 3 / 4) :] = 2
      subgs = dgl.transforms.metis_partition(
          g, 4, extra_cached_hops=1, balance_ntypes=ntypes
      )
      if subgs is not None:
          for i in subgs:
              subg = subgs[i]
              parent_nids = F.asnumpy(subg.ndata[dgl.NID])
              sub_ntypes = ntypes[parent_nids]
              print("type0:", np.sum(sub_ntypes == 0))
              print("type1:", np.sum(sub_ntypes == 1))
              print("type2:", np.sum(sub_ntypes == 2))
      subgs = dgl.transforms.metis_partition(
          g,
          4,
          extra_cached_hops=1,
          balance_ntypes=ntypes,
          balance_edges=True,
      )
      if subgs is not None:
          for i in subgs:
              subg = subgs[i]
              parent_nids = F.asnumpy(subg.ndata[dgl.NID])
              sub_ntypes = ntypes[parent_nids]
              print("type0:", np.sum(sub_ntypes == 0))
              print("type1:", np.sum(sub_ntypes == 1))
              print("type2:", np.sum(sub_ntypes == 2))
  
imports: import math
  import os
  import unittest
  import backend
  import dgl
  import dgl.function
  import dgl.partition
  import networkx
  import numpy
  import pytest
  from scipy import sparse
  from utils import parametrize_idtype
  from utils.graph_cases import get_cases
label_desc: Use image node_id 19 for calling a global function with example usage: check_metis_partition_with_constraint(g) without return types