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 MultiTaskPromptTuning works when Llama config use_cache=True.
docstr_tok: ["Test","that","MultiTaskPromptTuning","works","when","Llama","config","use_cache=True","."]
code: def test_use_cache(self) -> None:
      """Test that MultiTaskPromptTuning 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
      )
      task_ids = torch.LongTensor([1, 2]).to(self.torch_device)
  
      original = LlamaForCausalLM(
          self._create_test_llama_config()
      ).eval()
      mpt = get_peft_model(
          original, self._create_multitask_prompt_tuning_config()
      )
      mpt = mpt.to(self.torch_device)
  
      expected = mpt.generate(
          input_ids=input_ids, max_length=8, task_ids=task_ids
      )
  
      # Set use_cache = True and generate output again.
      mpt.base_model.config.use_cache = True
      actual = mpt.generate(
          input_ids=input_ids, max_length=8, task_ids=task_ids
      )
      assert_close(expected, actual, rtol=0, atol=0)
  
imports: import importlib
  import os
  import tempfile
  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.multitask_prompt_tuning import MultitaskPromptTuningConfig
  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 9 for calling the MultiTaskPromptTuningTester obj's underlying member method code with example usage: obj.test_use_cache() without return types