code: def _M2_dense(X, Y, weights=None, diag_only=False):
      
      if weights is not None:
          if diag_only:
              return np.sum(weights[:, None] * X * Y, axis=0)
          else:
              return np.dot((weights[:, None] * X).T, Y)
      else:
          if diag_only:
              return np.sum(X * Y, axis=0)
          else:
              return np.dot(X.T, Y)
docs: 2nd moment matrix using dense matrix computations.
  
      This function is encapsulated such that we can make easy modifications of the basic algorithms