class_docstr: Here we also overwrite some of the tests of test_modeling_common.py, as ViTMAE 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","ViTMAE","does","not","use","input_ids",",","inputs_embeds",",","attention_mask","and","seq_length","."]
code: def test_compile_tf_model(self):
      (
          config,
          inputs_dict,
      ) = self.model_tester.prepare_config_and_inputs_for_common()
      optimizer = tf.keras.optimizers.Adam(
          learning_rate=3e-5, epsilon=1e-08, clipnorm=1.0
      )
      loss = tf.keras.losses.SparseCategoricalCrossentropy(
          from_logits=True
      )
      metric = tf.keras.metrics.SparseCategoricalAccuracy("accuracy")
  
      for model_class in self.all_model_classes:
          # `pixel_values` implies that the input is an image
          inputs = tf.keras.Input(
              batch_shape=(
                  3,
                  self.model_tester.num_channels,
                  self.model_tester.image_size,
                  self.model_tester.image_size,
              ),
              name="pixel_values",
              dtype="float32",
          )
  
          # Prepare our model
          model = model_class(config)
          model(
              self._prepare_for_class(inputs_dict, model_class)
          )  # Model must be called before saving.
          # Let's load it from the disk to be sure we can use pretrained weights
          with tempfile.TemporaryDirectory() as tmpdirname:
              model.save_pretrained(tmpdirname, saved_model=False)
              model = model_class.from_pretrained(tmpdirname)
  
          outputs_dict = model(inputs)
          hidden_states = outputs_dict[0]
  
          # `TFViTMAEForPreTraining` outputs are not recommended to be used for
          #  downstream application. This is just to check if the outputs of
          # `TFViTMAEForPreTraining` can be integrated with other keras modules.
          if model_class.__name__ == "TFViTMAEForPreTraining":
              hidden_states = outputs_dict["logits"]
  
          # Add a dense layer on top to test integration with other keras modules
          outputs = tf.keras.layers.Dense(
              2, activation="softmax", name="outputs"
          )(hidden_states)
  
          # Compile extended model
          extended_model = tf.keras.Model(
              inputs=[inputs], outputs=[outputs]
          )
          extended_model.compile(
              optimizer=optimizer, loss=loss, metrics=[metric]
          )
  
imports: import copy
  import inspect
  import json
  import math
  import os
  import tempfile
  import unittest
  from importlib import import_module
  import numpy
  from transformers import ViTMAEConfig
  from transformers.file_utils import cached_property, is_tf_available, is_vision_available
  from transformers.testing_utils import require_tf, require_vision, slow
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
label_desc: Use image node_id 11 for calling the TFViTMAEModelTest obj's underlying member method code with example usage: obj.test_compile_tf_model() without return types