code: def create_instance_splitter(self, mode: str):
      assert mode in ["training", "validation", "test"]
  
      instance_sampler = {
          "training": self.train_sampler,
          "validation": self.validation_sampler,
          "test": TestSplitSampler(),
      }[mode]
  
      return InstanceSplitter(
          target_field=FieldName.TARGET,
          is_pad_field=FieldName.IS_PAD,
          start_field=FieldName.START,
          forecast_start_field=FieldName.FORECAST_START,
          instance_sampler=instance_sampler,
          past_length=self.context_length,
          future_length=self.prediction_length,
          time_series_fields=[FieldName.OBSERVED_VALUES],
      )
  
file_path: gluonts/src/gluonts/nursery/robust-mts-attack/pts/model/n_beats/n_beats_estimator.py
imports: from typing import List, Optional
  import torch
  import torch.nn
  from gluonts.core.component import validated
  from gluonts.dataset.field_names import FieldName
  from gluonts.model.predictor import Predictor
  from gluonts.torch.model.predictor import PyTorchPredictor
  from gluonts.torch.util import copy_parameters
  from gluonts.transform import InstanceSplitter, ValidationSplitSampler, TestSplitSampler, AddObservedValuesIndicator, Transformation, Chain, RemoveFields, ExpectedNumInstanceSampler
  from pts import Trainer
  from pts.model import PyTorchEstimator
  from pts.model.utils import get_module_forward_input_names
  from .n_beats_network import NBEATSPredictionNetwork, NBEATSTrainingNetwork, VALID_N_BEATS_STACK_TYPES
label_desc: Use image node_id 4 for calling the NBEATSEstimator obj's underlying member method code with example usage: obj.create_instance_splitter(mode) and returns: InstanceSplitter