code: def test_layer_local_attn(self):
      model = TFLongformerModel.from_pretrained(
          "patrickvonplaten/longformer-random-tiny"
      )
      layer = model.longformer.encoder.layer[0].attention.self_attention
      hidden_states = self._get_hidden_states()
      batch_size, seq_length, hidden_size = hidden_states.shape
  
      attention_mask = tf.zeros(
          (batch_size, seq_length), dtype=tf.float32
      )
      is_index_global_attn = tf.math.greater(attention_mask, 1)
      is_global_attn = tf.math.reduce_any(is_index_global_attn)
  
      attention_mask = tf.where(
          tf.range(4)[None, :, None, None] > 1,
          -10000.0,
          attention_mask[:, :, None, None],
      )
      is_index_masked = tf.math.less(attention_mask[:, :, 0, 0], 0)
  
      layer_head_mask = None
  
      output_hidden_states = layer(
          [
              hidden_states,
              attention_mask,
              layer_head_mask,
              is_index_masked,
              is_index_global_attn,
              is_global_attn,
          ]
      )[0]
  
      expected_slice = tf.convert_to_tensor(
          [
              0.00188,
              0.012196,
              -0.017051,
              -0.025571,
              -0.02996,
              0.017297,
              -0.011521,
              0.004848,
          ],
          dtype=tf.float32,
      )
  
      self.assertEqual(output_hidden_states.shape, (1, 4, 8))
      tf.debugging.assert_near(
          output_hidden_states[0, 1],
          expected_slice,
          rtol=1e-3,
          atol=1e-4,
      )
  
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 6 for calling the TFLongformerModelIntegrationTest obj's underlying member method code with example usage: obj.test_layer_local_attn() without return types