code: def test_block_sparse_context_layer(self):
      model = BigBirdModel.from_pretrained(
          "google/bigbird-roberta-base",
          attention_type="block_sparse",
          num_random_blocks=3,
          block_size=16,
      )
      model.to(torch_device)
      model.eval()
      config = model.config
  
      input_ids = self._get_dummy_input_ids()
      dummy_hidden_states = model.embeddings(input_ids)
  
      attn_mask = torch.ones_like(input_ids, device=torch_device)
      (
          blocked_mask,
          band_mask,
          from_mask,
          to_mask,
      ) = model.create_masks_for_block_sparse_attn(
          attn_mask, config.block_size
      )
      targeted_cl = torch.tensor(
          [
              [
                  0.1874,
                  1.5260,
                  0.2335,
                  -0.0473,
                  -0.0961,
                  1.8384,
                  -0.0141,
                  0.1250,
                  0.0085,
                  -0.0048,
              ],
              [
                  -0.0554,
                  0.0728,
                  0.1683,
                  -0.1332,
                  0.1741,
                  0.1337,
                  -0.2380,
                  -0.1849,
                  -0.0390,
                  -0.0259,
              ],
              [
                  -0.0419,
                  0.0767,
                  0.1591,
                  -0.1399,
                  0.1789,
                  0.1257,
                  -0.2406,
                  -0.1772,
                  -0.0261,
                  -0.0079,
              ],
              [
                  0.1860,
                  1.5172,
                  0.2326,
                  -0.0473,
                  -0.0953,
                  1.8291,
                  -0.0147,
                  0.1245,
                  0.0082,
                  -0.0046,
              ],
              [
                  0.1879,
                  1.5296,
                  0.2335,
                  -0.0471,
                  -0.0975,
                  1.8433,
                  -0.0136,
                  0.1260,
                  0.0086,
                  -0.0054,
              ],
              [
                  0.1854,
                  1.5147,
                  0.2334,
                  -0.0480,
                  -0.0956,
                  1.8250,
                  -0.0149,
                  0.1222,
                  0.0082,
                  -0.0060,
              ],
              [
                  0.1859,
                  1.5184,
                  0.2334,
                  -0.0474,
                  -0.0955,
                  1.8297,
                  -0.0143,
                  0.1234,
                  0.0079,
                  -0.0054,
              ],
              [
                  0.1885,
                  1.5336,
                  0.2335,
                  -0.0467,
                  -0.0979,
                  1.8481,
                  -0.0130,
                  0.1269,
                  0.0085,
                  -0.0049,
              ],
              [
                  0.1881,
                  1.5305,
                  0.2335,
                  -0.0471,
                  -0.0976,
                  1.8445,
                  -0.0135,
                  0.1262,
                  0.0086,
                  -0.0053,
              ],
              [
                  0.1852,
                  1.5148,
                  0.2333,
                  -0.0480,
                  -0.0949,
                  1.8254,
                  -0.0151,
                  0.1225,
                  0.0079,
                  -0.0055,
              ],
              [
                  0.1877,
                  1.5292,
                  0.2335,
                  -0.0470,
                  -0.0972,
                  1.8431,
                  -0.0135,
                  0.1259,
                  0.0084,
                  -0.0052,
              ],
              [
                  0.1874,
                  1.5261,
                  0.2334,
                  -0.0472,
                  -0.0968,
                  1.8393,
                  -0.0140,
                  0.1251,
                  0.0084,
                  -0.0052,
              ],
              [
                  0.1853,
                  1.5151,
                  0.2331,
                  -0.0478,
                  -0.0948,
                  1.8256,
                  -0.0154,
                  0.1228,
                  0.0086,
                  -0.0052,
              ],
              [
                  0.1867,
                  1.5233,
                  0.2334,
                  -0.0475,
                  -0.0965,
                  1.8361,
                  -0.0139,
                  0.1247,
                  0.0084,
                  -0.0054,
              ],
          ],
          device=torch_device,
      )
  
      context_layer = model.encoder.layer[0].attention.self(
          dummy_hidden_states,
          band_mask=band_mask,
          from_mask=from_mask,
          to_mask=to_mask,
          from_blocked_mask=blocked_mask,
          to_blocked_mask=blocked_mask,
      )
      context_layer = context_layer[0]
  
      self.assertEqual(context_layer.shape, torch.Size((1, 128, 768)))
      self.assertTrue(
          torch.allclose(
              context_layer[0, 64:78, 300:310], targeted_cl, atol=0.0001
          )
      )
  
imports: import unittest
  from transformers import BigBirdConfig, is_torch_available
  from transformers.models.auto import get_values
  from transformers.models.big_bird.tokenization_big_bird import BigBirdTokenizer
  from transformers.testing_utils import require_torch, slow, torch_device
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
label_desc: Use image node_id 5 for calling the BigBirdModelIntegrationTest obj's underlying member method code with example usage: obj.test_block_sparse_context_layer() without return types