code: def _bfmi(energy):
      r"""Calculate the estimated Bayesian fraction of missing information (BFMI).
  
      BFMI quantifies how well momentum resampling matches the marginal energy distribution. For more
      information on BFMI, see https://arxiv.org/pdf/1604.00695v1.pdf. The current advice is that
      values smaller than 0.3 indicate poor sampling. However, this threshold is provisional and may
      change. See http://mc-stan.org/users/documentation/case-studies/pystan_workflow.html for more
      information.
  
      Parameters
      ----------
      energy : NumPy array
          Should be extracted from a gradient based sampler, such as in Stan or PyMC3. Typically,
          after converting a trace or fit to InferenceData, the energy will be in
          `data.sample_stats.energy`.
  
      Returns
      -------
      z : array
          The Bayesian fraction of missing information of the model and trace. One element per
          chain in the trace.
      """
      energy_mat = np.atleast_2d(energy)
      num = np.square(np.diff(energy_mat, axis=1)).mean(
          axis=1
      )  # pylint: disable=no-member
      if energy_mat.ndim == 2:
          den = _numba_var(svar, np.var, energy_mat, axis=1, ddof=1)
      else:
          den = np.var(energy, axis=1, ddof=1)
      return num / den
  
imports: import warnings
  from collections.abc import Sequence
  import numpy
  import packaging
  import pandas
  import scipy
  from scipy import stats
  from ..data import convert_to_dataset
  from ..utils import Numba, _numba_var, _stack, _var_names
  from .density_utils import histogram
  from .stats_utils import _circular_standard_deviation, _sqrt
  from .stats_utils import autocov
  from .stats_utils import not_valid
  from .stats_utils import quantile
  from .stats_utils import stats_variance_2d
  from .stats_utils import wrap_xarray_ufunc
label_desc: Use image node_id 6 for calling a global function with example usage: _bfmi(energy) and returns: unknown