class_docstr: A common tester to run common operations that are performed on GPU such as generation, loading in 8bit, etc.
class_docstr_tok: ["A","common","tester","to","run","common","operations","that","are","performed","on","GPU","such","as","generation",",","loading","in","8bit",",","etc","."]
code: def test_print_4bit_expected(self):
      EXPECTED_TRAINABLE_PARAMS = 294912
      EXPECTED_ALL_PARAMS = 125534208
  
      model = AutoModelForCausalLM.from_pretrained(
          "facebook/opt-125m",
          load_in_4bit=True,
      )
  
      config = LoraConfig(
          r=8,
      )
      model = get_peft_model(model, config)
      trainable_params, all_params = model.get_nb_trainable_parameters()
  
      self.assertEqual(trainable_params, EXPECTED_TRAINABLE_PARAMS)
      self.assertEqual(all_params, EXPECTED_ALL_PARAMS)
  
      # test with double quant
      bnb_config = BitsAndBytesConfig(
          load_in_4bit=True,
          bnb_4bit_use_double_quant=True,
      )
  
      model = AutoModelForCausalLM.from_pretrained(
          "facebook/opt-125m",
          quantization_config=bnb_config,
      )
  
      config = LoraConfig(
          r=8,
      )
      model = get_peft_model(model, config)
      trainable_params, all_params = model.get_nb_trainable_parameters()
  
      self.assertEqual(trainable_params, EXPECTED_TRAINABLE_PARAMS)
      self.assertEqual(all_params, EXPECTED_ALL_PARAMS)
  
imports: import gc
  import tempfile
  import unittest
  import pytest
  import torch
  import torch.nn.functional
  from parameterized import parameterized
  from transformers import AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoModelForSequenceClassification, AutoModelForTokenClassification, AutoTokenizer, BitsAndBytesConfig, LlamaForCausalLM, WhisperForConditionalGeneration
  from peft import AdaLoraConfig, AdaptionPromptConfig, IA3Config, LoraConfig, PeftModel, TaskType, get_peft_model, prepare_model_for_kbit_training
  from peft.import_utils import is_bnb_4bit_available, is_bnb_available
  from .testing_utils import require_bitsandbytes, require_torch_gpu, require_torch_multi_gpu
label_desc: Use image node_id 15 for calling the PeftGPUCommonTests obj's underlying member method code with example usage: obj.test_print_4bit_expected() without return types