class_docstr: PyTorch implementation containing all the modelling needed for your NLP task. Combines a language
  model and a prediction head. Allows for gradient flow back to the language model component.
class_docstr_tok: ["PyTorch","implementation","containing","all","the","modelling","needed","for","your","NLP","task",".","Combines","a","language","model","and","a","prediction","head",".","Allows","for","gradient","flow","back","to","the","language","model","component","."]
docstr: Forward pass for the language model
  
  :param kwargs:
  :return:
code: def forward_lm(self, **kwargs):
      """
      Forward pass for the language model
  
      :param kwargs:
      :return:
      """
  
      # Check if we have to extract from a special layer of the LM (default = last layer)
      try:
          extraction_layer = self.language_model.extraction_layer
      except:
          extraction_layer = -1
  
      # Run forward pass of language model
      if extraction_layer == -1:
          sequence_output, pooled_output = self.language_model(
              **kwargs,
              return_dict=False,
              output_all_encoded_layers=False,
          )
      else:
          # get output from an earlier layer
          self.language_model.enable_hidden_states_output()
          (
              sequence_output,
              pooled_output,
              all_hidden_states,
          ) = self.language_model(**kwargs, return_dict=False)
          sequence_output = all_hidden_states[extraction_layer]
          pooled_output = None  # not available in earlier layers
          self.language_model.disable_hidden_states_output()
      return sequence_output, pooled_output
  
imports: import copy
  import json
  import logging
  import os
  from pathlib import Path
  import multiprocessing
  import numpy
  import torch
  from torch import nn
  from transformers import AutoConfig
  from transformers.convert_graph_to_onnx import convert, quantize
  from farm.data_handler.processor import Processor
  from farm.modeling.language_model import LanguageModel
  from farm.modeling.prediction_head import PredictionHead, pick_single_fn
  from farm.utils import MLFlowLogger, stack
  import farm.conversion.transformers
label_desc: Use image node_id 10 for calling the AdaptiveModel obj's underlying member method code with example usage: obj.forward_lm() and returns: sequence_output,  pooled_output