code: def test_batched_multinomial(self):
      num_categories = 5
      num_samples = 4
      Trulse = (True, False)
      for (
          batch_shape,
          dtype,
          replacement,
          use_gen,
          use_out,
      ) in itertools.product(
          ([], [3], [2, 3]),
          (torch.float, torch.double),
          Trulse,
          Trulse,
          Trulse,
      ):
          weights = torch.rand(
              *batch_shape, num_categories, dtype=dtype
          )
          out = None
          if use_out:
              out = torch.empty(
                  *batch_shape, num_samples, dtype=torch.long
              )
          samples = batched_multinomial(
              weights,
              num_samples,
              replacement=replacement,
              generator=torch.Generator() if use_gen else None,
              out=out,
          )
          self.assertEqual(
              samples.shape, torch.Size([*batch_shape, num_samples])
          )
          if use_out:
              self.assertTrue(torch.equal(samples, out))
          if not replacement:
              for s in samples.view(-1, num_samples):
                  self.assertTrue(torch.unique(s).size(0), num_samples)
  
imports: from __future__ import annotations
  import itertools
  import warnings
  from typing import Any, Dict, Type
  from unittest import mock
  import numpy
  import torch
  from botorch.exceptions.errors import BotorchError
  from botorch.models.gp_regression import SingleTaskGP
  from botorch.sampling.pathwise import draw_matheron_paths
  from botorch.utils.sampling import _convert_bounds_to_inequality_constraints, batched_multinomial, DelaunayPolytopeSampler, draw_sobol_samples, find_interior_point, get_polytope_samples, HitAndRunPolytopeSampler, manual_seed, normalize_linear_constraints, optimize_posterior_samples, PolytopeSampler, sample_hypersphere, sample_simplex, sparse_to_dense_constraints
  from botorch.utils.testing import BotorchTestCase
label_desc: Use image node_id 4 for calling the TestSampleUtils obj's underlying member method code with example usage: obj.test_batched_multinomial() without return types