code: def out_of_sample_ts_forecast(
      pipeline: Pipeline,
      input_data: Union[InputData, MultiModalData],
      horizon: int = None,
  ) -> np.array:
      """
      Method allow make forecast with appropriate forecast length. The previously
      predicted parts of the time series are used for forecasting next parts. Available
      only for time series forecasting task. Steps ahead provided iteratively.
      time series ----------------|
      forecast                    |---|---|---|
  
      :param pipeline: Pipeline for making time series forecasting
      :param input_data: data for prediction
      :param horizon: forecasting horizon
      :return final_forecast: array with forecast
      """
      task = input_data.task
      exception_if_not_ts_task(task)
  
      # How many elements to the future pipeline can produce
      forecast_length = task.task_params.forecast_length
  
      final_forecast = []
      if (
          isinstance(input_data, MultiModalData)
          or input_data.data_type == DataTypesEnum.multi_ts
      ):
          if forecast_length < horizon:
              raise ValueError(
                  "In case of multi-modal time-series and multi time-series"
                  "forecast horizon can not be bigger than forecast length model was fitted for.\n"
                  f"forecast_length = {forecast_length}\n"
                  f"horizon = {horizon}"
              )
          iter_predict = pipeline.predict(input_data).predict
          iter_predict = np.ravel(np.array(iter_predict))
          final_forecast.append(iter_predict)
      else:
          pre_history_ts = np.array(input_data.features)
          number_of_iterations = math.ceil(horizon / forecast_length)
          # Make forecast iteratively moving throw the horizon
          for _ in range(0, number_of_iterations):
              iter_predict = pipeline.predict(
                  input_data=input_data
              ).predict
              iter_predict = np.ravel(np.array(iter_predict))
              final_forecast.append(iter_predict)
  
              # Add prediction to the historical data - update it
              pre_history_ts = np.hstack((pre_history_ts, iter_predict))
  
              # Prepare InputData for next iteration
              input_data = _update_input(
                  pre_history_ts, forecast_length, task
              )
  
      # Create output data
      final_forecast = np.ravel(np.array(final_forecast))
      if final_forecast.ndim > 1:
          final_forecast = np.squeeze(final_forecast)
      # Clip the forecast if it is necessary
      final_forecast = final_forecast[:horizon]
      return final_forecast
  
file_path: FEDOT/fedot/core/pipelines/ts_wrappers.py
imports: import math
  from copy import copy
  from typing import Union, Optional
  import numpy
  from fedot.core.data.data import InputData, OutputData
  from fedot.core.data.multi_modal import MultiModalData
  from fedot.core.operations.evaluation.operation_implementations.data_operations.ts_transformations import ts_to_table
  from fedot.core.pipelines.pipeline import Pipeline
  from fedot.core.repository.dataset_types import DataTypesEnum
  from fedot.core.repository.tasks import TaskTypesEnum
label_desc: Use image node_id 1 for calling a global function with example usage: out_of_sample_ts_forecast(pipeline, input_data, horizon) and returns: final_forecast