code: def _check_batched_forward(self, attn_type, tolerance=1e-3):
      config, _ = self.model_tester.prepare_config_and_inputs()
      config.max_position_embeddings = 128
      config.block_size = 16
      config.attention_type = attn_type
      model = BigBirdPegasusForConditionalGeneration(config).to(
          torch_device
      )
      model.eval()
  
      chunk_length = 32
  
      sample_with_padding = [3, 8, 11] * chunk_length + [
          0
      ] * chunk_length
      sample_without_padding = [4, 7, 9, 13] * chunk_length
      target_ids_without_padding = [2, 3] * 8
      target_ids_with_padding = [7, 8] * 6 + 4 * [-100]
  
      attention_mask = torch.tensor(
          [
              [1] * 3 * chunk_length + [0] * chunk_length,
              [1] * 4 * chunk_length,
          ],
          device=torch_device,
          dtype=torch.long,
      )
  
      input_ids = torch.tensor(
          [sample_with_padding, sample_without_padding],
          device=torch_device,
          dtype=torch.long,
      )
      labels = torch.tensor(
          [target_ids_without_padding, target_ids_with_padding],
          device=torch_device,
          dtype=torch.long,
      )
  
      with torch.no_grad():
          logits_batched = model(
              input_ids=input_ids,
              attention_mask=attention_mask,
              labels=labels,
          ).logits
  
      with torch.no_grad():
          logits_single_first = model(
              input_ids=input_ids[:1, :-chunk_length], labels=labels[:1]
          ).logits
  
      self.assertTrue(
          torch.allclose(
              logits_batched[0, -3:],
              logits_single_first[0, -3:],
              atol=tolerance,
          )
      )
  
      with torch.no_grad():
          logits_single_second = model(
              input_ids=input_ids[1:], labels=labels[1:, :-4]
          ).logits
  
      self.assertTrue(
          torch.allclose(
              logits_batched[1, :3],
              logits_single_second[0, :3],
              atol=tolerance,
          )
      )
  
imports: import copy
  import tempfile
  import unittest
  from transformers import BigBirdPegasusConfig, is_torch_available
  from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, require_torch_fp16, slow, torch_device
  from ...generation.test_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 15 for calling the BigBirdPegasusModelTest obj's underlying member method code with example usage: obj._check_batched_forward(attn_type, tolerance) without return types