code: def load_model(lm_folder_path, device):
      word_map = torchfile.load(
          os.path.join(lm_folder_path, "word_map.th7")
      )
      word_map = [w.decode("utf-8") for w in word_map]
      word_to_idx = {w: i for i, w in enumerate(word_map)}
      word_freq = torchfile.load(
          os.path.join(os.path.join(lm_folder_path, "word_freq.th7"))
      )
      mapto = (
          torch.from_numpy(util_reverse(np.argsort(-word_freq)))
          .long()
          .to(device)
      )
  
      model_file = open(
          os.path.join(lm_folder_path, "lm-state-dict.pt"), "rb"
      )
  
      model = RNNModel(
          "GRU",
          793471,
          256,
          2048,
          1,
          [4200, 35000, 180000, 793471],
          dropout=0.01,
          proj=True,
          lm1b=True,
      )
  
      model.load_state_dict(torch.load(model_file, map_location=device))
      model.full = True  # Use real softmax--important!
      model.to(device)
      model.eval()
      model_file.close()
      return QueryHandler(model, word_to_idx, mapto, device)
  
file_path: TextAttack/textattack/constraints/grammaticality/language_models/learning_to_write/language_model_helpers.py
imports: import os
  import numpy
  import torch
  from textattack.shared.utils import LazyLoader
  from .rnn_model import RNNModel
label_desc: Use image node_id 4 for calling the QueryHandler obj's underlying member method code with example usage: obj.load_model(lm_folder_path, device) and returns: QueryHandler