class_docstr: Generic single-task model class that expects four components:
  
  1. `Embedding`
  2. `Representation`
  3. `Decoder`
  4. `Output Layer`
  
  Forward pass: `embedding -> representation -> decoder -> output_layer`
  
  These four components have specific responsibilities as described below.
  
  `Embedding` layer should implement the way to represent each token in the
  input text. It can be as simple as just token/word embedding or can be
  composed of multiple ways to represent a token, e.g., word embedding,
  character embedding, etc.
  
  `Representation` layer should implement the way to encode the entire input
  text such that the output vector(s) can be used by decoder to produce logits.
  There is no restriction on the number of inputs it should encode. There is
  also not restriction on the number of ways to encode input.
  
  `Decoder` layer should implement the way to consume the output of model's
  representation and produce logits that can be used by the output layer to
  compute loss or generate predictions (and prediction scores/confidence)
  
  `Output layer` should implement the way loss computation is done as well as
  the logic to generate predictions from the logits.
  
  Let us discuss the joint intent-slot model as a case to go over these layers.
  The model predicts intent of input utterance and the slots in the utterance.
  (Refer to :doc:`/atis_tutorial` for details about intent-slot model.)
  
  1. :class:`~EmbeddingList` layer is tasked with representing tokens. To do so we
     can use learnable word embedding table in conjunction with learnable character
     embedding table that are distilled to token level representation using CNN and
     pooling.
     Note: This class is meant to be reused by all models. It acts as a container
     of all the different ways of representing a token/word.
  2. :class:`~BiLSTMDocSlotAttention` is tasked with encoding the embedded input
     string for intent classification and slot filling. In order to do that it has a
     shared bidirectional LSTM layer followed by separate attention layers for
     document level attention and word level attention. Finally it produces two
     vectors per utterance.
  3. :class:`~IntentSlotModelDecoder` accepts the two input vectors from
     `BiLSTMDocSlotAttention` and produces logits for intent classification and
     slot filling. Conditioned on a flag it can also use the probabilities from
     intent classification for slot filling.
  4. :class:`~IntentSlotOutputLayer` implements the logic behind computing loss and
     prediction, as well as, how to export this layer to export to Caffe2. This is
     used by model exporter as a post-processing Caffe2 operator.
  
  
  Args:
      embedding (EmbeddingBase): Description of parameter `embedding`.
      representation (RepresentationBase): Description of parameter `representation`.
      decoder (DecoderBase): Description of parameter `decoder`.
      output_layer (OutputLayerBase): Description of parameter `output_layer`.
  
  Attributes:
      embedding
      representation
      decoder
      output_layer
