code: def _sanitize_signals(signals, ensure_finite):
      """Ensure signals are in the correct state."""
      if not isinstance(ensure_finite, bool):
          raise ValueError(
              "'ensure_finite' must be boolean type True or False "
              f"but you provided ensure_finite={ensure_finite}"
          )
      signals = signals.copy()
      if not isinstance(signals, np.ndarray):
          signals = as_ndarray(signals)
      if ensure_finite:
          mask = np.logical_not(np.isfinite(signals))
          if mask.any():
              signals[mask] = 0
      return _ensure_float(signals)
  
imports: import warnings
  import numpy
  import pandas
  from scipy import linalg, signal
  from scipy.interpolate import CubicSpline
  from sklearn.utils import as_float_array, gen_even_slices
  from nilearn._utils import fill_doc, stringify_path
  from nilearn._utils.numpy_conversions import as_ndarray, csv_to_array
  from nilearn._utils.param_validation import check_run_sample_masks
label_desc: Use image node_id 23 for calling a global function with example usage: _sanitize_signals(signals, ensure_finite) and returns: _ensure_float