code: def _check_baseline(
      baseline, times, sfreq, on_baseline_outside_data="raise"
  ):
      """Check if the baseline is valid and adjust it if requested.
  
      ``None`` values inside ``baseline`` will be replaced with ``times[0]`` and
      ``times[-1]``.
  
      Parameters
      ----------
      baseline : array-like, shape (2,) | None
          Beginning and end of the baseline period, in seconds. If ``None``,
          assume no baseline and return immediately.
      times : array
          The time points.
      sfreq : float
          The sampling rate.
      on_baseline_outside_data : 'raise' | 'info' | 'adjust'
          What to do if the baseline period exceeds the data.
          If ``'raise'``, raise an exception (default).
          If ``'info'``, log an info message.
          If ``'adjust'``, adjust the baseline such that it is within the data range.
  
      Returns
      -------
      (baseline_tmin, baseline_tmax) | None
          The baseline with ``None`` values replaced with times, and with adjusted times
          if ``on_baseline_outside_data='adjust'``; or ``None``, if ``baseline`` is
          ``None``.
      """
      if baseline is None:
          return None
  
      _validate_type(baseline, "array-like")
      baseline = tuple(baseline)
  
      if len(baseline) != 2:
          raise ValueError(
              f"baseline must have exactly two elements (got {len(baseline)})."
          )
  
      tmin, tmax = times[0], times[-1]
      tstep = 1.0 / float(sfreq)
  
      # check default value of baseline and `tmin=0`
      if baseline == (None, 0) and tmin == 0:
          raise ValueError(
              "Baseline interval is only one sample. Use `baseline=(0, 0)` if this is "
              "desired."
          )
  
      baseline_tmin, baseline_tmax = baseline
  
      if baseline_tmin is None:
          baseline_tmin = tmin
      baseline_tmin = float(baseline_tmin)
  
      if baseline_tmax is None:
          baseline_tmax = tmax
      baseline_tmax = float(baseline_tmax)
  
      if baseline_tmin > baseline_tmax:
          raise ValueError(
              f"Baseline min ({baseline_tmin}) must be less than baseline max ("
              f"{baseline_tmax})"
          )
  
      if (baseline_tmin < tmin - tstep) or (
          baseline_tmax > tmax + tstep
      ):
          msg = (
              f"Baseline interval [{baseline_tmin}, {baseline_tmax}] s is outside of "
              f"epochs data [{tmin}, {tmax}] s. Epochs were probably cropped."
          )
          if on_baseline_outside_data == "raise":
              raise ValueError(msg)
          elif on_baseline_outside_data == "info":
              logger.info(msg)
          elif on_baseline_outside_data == "adjust":
              if baseline_tmin < tmin - tstep:
                  baseline_tmin = tmin
              if baseline_tmax > tmax + tstep:
                  baseline_tmax = tmax
  
      return baseline_tmin, baseline_tmax
  
imports: import numpy
  from .utils import _check_option, _validate_type, logger, verbose
label_desc: Use image node_id 3 for calling a global function with example usage: _check_baseline(baseline, times, sfreq, on_baseline_outside_data) and returns: baseline_tmin,  baseline_tmax, None