class_docstr_tok: ["Generic","single-task","model","class","that","expects","four","components",":","1",".","`","Embedding","`","2",".","`","Representation","`","3",".","`","Decoder","`","4",".","`","Output","Layer","`","Forward","pass",":","`","embedding","-",">","representation","-",">","decoder","-",">","output_layer","`","These","four","components","have","specific","responsibilities","as","described","below",".","`","Embedding","`","layer","should","implement","the","way","to","represent","each","token","in","the","input","text",".","It","can","be","as","simple","as","just","token\/word","embedding","or","can","be","composed","of","multiple","ways","to","represent","a","token",",","e.g.",",","word","embedding",",","character","embedding",",","etc",".","`","Representation","`","layer","should","implement","the","way","to","encode","the","entire","input","text","such","that","the","output","vector","(","s",")","can","be","used","by","decoder","to","produce","logits",".","There","is","no","restriction","on","the","number","of","inputs","it","should","encode",".","There","is","also","not","restriction","on","the","number","of","ways","to","encode","input",".","`","Decoder","`","layer","should","implement","the","way","to","consume","the","output","of","model's","representation","and","produce","logits","that","can","be","used","by","the","output","layer","to","compute","loss","or","generate","predictions","(","and","prediction","scores\/confidence",")","`","Output","layer","`","should","implement","the","way","loss","computation","is","done","as","well","as","the","logic","to","generate","predictions","from","the","logits",".","Let","us","discuss","the","joint","intent-slot","model","as","a","case","to","go","over","these","layers",".","The","model","predicts","intent","of","input","utterance","and","the","slots","in","the","utterance",".","(","Refer","to",":","doc",":","`","\/atis_tutorial","`","for","details","about","intent-slot","model",".",")","1.",":","class",":","`","~EmbeddingList","`","layer","is","tasked","with","representing","tokens",".","To","do","so","we","can","use","learnable","word","embedding","table","in","conjunction","with","learnable","character","embedding","table","that","are","distilled","to","token","level","representation","using","CNN","and","pooling",".","Note",":","This","class","is","meant","to","be","reused","by","all","models",".","It","acts","as","a","container","of","all","the","different","ways","of","representing","a","token\/word",".","2.",":","class",":","`","~BiLSTMDocSlotAttention","`","is","tasked","with","encoding","the","embedded","input","string","for","intent","classification","and","slot","filling",".","In","order","to","do","that","it","has","a","shared","bidirectional","LSTM","layer","followed","by","separate","attention","layers","for","document","level","attention","and","word","level","attention",".","Finally","it","produces","two","vectors","per","utterance",".","3.",":","class",":","`","~IntentSlotModelDecoder","`","accepts","the","two","input","vectors","from","`","BiLSTMDocSlotAttention","`","and","produces","logits","for","intent","classification","and","slot","filling",".","Conditioned","on","a","flag","it","can","also","use","the","probabilities","from","intent","classification","for","slot","filling",".","4.",":","class",":","`","~IntentSlotOutputLayer","`","implements","the","logic","behind","computing","loss","and","prediction",",","as","well","as",",","how","to","export","this","layer","to","export","to","Caffe2",".","This","is","used","by","model","exporter","as","a","post-processing","Caffe2","operator",".","Args",":","embedding","(","EmbeddingBase",")",":","Description","of","parameter","`","embedding","`",".","representation","(","RepresentationBase",")",":","Description","of","parameter","`","representation","`",".","decoder","(","DecoderBase",")",":","Description","of","parameter","`","decoder","`",".","output_layer","(","OutputLayerBase",")",":","Description","of","parameter","`","output_layer","`",".","Attributes",":","embedding","representation","decoder","output_layer"]
code: def from_config(
      cls,
      config: Config,
      feat_config: FeatureConfig,
      metadata: CommonMetadata,
  ):
      embedding = create_module(
          feat_config, create_fn=cls.create_embedding, metadata=metadata
      )
      representation = create_module(
          config.representation, embed_dim=embedding.embedding_dim
      )
      # Find all inputs for the decoder layer
      decoder_in_dim = representation.representation_dim
      decoder_input_features_count = 0
      for decoder_feat in (ModelInput.DENSE_FEAT,):  # Only 1 right now.
          if getattr(feat_config, decoder_feat, False):
              decoder_input_features_count += 1
              decoder_in_dim += getattr(
                  feat_config, ModelInput.DENSE_FEAT
              ).dim
      decoder = create_module(
          config.decoder,
          in_dim=decoder_in_dim,
          out_dim=metadata.target.vocab_size,
      )
      decoder.num_decoder_modules = decoder_input_features_count
      output_layer = create_module(config.output_layer, metadata.target)
      return cls(embedding, representation, decoder, output_layer)
  
imports: import os
  from typing import Dict, List, Union
  import torch
  import torch.jit
  import torch.nn
  from pytext.common.constants import Stage, TORCH_VERSION
  from pytext.config.component import Component, ComponentType
  from pytext.config.doc_classification import ModelInput
  from pytext.config.field_config import FeatureConfig
  from pytext.config.pytext_config import ConfigBase, ConfigBaseMeta
  from pytext.data import CommonMetadata
  from pytext.data.tensorizers import Tensorizer
  from pytext.models.module import create_module
  from pytext.utils.file_io import PathManager
  from pytext.utils.path import is_absolute_path
  from pytext.utils.precision import maybe_float
  from pytext.utils.usage import log_class_usage
  from .decoders import DecoderBase
  from .embeddings import EmbeddingBase, EmbeddingList
  from .output_layers import OutputLayerBase
  from .representations.representation_base import RepresentationBase
label_desc: Use image node_id 5 for calling the Model obj's underlying member method code with example usage: obj.from_config(cls, config, feat_config, metadata) and returns: cls