code: def test_completion(Model, Tokenizer, model_path, prompt, answer):
      with torch.inference_mode():
          tokenizer = Tokenizer.from_pretrained(
              model_path, trust_remote_code=True
          )
          model = Model.from_pretrained(
              model_path,
              load_in_4bit=True,
              optimize_model=True,
              trust_remote_code=True,
          )
          model = model.to(device)
  
          input_ids = tokenizer.encode(prompt, return_tensors="pt").to(
              device
          )
          output = model.generate(input_ids, max_new_tokens=32)
          model.to("cpu")  # deallocate gpu memory
          output_str = tokenizer.decode(
              output[0], skip_special_tokens=True
          )
  
          assert answer in output_str
  
file_path: BigDL/python/llm/test/inference_gpu/test_transformers_api.py
imports: import os, time
  import pytest
  import torch
  from bigdl.llm.transformers import AutoModelForCausalLM, AutoModel, AutoModelForSpeechSeq2Seq
  from transformers import LlamaTokenizer, AutoTokenizer
label_desc: Use image node_id 1 for calling a global function with example usage: test_completion(Model, Tokenizer, model_path, prompt, answer) without return types