code: def lu(a, permute_l=False, overwrite_a=False, check_finite=True):
      """LU decomposition.
  
      Decomposes a given two-dimensional matrix into ``P @ L @ U``, where ``P``
      is a permutation matrix, ``L`` is a lower triangular or trapezoidal matrix
      with unit diagonal, and ``U`` is a upper triangular or trapezoidal matrix.
  
      Args:
          a (cupy.ndarray): The input matrix with dimension ``(M, N)``.
          permute_l (bool): If ``True``, perform the multiplication ``P @ L``.
          overwrite_a (bool): Allow overwriting data in ``a`` (may enhance
              performance)
          check_finite (bool): Whether to check that the input matrices contain
              only finite numbers. Disabling may give a performance gain, but may
              result in problems (crashes, non-termination) if the inputs do
              contain infinities or NaNs.
  
      Returns:
          tuple:
              ``(P, L, U)`` if ``permute_l == False``, otherwise ``(PL, U)``.
              ``P`` is a :class:`cupy.ndarray` storing permutation matrix with
              dimension ``(M, M)``. ``L`` is a :class:`cupy.ndarray` storing
              lower triangular or trapezoidal matrix with unit diagonal with
              dimension ``(M, K)`` where ``K = min(M, N)``. ``U`` is a
              :class:`cupy.ndarray` storing upper triangular or trapezoidal
              matrix with dimension ``(K, N)``. ``PL`` is a :class:`cupy.ndarray`
              storing permuted ``L`` matrix with dimension ``(M, K)``.
  
      .. seealso:: :func:`scipy.linalg.lu`
      """
      lu, piv = _lu_factor(a, overwrite_a, check_finite)
  
      m, n = lu.shape
      k = min(m, n)
      L, U = _cupy_split_lu(lu)
  
      if permute_l:
          _cupy_laswp(L, 0, k - 1, piv, -1)
          return (L, U)
      else:
          r_dtype = (
              numpy.float32 if lu.dtype.char in "fF" else numpy.float64
          )
          P = cupy.diag(cupy.ones((m,), dtype=r_dtype))
          _cupy_laswp(P, 0, k - 1, piv, -1)
          return (P, L, U)
  
file_path: cupy/cupyx/scipy/linalg/_decomp_lu.py
imports: from warnings import warn
  import numpy
  import cupy
  from cupy.cuda import cublas
  from cupy.cuda import device
  from cupy.cuda import runtime
  from cupy.linalg import _util
  from cupyx.scipy.linalg import _uarray
label_desc: Use image node_id 2 for calling a global function with example usage: lu(a, permute_l, overwrite_a, check_finite) and returns: L,  U, P,  L,  U