class_docstr: Machine Comprehension API
class_docstr_tok: ["Machine","Comprehension","API"]
code: def load_model(self):
      select_device = "GPU"
      restore_model = True
      # Create dictionary of filenames
      self.download_model()
  
      data_path = self.data_path
      # Paths for preprcessed files
      path_gen = (
          data_path  # data is actually in mrc_data/data not, mrc_data
      )
      train_para_ids = os.path.join(
          path_gen, self.file_name_dict["train_para_ids"]
      )
      train_ques_ids = os.path.join(
          path_gen, self.file_name_dict["train_ques_ids"]
      )
      answer_file = os.path.join(
          path_gen, self.file_name_dict["train_answer"]
      )
      val_paras_ids = os.path.join(
          path_gen, self.file_name_dict["val_para_ids"]
      )
      val_ques_ids = os.path.join(
          path_gen, self.file_name_dict["val_ques_ids"]
      )
      val_ans_file = os.path.join(
          path_gen, self.file_name_dict["val_ans"]
      )
      vocab_file = os.path.join(
          path_gen, self.file_name_dict["vocab_file"]
      )
  
      model_dir = self.model_path
      # Create model dir if it doesn't exist
      if not os.path.exists(model_dir):
          os.makedirs(model_dir)
  
      model_path = model_dir
  
      # Create lists for train and validation sets
      data_train = create_squad_training(
          train_para_ids, train_ques_ids, answer_file
      )
      data_dev = create_squad_training(
          val_paras_ids, val_ques_ids, val_ans_file
      )
      with open(vocab_file, encoding="UTF-8") as fp:
          vocab_list = fp.readlines()
      self.vocab_dict = {}
      self.vocab_rev = {}
  
      for i in range(len(vocab_list)):
          self.vocab_dict[i] = vocab_list[i].strip()
          self.vocab_rev[vocab_list[i].strip()] = i
  
          self.params_dict["train_set_size"] = len(data_train)
  
      # Combine train and dev data
      data_total = data_train + data_dev
  
      # obtain maximum length of question
      _, max_question = max_values_squad(data_total)
      self.params_dict["max_question"] = max_question
  
      # Load embeddings for vocab
      print("Loading Embeddings")
      embeddingz = np.load(
          os.path.join(path_gen, self.file_name_dict["embedding"])
      )
      embeddings = embeddingz["glove"]
  
      # Create train and dev sets
      print("Creating training and development sets")
      self.dev = get_data_array_squad(
          self.params_dict, data_dev, set_val="val"
      )
  
      # Define Reading Comprehension model
      with tf.device("/device:" + select_device + ":0"):
          self.model = MatchLSTMAnswerPointer(
              self.params_dict, embeddings
          )
  
      # Define Configs for training
      run_config = tf.ConfigProto(
          allow_soft_placement=True, log_device_placement=False
      )
  
      # Create session run training
      self.sess = tf.Session(config=run_config)
      init = tf.global_variables_initializer()
  
      # Model Saver
      # pylint: disable=no-member
      model_saver = tf.train.Saver()
      model_ckpt = tf.train.get_checkpoint_state(model_path)
      idx_path = (
          model_ckpt.model_checkpoint_path + ".index"
          if model_ckpt
          else ""
      )
  
      # Initialize with random or pretrained weights
      # pylint: disable=no-member
      if (
          model_ckpt
          and restore_model
          and (
              tf.gfile.Exists(model_ckpt.model_checkpoint_path)
              or tf.gfile.Exists(idx_path)
          )
      ):
          model_saver.restore(
              self.sess, model_ckpt.model_checkpoint_path
          )
          print("Loading from previously stored session")
      else:
          self.sess.run(init)
  
      shuffle(self.dev)
  
imports: from __future__ import division
  from __future__ import print_function
  import os
  import re
  import zipfile
  from os import makedirs
  from random import shuffle
  import numpy
  import tensorflow
  from nlp_architect import LIBRARY_OUT
  from nlp_architect.api.abstract_api import AbstractApi
  from nlp_architect.utils.generic import license_prompt
  from nlp_architect.utils.io import download_unlicensed_file
  from .matchlstm_ansptr import MatchLSTMAnswerPointer
  from .mrc_utils import create_squad_training, max_values_squad, get_data_array_squad
label_desc: Use image node_id 3 for calling the MachineComprehensionApi obj's underlying member method code with example usage: obj.load_model() without return types