def METHOD_NAME(intervals, intervals_time=None, remove_missing=True):
    """**Interval input sanitization**
    Parameters
    ----------
    intervals : list or array
        List or numpy array of intervals, in milliseconds.
    intervals_time : list or array, optional
        List or numpy array of timestamps corresponding to intervals, in seconds.
    remove_missing : bool, optional
        Whether to remove NaNs and infinite values from intervals and timestamps.
        The default is True.
    Returns
    -------
    intervals : array
        Sanitized intervals, in milliseconds.
    intervals_time : array
        Sanitized timestamps corresponding to intervals, in seconds.
    intervals_missing : bool
        Whether there were missing intervals detected.
    Examples
    ---------
    .. ipython:: python
      import neurokit2 as nk
      ibi = [500, 400, 700, 500, 300, 800, 500]
      ibi, ibi_time, intervals_missing = intervals_sanitize(ibi)
    """
    if intervals is None:
        return None, None
    else:
        # Ensure that input is numpy array
        intervals = np.array(intervals)
    if intervals_time is None:
        # Impute intervals with median in case of missing values to calculate timestamps
        imputed_intervals = np.where(
            np.isnan(intervals), np.nanmedian(intervals, axis=0), intervals
        )
        # Compute the timestamps of the intervals in seconds
        intervals_time = np.nancumsum(imputed_intervals / 1000)
    else:
        # Ensure that input is numpy array
        intervals_time = np.array(intervals_time)
        # Confirm that timestamps are in seconds
        successive_intervals = _intervals_successive(intervals, intervals_time=intervals_time)
        if np.all(successive_intervals) is False:
            # Check whether intervals appear to be interpolated
            if not _intervals_time_uniform(intervals_time):
                # If none of the differences between timestamps match
                # the length of the R-R intervals in seconds,
                # try converting milliseconds to seconds
                converted_successive_intervals = _intervals_successive(
                    intervals, intervals_time=intervals_time / 1000
                )
                # Check if converting to seconds increased the number of differences
                # between timestamps that match the length of the R-R intervals in seconds
                if len(converted_successive_intervals[converted_successive_intervals]) > len(
                    successive_intervals[successive_intervals]
                ):
                    # Assume timestamps were passed in milliseconds and convert to seconds
                    intervals_time = intervals_time / 1000
    intervals_missing = _intervals_missing(intervals, intervals_time)
    if remove_missing:
        # Remove NaN R-R intervals, if any
        intervals_time = intervals_time[np.isfinite(intervals)]
        intervals = intervals[np.isfinite(intervals)]
    return intervals, intervals_time, intervals_missing