code: def __init__(
      self,
      input_dim: int,
      output_dim: int,
      num_history: int = 1,
      *,
      nary: Optional[Dict[str, List[Tuple[int, ...]]]] = None,
      num_bases: int = 64,
      bases_dropout: float = 0.0,
      hidden_units: Optional[List[int]] = None,
      bias: bool = True,
      activation: str = "ReLU",
      batch_norm: bool = False,
      dropout: float = 0.0,
      encoder_settings: Optional[Dict[str, MLEncoderSettings]] = None,
      global_encoder_settings: Optional[MLGlobalEncoderSettings] = None,
  ):
      super().__init__(
          encoder_settings=encoder_settings,
          global_encoder_settings=global_encoder_settings,
      )
      if self.encoder is not None:
          input_dim += self.encoder.dim_increment
      input_dim *= num_history
      if hidden_units is None:
          dim = max(32, min(1024, 2 * input_dim))
          hidden_units = 2 * [dim]
  
      self.input_dim = input_dim
      self.output_dim = output_dim
      self.bias = bias
  
      self.bases = nn.ModuleDict()
      self.nary = nary or {"1": list(combinations(range(input_dim), 1))}
      self.num_bases = num_bases
      for order in self.nary:
          self.bases[order] = NBMBlock(
              int(order),
              num_bases,
              hidden_units=hidden_units,
              bias=bias,
              activation=activation,
              batch_norm=batch_norm,
              dropout=dropout,
          )
      self.bases_dropout = nn.Dropout(p=bases_dropout)
  
      self.all_indices = []
      for indices in self.nary.values():
          self.all_indices += indices
      self.latent_dim = len(self.all_indices)
  
      self.featurizer = nn.Conv1d(
          self.latent_dim * num_bases,
          self.latent_dim,
          kernel_size=1,
          groups=self.latent_dim,
          bias=bias,
      )
      self.head = nn.Linear(self.latent_dim, output_dim, bias=True)
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from typing import Dict
  from typing import List
  from typing import Tuple
  from typing import Optional
  from itertools import combinations
  from .base import MLModel
  from ...schema import MLEncoderSettings
  from ...schema import MLGlobalEncoderSettings
  from ...misc.toolkit import eval_context
  from ...modules.blocks import Activation
label_desc: Use image node_id 1 to create a new NBM object from inherited base classes: MLModel with example: obj = NBM(input_dim, output_dim, num_history)