class_docstr: PyTorch implementation containing all the modelling needed for your NLP task. Combines 2 language
  models for representation of 2 sequences and a prediction head. Allows for gradient flow back to the 2 language model components.
class_docstr_tok: ["PyTorch","implementation","containing","all","the","modelling","needed","for","your","NLP","task",".","Combines","2","language","models","for","representation","of","2","sequences","and","a","prediction","head",".","Allows","for","gradient","flow","back","to","the","2","language","model","components","."]
docstr: Loads a BiAdaptiveModel from a directory. The directory must contain:
  
  * directory "lm1_name" with following files:
      -> language_model.bin
      -> language_model_config.json
  * directory "lm2_name" with following files:
      -> 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 Token
  * special_tokens_map.json
  
  :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 lm1_name: the name to assign to the first loaded language model(for encoding queries)
  :type lm1_name: str
  :param lm2_name: the name to assign to the second loaded language model(for encoding context/passages)
  :type lm2_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
docstr_tok: ["Loads","a","BiAdaptiveModel","from","a","directory",".","The","directory","must","contain",":","*","directory","``","lm1_name","''","with","following","files",":","-",">","language_model.bin","-",">","language_model_config.json","*","directory","``","lm2_name","''","with","following","files",":","-",">","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","Token","*","special_tokens_map.json",":","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","lm1_name",":","the","name","to","assign","to","the","first","loaded","language","model","(","for","encoding","queries",")",":","type","lm1_name",":","str",":","param","lm2_name",":","the","name","to","assign","to","the","second","loaded","language","model","(","for","encoding","context\/passages",")",":","type","lm2_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=False,
      lm1_name="lm1",
      lm2_name="lm2",
      processor=None,
  ):
      """
      Loads a BiAdaptiveModel from a directory. The directory must contain:
  
      * directory "lm1_name" with following files:
          -> language_model.bin
          -> language_model_config.json
      * directory "lm2_name" with following files:
          -> 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 Token
      * special_tokens_map.json
  
      :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 lm1_name: the name to assign to the first loaded language model(for encoding queries)
      :type lm1_name: str
      :param lm2_name: the name to assign to the second loaded language model(for encoding context/passages)
      :type lm2_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 lm1_name:
          language_model1 = LanguageModel.load(
              os.path.join(load_dir, lm1_name)
          )
      else:
          language_model1 = LanguageModel.load(load_dir)
      if lm2_name:
          language_model2 = LanguageModel.load(
              os.path.join(load_dir, lm2_name)
          )
      else:
          language_model2 = 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=False, load_weights=False
          )
          prediction_heads.append(head)
          ph_output_type.append(head.ph_output_type)
  
      model = cls(
          language_model1,
          language_model2,
          prediction_heads,
          0.1,
          device,
      )
      if processor:
          model.connect_heads_with_processor(processor.tasks)
  
      return model
  
imports: import copy
  import json
  import logging
  import os
  from argparse import Namespace
  from pathlib import Path
  import multiprocessing
  import numpy
  import torch
  from torch import nn
  from farm.data_handler.processor import TextSimilarityProcessor
  from farm.data_handler.data_silo import DataSilo
  from farm.modeling.language_model import LanguageModel
  from farm.modeling.prediction_head import PredictionHead, TextSimilarityHead
  from farm.modeling.tokenization import Tokenizer
  from farm.utils import MLFlowLogger, stack
label_desc: Use image node_id 3 for calling the BiAdaptiveModel obj's underlying member method code with example usage: obj.load(cls, load_dir, device, strict, lm1_name, lm2_name, processor) and returns: model