code: def _warm_start(X, Y, weights, metric="euclid"):
      """Smart initialization of the minimization procedure.
  
      The loss function being optimized is a weighted sum of loss functions with
      the same structure and for which we know the exact analytic solution [1]_.
  
      As such, a natural way to warm start the optimization procedure is to list
      the minimizers of "local" loss function and set as Q0 the matrix that
      yields the smallest value for the "global" loss function.
  
      Note that the initialization is the same for both 'euclid' and 'riemann'.
  
      References
      ----------
      .. [1] `Procrustes problems in Riemannian manifolds of positive definite
          matrices
          <https://hal.archives-ouvertes.fr/hal-02023293>`_
          R. Bhatia and M. Congedo, Linear Algebra and its Applications,
          Elsevier, 2019, 563, pp.440-445.
      """
  
      # obtain the solution of the local loss function
      def _get_local_solution(Xi, Yi):
          wX, qX = np.linalg.eig(Xi)
          idx = wX.argsort()[::-1]
          qX = qX[:, idx]
          wY, qY = np.linalg.eig(Yi)
          idx = wY.argsort()[::-1]
          qY = qY[:, idx]
          Qstar = qX @ qY.T
          return Qstar
  
      Q0_candidates, losses = [], []
      for i in range(len(X)):
          Q0_candidates.append(_get_local_solution(X[i], Y[i]))
          losses.append(
              _loss(Q0_candidates[i], X, Y, weights, metric=metric)
          )
  
      i_min = np.argmin(losses)
  
      return Q0_candidates[i_min]
  
file_path: pyRiemann/pyriemann/transfer/_rotate.py
imports: import warnings
  import numpy
  from ..utils.distance import distance
  from ..utils.utils import check_weights
label_desc: Use image node_id 5 for calling a global function with example usage: _warm_start(X, Y, weights, metric) and returns: Q0_candidates, Qstar