class_docstr: Gaussian mixture model (GMM).
  
  Parameters
  ----------
  space : Manifold
      Equipped manifold.
  means : array-like, shape=[n_gaussians, dim]
      Means of each component of the GMM.
  variances : array-like, shape=[n_gaussians,]
      Variances of each component of the GMM.
  
  Attributes
  ----------
  normalization_factor_var : array-like, shape=[n_variances,]
      Array of computed normalization factor.
  variances_range : array-like, shape=[n_variances,]
      Array of standard deviations.
  phi_inv_var : array-like, shape=[n_variances,]
      Array of the computed inverse of a function phi
      whose expression is closed-form
      :math:`\sigma\mapsto \sigma^3 \times \frac{d}
      {\mathstrut d\sigma}\log \zeta_m(\sigma)`
      where :math:`\sigma` denotes the variance
      and :math:`\zeta` the normalization coefficient
      and :math:`m` the dimension.
class_docstr_tok: ["Gaussian","mixture","model","(","GMM",")",".","Parameters","--","--","--","--","--","space",":","Manifold","Equipped","manifold",".","means",":","array-like",",","shape=","[","n_gaussians",",","dim","]","Means","of","each","component","of","the","GMM",".","variances",":","array-like",",","shape=","[","n_gaussians",",","]","Variances","of","each","component","of","the","GMM",".","Attributes","--","--","--","--","--","normalization_factor_var",":","array-like",",","shape=","[","n_variances",",","]","Array","of","computed","normalization","factor",".","variances_range",":","array-like",",","shape=","[","n_variances",",","]","Array","of","standard","deviations",".","phi_inv_var",":","array-like",",","shape=","[","n_variances",",","]","Array","of","the","computed","inverse","of","a","function","phi","whose","expression","is","closed-form",":","math",":","`","\\sigma\\mapsto","\\sigma^3","\\times","\\frac","{","d","}","{","\\mathstrut","d\\sigma","}","\\log","\\zeta_m","(","\\sigma",")","`","where",":","math",":","`","\\sigma","`","denotes","the","variance","and",":","math",":","`","\\zeta","`","the","normalization","coefficient","and",":","math",":","`","m","`","the","dimension","."]
docstr: Return the variance given weighted distances.
  
  Parameters
  ----------
  weighted_distances : array-like, shape=[n_gaussians,]
      Mean of the weighted distances between training data
      and current barycentres. The weights of each data sample
      corresponds to the probability of belonging to a component
      of the Gaussian mixture model.
  
  Returns
  -------
  var : array-like, shape=[n_gaussians,]
      Estimated variances for each component of the GMM.
docstr_tok: ["Return","the","variance","given","weighted","distances",".","Parameters","--","--","--","--","--","weighted_distances",":","array-like",",","shape=","[","n_gaussians",",","]","Mean","of","the","weighted","distances","between","training","data","and","current","barycentres",".","The","weights","of","each","data","sample","corresponds","to","the","probability","of","belonging","to","a","component","of","the","Gaussian","mixture","model",".","Returns","--","--","--","-","var",":","array-like",",","shape=","[","n_gaussians",",","]","Estimated","variances","for","each","component","of","the","GMM","."]
code: def compute_variance_from_index(self, weighted_distances):
      r"""Return the variance given weighted distances.
  
      Parameters
      ----------
      weighted_distances : array-like, shape=[n_gaussians,]
          Mean of the weighted distances between training data
          and current barycentres. The weights of each data sample
          corresponds to the probability of belonging to a component
          of the Gaussian mixture model.
  
      Returns
      -------
      var : array-like, shape=[n_gaussians,]
          Estimated variances for each component of the GMM.
      """
      n_gaussians, precision = (
          weighted_distances.shape[0],
          self.variances_range.shape[0],
      )
  
      ref = gs.expand_dims(self.phi_inv_var, 0)
      ref = gs.repeat(ref, n_gaussians, axis=0)
  
      val = gs.expand_dims(weighted_distances, 1)
      val = gs.repeat(val, precision, axis=1)
  
      abs_difference = gs.abs(ref - val)
  
      index = gs.argmin(abs_difference, -1)
  
      var = self.variances_range[index]
  
      return var
  
imports: import logging
  from sklearn.base import BaseEstimator, ClusterMixin
  import geomstats.backend
  from geomstats.learning._template import TransformerMixin
  from geomstats.learning.frechet_mean import FrechetMean, variance
  from geomstats.learning.kmeans import RiemannianKMeans
label_desc: Use image node_id 5 for calling the GaussianMixtureModel obj's underlying member method code with example usage: obj.compute_variance_from_index(weighted_distances) and returns: var