code: def pinv(a, rcond=1e-15):
      """Compute the Moore-Penrose pseudoinverse of a matrix.
  
      It computes a pseudoinverse of a matrix ``a``, which is a generalization
      of the inverse matrix with Singular Value Decomposition (SVD).
      Note that it automatically removes small singular values for stability.
  
      Args:
          a (cupy.ndarray): The matrix with dimension ``(..., M, N)``
          rcond (float or cupy.ndarray): Cutoff parameter for small singular
              values. For stability it computes the largest singular value
              denoted by ``s``, and sets all singular values smaller than
              ``rcond * s`` to zero. Broadcasts against the stack of matrices.
  
      Returns:
          cupy.ndarray: The pseudoinverse of ``a`` with dimension
          ``(..., N, M)``.
  
      .. warning::
          This function calls one or more cuSOLVER routine(s) which may yield
          invalid results if input conditions are not met.
          To detect these invalid results, you can set the `linalg`
          configuration to a value that is not `ignore` in
          :func:`cupyx.errstate` or :func:`cupyx.seterr`.
  
      .. seealso:: :func:`numpy.linalg.pinv`
      """
      _util._assert_cupy_array(a)
      if a.size == 0:
          _, out_dtype = _util.linalg_common_type(a)
          m, n = a.shape[-2:]
          if m == 0 or n == 0:
              out_dtype = a.dtype  # NumPy bug?
          return cupy.empty(a.shape[:-2] + (n, m), dtype=out_dtype)
  
      u, s, vt = _decomposition.svd(a.conj(), full_matrices=False)
  
      # discard small singular values
      cutoff = rcond * cupy.amax(s, axis=-1)
      leq = s <= cutoff[..., None]
      cupy.reciprocal(s, out=s)
      s[leq] = 0
  
      return cupy.matmul(
          vt.swapaxes(-2, -1), s[..., None] * u.swapaxes(-2, -1)
      )
  
file_path: cupy/cupy/linalg/_solve.py
imports: import warnings
  import numpy
  from numpy import linalg
  import cupy
  from cupy._core import internal
  from cupy.cuda import device
  from cupy.linalg import _decomposition
  from cupy.linalg import _util
  import cupyx
label_desc: Use image node_id 7 for calling a global function with example usage: pinv(a, rcond) and returns: cupy, cupy