class_docstr: Tests the `create_lagged_training_data` function defined in `darts.utils.data.tabularization`. There are broadly
  two 'groups' of tests defined in this module:
      1. 'Generated Test Cases': these test that `create_lagged_training_data` produces the same outputs
      as a simplified implementation of the 'time intersection' feature generation method (see
      `darts.utils.data.tabularization` for further details). For these tests, the 'correct answer' is not
      directly specified; instead, it is generated from a set of input parameters using the set of simplified
      functions. The rationale behind this approach is that it allows for many different combinations of input
      values to be effortlessly tested. The drawback of this, however, is that the correctness of these tests
      assumes that the simplified functions have been implemented correctly - if this isn't the case, then these
      tests are not to be trusted. In saying this, these simplified functions are significantly easier to
      understand and debug than the `create_lagged_training_data` function they're helping to test.
      2. 'Specified Test Cases': these test that `create_lagged_training_data` returns an exactly specified
      output; these specified outputs are *not* 'generated' by another function. Although these 'specified'
      test cases tend to be simpler and less extensive than the 'generated' test cases, their correctness does
      not assume the correct implementation of any other function.
class_docstr_tok: ["Tests","the","`","create_lagged_training_data","`","function","defined","in","`","darts.utils.data.tabularization","`",".","There","are","broadly","two","'groups","'","of","tests","defined","in","this","module",":","1",".","'Generated","Test","Cases","'",":","these","test","that","`","create_lagged_training_data","`","produces","the","same","outputs","as","a","simplified","implementation","of","the","'time","intersection","'","feature","generation","method","(","see","`","darts.utils.data.tabularization","`","for","further","details",")",".","For","these","tests",",","the","'correct","answer","'","is","not","directly","specified",";","instead",",","it","is","generated","from","a","set","of","input","parameters","using","the","set","of","simplified","functions",".","The","rationale","behind","this","approach","is","that","it","allows","for","many","different","combinations","of","input","values","to","be","effortlessly","tested",".","The","drawback","of","this",",","however",",","is","that","the","correctness","of","these","tests","assumes","that","the","simplified","functions","have","been","implemented","correctly","-","if","this","is","n't","the","case",",","then","these","tests","are","not","to","be","trusted",".","In","saying","this",",","these","simplified","functions","are","significantly","easier","to","understand","and","debug","than","the","`","create_lagged_training_data","`","function","they","'re","helping","to","test",".","2",".","'Specified","Test","Cases","'",":","these","test","that","`","create_lagged_training_data","`","returns","an","exactly","specified","output",";","these","specified","outputs","are","*","not","*","'generated","'","by","another","function",".","Although","these","'specified'","test","cases","tend","to","be","simpler","and","less","extensive","than","the","'generated","'","test","cases",",","their","correctness","does","not","assume","the","correct","implementation","of","any","other","function","."]
docstr: Helper function that constructs the labels array `y` from the target series.
  This is done by by looping over each time in `feature_times`, finding the index
  position of that time in the target series, and then for each timestep ahead of
  this time we wish to predict, offset this time index by this timestep. This offset
  index is then used to extract all components of the target series at this time which
  is to be predicted. Please refer to the `create_lagged_features` docstring for further
  details about the structure of the `y` labels matrix.
  
  Unlike `construct_X_block`, we don't need to worry about times in `feature_times` lying
  outside of `target.time_index` here: each label *must* be contained in the `target`
  series already.
docstr_tok: ["Helper","function","that","constructs","the","labels","array","`","y","`","from","the","target","series",".","This","is","done","by","by","looping","over","each","time","in","`","feature_times","`",",","finding","the","index","position","of","that","time","in","the","target","series",",","and","then","for","each","timestep","ahead","of","this","time","we","wish","to","predict",",","offset","this","time","index","by","this","timestep",".","This","offset","index","is","then","used","to","extract","all","components","of","the","target","series","at","this","time","which","is","to","be","predicted",".","Please","refer","to","the","`","create_lagged_features","`","docstring","for","further","details","about","the","structure","of","the","`","y","`","labels","matrix",".","Unlike","`","construct_X_block","`",",","we","do","n't","need","to","worry","about","times","in","`","feature_times","`","lying","outside","of","`","target.time_index","`","here",":","each","label","*","must","*","be","contained","in","the","`","target","`","series","already","."]
code: def create_y(
      target: TimeSeries,
      feature_times: pd.Index,
      output_chunk_length: int,
      multi_models: bool,
  ) -> np.ndarray:
      """
      Helper function that constructs the labels array `y` from the target series.
      This is done by by looping over each time in `feature_times`, finding the index
      position of that time in the target series, and then for each timestep ahead of
      this time we wish to predict, offset this time index by this timestep. This offset
      index is then used to extract all components of the target series at this time which
      is to be predicted. Please refer to the `create_lagged_features` docstring for further
      details about the structure of the `y` labels matrix.
  
      Unlike `construct_X_block`, we don't need to worry about times in `feature_times` lying
      outside of `target.time_index` here: each label *must* be contained in the `target`
      series already.
      """
      array_vals = target.all_values(copy=False)
      y = []
      for time in feature_times:
          raise_if(
              time < target.start_time(),
              f"Unexpected label time at {time}, but `series` starts at {target.start_time()}.",
          )
          raise_if(
              time > target.end_time(),
              f"Unexpected label time at {time}, but `series` ends at {target.end_time()}.",
          )
          time_idx = np.searchsorted(target.time_index, time)
          # If `multi_models = True`, want to predict all of the values from time `t` to
          # time `t + output_chunk_lenth - 1`; if `multi_models = False`, only want to
          # predict time `t + output_chunk_length - 1`:
          timesteps_ahead = (
              range(output_chunk_length)
              if multi_models
              else (output_chunk_length - 1,)
          )
          y_row = []
          for i in timesteps_ahead:
              # Offset index of `time` by how many timesteps we're looking ahead:
              idx_to_get = time_idx + i
              # Extract all components at this time:
              y_row.append(array_vals[idx_to_get, :, 0].reshape(-1))
          # Concatenate all times to be predicted into a single row:
          y_row = np.concatenate(y_row, axis=0)
          y.append(y_row)
      # Stack all rows into a single labels matrix:
      y = np.stack(y, axis=0)
      return y
  
imports: import warnings
  from itertools import product
  from typing import Optional, Sequence
  import numpy
  import pandas
  import pytest
  from darts import TimeSeries
  from darts import concatenate
  from darts.logging import get_logger, raise_if, raise_if_not, raise_log
  from darts.utils.data.tabularization import create_lagged_component_names, create_lagged_training_data
  from darts.utils.timeseries_generation import linear_timeseries
label_desc: Use image node_id 7 for calling the TestCreateLaggedTrainingData obj's underlying member method code with example usage: obj.create_y(target, feature_times, output_chunk_length, multi_models) and returns: y