class_docstr: Selects instances, by slicing the target and other time series like arrays
  at random points in training mode or at the last time point in prediction
  mode. Assumption is that all time like arrays start at the same time point.
  
  In training mode, the returned instances contain past_`target_field`
  as well as past_`time_series_fields`.
  
  In prediction mode, one can set `use_prediction_features` to get
  future_`time_series_fields`.
  
  If the target array is one-dimensional, the `target_field` in the resulting
  instance has shape (`instance_length`). In the multi-dimensional case, the
  instance has shape (`dim`, `instance_length`), where `dim` can also take a
  value of 1.
  
  In the case of insufficient number of time series values, the
  transformation also adds a field 'past_is_pad' that indicates whether
  values where padded or not, and the value is padded with
  `default_pad_value` with a default value 0.
  This is done only if `allow_target_padding` is `True`,
  and the length of `target` is smaller than `instance_length`.
  
  Parameters
  ----------
  target_field
      fields that contains time series
  is_pad_field
      output field indicating whether padding happened
  start_field
      field containing the start date of the time series
  forecast_start_field
      field containing the forecast start date
  instance_sampler
      instance sampler that provides sampling indices given a time series
  instance_length
      length of the target seen before making prediction
  output_NTC
      whether to have time series output in (time, dimension) or in
      (dimension, time) layout
  time_series_fields
      fields that contains time series, they are split in the same interval
      as the target
  allow_target_padding
      flag to allow padding
  pad_value
      value to be used for padding
  use_prediction_features
      flag to indicate if prediction range features should be returned
  prediction_length
      length of the prediction range, must be set if
      use_prediction_features is True
code: def flatmap_transform(
      self, data: DataEntry, is_train: bool
  ) -> Iterator[DataEntry]:
      ts_fields = self.dynamic_feature_fields + [self.target_field]
      ts_target = data[self.target_field]
  
      sampling_indices = self.instance_sampler(ts_target)
  
      for i in sampling_indices:
          d = data.copy()
  
          pad_length = max(self.instance_length - i, 0)
  
          # update start field
          d[self.start_field] = (
              data[self.start_field] + i - self.instance_length
          )
  
          # set is_pad field
          is_pad = np.zeros(self.instance_length, dtype=ts_target.dtype)
          if pad_length > 0:
              is_pad[:pad_length] = 1
          d[self.is_pad_field] = is_pad
  
          # update time series fields
          for ts_field in ts_fields:
              full_ts = data[ts_field]
              if pad_length > 0:
                  pad_pre = self.pad_value * np.ones(
                      shape=full_ts.shape[:-1] + (pad_length,)
                  )
                  past_ts = np.concatenate(
                      [pad_pre, full_ts[..., :i]], axis=-1
                  )
              else:
                  past_ts = full_ts[..., (i - self.instance_length) : i]
  
              past_ts = (
                  past_ts.transpose() if self.output_NTC else past_ts
              )
              d[self._past(ts_field)] = past_ts
  
              if self.use_prediction_features:
                  if not ts_field == self.target_field:
                      future_ts = full_ts[
                          ..., i : i + self.prediction_length
                      ]
                      future_ts = (
                          future_ts.transpose()
                          if self.output_NTC
                          else future_ts
                      )
                      d[self._future(ts_field)] = future_ts
  
              del d[ts_field]
  
          d[self.forecast_start_field] = (
              d[self.start_field] + self.instance_length
          )
  
          yield d
  
imports: from typing import Iterator, List, Optional, Tuple
  import numpy
  from pandas.tseries.offsets import BaseOffset
  from gluonts.core.component import validated
  from gluonts.dataset.common import DataEntry
  from gluonts.dataset.field_names import FieldName
  from gluonts.zebras._util import pad_axis
  from ._base import FlatMapTransformation
  from .sampler import ContinuousTimePointSampler, InstanceSampler
label_desc: Use image node_id 4 for calling the CanonicalInstanceSplitter obj's underlying member method code with example usage: obj.flatmap_transform(data, is_train) without return types