<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_baseline_data( data, start=None, end=None, max_days=365, allow_billing_period_overshoot=False, ignore_billing_period_gap_for_day_count=False, ):
 """ Filter down to baseline period data. .. note:: For compliance with CalTRACK, set ``max_days=365`` (section 2.2.1.1). Parameters data : :any:`pandas.DataFrame` or :any:`pandas.Series` The data to filter to baseline data. This data will be filtered down to an acceptable baseline period according to the dates passed as `start` and `end`, or the maximum period specified with `max_days`. start : :any:`datetime.datetime` A timezone-aware datetime that represents the earliest allowable start date for the baseline data. The stricter of this or `max_days` is used to determine the earliest allowable baseline period date. end : :any:`datetime.datetime` A timezone-aware datetime that represents the latest allowable end date for the baseline data, i.e., the latest date for which data is available before the intervention begins. max_days : :any:`int`, default 365 The maximum length of the period. Ignored if `end` is not set. The stricter of this or `start` is used to determine the earliest allowable baseline period date. allow_billing_period_overshoot : :any:`bool`, default False If True, count `max_days` from the end of the last billing data period that ends before the `end` date, rather than from the exact `end` date. Otherwise use the exact `end` date as the cutoff. ignore_billing_period_gap_for_day_count : :any:`bool`, default False If True, instead of going back `max_days` from either the `end` date or end of the last billing period before that date (depending on the value of the `allow_billing_period_overshoot` setting) and excluding the last period that began before that date, first check to see if excluding or including that period gets closer to a total of `max_days` of data. For example, with `max_days=365`, if an exact 365 period would targeted Feb 15, but the billing period went from Jan 20 to Feb 20, exclude that period for a total of ~360 days of data, because that's closer to 365 than ~390 days, which would be the total if that period was included. If, on the other hand, if that period started Feb 10 and went to Mar 10, include the period, because ~370 days of data is closer to than ~340. Returns ------- baseline_data, warnings : :any:`tuple` of (:any:`pandas.DataFrame` or :any:`pandas.Series`, :any:`list` of :any:`eemeter.EEMeterWarning`) Data for only the specified baseline period and any associated warnings. """

    if max_days is not None:
        if start is not None:
            raise ValueError(  # pragma: no cover
                "If max_days is set, start cannot be set: start={}, max_days={}.".format(
                    start, max_days
                )
            )

    start_inf = False
    if start is None:
        # py datetime min/max are out of range of pd.Timestamp min/max
        start_target = pytz.UTC.localize(pd.Timestamp.min)
        start_inf = True
    else:
        start_target = start

    end_inf = False
    if end is None:
        end_limit = pytz.UTC.localize(pd.Timestamp.max)
        end_inf = True
    else:
        end_limit = end

    # copying prevents setting on slice warnings
    data_before_end_limit = data[:end_limit].copy()

    if ignore_billing_period_gap_for_day_count:
        end_limit = data_before_end_limit.index.max()

    if not end_inf and max_days is not None:
        start_target = end_limit - timedelta(days=max_days)

    if allow_billing_period_overshoot:
        # adjust start limit to get a selection closest to max_days
        # also consider ffill for get_loc method - always picks previous
        try:
            loc = data_before_end_limit.index.get_loc(start_target, method="nearest")
        except (KeyError, IndexError):  # pragma: no cover
            baseline_data = data_before_end_limit
            start_limit = start_target
        else:
            start_limit = data_before_end_limit.index[loc]
            baseline_data = data_before_end_limit[start_limit:].copy()

    else:
        # use hard limit for baseline start
        start_limit = start_target
        baseline_data = data_before_end_limit[start_limit:].copy()

    if baseline_data.dropna().empty:
        raise NoBaselineDataError()

    baseline_data.iloc[-1] = np.nan

    data_end = data.index.max()
    data_start = data.index.min()
    return (
        baseline_data,
        _make_baseline_warnings(
            end_inf, start_inf, data_start, data_end, start_limit, end_limit
        ),
    )