code: def _check_encoder_attention_for_generate(
      self, attentions, batch_size, config, seq_length
  ):
      encoder_expected_shape = (
          batch_size,
          config.num_attention_heads,
          math.ceil(seq_length / config.block_size),
          config.block_size,
          config.block_size + config.num_global_tokens,
      )
      self.assertIsInstance(attentions, tuple)
      self.assertListEqual(
          [
              layer_attentions["local"].shape
              for layer_attentions in attentions
          ],
          [encoder_expected_shape] * len(attentions),
      )
  
imports: import copy
  import math
  import tempfile
  import unittest
  from transformers import is_torch_available
  from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
  from transformers.utils import cached_property
  from ...generation.test_generation_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor
label_desc: Use image node_id 10 for calling the PegasusXModelTest obj's underlying member method code with example usage: obj._check_encoder_attention_for_generate(attentions, batch_size, config, seq_length) without return types