code: def eval_evec(
      symmetric,
      d,
      typ,
      k,
      which,
      v0=None,
      sigma=None,
      mattype=np.asarray,
      OPpart=None,
      mode="normal",
  ):
      general = "bmat" in d
  
      if symmetric:
          eigs_func = eigsh
      else:
          eigs_func = eigs
  
      if general:
          err = (
              "error for %s:general, typ=%s, which=%s, sigma=%s, "
              "mattype=%s, OPpart=%s, mode=%s"
              % (
                  eigs_func.__name__,
                  typ,
                  which,
                  sigma,
                  mattype.__name__,
                  OPpart,
                  mode,
              )
          )
      else:
          err = (
              "error for %s:standard, typ=%s, which=%s, sigma=%s, "
              "mattype=%s, OPpart=%s, mode=%s"
              % (
                  eigs_func.__name__,
                  typ,
                  which,
                  sigma,
                  mattype.__name__,
                  OPpart,
                  mode,
              )
          )
  
      a = d["mat"].astype(typ)
      ac = mattype(a)
  
      if general:
          b = d["bmat"].astype(typ)
          bc = mattype(b)
  
      # get exact eigenvalues
      exact_eval = d["eval"].astype(typ.upper())
      ind = argsort_which(
          exact_eval, typ, k, which, sigma, OPpart, mode
      )
      exact_eval = exact_eval[ind]
  
      # compute arpack eigenvalues
      kwargs = dict(which=which, v0=v0, sigma=sigma)
      if eigs_func is eigsh:
          kwargs["mode"] = mode
      else:
          kwargs["OPpart"] = OPpart
  
      # compute suitable tolerances
      kwargs["tol"], rtol, atol = _get_test_tolerance(typ, mattype)
  
      # on rare occasions, ARPACK routines return results that are proper
      # eigenvalues and -vectors, but not necessarily the ones requested in
      # the parameter which. This is inherent to the Krylov methods, and
      # should not be treated as a failure. If such a rare situation
      # occurs, the calculation is tried again (but at most a few times).
      ntries = 0
      while ntries < 5:
          # solve
          if general:
              try:
                  eval, evec = eigs_func(ac, k, bc, **kwargs)
              except ArpackNoConvergence:
                  kwargs["maxiter"] = 20 * a.shape[0]
                  eval, evec = eigs_func(ac, k, bc, **kwargs)
          else:
              try:
                  eval, evec = eigs_func(ac, k, **kwargs)
              except ArpackNoConvergence:
                  kwargs["maxiter"] = 20 * a.shape[0]
                  eval, evec = eigs_func(ac, k, **kwargs)
  
          ind = argsort_which(eval, typ, k, which, sigma, OPpart, mode)
          eval = eval[ind]
          evec = evec[:, ind]
  
          # check eigenvectors
          LHS = np.dot(a, evec)
          if general:
              RHS = eval * np.dot(b, evec)
          else:
              RHS = eval * evec
  
              assert_allclose(
                  LHS, RHS, rtol=rtol, atol=atol, err_msg=err
              )
  
          try:
              # check eigenvalues
              assert_allclose_cc(
                  eval, exact_eval, rtol=rtol, atol=atol, err_msg=err
              )
              break
          except AssertionError:
              ntries += 1
  
      # check eigenvalues
      assert_allclose_cc(
          eval, exact_eval, rtol=rtol, atol=atol, err_msg=err
      )
  
imports: from __future__ import division, print_function, absolute_import
  import threading
  import itertools
  import numpy
  from numpy.testing import assert_allclose, assert_array_almost_equal_nulp, assert_equal, assert_array_equal
  from pytest import raises
  import pytest
  from numpy import dot, conj, random
  from scipy.linalg import eig, eigh, hilbert, svd
  from scipy.sparse import csc_matrix, csr_matrix, isspmatrix, diags, rand
  from scipy.sparse.linalg import LinearOperator, aslinearoperator
  from scipy.sparse.linalg.eigen.arpack import eigs, eigsh, svds, ArpackNoConvergence, arpack
  from scipy._lib._gcutils import assert_deallocated, IS_PYPY
  from scipy._lib._numpy_compat import suppress_warnings
label_desc: Use image node_id 7 for calling a global function with example usage: eval_evec(symmetric, d, typ, k, which, v0, sigma, mattype, OPpart, mode) without return types