docstr: format_fn: A function to format the prompt. Defaults to identity.
docstr_tok: ["format_fn",":","A","function","to","format","the","prompt",".","Defaults","to","identity","."]
code: def __init__(self, model, tokenizer, device="cuda", format_fn=None):
      """
      format_fn: A function to format the prompt. Defaults to identity.
      """
      self.tokenizer = tokenizer
      self.model = model
      self.device = device
      self.tokenizer.pad_token_id = self.tokenizer.eos_token_id
      self.tokenizer.padding_side = "left"
      self.format_fn = (
          format_fn if format_fn is not None else (lambda x: x)
      )
  
file_path: interpret-text/python/interpret_text/generative/model_lib/hf_tooling.py
imports: import torch
  import numpy
  from tqdm import tqdm
  import torch.nn.functional
  from scipy.special import log_softmax, logsumexp
label_desc: Use image node_id 1 to create a new HF_LM object  with example: obj = HF_LM(model, tokenizer, device, format_fn)