code: def rescale(
      data,
      times,
      baseline,
      mode="mean",
      copy=True,
      picks=None,
      verbose=None,
  ):
      """Rescale (baseline correct) data.
  
      Parameters
      ----------
      data : array
          It can be of any shape. The only constraint is that the last
          dimension should be time.
      times : 1D array
          Time instants is seconds.
      %(baseline_rescale)s
      mode : 'mean' | 'ratio' | 'logratio' | 'percent' | 'zscore' | 'zlogratio'
          Perform baseline correction by
  
          - subtracting the mean of baseline values ('mean')
          - dividing by the mean of baseline values ('ratio')
          - dividing by the mean of baseline values and taking the log
            ('logratio')
          - subtracting the mean of baseline values followed by dividing by
            the mean of baseline values ('percent')
          - subtracting the mean of baseline values and dividing by the
            standard deviation of baseline values ('zscore')
          - dividing by the mean of baseline values, taking the log, and
            dividing by the standard deviation of log baseline values
            ('zlogratio')
  
      copy : bool
          Whether to return a new instance or modify in place.
      picks : list of int | None
          Data to process along the axis=-2 (None, default, processes all).
      %(verbose)s
  
      Returns
      -------
      data_scaled: array
          Array of same shape as data after rescaling.
      """
      if copy:
          data = data.copy()
      if verbose is not False:
          msg = _log_rescale(baseline, mode)
          logger.info(msg)
      if baseline is None or data.shape[-1] == 0:
          return data
  
      bmin, bmax = baseline
      if bmin is None:
          imin = 0
      else:
          imin = np.where(times >= bmin)[0]
          if len(imin) == 0:
              raise ValueError(
                  f"bmin is too large ({bmin}), it exceeds the largest time value"
              )
          imin = int(imin[0])
      if bmax is None:
          imax = len(times)
      else:
          imax = np.where(times <= bmax)[0]
          if len(imax) == 0:
              raise ValueError(
                  f"bmax is too small ({bmax}), it is smaller than the smallest time "
                  "value"
              )
          imax = int(imax[-1]) + 1
      if imin >= imax:
          raise ValueError(
              f"Bad rescaling slice ({imin}:{imax}) from time values {bmin}, {bmax}"
          )
  
      # technically this is inefficient when `picks` is given, but assuming
      # that we generally pick most channels for rescaling, it's not so bad
      mean = np.mean(data[..., imin:imax], axis=-1, keepdims=True)
  
      if mode == "mean":
  
          def fun(d, m):
              d -= m
  
      elif mode == "ratio":
  
          def fun(d, m):
              d /= m
  
      elif mode == "logratio":
  
          def fun(d, m):
              d /= m
              np.log10(d, out=d)
  
      elif mode == "percent":
  
          def fun(d, m):
              d -= m
              d /= m
  
      elif mode == "zscore":
  
          def fun(d, m):
              d -= m
              d /= np.std(d[..., imin:imax], axis=-1, keepdims=True)
  
      elif mode == "zlogratio":
  
          def fun(d, m):
              d /= m
              np.log10(d, out=d)
              d /= np.std(d[..., imin:imax], axis=-1, keepdims=True)
  
      if picks is None:
          fun(data, mean)
      else:
          for pi in picks:
              fun(data[..., pi, :], mean[..., pi, :])
      return data
  
imports: import numpy
  from .utils import _check_option, _validate_type, logger, verbose
label_desc: Use image node_id 2 for calling a global function with example usage: rescale(data, times, baseline, mode, copy, picks, verbose) and returns: data, data