code: def __init__(
      self,
      freq: str,
      prediction_length: int,
      context_length: Optional[int] = None,
      trainer: Trainer = Trainer(),
      num_stacks: int = 30,
      widths: Optional[List[int]] = None,
      num_blocks: Optional[List[int]] = None,
      num_block_layers: Optional[List[int]] = None,
      expansion_coefficient_lengths: Optional[List[int]] = None,
      sharing: Optional[List[bool]] = None,
      stack_types: Optional[List[str]] = None,
      loss_function: Optional[str] = "MAPE",
      **kwargs,
  ) -> None:
      super().__init__(trainer=trainer, **kwargs)
  
      self.freq = freq
      self.prediction_length = prediction_length
      self.context_length = (
          context_length
          if context_length is not None
          else 2 * prediction_length
      )
      # num_stacks has to be handled separately because other arguments have to match its length
      self.num_stacks = num_stacks
      self.loss_function = loss_function
  
      self.widths = self._validate_nbeats_argument(
          argument_value=widths,
          argument_name="widths",
          default_value=[512],
          validation_condition=lambda val: val > 0,
          invalidation_message="Values of 'widths' should be > 0",
      )
      self.num_blocks = self._validate_nbeats_argument(
          argument_value=num_blocks,
          argument_name="num_blocks",
          default_value=[1],
          validation_condition=lambda val: val > 0,
          invalidation_message="Values of 'num_blocks' should be > 0",
      )
      self.num_block_layers = self._validate_nbeats_argument(
          argument_value=num_block_layers,
          argument_name="num_block_layers",
          default_value=[4],
          validation_condition=lambda val: val > 0,
          invalidation_message="Values of 'block_layers' should be > 0",
      )
      self.sharing = self._validate_nbeats_argument(
          argument_value=sharing,
          argument_name="sharing",
          default_value=[False],
          validation_condition=lambda val: True,
          invalidation_message="",
      )
      self.expansion_coefficient_lengths = self._validate_nbeats_argument(
          argument_value=expansion_coefficient_lengths,
          argument_name="expansion_coefficient_lengths",
          default_value=[32],
          validation_condition=lambda val: val > 0,
          invalidation_message="Values of 'expansion_coefficient_lengths' should be > 0",
      )
      self.stack_types = self._validate_nbeats_argument(
          argument_value=stack_types,
          argument_name="stack_types",
          default_value=["G"],
          validation_condition=lambda val: val
          in VALID_N_BEATS_STACK_TYPES,
          invalidation_message=f"Values of 'stack_types' should be one of {VALID_N_BEATS_STACK_TYPES}",
      )
  
      self.train_sampler = ExpectedNumInstanceSampler(
          num_instances=1.0, min_future=prediction_length
      )
      self.validation_sampler = ValidationSplitSampler(
          min_future=prediction_length
      )
  
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 1 to create a new NBEATSEstimator object  with example: obj = NBEATSEstimator(freq, prediction_length, context_length, trainer, num_stacks, widths, num_blocks, num_block_layers, expansion_coefficient_lengths, sharing, stack_types, loss_function)