code: def _get_single_curve(
      curve_series: Dict[str, pd.Series],
      curve_name: str,
      map_key: str,
      trial: BaseTrial,
      cumulative_best: bool,
      lower_is_better: bool,
      smoothing_window: Optional[int],
      metric_name: Optional[str] = None,
  ) -> pd.DataFrame:
      """Get a single curve from `curve_series` and return as a dataframe.
      By default, the `metric_name` is set to be the `curve_name`, but if
      an additional `metric_name` is passed, it will be used instead.
      """
      if metric_name is None:
          metric_name = curve_name
      cs = curve_series[curve_name].rename("mean")  # pyre-ignore [6]
      dfi = cs.reset_index().rename(
          columns={"index": map_key}
      )  # pyre-ignore [16]
      dfi["trial_index"] = trial.index
      dfi["arm_name"] = trial.arm.name  # pyre-ignore [16]
      dfi["metric_name"] = metric_name
      dfi["sem"] = float("nan")
      if (
          smoothing_window is not None
          and len(dfi["mean"]) >= smoothing_window
      ):
          dfi["mean"] = (
              dfi["mean"].rolling(window=smoothing_window).mean()
          )
          first_smoothed = dfi["mean"].iloc[smoothing_window - 1]
          dfi.iloc[
              : smoothing_window - 1, dfi.columns.get_loc("mean")
          ] = first_smoothed
      if cumulative_best:
          dfi["mean"] = (
              dfi["mean"].cummin()
              if lower_is_better
              else dfi["mean"].cummax()
          )
      return dfi.drop_duplicates()
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from logging import Logger
  from typing import Any, Dict, Iterable, Optional, Set, Union
  import numpy
  import pandas
  from ax.core.base_trial import BaseTrial
  from ax.core.batch_trial import BatchTrial
  from ax.core.experiment import Experiment
  from ax.core.map_data import MapData, MapKeyInfo
  from ax.core.map_metric import MapMetric
  from ax.core.metric import Metric, MetricFetchE, MetricFetchResult
  from ax.core.trial import Trial
  from ax.early_stopping.utils import align_partial_results
  from ax.exceptions.core import UnsupportedError
  from ax.utils.common.logger import get_logger
  from ax.utils.common.result import Err, Ok
  from ax.utils.common.typeutils import checked_cast
label_desc: Use image node_id 3 for calling a global function with example usage: _get_single_curve(curve_series, curve_name, map_key, trial, cumulative_best, lower_is_better, smoothing_window, metric_name) and returns: dfi