code: def test_gcd_train_end_date():
      """Tests train_end_date for data without regressors"""
      df = pd.DataFrame(
          {
              TIME_COL: [
                  datetime.datetime(2018, 1, 1, 3, 0, 0),
                  datetime.datetime(2018, 1, 1, 4, 0, 0),
                  datetime.datetime(2018, 1, 1, 5, 0, 0),
                  datetime.datetime(2018, 1, 1, 6, 0, 0),
                  datetime.datetime(2018, 1, 1, 7, 0, 0),
              ],
              VALUE_COL: [1, np.nan, 3, np.nan, np.nan],
          }
      )
  
      # no train_end_date
      with pytest.warns(UserWarning) as record:
          train_end_date = datetime.datetime(2018, 1, 1, 5, 0, 0)
          get_canonical_data(df=df)
          assert (
              f"{VALUE_COL} column of the provided time series contains "
              f"null values at the end, or the input `train_end_date` is beyond the last timestamp available. "
              f"Setting `train_end_date` to the last timestamp with a non-null value "
              f"({train_end_date})." in record[0].message.args[0]
          )
  
      # train_end_date later than last date in df
      with pytest.warns(UserWarning) as record:
          train_end_date = datetime.datetime(2018, 1, 1, 8, 0, 0)
          get_canonical_data(df, train_end_date=train_end_date)
          assert (
              f"{VALUE_COL} column of the provided time series contains null values at the end, "
              f"or the input `train_end_date` is beyond the last timestamp available."
              in record[0].message.args[0]
          )
  
      # train_end_date in between last date in df and last date before
      with pytest.warns(UserWarning) as record:
          train_end_date = datetime.datetime(2018, 1, 1, 6, 0, 0)
          get_canonical_data(df, train_end_date=train_end_date)
          assert (
              f"{VALUE_COL} column of the provided time series contains trailing NAs"
              in record[0].message.args[0]
          )
  
      # train end date equal to last date before null
      canonical_data_dict = get_canonical_data(
          df, train_end_date=datetime.datetime(2018, 1, 1, 5, 0, 0)
      )
      assert canonical_data_dict["train_end_date"] == datetime.datetime(
          2018, 1, 1, 5, 0, 0
      )
  
      # train_end_date smaller than last date before null
      canonical_data_dict = get_canonical_data(
          df, train_end_date=datetime.datetime(2018, 1, 1, 4, 0, 0)
      )
      assert_equal(
          canonical_data_dict["fit_df"],
          canonical_data_dict["df"].iloc[:2],
      )
      assert canonical_data_dict["regressor_cols"] == []
      assert canonical_data_dict["fit_cols"] == [TIME_COL, VALUE_COL]
      assert canonical_data_dict["train_end_date"] == datetime.datetime(
          2018, 1, 1, 4, 0, 0
      )
      assert canonical_data_dict[
          "last_date_for_val"
      ] == datetime.datetime(2018, 1, 1, 5, 0, 0)
      assert canonical_data_dict["last_date_for_reg"] is None
  
imports: import datetime
  import numpy
  import pandas
  import pytest
  from greykite.common.constants import ADJUSTMENT_DELTA_COL
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import METRIC_COL
  from greykite.common.constants import START_TIME_COL
  from greykite.common.constants import TIME_COL
  from greykite.common.constants import VALUE_COL
  from greykite.common.data_loader import DataLoader
  from greykite.common.enums import TimeEnum
  from greykite.common.python_utils import assert_equal
  from greykite.common.testing_utils import generate_df_with_reg_for_tests
  from greykite.common.time_properties import describe_timeseries
  from greykite.common.time_properties import fill_missing_dates
  from greykite.common.time_properties import find_missing_dates
  from greykite.common.time_properties import get_canonical_data
  from greykite.common.time_properties import infer_freq
  from greykite.common.time_properties import min_gap_in_seconds
label_desc: Use image node_id 10 for calling a global function with example usage: test_gcd_train_end_date() without return types