code: def _numeric_ac(M, mapping):
      # M is a 2D numpy array
      # numeric assortativity coefficient, pearsonr
      import numpy as np
  
      if M.sum() != 1.0:
          M = M / M.sum()
      x = np.array(list(mapping.keys()))
      y = x  # x and y have the same support
      idx = list(mapping.values())
      a = M.sum(axis=0)
      b = M.sum(axis=1)
      vara = (a[idx] * x**2).sum() - ((a[idx] * x).sum()) ** 2
      varb = (b[idx] * y**2).sum() - ((b[idx] * y).sum()) ** 2
      xy = np.outer(x, y)
      ab = np.outer(a[idx], b[idx])
      return (xy * (M - ab)).sum() / np.sqrt(vara * varb)
  
file_path: networkx/networkx/algorithms/assortativity/correlation.py
imports: import networkx
  from networkx.algorithms.assortativity.mixing import attribute_mixing_matrix, degree_mixing_matrix
  from networkx.algorithms.assortativity.pairs import node_degree_xy
label_desc: Use image node_id 6 for calling a global function with example usage: _numeric_ac(M, mapping) and returns: unknown