code: def test_indivisible_batch(self):
      batch_size = 7
      batch_sampler = AspectRatioBatchSampler(
          self.sampler, batch_size=batch_size, drop_last=False
      )
      all_batch_idxs = list(batch_sampler)
      self.assertEqual(
          len(batch_sampler),
          (self.length + batch_size - 1) // batch_size,
      )
      self.assertEqual(
          len(all_batch_idxs),
          (self.length + batch_size - 1) // batch_size,
      )
  
      batch_sampler = AspectRatioBatchSampler(
          self.sampler, batch_size=batch_size, drop_last=True
      )
      all_batch_idxs = list(batch_sampler)
      self.assertEqual(len(batch_sampler), self.length // batch_size)
      self.assertEqual(len(all_batch_idxs), self.length // batch_size)
  
      # the last batch may not have the same aspect ratio
      for batch_idxs in all_batch_idxs[:-1]:
          self.assertEqual(len(batch_idxs), batch_size)
          batch = [self.dataset[idx] for idx in batch_idxs]
          flag = batch[0][0] < batch[0][1]
          for i in range(1, batch_size):
              self.assertEqual(batch[i][0] < batch[i][1], flag)
  
file_path: mmdetection/tests/test_datasets/test_samplers/test_batch_sampler.py
imports: from unittest import TestCase
  from unittest.mock import patch
  import numpy
  from mmengine.dataset import DefaultSampler
  from torch.utils.data import Dataset
  from mmdet.datasets.samplers import AspectRatioBatchSampler
label_desc: Use image node_id 4 for calling the TestAspectRatioBatchSampler obj's underlying member method code with example usage: obj.test_indivisible_batch() without return types