code: def random_diagonal(p, v_min=1.0, v_max=2.0, random_state=0):
      """Generate a random diagonal matrix.
  
      Parameters
      ----------
      p : int
          The first dimension of the array.
  
      v_min : float, optional (default to 1.)
          Minimal element.
  
      v_max : float, optional (default to 2.)
          Maximal element.
  
      random_state : int or numpy.random.RandomState instance, optional
          random number generator, or seed.
  
      Returns
      -------
      output : numpy.ndarray, shape (p, p)
          A diagonal matrix with the given minimal and maximal elements.
  
      """
      random_state = np.random.default_rng(random_state)
      diag = random_state.random(p) * (v_max - v_min) + v_min
      diag[diag == np.amax(diag)] = v_max
      diag[diag == np.amin(diag)] = v_min
      return np.diag(diag)
  
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 1 for calling a global function with example usage: random_diagonal(p, v_min, v_max, random_state) and returns: np