code: def check_monotonicity(matrix: np.ndarray) -> bool:
      """Check if alignment is monotonous - i.e. the relative order is preserved (no swaps).
  
      Args:
          matrix: a numpy array of shape (src_len, dst_len) filled with [0, 1, 2, 3], where 3 means a reliable alignment
           the corresponding words were aligned to one another in direct and reverse alignment runs, 1 and 2 mean that the
           words were aligned only in one direction, 0 - no alignment.
      """
      is_sorted = lambda k: np.all(k[:-1] <= k[1:])
  
      a = np.argwhere(matrix == 3)
      b = np.argwhere(matrix == 2)
      c = np.vstack((a, b))
      d = c[c[:, 1].argsort()]  # sort by second column (less important)
      d = d[d[:, 0].argsort(kind="mergesort")]
      return is_sorted(d[:, 1])
  
file_path: NeMo/nemo/collections/nlp/data/text_normalization_as_tagging/utils.py
imports: import re
  from itertools import groupby
  from typing import Dict, List, Tuple
  import numpy
label_desc: Use image node_id 9 for calling a global function with example usage: check_monotonicity(matrix) and returns: is_sorted