class_docstr: BERT language model pretraining.
class_docstr_tok: ["BERT","language","model","pretraining","."]
docstr: No special modification required for Lightning, define it as you normally would
  in the `nn.Module` in vanilla PyTorch.
docstr_tok: ["No","special","modification","required","for","Lightning",",","define","it","as","you","normally","would","in","the","`","nn.Module","`","in","vanilla","PyTorch","."]
code: def forward(self, input_ids, attention_mask, token_type_ids):
      """
      No special modification required for Lightning, define it as you normally would
      in the `nn.Module` in vanilla PyTorch.
      """
      hidden_states = self.bert_model(
          input_ids=input_ids,
          token_type_ids=token_type_ids,
          attention_mask=attention_mask,
      )
      if isinstance(hidden_states, tuple):
          hidden_states = hidden_states[0]
  
      mlm_log_probs = self.mlm_classifier(hidden_states=hidden_states)
      if self.only_mlm_loss:
          return (mlm_log_probs,)
      nsp_logits = self.nsp_classifier(hidden_states=hidden_states)
      return mlm_log_probs, nsp_logits
  
imports: import os
  from typing import Dict, Optional
  import torch
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from torch.utils.data import DataLoader
  from nemo.collections.common.losses import AggregatorLoss, CrossEntropyLoss, SmoothedCrossEntropyLoss
  from nemo.collections.common.metrics import Perplexity
  from nemo.collections.nlp.data.language_modeling.lm_bert_dataset import BertPretrainingDataset, BertPretrainingPreprocessedDataloader
  from nemo.collections.nlp.modules.common import BertPretrainingTokenClassifier, SequenceClassifier
  from nemo.collections.nlp.modules.common.lm_utils import get_lm_model
  from nemo.collections.nlp.modules.common.tokenizer_utils import get_tokenizer
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.classes.modelPT import ModelPT
  from nemo.core.neural_types import NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling the BERTLMModel obj's underlying member method code with example usage: obj.forward(input_ids, attention_mask, token_type_ids) and returns: mlm_log_probs,  nsp_logits, mlm_log_probs