code: def test_get_collapsed_shape(self):
      posterior = MockPosterior(base_shape=torch.Size([4, 3, 2]))
      sampler = NonAbstractSampler(sample_shape=torch.Size([4]))
      self.assertEqual(
          sampler._get_collapsed_shape(posterior=posterior),
          torch.Size([4, 1, 3, 2]),
      )
      posterior = MockPosterior(
          base_shape=torch.Size([3, 4, 3, 2]), batch_range=(0, 0)
      )
      self.assertEqual(
          sampler._get_collapsed_shape(posterior=posterior),
          torch.Size([4, 3, 4, 3, 2]),
      )
      posterior = MockPosterior(
          base_shape=torch.Size([3, 4, 3, 2]), batch_range=(0, -1)
      )
      self.assertEqual(
          sampler._get_collapsed_shape(posterior=posterior),
          torch.Size([4, 1, 1, 1, 2]),
      )
  
file_path: botorch/test/sampling/test_base.py
imports: import torch
  from botorch.exceptions.errors import InputDataError
  from botorch.sampling.base import MCSampler
  from botorch.utils.testing import BotorchTestCase, MockPosterior
label_desc: Use image node_id 4 for calling the TestBaseMCSampler obj's underlying member method code with example usage: obj.test_get_collapsed_shape() without return types