code: def _inv_gpu(b):
      # We do a batched LU decomposition on the GPU to compute the inverse
      # Change the shape of the array to be size=1 minibatch if necessary
      # Also copy the matrix as the elements will be modified in-place
      a = matmul._as_batch_mat(b).copy()
      n = a.shape[1]
      n_matrices = len(a)
      # Pivot array
      p = cuda.cupy.empty((n, n_matrices), dtype=numpy.int32)
      # Output array
      c = cuda.cupy.empty_like(a)
      # These arrays hold information on the execution success
      # or if the matrix was singular
      info = cuda.cupy.empty(n_matrices, dtype=numpy.int32)
      ap = matmul._mat_ptrs(a)
      cp = matmul._mat_ptrs(c)
      _, lda = matmul._get_ld(a)
      _, ldc = matmul._get_ld(c)
      handle = cuda.Device().cublas_handle
      if b.dtype == numpy.float32:
          cuda.cublas.sgetrfBatched(
              handle,
              n,
              ap.data.ptr,
              lda,
              p.data.ptr,
              info.data.ptr,
              n_matrices,
          )
          cuda.cublas.sgetriBatched(
              handle,
              n,
              ap.data.ptr,
              lda,
              p.data.ptr,
              cp.data.ptr,
              ldc,
              info.data.ptr,
              n_matrices,
          )
      elif b.dtype == numpy.float64:
          cuda.cublas.dgetrfBatched(
              handle,
              n,
              ap.data.ptr,
              lda,
              p.data.ptr,
              info.data.ptr,
              n_matrices,
          )
          cuda.cublas.dgetriBatched(
              handle,
              n,
              ap.data.ptr,
              lda,
              p.data.ptr,
              cp.data.ptr,
              ldc,
              info.data.ptr,
              n_matrices,
          )
      else:
          assert False
      return c, info
  
imports: import numpy.linalg
  import chainer
  from chainer.backends import cuda
  from chainer import function_node
  import chainer.functions
  from chainer.functions.math import matmul
  from chainer import utils
  from chainer.utils import precision
  from chainer.utils import type_check
label_desc: Use image node_id 1 for calling a global function with example usage: _inv_gpu(b) and returns: c,  info