code: def barycenter_weights(X, Z, reg=1e-3):
      """Compute barycenter weights of X from Y along the first axis
  
      We estimate the weights to assign to each point in Y[i] to recover
      the point X[i]. The barycenter weights sum to 1.
  
      Parameters
      ----------
      X : array-like, shape (n_samples, n_dim)
  
      Z : array-like, shape (n_samples, n_neighbors, n_dim)
  
      reg: float, optional
          amount of regularization to add for the problem to be
          well-posed in the case of n_neighbors > n_dim
  
      Returns
      -------
      B : array-like, shape (n_samples, n_neighbors)
  
      Notes
      -----
      See developers note for more information.
      """
      X = check_array(X, dtype=FLOAT_DTYPES)
      Z = check_array(Z, dtype=FLOAT_DTYPES, allow_nd=True)
  
      n_samples, n_neighbors = X.shape[0], Z.shape[1]
      B = np.empty((n_samples, n_neighbors), dtype=X.dtype)
      v = np.ones(n_neighbors, dtype=X.dtype)
  
      # this might raise a LinalgError if G is singular and has trace
      # zero
      for i, A in enumerate(Z.transpose(0, 2, 1)):
          C = A.T - X[i]  # broadcasting
          G = np.dot(C, C.T)
          trace = np.trace(G)
          if trace > 0:
              R = reg * trace
          else:
              R = reg
          G.flat[:: Z.shape[1] + 1] += R
          w = solve(G, v, sym_pos=True)
          B[i, :] = w / np.sum(w)
      return B
  
imports: import numpy
  from scipy.linalg import eigh, svd, qr, solve
  from scipy.sparse import eye, csr_matrix
  from ..base import BaseEstimator, TransformerMixin
  from ..utils import check_random_state, check_array
  from ..utils.arpack import eigsh
  from ..utils.validation import check_is_fitted
  from ..utils.validation import FLOAT_DTYPES
  from ..neighbors import NearestNeighbors
label_desc: Use image node_id 1 for calling a global function with example usage: barycenter_weights(X, Z, reg) and returns: B