code: def solve_sylvester(a, b, q, tol=atol):
      if a.shape == b.shape:
          axes = (0, 2, 1) if a.ndim == 3 else (1, 0)
          if _np.all(_np.isclose(a, b)) and _np.all(
              _np.abs(a - _np.transpose(a, axes)) < tol
          ):
              eigvals, eigvecs = _np.linalg.eigh(a)
              if _np.all(eigvals >= tol):
                  tilde_q = _np.transpose(eigvecs, axes) @ q @ eigvecs
                  tilde_x = tilde_q / (
                      eigvals[..., :, None] + eigvals[..., None, :]
                  )
                  return (
                      eigvecs @ tilde_x @ _np.transpose(eigvecs, axes)
                  )
  
      return _np.vectorize(
          _scipy.linalg.solve_sylvester,
          signature="(m,m),(n,n),(m,n)->(m,n)",
      )(a, b, q)
  
file_path: geomstats/geomstats/_backend/_shared_numpy/linalg.py
imports: from ._dispatch import _common
  from ._dispatch import numpy
  from ._dispatch import scipy
label_desc: Use image node_id 4 for calling a global function with example usage: solve_sylvester(a, b, q, tol) and returns: _np, unknown