code: def check_sort(spm, tag_arr=None, tag_pos=None):
      if tag_arr is None:
          tag_arr = np.arange(spm.shape[0])
      else:
          tag_arr = F.asnumpy(tag_arr)
      if tag_pos is not None:
          tag_pos = F.asnumpy(tag_pos)
      for i in range(spm.shape[0]):
          row = spm.getrow(i)
          dst = row.nonzero()[1]
          if tag_pos is not None:
              tag_pos_row = tag_pos[i]
              tag_pos_ptr = tag_arr[dst[0]] if len(dst) > 0 else 0
          for j in range(len(dst) - 1):
              if tag_pos is not None and tag_arr[dst[j]] != tag_pos_ptr:
                  # `tag_pos_ptr` is the expected tag value. Here we check whether the
                  # tag value is equal to `tag_pos_ptr`
                  return False
              if tag_arr[dst[j]] > tag_arr[dst[j + 1]]:
                  # The tag should be in ascending order after sorting
                  return False
              if (
                  tag_pos is not None
                  and tag_arr[dst[j]] < tag_arr[dst[j + 1]]
              ):
                  if j + 1 != int(tag_pos_row[tag_pos_ptr + 1]):
                      # The boundary of tag should be consistent with `tag_pos`
                      return False
                  tag_pos_ptr = tag_arr[dst[j + 1]]
      return True
  
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 2 for calling a global function with example usage: check_sort(spm, tag_arr, tag_pos) and returns: True, False, False, False