code: def build_generator(
      model,
      tokenizer,
      temperature=0.6,
      top_p=0.9,
      max_gen_len=4096,
      use_cache=True,
  ):
      def response(prompt):
          inputs = tokenizer(prompt, return_tensors="pt").to(
              model.device
          )
  
          streamer = TextStreamer(tokenizer)
  
          output = model.generate(
              **inputs,
              max_new_tokens=max_gen_len,
              temperature=temperature,
              top_p=top_p,
              use_cache=use_cache,
              streamer=streamer,
          )
  
          out = tokenizer.decode(output[0], skip_special_tokens=True)
  
          out = out.split(prompt.lstrip("<s>"))[1].strip()
          return out
  
      return response
  
file_path: long-lora/inference.py
imports: import os
  import sys
  import math
  import torch
  import argparse
  import textwrap
  import transformers
  from peft import PeftModel
  from transformers import GenerationConfig, TextStreamer
  from llama_attn_replace import replace_llama_attn
label_desc: Use image node_id 3 for calling a global function with example usage: build_generator(model, tokenizer, temperature, top_p, max_gen_len, use_cache) and returns: response, out