code: def nanmean_riemann(
      X=None,
      tol=10e-9,
      maxiter=100,
      init=None,
      sample_weight=None,
      covmats=None,
  ):
      """Riemannian NaN-mean of SPD/HPD matrices.
  
      The Riemannian NaN-mean is the masked Riemannian mean applied to SPD/HPD
      matrices potentially corrupted by symmetric NaN values [1]_.
  
      Parameters
      ----------
      X : ndarray, shape (n_matrices, n, n)
          Set of SPD/HPD matrices, corrupted by symmetric NaN values [1]_.
      tol : float, default=10e-9
          The tolerance to stop the gradient descent.
      maxiter : int, default=100
          The maximum number of iteration.
      init : None | ndarray, shape (n, n), default=None
          A SPD/HPD matrix used to initialize the gradient descent.
          If None, a regularized Euclidean NaN-mean is used.
      sample_weight : None | ndarray, shape (n_matrices,), default=None
          Weights for each matrix. If None, it uses equal weights.
  
      Returns
      -------
      M : ndarray, shape (n, n)
          Riemannian NaN-mean.
  
      Notes
      -----
      .. versionadded:: 0.3
  
      See Also
      --------
      maskedmean_riemann
      mean_covariance
  
      References
      ----------
      .. [1] `Geodesically-convex optimization for averaging partially observed
          covariance matrices
          <https://hal.archives-ouvertes.fr/hal-02984423>`_
          F. Yger, S. Chevallier, Q. Barthélemy, and S. Sra. Asian Conference on
          Machine Learning (ACML), Nov 2020, Bangkok, Thailand. pp.417 - 432.
      """
      X = _deprecate_covmats(covmats, X)
      n_matrices, n, _ = X.shape
      if init is None:
          Minit = np.nanmean(X, axis=0) + 1e-6 * np.eye(n)
      else:
          Minit = init
  
      M = maskedmean_riemann(
          np.nan_to_num(X),  # avoid nan contamination in matmul
          _get_masks_from_nan(X),
          tol=tol,
          maxiter=maxiter,
          init=Minit,
          sample_weight=sample_weight,
      )
      return M
  
imports: from copy import deepcopy
  import numpy
  import warnings
  from .ajd import ajd_pham
  from .base import sqrtm, invsqrtm, logm, expm, powm
  from .distance import distance_riemann
  from .geodesic import geodesic_riemann
  from .utils import check_weights
label_desc: Use image node_id 19 for calling a global function with example usage: nanmean_riemann(X, tol, maxiter, init, sample_weight, covmats) and returns: M