code: def __init__(
      self,
      input_dim: int,
      output_dim: int,
      num_history: int = 1,
      hidden_units: Optional[List[int]] = None,
      *,
      mapping_type: str = "highway",
      bias: bool = True,
      activation: str = "ReLU",
      batch_norm: bool = False,
      dropout: float = 0.0,
      w_sin: float = 1.0,
      w_sin_initial: float = 30.0,
      num_random_samples: int = 16,
      use_extra_modulars: bool = False,
      predict_quantiles: bool = True,
      predict_cdf: bool = True,
      dual_period: Optional[int] = 2,
      use_dual_quantiles: bool = False,
      correction_period: Optional[int] = 2,
      use_mean_correction: bool = False,
      num_mean_samples: int = 64,
      y_min_max: Optional[Tuple[float, float]] = None,
      encoder_settings: Optional[Dict[str, MLEncoderSettings]] = None,
      global_encoder_settings: Optional[MLGlobalEncoderSettings] = None,
  ):
      def _make_fcnn() -> FCNN:
          return FCNN(
              input_dim,
              output_dim,
              num_history,
              mapping_type=mapping_type,
              bias=bias,
              activation=activation,
              batch_norm=batch_norm,
              dropout=dropout,
          )
  
      def _make_siren(_in_dim: Optional[int] = None) -> Siren:
          return Siren(
              None,
              _in_dim or 1,
              output_dim,
              hidden_units[0],  # type: ignore
              num_layers=len(hidden_units),  # type: ignore
              w_sin=w_sin,
              w_sin_initial=w_sin_initial,
              bias=False,
              use_modulator=False,
          )
  
      super().__init__(
          encoder_settings=encoder_settings,
          global_encoder_settings=global_encoder_settings,
      )
      if self.encoder is not None:
          input_dim += self.encoder.dim_increment
      self.fcnn = _make_fcnn()
      hidden_units = self.fcnn.hidden_units
      assert hidden_units is not None
      if not len(set(hidden_units)) == 1:
          raise ValueError(
              "`DDR` requires all hidden units to be identical"
          )
  
      use_q_mod = predict_quantiles and use_extra_modulars
      use_cdf_mod = predict_cdf and use_extra_modulars
      self.q_mod = None if not use_q_mod else _make_fcnn()
      self.cdf_mod = None if not use_cdf_mod else _make_fcnn()
  
      self.dual_period = dual_period
      self.use_dual_quantiles = use_dual_quantiles
  
      if use_mean_correction and not predict_quantiles:
          print_warning(
              "`use_mean_correction` is set to `True` but "
              "`predict_quantiles` is `False`, so `use_mean_correction` "
              "will fallback to `False`"
          )
          use_mean_correction = False
      self.correction_period = correction_period
      self.use_mean_correction = use_mean_correction
      self.num_mean_samples = num_mean_samples
  
      self.predict_quantiles = predict_quantiles
      self.predict_cdf = predict_cdf
      self.q_siren = None if not predict_quantiles else _make_siren()
      self.cdf_siren = (
          None if not predict_cdf else _make_siren(output_dim)
      )
      self.num_random_samples = num_random_samples
      self._y_min_max = y_min_max
      self.register_buffer("y_min_max", torch.tensor([0.0, 0.0]))
  
imports: import torch
  import numpy
  import torch.nn.functional
  from torch import Tensor
  from typing import Any
  from typing import Dict
  from typing import List
  from typing import Tuple
  from typing import Union
  from typing import Optional
  from cftool.misc import print_warning
  from cftool.types import tensor_dict_type
  from .base import MLModel
  from .fcnn import FCNN
  from ...types import losses_type
  from ...schema import ILoss
  from ...schema import ITrainer
  from ...schema import TrainerState
  from ...schema import MLEncoderSettings
  from ...schema import MLGlobalEncoderSettings
  from ...constants import LOSS_KEY
  from ...constants import INPUT_KEY
  from ...constants import LABEL_KEY
  from ...constants import PREDICTIONS_KEY
  from ..implicit.siren import make_grid
  from ..implicit.siren import Siren
  from ...misc.toolkit import get_gradient
label_desc: Use image node_id 1 to create a new DDR object from inherited base classes: MLModel with example: obj = DDR(input_dim, output_dim, num_history, hidden_units)