code: def test_geometric_mean_properties_check_gradient():
      n_matrices = 40
      n_features = 15
      spds = [
          random_spd(n_features, eig_min=1.0, cond=10.0, random_state=0)
          for _ in range(n_matrices)
      ]
  
      grad_norm = grad_geometric_mean(spds, tol=1e-20)
  
      # Gradient norm is decreasing
      difference = np.diff(grad_norm)
      assert np.amax(difference) <= 0.0
  
      # Check warning if gradient norm in the last step is less than
      # tolerance
      max_iter = 1
      tol = 1e-20
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always")
          _geometric_mean(spds, max_iter=max_iter, tol=tol)
          assert len(w) == 1
  
      grad_norm = grad_geometric_mean(spds, max_iter=max_iter, tol=tol)
  
      assert len(grad_norm) == max_iter
      assert grad_norm[-1] > tol
  
imports: import copy
  import warnings
  from math import cosh, exp, log, sinh, sqrt
  import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from pandas import DataFrame
  from scipy import linalg
  from sklearn.covariance import EmpiricalCovariance, LedoitWolf
  from nilearn._utils.extmath import is_spd
  from nilearn.connectome.connectivity_matrices import ConnectivityMeasure, _check_spd, _check_square, _form_symmetric, _geometric_mean, _map_eigenvalues, prec_to_partial, sym_matrix_to_vec, vec_to_sym_matrix
  from nilearn.tests.test_signal import generate_signals
label_desc: Use image node_id 18 for calling a global function with example usage: test_geometric_mean_properties_check_gradient() without return types