code: def test_connectivity_measure_check_inverse_transformation_discard_diag(
      kind, signals
  ):
      # with vectorization
      connectivities = ConnectivityMeasure(kind=kind).fit_transform(
          signals
      )
      conn_measure = ConnectivityMeasure(
          kind=kind, vectorize=True, discard_diagonal=True
      )
      vectorized_connectivities = conn_measure.fit_transform(signals)
  
      if kind in ["correlation", "partial correlation"]:
          assert_array_almost_equal(
              conn_measure.inverse_transform(vectorized_connectivities),
              connectivities,
          )
      elif kind in ["covariance", "precision"]:
          diagonal = np.array(
              [np.diagonal(conn) / sqrt(2) for conn in connectivities]
          )
          inverse_transformed = conn_measure.inverse_transform(
              vectorized_connectivities, diagonal=diagonal
          )
  
          assert_array_almost_equal(inverse_transformed, connectivities)
          with pytest.raises(
              ValueError,
              match="cannot reconstruct connectivity matrices",
          ):
              conn_measure.inverse_transform(vectorized_connectivities)
  
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 38 for calling a global function with example usage: test_connectivity_measure_check_inverse_transformation_discard_diag(kind, signals) without return types