code: def cancorr(x1, x2, demean=True, standardize=False):
      """canonical correlation coefficient beween 2 arrays
  
      Parameters
      ----------
      x1, x2 : ndarrays, 2_D
          two 2-dimensional data arrays, observations in rows, variables in columns
      demean : bool
           If demean is true, then the mean is subtracted from each variable
      standardize : bool
           If standardize is true, then each variable is demeaned and divided by
           its standard deviation. Rescaling does not change the canonical
           correlation coefficients.
  
      Returns
      -------
      ccorr : ndarray, 1d
          canonical correlation coefficients, sorted from largest to smallest.
          Note, that these are the square root of the eigenvalues.
  
      Notes
      -----
      This is a helper function for other statistical functions. It only
      calculates the canonical correlation coefficients and does not do a full
      canoncial correlation analysis
  
      The canonical correlation coefficient is calculated with the generalized
      matrix inverse and does not raise an exception if one of the data arrays
      have less than full column rank.
  
      See Also
      --------
      cc_ranktest
      cc_stats
      CCA not yet
  
      """
      # x, y = x1, x2
      if demean or standardize:
          x1 = x1 - x1.mean(0)
          x2 = x2 - x2.mean(0)
  
      if standardize:
          # std does not make a difference to canonical correlation coefficients
          x1 /= x1.std(0)
          x2 /= x2.std(0)
  
      t1 = np.linalg.pinv(x1).dot(x2)
      t2 = np.linalg.pinv(x2).dot(x1)
      m = t1.dot(t2)
      cc = np.sqrt(np.linalg.eigvals(m))
      cc.sort()
      return cc[::-1]
  
imports: import numpy
  from statsmodels.tools.tools import Bunch
label_desc: Use image node_id 2 for calling a global function with example usage: cancorr(x1, x2, demean, standardize) and returns: cc