code: def _construct_sample_weights(
      prev_weights: Tensor, sampler: MCSampler
  ) -> Optional[Tensor]:
      r"""Iteratively construct tensor of sample weights for multi-step look-ahead.
  
      Args:
          prev_weights: A `f_i x .... x f_1 x batch_shape` tensor of previous sample
              weights.
          sampler: A `MCSampler` that may have sample weights as the `base_weights`
              attribute. If the sampler does not have a `base_weights` attribute,
              samples are weighted uniformly.
  
      Returns:
          A `f_{i+1} x .... x f_1 x batch_shape` tensor of sample weights for the next
          step.
      """
      new_weights = getattr(
          sampler, "base_weights", None
      )  # TODO: generalize this
      if new_weights is None:
          # uniform weights
          nf = sampler.sample_shape[0]
          new_weights = torch.ones(
              nf, device=prev_weights.device, dtype=prev_weights.dtype
          )
      # reshape new_weights to be f_{i+1} x 1 x ... x 1
      new_weights = new_weights.view(
          -1, *(1 for _ in prev_weights.shape)
      )
      # normalize new_weights to sum to 1.0
      new_weights = new_weights / new_weights.sum()
      return new_weights * prev_weights
  
imports: from __future__ import annotations
  import math
  import warnings
  from typing import Any, Callable, Dict, List, Optional, Tuple, Type
  import numpy
  import torch
  from botorch.acquisition import AcquisitionFunction, OneShotAcquisitionFunction
  from botorch.acquisition.analytic import AnalyticAcquisitionFunction, PosteriorMean
  from botorch.acquisition.monte_carlo import MCAcquisitionFunction
  from botorch.acquisition.objective import MCAcquisitionObjective, PosteriorTransform
  from botorch.exceptions.errors import UnsupportedError
  from botorch.exceptions.warnings import BotorchWarning
  from botorch.models.model import Model
  from botorch.optim.initializers import initialize_q_batch
  from botorch.sampling.base import MCSampler
  from botorch.sampling.normal import SobolQMCNormalSampler
  from botorch.utils.transforms import match_batch_shape, t_batch_mode_transform, unnormalize
  from torch import Size, Tensor
  from torch.distributions import Beta
  from torch.nn import ModuleList
label_desc: Use image node_id 3 for calling a global function with example usage: _construct_sample_weights(prev_weights, sampler) and returns: unknown