code: def nearest_sym_pos_def(X, reg=1e-6):
      """Find the nearest SPD matrices.
  
      A NumPy port of John D'Errico's `nearestSPD` MATLAB code [1]_,
      which credits [2]_.
  
      Parameters
      ----------
      X : ndarray, shape (..., n, n)
          Square matrices, at least 2D ndarray.
      reg : float
          Regularization parameter.
  
      Returns
      -------
      P : ndarray, shape (..., n, n)
          Nearest SPD matrices.
  
      Notes
      -----
      .. versionadded:: 0.4
  
      References
      ----------
      .. [1] `nearestSPD
          <https://www.mathworks.com/matlabcentral/fileexchange/42885-nearestspd>`_
          J. D'Errico, MATLAB Central File Exchange
      .. [2] `Computing a nearest symmetric positive semidefinite matrix
          <https://www.sciencedirect.com/science/article/pii/0024379588902236>`_
          N.J. Higham, Linear Algebra and its Applications, vol 103, 1988
      """
      return np.array([_nearest_sym_pos_def(x, reg) for x in X])
  
file_path: pyRiemann/pyriemann/utils/base.py
imports: import numpy
  from numpy.core.numerictypes import typecodes
  from .test import is_pos_def
label_desc: Use image node_id 8 for calling a global function with example usage: nearest_sym_pos_def(X, reg) and returns: np