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: Loads an AdaptiveModel from a directory. The directory must contain:
  
  * language_model.bin
  * language_model_config.json
  * prediction_head_X.bin  multiple PH possible
  * prediction_head_X_config.json
  * processor_config.json config for transforming input
  * vocab.txt vocab file for language model, turning text to Wordpiece Tokens
  
  :param load_dir: location where adaptive model is stored
  :type load_dir: Path
  :param device: to which device we want to sent the model, either cpu or cuda
  :type device: torch.device
  :param lm_name: the name to assign to the loaded language model
  :type lm_name: str
  :param strict: whether to strictly enforce that the keys loaded from saved model match the ones in
                 the PredictionHead (see torch.nn.module.load_state_dict()).
                 Set to `False` for backwards compatibility with PHs saved with older version of FARM.
  :type strict: bool
  :param processor: populates prediction head with information coming from tasks
  :type processor: Processor
code: def load(
      cls, load_dir, device, strict=True, lm_name=None, processor=None
  ):
      """
      Loads an AdaptiveModel from a directory. The directory must contain:
  
      * language_model.bin
      * language_model_config.json
      * prediction_head_X.bin  multiple PH possible
      * prediction_head_X_config.json
      * processor_config.json config for transforming input
      * vocab.txt vocab file for language model, turning text to Wordpiece Tokens
  
      :param load_dir: location where adaptive model is stored
      :type load_dir: Path
      :param device: to which device we want to sent the model, either cpu or cuda
      :type device: torch.device
      :param lm_name: the name to assign to the loaded language model
      :type lm_name: str
      :param strict: whether to strictly enforce that the keys loaded from saved model match the ones in
                     the PredictionHead (see torch.nn.module.load_state_dict()).
                     Set to `False` for backwards compatibility with PHs saved with older version of FARM.
      :type strict: bool
      :param processor: populates prediction head with information coming from tasks
      :type processor: Processor
      """
  
      # Language Model
      if lm_name:
          language_model = LanguageModel.load(
              load_dir, farm_lm_name=lm_name
          )
      else:
          language_model = LanguageModel.load(load_dir)
  
      # Prediction heads
      _, ph_config_files = cls._get_prediction_head_files(load_dir)
      prediction_heads = []
      ph_output_type = []
      for config_file in ph_config_files:
          head = PredictionHead.load(config_file, strict=strict)
          prediction_heads.append(head)
          ph_output_type.append(head.ph_output_type)
  
      model = cls(
          language_model, prediction_heads, 0.1, ph_output_type, device
      )
      if processor:
          model.connect_heads_with_processor(processor.tasks)
  
      return model
  
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 5 for calling the AdaptiveModel obj's underlying member method code with example usage: obj.load(cls, load_dir, device, strict, lm_name, processor) and returns: model