code: def _eigsh_solve_ritz(alpha, beta, beta_k, k, which):
      # Note: This is done on the CPU, because there is an issue in
      # cupy.linalg.eigh with CUDA 9.2, which can return NaNs. It will has little
      # impact on performance, since the matrix size processed here is not large.
      alpha = cupy.asnumpy(alpha)
      beta = cupy.asnumpy(beta)
      t = numpy.diag(alpha)
      t = t + numpy.diag(beta[:-1], k=1)
      t = t + numpy.diag(beta[:-1], k=-1)
      if beta_k is not None:
          beta_k = cupy.asnumpy(beta_k)
          t[k, :k] = beta_k
          t[:k, k] = beta_k
      w, s = numpy.linalg.eigh(t)
  
      # Pick-up k ritz-values and ritz-vectors
      if which == "LA":
          idx = numpy.argsort(w)
          wk = w[idx[-k:]]
          sk = s[:, idx[-k:]]
      elif which == "LM":
          idx = numpy.argsort(numpy.absolute(w))
          wk = w[idx[-k:]]
          sk = s[:, idx[-k:]]
  
      elif which == "SA":
          idx = numpy.argsort(w)
          wk = w[idx[:k]]
          sk = s[:, idx[:k]]
      # elif which == 'SM':  #dysfunctional
      #   idx = cupy.argsort(abs(w))
      #   wk = w[idx[:k]]
      #   sk = s[:,idx[:k]]
      return cupy.array(wk), cupy.array(sk)
  
file_path: cupy/cupyx/scipy/sparse/linalg/_eigen.py
imports: import numpy
  import cupy
  from cupy import cublas
  from cupy._core import _dtype
  from cupy.cuda import device
  from cupy_backends.cuda.libs import cublas
  from cupyx.scipy.sparse import _csr
  from cupyx.scipy.sparse.linalg import _interface
label_desc: Use image node_id 4 for calling a global function with example usage: _eigsh_solve_ritz(alpha, beta, beta_k, k, which) and returns: cupy,  cupy