code: def get_best_raw_objective_point_with_trial_index(
      experiment: Experiment,
      optimization_config: Optional[OptimizationConfig] = None,
      trial_indices: Optional[Iterable[int]] = None,
  ) -> Tuple[int, TParameterization, Dict[str, Tuple[float, float]]]:
      """Given an experiment, identifies the arm that had the best raw objective,
      based on the data fetched from the experiment.
  
      Args:
          experiment: Experiment, on which to identify best raw objective arm.
          optimization_config: Optimization config to use in place of the one stored
              on the experiment.
          trial_indices: Indices of trials for which to retrieve data. If None will
              retrieve data from all available trials.
  
      Returns:
          Tuple of parameterization and a mapping from metric name to a tuple of
              the corresponding objective mean and SEM.
      """
      optimization_config = (
          optimization_config or experiment.optimization_config
      )
      if optimization_config is None:
          raise UserInputError(
              "Cannot identify the best point without an optimization config, but no "
              "optimization config was provided on the experiment or as an argument."
          )
      if optimization_config.is_moo_problem:
          logger.warning(
              "get_best_raw_objective_point is deprecated for multi-objective "
              "optimization. This method will return an arbitrary point on the "
              "pareto frontier."
          )
  
      dat = experiment.lookup_data(trial_indices=trial_indices)
      if dat.df.empty:
          raise ValueError(
              "Cannot identify best point if experiment contains no data."
          )
      if any(oc.relative for oc in optimization_config.all_constraints):
          if experiment.status_quo is not None:
              optimization_config = _derel_opt_config_wrapper(
                  optimization_config=optimization_config,
                  experiment=experiment,
              )
          else:
              logger.warning(
                  "No status quo provided; relative constraints will be ignored."
              )
  
      # Only COMPLETED trials should be considered when identifying the best point
      completed_indices = {
          t.index
          for t in experiment.trials_by_status[TrialStatus.COMPLETED]
      }
      completed_df = dat.df[
          dat.df["trial_index"].isin(completed_indices)
      ]
  
      feasible_df = _filter_feasible_rows(
          df=completed_df,
          optimization_config=optimization_config,
      )
      objective = optimization_config.objective
      best_row_helper = (
          _get_best_row_for_scalarized_objective
          if isinstance(objective, ScalarizedObjective)
          else _get_best_row_for_single_objective
      )
      # pyre-ignore Incompatible parameter type [6]
      best_row = best_row_helper(df=feasible_df, objective=objective)
      best_arm = experiment.arms_by_name[best_row["arm_name"]]
      best_trial_index = int(best_row["trial_index"])
      objective_rows = dat.df.loc[
          (dat.df["arm_name"] == best_arm.name)
          & (dat.df["trial_index"] == best_trial_index)
      ]
      vals = {
          row["metric_name"]: (row["mean"], row["sem"])
          for _, row in objective_rows.iterrows()
      }
  
      return best_trial_index, not_none(best_arm).parameters, vals
  
imports: from collections import OrderedDict
  from functools import reduce
  from logging import Logger
  from typing import Dict, Iterable, List, Optional, Tuple, Type
  import pandas
  import torch
  from ax.core.base_trial import TrialStatus
  from ax.core.batch_trial import BatchTrial
  from ax.core.data import Data
  from ax.core.experiment import Experiment
  from ax.core.generator_run import GeneratorRun
  from ax.core.objective import MultiObjective, Objective, ScalarizedObjective
  from ax.core.observation import Observation
  from ax.core.optimization_config import MultiObjectiveOptimizationConfig, OptimizationConfig
  from ax.core.outcome_constraint import ObjectiveThreshold, OutcomeConstraint
  from ax.core.trial import Trial
  from ax.core.types import ComparisonOp, TModelPredictArm, TParameterization
  from ax.exceptions.core import UnsupportedError, UserInputError
  from ax.modelbridge.base import ModelBridge
  from ax.modelbridge.cross_validation import assess_model_fit, compute_diagnostics, cross_validate
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.modelbridge.modelbridge_utils import observed_pareto_frontier, predicted_pareto_frontier
  from ax.modelbridge.registry import get_model_from_generator_run, ModelRegistryBase, Models
  from ax.modelbridge.torch import TorchModelBridge
  from ax.modelbridge.transforms.utils import derelativize_optimization_config_with_raw_status_quo
  from ax.plot.pareto_utils import get_tensor_converter_model
  from ax.utils.common.logger import get_logger
  from ax.utils.common.typeutils import checked_cast, not_none
  from numpy import NaN
  from torch import Tensor
label_desc: Use image node_id 1 for calling a global function with example usage: get_best_raw_objective_point_with_trial_index(experiment, optimization_config, trial_indices) and returns: best_trial_index,  not_none,  vals