code: def barycenter_weights(X, Y, indices, metric="riemann", reg=1e-3):
      """Compute Riemannian barycenter weights of X from Y along the first axis.
  
      Estimates the weights to assign to each point in Y[indices] to recover
      the point X[i] by geodesic interpolation. The barycenter weights sum to 1.
  
      Parameters
      ----------
      X : ndarray, shape (n_matrices, n_channels, n_channels)
          Set of SPD matrices.
      Y : ndarray, shape (n_matrices, n_channels, n_channels)
          Set of SPD matrices.
      indices : ndarray, shape (n_matrices, n_neighbors)
          Indices of the points in Y used to compute the barycenter
      metric : {'riemann', 'logeuclid', 'euclid'}, default='riemann'
          Kernel metric.
      reg : float, default=1e-3
          Amount of regularization to add for the problem to be
          well-posed in the case of n_neighbors > n_channels.
  
      Returns
      -------
      B : ndarray, shape (n_matrices, n_neighbors)
          Interpolation weights.
  
      Notes
      -----
      .. versionadded:: 0.3
      """
      n_matrices, n_neighbors = indices.shape
      msg = (
          f"Number of index-sets in indices (is {n_matrices}) must match "
          f"number of matrices in X (is {X.shape[0]})."
      )
      assert X.shape[0] == n_matrices, msg
  
      B = np.empty((n_matrices, n_neighbors), dtype=X.dtype)
      v = np.ones(n_neighbors, dtype=X.dtype)
  
      for i in range(n_matrices):
          X_neighbors = Y[indices[i]]
          G = kernel(X_neighbors, Cref=X[i], metric=metric)
          trace = np.trace(G)
          if trace > 0:
              R = reg * trace
          else:
              R = reg
          G.flat[:: n_neighbors + 1] += R
          w = solve(G, v, assume_a="pos")
          B[i] = w / np.sum(w)
      return B
  
imports: import numpy
  from scipy.linalg import solve, eigh
  from scipy.sparse import csr_matrix
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.manifold import spectral_embedding
  from .utils.kernel import kernel
  from .utils.distance import pairwise_distance
label_desc: Use image node_id 1 for calling a global function with example usage: barycenter_weights(X, Y, indices, metric, reg) and returns: B