class_docstr: ## Configurations
  
  This inherits from
  [`NLPAutoRegressionConfigs`](../../experiments/nlp_autoregression.html)
  because it has the data pipeline implementations that we reuse here.
  We have implemented a custom training step form MLM.
class_docstr_tok: ["#","#","Configurations","This","inherits","from","[","`","NLPAutoRegressionConfigs","`","]","(","..","\/","..","\/experiments\/nlp_autoregression.html",")","because","it","has","the","data","pipeline","implementations","that","we","reuse","here",".","We","have","implemented","a","custom","training","step","form","MLM","."]
docstr: ### Initialization
docstr_tok: ["#","#","#","Initialization"]
code: def init(self):
      """
      ### Initialization
      """
  
      # `[MASK]` token
      self.mask_token = self.n_tokens - 1
      # `[PAD]` token
      self.padding_token = self.n_tokens - 2
  
      # [Masked Language Model (MLM) class](index.html) to generate the mask
      self.mlm = MLM(
          padding_token=self.padding_token,
          mask_token=self.mask_token,
          no_mask_tokens=self.no_mask_tokens,
          n_tokens=self.n_tokens,
          masking_prob=self.masking_prob,
          randomize_prob=self.randomize_prob,
          no_change_prob=self.no_change_prob,
      )
  
      # Accuracy metric (ignore the labels equal to `[PAD]`)
      self.accuracy = Accuracy(ignore_index=self.padding_token)
      # Cross entropy loss (ignore the labels equal to `[PAD]`)
      self.loss_func = nn.CrossEntropyLoss(
          ignore_index=self.padding_token
      )
      #
      super().init()
  
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 for calling the Configs obj's underlying member method code with example usage: obj.init() without return types