class_docstr: `LMLSTM` implements a word-level language model that uses LSTMs to
  represent the document.
class_docstr_tok: ["`","LMLSTM","`","implements","a","word-level","language","model","that","uses","LSTMs","to","represent","the","document","."]
code: def from_config(
      cls, config: Config, tensorizers: Dict[str, Tensorizer]
  ):
      cls.checkTokenConfig(tensorizers["tokens"])
      embedding = create_module(
          config.embedding, tensorizer=tensorizers["tokens"]
      )
      representation = create_module(
          config.representation, embed_dim=embedding.embedding_dim
      )
      labels = tensorizers["tokens"].vocab
      decoder = create_module(
          config.decoder,
          in_dim=representation.representation_dim,
          out_dim=len(labels),
      )
      if config.tied_weights:
          if (
              decoder.get_decoder()[0][-1].weight.size()
              != embedding.weight.size()
          ):
              raise ValueError(
                  "Embedding dimension must be same as representation "
                  "dimensions when using tied weights"
              )
          decoder.get_decoder()[0][-1].weight = embedding.weight
      output_layer = create_module(config.output_layer, labels=labels)
      exporter = get_exporter(config.caffe2_format)
      return cls(
          embedding=embedding,
          representation=representation,
          decoder=decoder,
          output_layer=output_layer,
          stateful=config.stateful,
          exporter=exporter,
      )
  
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  from pytext.config import ConfigBase
  from pytext.config.module_config import ExporterType
  from pytext.data import CommonMetadata
  from pytext.data.tensorizers import Tensorizer, TokenTensorizer
  from pytext.exporters.custom_exporters import get_exporter
  from pytext.exporters.exporter import ModelExporter
  from pytext.models.decoders import DecoderBase
  from pytext.models.decoders.mlp_decoder import MLPDecoder
  from pytext.models.embeddings import EmbeddingBase
  from pytext.models.embeddings.word_embedding import WordEmbedding
  from pytext.models.model import BaseModel, Model
  from pytext.models.module import create_module
  from pytext.models.output_layers import OutputLayerBase
  from pytext.models.output_layers.lm_output_layer import LMOutputLayer
  from pytext.models.representations.bilstm import BiLSTM
  from pytext.models.representations.deepcnn import DeepCNNRepresentation
  from pytext.models.representations.representation_base import RepresentationBase
  from pytext.utils.usage import log_class_usage
label_desc: Use image node_id 2 for calling the LMLSTM obj's underlying member method code with example usage: obj.from_config(cls, config, tensorizers) and returns: cls