code: def test_sort_with_tag(idtype):
      num_nodes, num_adj, num_tags = 200, [20, 50], 5
      g = create_test_heterograph(num_nodes, num_adj, idtype=idtype)
      tag = F.tensor(np.random.choice(num_tags, g.num_nodes()))
      src, dst = g.edges()
      edge_tag_dst = F.gather_row(tag, F.tensor(dst))
      edge_tag_src = F.gather_row(tag, F.tensor(src))
  
      for tag_type in ["node", "edge"]:
          new_g = dgl.sort_csr_by_tag(
              g,
              tag if tag_type == "node" else edge_tag_dst,
              tag_type=tag_type,
          )
          old_csr = g.adj_external(scipy_fmt="csr")
          new_csr = new_g.adj_external(scipy_fmt="csr")
          assert check_sort(new_csr, tag, new_g.dstdata["_TAG_OFFSET"])
          assert not check_sort(
              old_csr, tag
          )  # Check the original csr is not modified.
  
      for tag_type in ["node", "edge"]:
          new_g = dgl.sort_csc_by_tag(
              g,
              tag if tag_type == "node" else edge_tag_src,
              tag_type=tag_type,
          )
          old_csc = g.adj_external(transpose=True, scipy_fmt="csr")
          new_csc = new_g.adj_external(transpose=True, scipy_fmt="csr")
          assert check_sort(new_csc, tag, new_g.srcdata["_TAG_OFFSET"])
          assert not check_sort(old_csc, tag)
  
file_path: dgl/tests/python/common/transforms/test_functional-sort.py
imports: import itertools
  import unittest
  from collections import Counter
  import backend
  import dgl
  import dgl.function
  import networkx
  import numpy
  import pytest
  import scipy.sparse
  from dgl import DGLError
  from utils import parametrize_idtype
label_desc: Use image node_id 3 for calling a global function with example usage: test_sort_with_tag(idtype) without return types