code: def matrix_rank(M: ArrayLike, tol: ArrayLike | None = None) -> Array:
      check_arraylike("jnp.linalg.matrix_rank", M)
      (M,) = promote_dtypes_inexact(jnp.asarray(M))
      if M.ndim < 2:
          return (M != 0).any().astype(jnp.int32)
      S = svd(M, full_matrices=False, compute_uv=False)
      if tol is None:
          tol = (
              S.max(-1)
              * np.max(M.shape[-2:]).astype(S.dtype)
              * jnp.finfo(S.dtype).eps
          )
      tol = jnp.expand_dims(tol, np.ndim(tol))
      return reductions.sum(S > tol, axis=-1)
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  from functools import partial
  import numpy
  import textwrap
  import operator
  from typing import Literal, cast, overload
  import jax
  from jax import jit, custom_jvp
  from jax import lax
  from jax._src.lax import lax
  from jax._src.lax import linalg
  from jax._src.numpy import lax_numpy
  from jax._src.numpy import reductions, ufuncs
  from jax._src.numpy.util import _wraps, promote_dtypes_inexact, check_arraylike
  from jax._src.util import canonicalize_axis
  from jax._src.typing import ArrayLike, Array
label_desc: Use image node_id 11 for calling a global function with example usage: matrix_rank(M, tol) and returns: reductions, unknown