code: def _prepare_csd_array(
      X, sfreq, t0, tmin, tmax, fmin=None, fmax=None
  ):
      """Do some checking and preprocessing of common csd_r=array_* parameters.
  
      See the csd_array_* functions for documentation of the parameters.
      """
      X = np.asarray(X, dtype=float)
      if X.ndim != 3:
          raise ValueError("X must be n_epochs x n_channels x n_times.")
  
      n_times = X.shape[2]
      tstep = 1.0 / sfreq
      times = np.arange(n_times) * tstep + t0
  
      # Check tmin and tmax
      if tmax is None:
          tmax = times.max()
      if tmin is None:
          tmin = times.min()
      if tmax <= tmin:
          raise ValueError("tmax must be larger than tmin")
      if tmin < times[0] - tstep:
          raise ValueError(
              "tmin should be larger than the smallest data time "
              "point"
          )
      if tmax > times[-1] + tstep:
          raise ValueError(
              "tmax should be smaller than the largest data time "
              "point"
          )
  
      # Check fmin and fmax
      if fmax is not None and fmin is not None and fmax <= fmin:
          raise ValueError("fmax must be larger than fmin")
  
      return X, times, tmin, tmax, fmin, fmax
  
imports: import copy
  import numbers
  import numpy
  from scipy.fft import rfftfreq
  from .._fiff.pick import _picks_to_idx, pick_channels
  from ..parallel import parallel_func
  from ..time_frequency.multitaper import _compute_mt_params, _csd_from_mt, _mt_spectra, _psd_from_mt_adaptive
  from ..utils import ProgressBar, _check_fname, _import_h5io_funcs, _validate_type, copy_function_doc_to_method_doc, logger, verbose, warn
  from ..viz.misc import plot_csd
  from .tfr import EpochsTFR, _cwt_array, _get_nfft, morlet
label_desc: Use image node_id 13 for calling a global function with example usage: _prepare_csd_array(X, sfreq, t0, tmin, tmax, fmin, fmax) and returns: X,  times,  tmin,  tmax,  fmin,  fmax