code: def rescale_laplacian(L, lmax=None):
      """
      Rescales the Laplacian eigenvalues in [-1,1], using lmax as largest eigenvalue.
      :param L: rank 2 array or sparse matrix;
      :param lmax: if None, compute largest eigenvalue with scipy.linalg.eisgh.
      If the eigendecomposition fails, lmax is set to 2 automatically.
      If scalar, use this value as largest eigenvalue when rescaling.
      :return:
      """
      if lmax is None:
          try:
              if sp.issparse(L):
                  lmax = sp.linalg.eigsh(
                      L, 1, which="LM", return_eigenvectors=False
                  )[0]
              else:
                  n = L.shape[-1]
                  lmax = linalg.eigh(
                      L, eigvals_only=True, eigvals=[n - 2, n - 1]
                  )[-1]
          except ArpackNoConvergence:
              lmax = 2
      if sp.issparse(L):
          I = sp.eye(L.shape[-1], dtype=L.dtype)
      else:
          I = np.eye(L.shape[-1], dtype=L.dtype)
      L_scaled = (2.0 / lmax) * L - I
      return L_scaled
  
imports: import copy
  import warnings
  from functools import partial
  import numpy
  import tensorflow
  from scipy import linalg
  from scipy import sparse
  from scipy.sparse.linalg import ArpackNoConvergence
label_desc: Use image node_id 6 for calling a global function with example usage: rescale_laplacian(L, lmax) and returns: L_scaled