code: def test_training_gradient_checkpointing(self):
      if not self.model_tester.is_training:
          return
  
      for model_class in self.all_model_classes:
          # IdeficsModel does not support training, users should use
          # IdeficsForVisionText2Text for this purpose
          if model_class == IdeficsModel:
              return
  
          (
              config,
              inputs_dict,
          ) = self.model_tester.prepare_config_and_inputs_for_common()
          config.use_cache = False
          config.return_dict = True
  
          model = model_class(config)
          model.to(torch_device)
          model.gradient_checkpointing_enable()
          model.train()
          inputs = self._prepare_for_class(
              inputs_dict, model_class, return_labels=True
          )
          loss = model(**inputs).loss
          loss.backward()
  
imports: import unittest
  from parameterized import parameterized
  from transformers import BitsAndBytesConfig, IdeficsConfig, is_torch_available, is_vision_available
  from transformers.testing_utils import TestCasePlus, require_bitsandbytes, require_torch, require_torch_sdpa, require_vision, slow, torch_device
  from transformers.utils import cached_property
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 13 for calling the IdeficsModelTest obj's underlying member method code with example usage: obj.test_training_gradient_checkpointing() without return types