code: def encode(self, net: Tensor) -> MLEncodePack:
      if self.encoder is None or self.encoder.is_empty:
          return MLEncodePack(None, None, net, None, net)
      numerical_columns = [
          index
          for index in range(net.shape[-1])
          if index not in self.encoder.tgt_columns
      ]
      numerical = net[..., numerical_columns]
      res: EncodingResult = self.encoder(net)
      merged_categorical = res.merged
      if merged_categorical is None:
          merged_all = numerical
      else:
          merged_all = torch.cat(
              [numerical, merged_categorical], dim=-1
          )
      return MLEncodePack(
          res.one_hot,
          res.embedding,
          numerical,
          merged_categorical,
          merged_all,
      )
  
file_path: carefree-learn/cflearn/models/ml/base.py
imports: import torch
  from torch import Tensor
  from typing import Any
  from typing import Dict
  from typing import Optional
  from typing import NamedTuple
  from .encoders import Encoder
  from .encoders import EncodingResult
  from ...schema import IMLModel
  from ...schema import MLEncoderSettings
  from ...schema import MLGlobalEncoderSettings
label_desc: Use image node_id 2 for calling the MLModel obj's underlying member method code with example usage: obj.encode(net) and returns: MLEncodePack, MLEncodePack