class_docstr: Tests for the AdaptionPrompt model.
  
  Some of these tests were adapted from `test_peft_model.py` (which has been refactored since), but since we haven't
  checked in the test checkpoints for Llama into `hf-internal-testing`, we separate them for now.
class_docstr_tok: ["Tests","for","the","AdaptionPrompt","model",".","Some","of","these","tests","were","adapted","from","`","test_peft_model.py","`","(","which","has","been","refactored","since",")",",","but","since","we","haven't","checked","in","the","test","checkpoints","for","Llama","into","`","hf-internal-testing","`",",","we","separate","them","for","now","."]
docstr: Test that AdaptionPrompt works when Llama config use_cache=True.
docstr_tok: ["Test","that","AdaptionPrompt","works","when","Llama","config","use_cache=True","."]
code: def test_use_cache(self) -> None:
      """Test that AdaptionPrompt works when Llama config use_cache=True."""
      torch.manual_seed(0)
      input_ids = torch.LongTensor([[1, 1, 1], [2, 1, 2]]).to(
          self.torch_device
      )
      original = LlamaForCausalLM(
          LlamaConfig(
              vocab_size=16,
              hidden_size=8,
              intermediate_size=8,
              num_hidden_layers=8,
              num_attention_heads=4,
              use_cache=False,
          )
      ).eval()
      adapted = get_peft_model(
          original,
          AdaptionPromptConfig(
              adapter_layers=2, adapter_len=4, task_type="CAUSAL_LM"
          ),
      )
      adapted = adapted.to(self.torch_device)
      expected = adapted.generate(input_ids=input_ids, max_length=8)
  
      # Set use_cache = True and generate output again.
      adapted.base_model.config.use_cache = True
      actual = adapted.generate(input_ids=input_ids, max_length=8)
      assert_close(expected, actual, rtol=0, atol=0)
  
imports: import importlib
  import os
  import tempfile
  import unittest
  from unittest import TestCase
  import torch
  from torch.testing import assert_close
  from peft.mapping import get_peft_model
  from peft.peft_model import PeftModel
  from peft.tuners.adaption_prompt import AdaptionPromptConfig
  from peft.utils.other import prepare_model_for_int8_training
  from peft.utils.save_and_load import get_peft_model_state_dict
  from tests.testing_common import PeftCommonTester
label_desc: Use image node_id 12 for calling the AdaptionPromptTester obj's underlying member method code with example usage: obj.test_use_cache() without return types