code: def test_init(self):
      # Without weights.
      tf = ExpectationPosteriorTransform(n_w=5)
      self.assertEqual(tf.n_w, 5)
      self.assertAllClose(tf.weights, torch.ones(5, 1) * 0.2)
      # Errors with weights.
      with self.assertRaisesRegex(ValueError, "a tensor of size"):
          ExpectationPosteriorTransform(n_w=3, weights=torch.ones(5, 1))
      with self.assertRaisesRegex(ValueError, "non-negative"):
          ExpectationPosteriorTransform(
              n_w=3, weights=-torch.ones(3, 1)
          )
      # Successful init with weights.
      weights = torch.tensor([[1.0, 2.0], [2.0, 4.0], [3.0, 6.0]])
      tf = ExpectationPosteriorTransform(n_w=3, weights=weights)
      self.assertAllClose(
          tf.weights, weights / torch.tensor([6.0, 12.0])
      )
  
imports: import itertools
  import warnings
  from typing import Optional
  import torch
  from botorch import settings
  from botorch.acquisition import LearnedObjective
  from botorch.acquisition.objective import ConstrainedMCObjective, DEFAULT_NUM_PREF_SAMPLES, ExpectationPosteriorTransform, GenericMCObjective, IdentityMCObjective, LEARNED_OBJECTIVE_PREF_MODEL_MIXED_DTYPE_WARN, LinearMCObjective, MCAcquisitionObjective, PosteriorTransform, ScalarizedPosteriorTransform
  from botorch.exceptions.errors import UnsupportedError
  from botorch.exceptions.warnings import _get_single_precision_warning, InputDataWarning
  from botorch.models.deterministic import PosteriorMeanModel
  from botorch.models.pairwise_gp import PairwiseGP
  from botorch.models.transforms.input import Normalize
  from botorch.posteriors import GPyTorchPosterior
  from botorch.utils import apply_constraints
  from botorch.utils.testing import _get_test_posterior, BotorchTestCase
  from gpytorch.distributions import MultitaskMultivariateNormal, MultivariateNormal
  from linear_operator.operators.dense_linear_operator import to_linear_operator
  from torch import Tensor
label_desc: Use image node_id 1 for calling the TestExpectationPosteriorTransform obj's underlying member method code with example usage: obj.test_init() without return types