code: def __init__(
      self,
      settings: Dict[str, MLEncoderSettings],
      global_encoder_settings: Optional[MLGlobalEncoderSettings] = None,
  ):
      super().__init__()
      self.embeddings = nn.ModuleDict()
      self.one_hot_encoders = nn.ModuleDict()
      dims = []
      self.tgt_columns = []
      self.one_hot_columns = []
      self.embedding_columns = []
      self.one_hot_dim = 0
      self.embedding_dim = 0
      self.dim_increment = 0
      for str_idx in sorted(settings):
          idx = int(str_idx)
          setting = settings[str_idx]
          dim = setting.dim
          dims.append(dim)
          self.tgt_columns.append(idx)
          if setting.use_one_hot:
              self.one_hot_columns.append(idx)
              self.one_hot_encoders[str_idx] = OneHot(dim)
              self.one_hot_dim += dim
              self.dim_increment += dim - 1
          if setting.use_embedding:
              self.embedding_columns.append(idx)
              kw = shallow_copy_dict(setting.method_configs or {})
              config = get_embedding_config(
                  dim, kw, global_encoder_settings
              )
              self.embeddings[str_idx] = Embedding(dim, config)
              self.embedding_dim += config.out_dim
              self.dim_increment += config.out_dim - 1
      # setup useful properties
      self.categorical_dim = self.one_hot_dim + self.embedding_dim
      self.num_one_hot = len(self.one_hot_encoders)
      self.num_embedding = len(self.embeddings)
      self.use_one_hot = self.num_one_hot > 0
      self.use_embedding = self.num_embedding > 0
      self.is_empty = not self.use_one_hot and not self.use_embedding
      self.all_one_hot = len(self.one_hot_columns) == len(
          self.tgt_columns
      )
      self.all_embedding = len(self.embedding_columns) == len(
          self.tgt_columns
      )
      self.register_buffer(
          "dims", torch.tensor(dims, dtype=torch.float32)
      )
  
imports: import math
  import torch
  import numpy
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
  from typing import Any
  from typing import Dict
  from typing import List
  from typing import Union
  from typing import Optional
  from typing import NamedTuple
  from cftool.array import to_torch
  from cftool.types import arr_type
  from ...schema import MLEncoderSettings
  from ...schema import MLGlobalEncoderSettings
  from ...misc.toolkit import shallow_copy_dict
  from ...misc.toolkit import Initializer
  from ...modules.blocks import Lambda
label_desc: Use image node_id 1 to create a new Encoder object from inherited base classes: nn with example: obj = Encoder(settings, global_encoder_settings)