code: def _sym_quad_form(x, mu, A):
      """helper function to calculate symmetric quadratic form x.T * A * x"""
      q = (cdist(x, mu[np.newaxis], "mahalanobis", VI=A) ** 2).reshape(
          -1
      )
      return q
  
imports: from __future__ import print_function
  import numpy
  from scipy.special import digamma, gammaln
  from scipy import linalg
  from scipy.spatial.distance import cdist
  from ..externals.six.moves import xrange
  from ..utils import check_random_state, check_array, deprecated
  from ..utils.extmath import logsumexp, pinvh, squared_norm
  from ..utils.validation import check_is_fitted
  from ..None import cluster
  from .gmm import _GMMBase
label_desc: Use image node_id 7 for calling a global function with example usage: _sym_quad_form(x, mu, A) and returns: q