code: def matrix_rank(
      x: Array, /, *, rtol: Optional[Union[float, Array]] = None
  ) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.matrix_rank <numpy.matrix_rank>`.
  
      See its docstring for more information.
      """
      # Note: this is different from np.linalg.matrix_rank, which supports 1
      # dimensional arrays.
      if x.ndim < 2:
          raise np.linalg.LinAlgError(
              "1-dimensional array given. Array must be at least two-dimensional"
          )
      S = np.linalg.svd(x._array, compute_uv=False)
      if rtol is None:
          tol = (
              S.max(axis=-1, keepdims=True)
              * max(x.shape[-2:])
              * np.finfo(S.dtype).eps
          )
      else:
          if isinstance(rtol, Array):
              rtol = rtol._array
          # Note: this is different from np.linalg.matrix_rank, which does not multiply
          # the tolerance by the largest singular value.
          tol = (
              S.max(axis=-1, keepdims=True)
              * np.asarray(rtol)[..., np.newaxis]
          )
      return Array._new(np.count_nonzero(S > tol, axis=-1))
  
imports: from __future__ import annotations
  import functools
  from ._dtypes import _floating_dtypes, _numeric_dtypes
  from ._manipulation_functions import reshape
  from ._array_object import Array
  from .._core.internal import _normalize_axis_indices
  from typing import TYPE_CHECKING
  from typing import NamedTuple
  import cupy
label_desc: Use image node_id 11 for calling a global function with example usage: matrix_rank() and returns: Array