code: def _qr_batched(a, mode):
      from cupyx.cusolver import _geqrf_orgqr_batched
  
      batch_shape = a.shape[:-2]
      batch_size = internal.prod(batch_shape)
      m, n = a.shape[-2:]
      k = min(m, n)
  
      # first handle any 0-size inputs
      if batch_size == 0 or k == 0:
          # support float32, float64, complex64, and complex128
          dtype, out_dtype = _util.linalg_common_type(a)
  
          if mode == "reduced":
              return (
                  cupy.empty(batch_shape + (m, k), out_dtype),
                  cupy.empty(batch_shape + (k, n), out_dtype),
              )
          elif mode == "complete":
              q = _util.stacked_identity(batch_shape, m, out_dtype)
              return (q, cupy.empty(batch_shape + (m, n), out_dtype))
          elif mode == "r":
              return cupy.empty(batch_shape + (k, n), out_dtype)
          elif mode == "raw":
              return (
                  cupy.empty(batch_shape + (n, m), out_dtype),
                  cupy.empty(batch_shape + (k,), out_dtype),
              )
  
      # ...then delegate real computation to cuSOLVER/rocSOLVER
      a = a.reshape(-1, *(a.shape[-2:]))
      out = _geqrf_orgqr_batched(a, mode)
  
      if mode == "r":
          return out.reshape(batch_shape + out.shape[-2:])
      q, r = out
      q = q.reshape(batch_shape + q.shape[-2:])
      idx = -1 if mode == "raw" else -2
      r = r.reshape(batch_shape + r.shape[idx:])
      return (q, r)
  
file_path: cupy/cupy/linalg/_decomposition.py
imports: import numpy
  import cupy
  from cupy_backends.cuda.api import runtime
  from cupy._core import internal
  from cupy.cuda import device
  from cupy.linalg import _util
label_desc: Use image node_id 4 for calling a global function with example usage: _qr_batched(a, mode) and returns: q,  r, out, cupy,  cupy, q,  cupy, cupy, cupy,  cupy