code: def greedy_generate(
      model, tokenizer, input_ids, past_key_values, max_gen_len
  ):
      outputs = model(
          input_ids=input_ids,
          past_key_values=past_key_values,
          use_cache=True,
      )
      past_key_values = outputs.past_key_values
      pred_token_idx = (
          outputs.logits[:, -1, :].argmax(dim=-1).unsqueeze(1)
      )
      generated_ids = [pred_token_idx.item()]
      pos = 0
      for _ in range(max_gen_len - 1):
          outputs = model(
              input_ids=pred_token_idx,
              past_key_values=past_key_values,
              use_cache=True,
          )
          past_key_values = outputs.past_key_values
          pred_token_idx = (
              outputs.logits[:, -1, :].argmax(dim=-1).unsqueeze(1)
          )
          generated_ids.append(pred_token_idx.item())
          generated_text = (
              tokenizer.decode(
                  generated_ids,
                  skip_special_tokens=True,
                  clean_up_tokenization_spaces=True,
                  spaces_between_special_tokens=False,
              )
              .strip()
              .split(" ")
          )
  
          now = len(generated_text) - 1
          if now > pos:
              print(
                  " ".join(generated_text[pos:now]), end=" ", flush=True
              )
              pos = now
  
          if pred_token_idx == tokenizer.eos_token_id:
              break
      print(" ".join(generated_text[pos:]), flush=True)
      return past_key_values
  
file_path: long-lora/run_streaming_llama_longalpaca.py
imports: import warnings
  import torch
  import argparse
  import json
  import os
  import time
  import re
  import sys
  from tqdm import tqdm
  from streaming_llm.utils import load, download_url, load_jsonl
  from streaming_llm.enable_streaming_llm import enable_streaming_llm
label_desc: Use image node_id 1 for calling a global function with example usage: greedy_generate(model, tokenizer, input_ids, past_key_values, max_gen_len) and returns: past_key_values