class_docstr: Expectation-maximization algorithm.
  
  A class for performing Expectation-Maximization to fit a Gaussian Mixture
  Model (GMM) to data on a manifold. This method is only implemented for
  the hypersphere and the Poincare ball.
  
  Parameters
  ----------
  space : Manifold
      Equipped manifold.
  n_gaussians : int
      Number of Gaussian components in the mix.
  initialisation_method : basestring
      Optional, default: 'random'.
      Choice between initialization method for variances, means and weights.
  
      - 'random' : will select random uniformly train points as
        initial cluster centers.
      - 'kmeans' : will apply Riemannian kmeans to deduce
        variances and means that the EM will use initially.
  tol : float
      Optional, default: 1e-2.
      Convergence tolerance. If the difference of mean distance
      between two steps is lower than tol.
  max_iter : int
      Maximum number of iterations for the gradient descent.
      Optional, default: 100.
  
  Attributes
  ----------
  mixture_coefficients_ : array-like, shape=[n_gaussians,]
      Weights for each GMM component.
  variances_ : array-like, shape=[n_gaussians,]
      Variances for each GMM component.
  means_ : array-like, shape=[n_gaussian, _dimension]
      Barycentre of each component of the GMM.
  
  Example
  -------
  Available example on the Poincaré Ball manifold
  :mod:`examples.plot_expectation_maximization_ball`
class_docstr_tok: ["Expectation-maximization","algorithm",".","A","class","for","performing","Expectation-Maximization","to","fit","a","Gaussian","Mixture","Model","(","GMM",")","to","data","on","a","manifold",".","This","method","is","only","implemented","for","the","hypersphere","and","the","Poincare","ball",".","Parameters","--","--","--","--","--","space",":","Manifold","Equipped","manifold",".","n_gaussians",":","int","Number","of","Gaussian","components","in","the","mix",".","initialisation_method",":","basestring","Optional",",","default",":","'random","'",".","Choice","between","initialization","method","for","variances",",","means","and","weights",".","-","'random","'",":","will","select","random","uniformly","train","points","as","initial","cluster","centers",".","-","'kmeans","'",":","will","apply","Riemannian","kmeans","to","deduce","variances","and","means","that","the","EM","will","use","initially",".","tol",":","float","Optional",",","default",":","1e-2",".","Convergence","tolerance",".","If","the","difference","of","mean","distance","between","two","steps","is","lower","than","tol",".","max_iter",":","int","Maximum","number","of","iterations","for","the","gradient","descent",".","Optional",",","default",":","100",".","Attributes","--","--","--","--","--","mixture_coefficients_",":","array-like",",","shape=","[","n_gaussians",",","]","Weights","for","each","GMM","component",".","variances_",":","array-like",",","shape=","[","n_gaussians",",","]","Variances","for","each","GMM","component",".","means_",":","array-like",",","shape=","[","n_gaussian",",","_dimension","]","Barycentre","of","each","component","of","the","GMM",".","Example","--","--","--","-","Available","example","on","the","Poincar\u00e9","Ball","manifold",":","mod",":","`","examples.plot_expectation_maximization_ball","`"]
code: def _initialization(self, X):
      if self.initialisation_method == "kmeans":
          kmeans_estimator = RiemannianKMeans(
              space=self.space,
              n_clusters=self.n_gaussians,
              init="random",
          )
  
          kmeans_estimator.fit(X=X)
          cluster_centers = kmeans_estimator.cluster_centers_
          labels = kmeans_estimator.labels_
  
          means = cluster_centers
          variances = gs.zeros(self.n_gaussians)
  
          labeled_data = gs.vstack([labels, gs.transpose(X)])
          labeled_data = gs.transpose(labeled_data)
          for label, cluster_center in enumerate(cluster_centers):
              label_mask = gs.where(labeled_data[:, 0] == label)
              grouped_by_label = labeled_data[label_mask][:, 1:]
              v = variance(self.space, grouped_by_label, cluster_center)
              if grouped_by_label.shape[0] == 1:
                  v += MIN_VAR_INIT
              variances[label] = v
      else:
          dim = self.space.shape[-1]
          means = (gs.random.rand(self.n_gaussians, dim) - 0.5) / dim
          variances = gs.random.rand(self.n_gaussians) / 10 + 0.8
  
      return means, variances
  
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 9 for calling the RiemannianEM obj's underlying member method code with example usage: obj._initialization(X) and returns: means,  variances