class_docstr: # Transformer based model for MLM
class_docstr_tok: ["#","Transformer","based","model","for","MLM"]
docstr: * `encoder` is the transformer [Encoder](../models.html#Encoder)
  * `src_embed` is the token
  [embedding module (with positional encodings)](../models.html#EmbeddingsWithLearnedPositionalEncoding)
  * `generator` is the [final fully connected layer](../models.html#Generator) that gives the logits.
docstr_tok: ["*","`","encoder","`","is","the","transformer","[","Encoder","]","(","..","\/models.html","#","Encoder",")","*","`","src_embed","`","is","the","token","[","embedding","module","(","with","positional","encodings",")","]","(","..","\/models.html","#","EmbeddingsWithLearnedPositionalEncoding",")","*","`","generator","`","is","the","[","final","fully","connected","layer","]","(","..","\/models.html","#","Generator",")","that","gives","the","logits","."]
code: def __init__(
      self, *, encoder: Encoder, src_embed: Module, generator: Generator
  ):
      """
      * `encoder` is the transformer [Encoder](../models.html#Encoder)
      * `src_embed` is the token
      [embedding module (with positional encodings)](../models.html#EmbeddingsWithLearnedPositionalEncoding)
      * `generator` is the [final fully connected layer](../models.html#Generator) that gives the logits.
      """
      super().__init__()
      self.generator = generator
      self.src_embed = src_embed
      self.encoder = encoder
  
imports: from typing import List
  import torch
  from torch import nn
  from labml import experiment, tracker, logger
  from labml.configs import option
  from labml.logger import Text
  from labml_helpers.metrics.accuracy import Accuracy
  from labml_helpers.module import Module
  from labml_helpers.train_valid import BatchIndex
  from labml_nn.experiments.nlp_autoregression import NLPAutoRegressionConfigs
  from labml_nn.transformers import Encoder, Generator
  from labml_nn.transformers import TransformerConfigs
  from labml_nn.transformers.mlm import MLM
label_desc: Use image node_id 1 to create a new TransformerMLM object from inherited base classes: nn with example: obj = TransformerMLM()