code: def test_diagonalize(self):
      hidden_states = self._get_hidden_states()
      hidden_states = tf.reshape(
          hidden_states, (1, 8, 4)
      )  # set seq length = 8, hidden dim = 4
      chunked_hidden_states = TFLongformerSelfAttention._chunk(
          hidden_states, window_overlap=2
      )
      window_overlap_size = shape_list(chunked_hidden_states)[2]
      self.assertTrue(window_overlap_size == 4)
  
      padded_hidden_states = (
          TFLongformerSelfAttention._pad_and_diagonalize(
              chunked_hidden_states
          )
      )
  
      self.assertTrue(
          shape_list(padded_hidden_states)[-1]
          == shape_list(chunked_hidden_states)[-1]
          + window_overlap_size
          - 1
      )
  
      # first row => [0.4983,  2.6918, -0.0071,  1.0492, 0.0000,  0.0000,  0.0000]
      tf.debugging.assert_near(
          padded_hidden_states[0, 0, 0, :4],
          chunked_hidden_states[0, 0, 0],
          rtol=1e-3,
      )
      tf.debugging.assert_near(
          padded_hidden_states[0, 0, 0, 4:],
          tf.zeros((3,), dtype=tf.float32),
          rtol=1e-3,
      )
  
      # last row => [0.0000,  0.0000,  0.0000, 2.0514, -1.1600,  0.5372,  0.2629]
      tf.debugging.assert_near(
          padded_hidden_states[0, 0, -1, 3:],
          chunked_hidden_states[0, 0, -1],
          rtol=1e-3,
      )
      tf.debugging.assert_near(
          padded_hidden_states[0, 0, -1, :3],
          tf.zeros((3,), dtype=tf.float32),
          rtol=1e-3,
      )
  
imports: import unittest
  from transformers import is_tf_available
  from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow, tooslow
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
label_desc: Use image node_id 2 for calling the TFLongformerModelIntegrationTest obj's underlying member method code with example usage: obj.test_diagonalize() without return types