code: def _get_acquisition_func(
      model: Model,
      acquisition_function_name: str,
      objective_weights: Tensor,
      outcome_constraints: Optional[Tuple[Tensor, Tensor]] = None,
      X_observed: Optional[Tensor] = None,
      X_pending: Optional[Tensor] = None,
      mc_objective: Type[GenericMCObjective] = GenericMCObjective,
      constrained_mc_objective: Optional[
          Type[ConstrainedMCObjective]
      ] = ConstrainedMCObjective,
      # pyre-fixme[24]: Generic type `dict` expects 2 type parameters, use
      #  `typing.Dict` to avoid runtime subscripting errors.
      mc_objective_kwargs: Optional[Dict] = None,
      *,
      chebyshev_scalarization: bool = False,
      prune_baseline: bool = True,
      mc_samples: int = 512,
      marginalize_dim: Optional[int] = None,
  ) -> AcquisitionFunction:
      r"""Instantiates a acquisition function.
  
      Args:
          model: The underlying model which the acqusition function uses
              to estimate acquisition values of candidates.
          acquisition_function_name: Name of the acquisition function.
          objective_weights: The objective is to maximize a weighted sum of
              the columns of f(x). These are the weights.
          outcome_constraints: A tuple of (A, b). For k outcome constraints
              and m outputs at f(x), A is (k x m) and b is (k x 1) such that
              A f(x) <= b. (Not used by single task models)
          X_observed: A tensor containing points observed for all objective
              outcomes and outcomes that appear in the outcome constraints (if
              there are any).
          X_pending: A tensor containing points whose evaluation is pending (i.e.
              that have been submitted for evaluation) present for all objective
              outcomes and outcomes that appear in the outcome constraints (if
              there are any).
          mc_objective: GenericMCObjective class, used for constructing a
              MC-objective. If constructing a penalized MC-objective, pass in
              PenalizedMCObjective together with mc_objective_kwargs .
          constrained_mc_objective: ConstrainedMCObjective class, used when
              applying constraints on the outcomes.
          mc_objective_kwargs: kwargs for constructing MC-objective.
              For GenericMCObjective, leave it as None. For PenalizedMCObjective,
              it needs to be specified in the format of kwargs.
          mc_samples: The number of MC samples to use (default: 512).
          prune_baseline: If True, prune the baseline points for NEI (default: True).
          chebyshev_scalarization: Use augmented Chebyshev scalarization.
  
      Returns:
          The instantiated acquisition function.
      """
      if acquisition_function_name not in [
          "qSR",
          "qEI",
          "qLogEI",
          "qPI",
          "qNEI",
          "qLogNEI",
      ]:
          raise NotImplementedError(
              f"{acquisition_function_name=} not implemented yet."
          )
  
      if X_observed is None:
          raise ValueError(NO_FEASIBLE_POINTS_MESSAGE)
      # construct Objective module
      if chebyshev_scalarization:
          with torch.no_grad():
              Y = model.posterior(X_observed).mean  # pyre-ignore [16]
          if is_ensemble(model):
              Y = torch.mean(Y, dim=0)
          obj_tf = get_chebyshev_scalarization(
              weights=objective_weights, Y=Y
          )
      else:
          obj_tf = get_objective_weights_transform(objective_weights)
  
      # pyre-fixme[53]: Captured variable `obj_tf` is not annotated.
      def objective(
          samples: Tensor, X: Optional[Tensor] = None
      ) -> Tensor:
          return obj_tf(samples)
  
      mc_objective_kwargs = (
          {} if mc_objective_kwargs is None else mc_objective_kwargs
      )
      objective = mc_objective(
          objective=objective, **mc_objective_kwargs
      )
  
      if outcome_constraints is None:
          con_tfs = None
      else:
          con_tfs = get_outcome_constraint_transforms(
              outcome_constraints
          )
          # All acquisition functions registered in BoTorch's `get_acquisition_function`
          # except qSR and qUCB support a principled treatment of the constraints by
          # directly passing them to the constructor.
          if acquisition_function_name == "qSR":
              if constrained_mc_objective is None:
                  raise ValueError(
                      "constrained_mc_objective cannot be set to None "
                      "when applying outcome constraints."
                  )
  
              inf_cost = get_infeasible_cost(
                  X=X_observed, model=model, objective=objective
              )
              objective = constrained_mc_objective(
                  objective=objective,
                  constraints=con_tfs or [],
                  infeasible_cost=inf_cost,
              )
  
      return get_acquisition_function(
          acquisition_function_name=acquisition_function_name,
          model=model,
          objective=objective,
          X_observed=X_observed,
          X_pending=X_pending,
          prune_baseline=prune_baseline,
          mc_samples=mc_samples,
          seed=randint(1, 10000),
          marginalize_dim=marginalize_dim,
          constraints=con_tfs,
      )
  
imports: import functools
  from copy import deepcopy
  from random import randint
  from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, Type, Union
  import torch
  from ax.models.model_utils import best_observed_point, get_observed
  from ax.models.torch.utils import _to_inequality_constraints
  from ax.models.torch_base import TorchModel
  from ax.models.types import TConfig
  from botorch.acquisition import get_acquisition_function
  from botorch.acquisition.acquisition import AcquisitionFunction
  from botorch.acquisition.fixed_feature import FixedFeatureAcquisitionFunction
  from botorch.acquisition.objective import ConstrainedMCObjective, GenericMCObjective
  from botorch.acquisition.utils import get_infeasible_cost
  from botorch.exceptions.errors import UnsupportedError
  from botorch.fit import fit_gpytorch_mll
  from botorch.models.gp_regression import SingleTaskGP
  from botorch.models.gp_regression_fidelity import SingleTaskMultiFidelityGP
  from botorch.models.gpytorch import GPyTorchModel
  from botorch.models.model import Model
  from botorch.models.model_list_gp_regression import ModelListGP
  from botorch.models.multitask import MultiTaskGP
  from botorch.models.transforms.input import Warp
  from botorch.optim.optimize import optimize_acqf
  from botorch.utils import get_objective_weights_transform, get_outcome_constraint_transforms
  from botorch.utils.multi_objective.scalarization import get_chebyshev_scalarization
  from botorch.utils.transforms import is_ensemble
  from gpytorch.kernels import MaternKernel, ScaleKernel
  from gpytorch.kernels.kernel import Kernel
  from gpytorch.mlls.exact_marginal_log_likelihood import ExactMarginalLogLikelihood
  from gpytorch.mlls.leave_one_out_pseudo_likelihood import LeaveOneOutPseudoLikelihood
  from gpytorch.mlls.sum_marginal_log_likelihood import SumMarginalLogLikelihood
  from gpytorch.priors import Prior
  from gpytorch.priors.lkj_prior import LKJCovariancePrior
  from gpytorch.priors.torch_priors import GammaPrior, LogNormalPrior
  from torch import Tensor
label_desc: Use image node_id 8 for calling a global function with example usage: _get_acquisition_func(model, acquisition_function_name, objective_weights, outcome_constraints, X_observed, X_pending, mc_objective, constrained_mc_objective, mc_objective_kwargs) and returns: get_acquisition_function, obj_tf