class_docstr: `MLPDecoder` implements a fully connected network and uses ReLU as the
  activation function. The module projects an input tensor to `out_dim`.
  
  Args:
      config (Config): Configuration object of type MLPDecoder.Config.
      in_dim (int): Dimension of input Tensor passed to MLP.
      out_dim (int): Dimension of output Tensor produced by MLP. Defaults to 0.
  
  Attributes:
      mlp (type): Module that implements the MLP.
      out_dim (type): Dimension of the output of this module.
      hidden_dims (List[int]): Dimensions of the outputs of hidden layers.
code: def __init__(
      self, config: Config, in_dim: int, out_dim: int = 0
  ) -> None:
      super().__init__(config)
  
      layers = []
      for dim in config.hidden_dims or []:
          layers.append(nn.Linear(in_dim, dim, config.bias))
          layers.append(get_activation(config.activation))
          if config.layer_norm:
              layers.append(nn.LayerNorm(dim))
          if config.dropout > 0:
              layers.append(nn.Dropout(config.dropout))
          in_dim = dim
      if config.out_dim is not None:
          out_dim = config.out_dim
      if out_dim > 0:
          layers.append(nn.Linear(in_dim, out_dim, config.bias))
  
      assert len(layers) > 0
      if config.spectral_normalization:
          layers[-1] = torch.nn.utils.spectral_norm(layers[-1])
      self.mlp = nn.Sequential(*layers)
      self.out_dim = out_dim if out_dim > 0 else config.hidden_dims[-1]
      self.temperature = config.temperature
  
      if config.load_model_path:
          with PathManager.open(config.load_model_path, "rb") as f:
              mlp_state = torch.load(
                  f,
                  map_location=lambda s, l: default_restore_location(
                      s, "cpu"
                  ),
              )
          print("loaded mlp state")
          self.load_state_dict(mlp_state, strict=config.load_strict)
  
      log_class_usage(__class__)
  
file_path: pytext/pytext/models/decoders/mlp_decoder.py
imports: from typing import List, Optional
  import torch
  import torch.nn
  from pytext.config.module_config import Activation
  from pytext.optimizer import get_activation
  from pytext.utils.file_io import PathManager
  from pytext.utils.usage import log_class_usage
  from torch.serialization import default_restore_location
  from .decoder_base import DecoderBase
label_desc: Use image node_id 1 to create a new MLPDecoder object from inherited base classes: DecoderBase with example: obj = MLPDecoder(config, in_dim, out_dim)