docstr: Test that `scalarize_posterior` raises `NotImplementedError` when provided
  input shapes that are not supported for `PosteriorList`.
code: def test_scalarize_posterior_raises_not_implemented(self) -> None:
      """
      Test that `scalarize_posterior` raises `NotImplementedError` when provided
      input shapes that are not supported for `PosteriorList`.
      """
      for batch_shape, m, lazy, dtype in itertools.product(
          ([], [3]), (1, 2), (False, True), (torch.float, torch.double)
      ):
          tkwargs = {"device": self.device, "dtype": dtype}
          offset = torch.rand(1).item()
          weights = torch.randn(m, **tkwargs)
          # Make sure the weights are not too small.
          while torch.any(weights.abs() < 0.1):
              weights = torch.randn(m, **tkwargs)
          # test q=1
          posterior = _get_test_posterior(
              batch_shape, m=m, lazy=lazy, **tkwargs
          )
          posterior_list = PosteriorList(posterior)
          if m > 1:
              with self.assertRaisesRegex(
                  NotImplementedError,
                  "scalarize_posterior only works with a PosteriorList if each "
                  "sub-posterior has one outcome.",
              ):
                  scalarize_posterior(posterior_list, weights, offset)
  
          # test q=2, interleaved
          q = 2
          posterior = _get_test_posterior(
              batch_shape,
              q=q,
              m=m,
              lazy=lazy,
              interleaved=True,
              **tkwargs,
          )
          posterior_list = PosteriorList(posterior)
          with self.assertRaisesRegex(
              NotImplementedError,
              "scalarize_posterior only works with a PosteriorList if each "
              "sub-posterior has q=1.",
          ):
              scalarize_posterior(posterior_list, weights, offset)
  
          # test q=2, non-interleaved
          # test independent special case as well
          for independent in (False, True) if m > 1 else (False,):
              posterior = _get_test_posterior(
                  batch_shape,
                  q=q,
                  m=m,
                  lazy=lazy,
                  interleaved=False,
                  independent=independent,
                  **tkwargs,
              )
              posterior_list = PosteriorList(posterior)
              with self.assertRaisesRegex(
                  NotImplementedError,
                  "scalarize_posterior only works with a PosteriorList if each "
                  "sub-posterior has q=1.",
              ):
                  scalarize_posterior(posterior_list, weights, offset)
  
file_path: botorch/test/posteriors/test_posteriorlist.py
imports: import itertools
  import torch
  from botorch.posteriors.gpytorch import scalarize_posterior
  from botorch.posteriors.posterior_list import PosteriorList
  from botorch.utils.testing import _get_test_posterior, BotorchTestCase
label_desc: Use image node_id 3 for calling the TestPosteriorList obj's underlying member method code with example usage: obj.test_scalarize_posterior_raises_not_implemented() without return types