code: def qnei_candidates_func(
      train_x: "torch.Tensor",
      train_obj: "torch.Tensor",
      train_con: Optional["torch.Tensor"],
      bounds: "torch.Tensor",
      pending_x: Optional["torch.Tensor"],
  ) -> "torch.Tensor":
      """Quasi MC-based batch Noisy Expected Improvement (qNEI).
  
      This function may perform better than qEI (`qei_candidates_func`) when
      the evaluated values of objective function are noisy.
  
      .. seealso::
          :func:`~optuna.integration.botorch.qei_candidates_func` for argument and return value
          descriptions.
      """
      if train_obj.size(-1) != 1:
          raise ValueError(
              "Objective may only contain single values with qNEI."
          )
      if train_con is not None:
          train_y = torch.cat([train_obj, train_con], dim=-1)
  
          n_constraints = train_con.size(1)
          objective = ConstrainedMCObjective(
              objective=lambda Z: Z[..., 0],
              constraints=[
                  (lambda Z, i=i: Z[..., -n_constraints + i])
                  for i in range(n_constraints)
              ],
          )
      else:
          train_y = train_obj
  
          objective = None  # Using the default identity objective.
  
      train_x = normalize(train_x, bounds=bounds)
      if pending_x is not None:
          pending_x = normalize(pending_x, bounds=bounds)
  
      model = SingleTaskGP(
          train_x,
          train_y,
          outcome_transform=Standardize(m=train_y.size(-1)),
      )
      mll = ExactMarginalLogLikelihood(model.likelihood, model)
      fit_gpytorch_mll(mll)
  
      acqf = qNoisyExpectedImprovement(
          model=model,
          X_baseline=train_x,
          sampler=_get_sobol_qmc_normal_sampler(256),
          objective=objective,
          X_pending=pending_x,
      )
  
      standard_bounds = torch.zeros_like(bounds)
      standard_bounds[1] = 1
  
      candidates, _ = optimize_acqf(
          acq_function=acqf,
          bounds=standard_bounds,
          q=1,
          num_restarts=10,
          raw_samples=512,
          options={"batch_limit": 5, "maxiter": 200},
          sequential=True,
      )
  
      candidates = unnormalize(candidates.detach(), bounds=bounds)
  
      return candidates
  
imports: from typing import Any
  from typing import Callable
  from typing import Dict
  from typing import Optional
  from typing import Sequence
  from typing import Union
  import warnings
  import numpy
  from packaging import version
  from optuna import logging
  from optuna._experimental import experimental_class
  from optuna._experimental import experimental_func
  from optuna._imports import try_import
  from optuna._transform import _SearchSpaceTransform
  from optuna.distributions import BaseDistribution
  from optuna.samplers import BaseSampler
  from optuna.samplers import RandomSampler
  from optuna.samplers._base import _CONSTRAINTS_KEY
  from optuna.samplers._base import _process_constraints_after_trial
  from optuna.search_space import IntersectionSearchSpace
  from optuna.study import Study
  from optuna.study import StudyDirection
  from optuna.trial import FrozenTrial
  from optuna.trial import TrialState
label_desc: Use image node_id 3 for calling a global function with example usage: qnei_candidates_func(train_x, train_obj, train_con, bounds, pending_x) and returns: candidates