code: def calc_train_trade_starts_ends_if_rolling(
      init_train_dates: list[str],
      init_trade_dates: list[str],
      rolling_window_length: int,
  ) -> tuple[list[str], list[str], list[str], list[str]]:
      trade_dates_length = len(init_trade_dates)
      train_window_length = len(init_train_dates)
      trade_window_length = min(
          rolling_window_length, trade_dates_length
      )
      num_subsets_if_rolling = int(
          np.ceil(trade_dates_length / trade_window_length)
      )
      print("num_subsets_if_rolling: ", num_subsets_if_rolling)
      dates = np.concatenate(
          (init_train_dates, init_trade_dates), axis=0
      )
      train_starts = []
      train_ends = []
      trade_starts = []
      trade_ends = []
  
      for i in range(num_subsets_if_rolling):
          trade_start_index = (
              train_window_length + i * trade_window_length
          )
          trade_start = dates[trade_start_index]
          trade_starts.append(trade_start)
          trade_end_index = min(
              trade_start_index + trade_window_length, len(dates) - 1
          )
          trade_end = dates[trade_end_index]
          trade_ends.append(trade_end)
          train_start = dates[trade_start_index - train_window_length]
          train_starts.append(train_start)
          train_end = dates[trade_start_index]
          train_ends.append(train_end)
      print("train_starts: ", train_starts)
      print("train_ends__: ", train_ends)
      print("trade_starts: ", trade_starts)
      print("trade_ends__: ", trade_ends)
      return train_starts, train_ends, trade_starts, trade_ends
  
file_path: FinRL/finrl/meta/data_processors/func.py
imports: from __future__ import annotations
  import copy
  import datetime
  import os
  from datetime import date
  from datetime import timedelta
  from typing import List
  from typing import Tuple
  import numpy
  import pandas
label_desc: Use image node_id 8 for calling a global function with example usage: calc_train_trade_starts_ends_if_rolling(init_train_dates, init_trade_dates, rolling_window_length) and returns: train_starts,  train_ends,  trade_starts,  trade_ends