class_docstr: Classification model following the pattern of tensorizer + encoder.
class_docstr_tok: ["Classification","model","following","the","pattern","of","tensorizer","+","encoder","."]
code: def from_config(
      cls, config: Config, tensorizers: Dict[str, Tensorizer]
  ):
      labels = tensorizers["labels"].vocab
      if not labels:
          raise ValueError(
              "Labels were not created, see preceding errors"
          )
  
      vocab = tensorizers["tokens"].vocab
      encoder = create_module(
          config.encoder,
          padding_idx=vocab.get_pad_index(),
          vocab_size=len(vocab),
      )
      if getattr(config, "use_selfie", False):
          # No MLP fusion in SELFIE
          dense_dim = 0
      else:
          dense_dim = (
              tensorizers["dense"].dim if "dense" in tensorizers else 0
          )
      decoder = create_module(
          config.decoder,
          in_dim=encoder.representation_dim + dense_dim,
          out_dim=len(labels),
      )
  
      label_weights = (
          get_label_weights(
              labels.idx, config.output_layer.label_weights
          )
          if config.output_layer.label_weights
          else None
      )
  
      loss = create_loss(config.output_layer.loss, weight=label_weights)
  
      if isinstance(loss, BinaryCrossEntropyLoss):
          output_layer_cls = BinaryClassificationOutputLayer
      elif isinstance(loss, MultiLabelSoftMarginLoss):
          output_layer_cls = MultiLabelOutputLayer
      else:
          output_layer_cls = MulticlassOutputLayer
  
      additional_kwargs = {}
      if hasattr(config, "r3f_options"):
          additional_kwargs["r3f_options"] = config.r3f_options
  
      output_layer = output_layer_cls(list(labels), loss)
      return cls(encoder, decoder, output_layer, **additional_kwargs)
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  from pytext.common.constants import Stage
  from pytext.config.component import create_loss
  from pytext.data.bert_tensorizer import BERTTensorizer, BERTTensorizerBase
  from pytext.data.dense_retrieval_tensorizer import BERTContextTensorizerForDenseRetrieval, PositiveLabelTensorizerForDenseRetrieval
  from pytext.data.tensorizers import FloatListTensorizer, LabelTensorizer, NtokensTensorizer, Tensorizer
  from pytext.loss import BinaryCrossEntropyLoss, MultiLabelSoftMarginLoss
  from pytext.models.decoders.mlp_decoder import MLPDecoder
  from pytext.models.model import BaseModel, ModelInputBase
  from pytext.models.module import create_module
  from pytext.models.output_layers import ClassificationOutputLayer
  from pytext.models.output_layers.doc_classification_output_layer import BinaryClassificationOutputLayer, MulticlassOutputLayer, MultiLabelOutputLayer
  from pytext.models.pair_classification_model import BasePairwiseModel
  from pytext.models.representations.huggingface_bert_sentence_encoder import HuggingFaceBertSentenceEncoder
  from pytext.models.representations.huggingface_electra_sentence_encoder import HuggingFaceElectraSentenceEncoder
  from pytext.models.representations.representation_base import RepresentationBase
  from pytext.models.representations.transformer_sentence_encoder_base import TransformerSentenceEncoderBase
  from pytext.torchscript.module import ScriptPyTextEmbeddingModuleIndex, ScriptPyTextEmbeddingModuleWithDenseIndex
  from pytext.torchscript.utils import ScriptBatchInput, squeeze_1d, squeeze_2d
  from pytext.utils.label import get_label_weights
  from pytext.utils.usage import log_class_usage
label_desc: Use image node_id 5 for calling the _EncoderBaseModel obj's underlying member method code with example usage: obj.from_config(cls, config, tensorizers) and returns: cls