class_docstr: Here we also overwrite some of the tests of test_modeling_common.py, as BEiT does not use input_ids, inputs_embeds,
  attention_mask and seq_length.
class_docstr_tok: ["Here","we","also","overwrite","some","of","the","tests","of","test_modeling_common.py",",","as","BEiT","does","not","use","input_ids",",","inputs_embeds",",","attention_mask","and","seq_length","."]
code: def test_training_gradient_checkpointing(self):
      (
          config,
          inputs_dict,
      ) = self.model_tester.prepare_config_and_inputs_for_common()
      if not self.model_tester.is_training:
          return
  
      config.use_cache = False
      config.return_dict = True
  
      for model_class in self.all_model_classes:
          # we don't test BeitForMaskedImageModeling
          if (
              model_class
              in [
                  *get_values(MODEL_MAPPING),
                  BeitForMaskedImageModeling,
              ]
              or not model_class.supports_gradient_checkpointing
          ):
              continue
  
          model = model_class(config)
          model.gradient_checkpointing_enable()
          model.to(torch_device)
          model.train()
          inputs = self._prepare_for_class(
              inputs_dict, model_class, return_labels=True
          )
          loss = model(**inputs).loss
          loss.backward()
  
imports: import inspect
  import unittest
  from datasets import load_dataset
  from packaging import version
  from transformers import BeitConfig
  from transformers.models.auto import get_values
  from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
  from transformers.utils import cached_property, is_torch_available, is_vision_available
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
label_desc: Use image node_id 12 for calling the BeitModelTest obj's underlying member method code with example usage: obj.test_training_gradient_checkpointing() without return types