code: def test_connectivity_measure_inverse_transform_tangent(
      signals,
  ):
      """For 'tangent' kind, covariance matrices are reconstructed"""
      # Without vectorization
      tangent_measure = ConnectivityMeasure(kind="tangent")
      displacements = tangent_measure.fit_transform(signals)
      covariances = ConnectivityMeasure(
          kind="covariance"
      ).fit_transform(signals)
  
      assert_array_almost_equal(
          tangent_measure.inverse_transform(displacements), covariances
      )
  
      # with vectorization
      # when diagonal has not been discarded
      tangent_measure = ConnectivityMeasure(
          kind="tangent", vectorize=True
      )
      vectorized_displacements = tangent_measure.fit_transform(signals)
  
      assert_array_almost_equal(
          tangent_measure.inverse_transform(vectorized_displacements),
          covariances,
      )
  
      # When diagonal has been discarded
      tangent_measure = ConnectivityMeasure(
          kind="tangent", vectorize=True, discard_diagonal=True
      )
      vectorized_displacements = tangent_measure.fit_transform(signals)
  
      diagonal = np.array(
          [np.diagonal(matrix) / sqrt(2) for matrix in displacements]
      )
      inverse_transformed = tangent_measure.inverse_transform(
          vectorized_displacements, diagonal=diagonal
      )
  
      assert_array_almost_equal(inverse_transformed, covariances)
      with pytest.raises(
          ValueError, match="cannot reconstruct connectivity matrices"
      ):
          tangent_measure.inverse_transform(vectorized_displacements)
  
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 39 for calling a global function with example usage: test_connectivity_measure_inverse_transform_tangent(signals) without return types