code: def optimization_trace_single_method_plotly(
      y: np.ndarray,
      optimum: Optional[float] = None,
      model_transitions: Optional[List[int]] = None,
      title: str = "",
      ylabel: str = "",
      hover_labels: Optional[List[str]] = None,
      trace_color: Tuple[int] = COLORS.STEELBLUE.value,
      optimum_color: Tuple[int] = COLORS.ORANGE.value,
      generator_change_color: Tuple[int] = COLORS.TEAL.value,
      optimization_direction: Optional[str] = "passthrough",
      plot_trial_points: bool = False,
      trial_points_color: Tuple[int] = COLORS.LIGHT_PURPLE.value,
      autoset_axis_limits: bool = True,
  ) -> go.Figure:
      """Plots an optimization trace with mean and 2 SEMs
  
      Args:
          y: (r x t) array; result to plot, with r runs and t trials
          optimum: value of the optimal objective
          model_transitions: iterations, before which generators
              changed
          title: title for this plot.
          ylabel: label for the Y-axis.
          hover_labels: optional, text to show on hover; list where the i-th value
              corresponds to the i-th value in the value of the `y` argument.
          trace_color: tuple of 3 int values representing an RGB color for plotting
              running optimum. Defaults to blue.
          optimum_color: tuple of 3 int values representing an RGB color.
              Defaults to orange.
          generator_change_color: tuple of 3 int values representing
              an RGB color. Defaults to teal.
          optimization_direction: str, "minimize" will plot running minimum,
              "maximize" will plot running maximum, "passthrough" (default) will plot
              y as lines, None does not plot running optimum)
          plot_trial_points: bool, whether to plot the objective for each trial, as
              supplied in y (default False for backward compatibility)
          trial_points_color: tuple of 3 int values representing an RGB color for
              plotting trial points. Defaults to light purple.
          autoset_axis_limits: Automatically try to set the limit for each axis to focus
              on the region of interest.
  
      Returns:
          go.Figure: plot of the optimization trace with IQR
      """
      if optimization_direction not in {
          "minimize",
          "maximize",
          "passthrough",
          None,
      }:
          raise ValueError(
              'optimization_direction must be "minimize", "maximize", "passthrough", or '
              "None"
          )
      if (not plot_trial_points) and (optimization_direction is None):
          raise ValueError(
              "If plot_trial_points is False, optimization_direction must not be None."
          )
      data = []
      if plot_trial_points:
          markers = mean_markers_scatter(
              y=y,
              marker_color=trial_points_color,
              hover_labels=hover_labels,
              legend_label="objective value",
          )
          data.extend([markers])
  
      if optimization_direction is not None:
          legend_label = "best objective so far"
          if optimization_direction == "minimize":
              y_running_optimum = np.minimum.accumulate(y, axis=1)
          elif optimization_direction == "maximize":
              y_running_optimum = np.maximum.accumulate(y, axis=1)
          else:
              y_running_optimum = y
              legend_label = "objective value"
          trace = mean_trace_scatter(
              y=y_running_optimum,
              trace_color=trace_color,
              hover_labels=hover_labels,
              legend_label=legend_label,
          )
          lower, upper = sem_range_scatter(
              y=y_running_optimum, trace_color=trace_color
          )
          data.extend([lower, trace, upper])
  
      if optimum is not None:
          data.append(
              optimum_objective_scatter(
                  optimum=optimum,
                  num_iterations=y.shape[1],
                  optimum_color=optimum_color,
              )
          )
  
      if model_transitions is not None:
          if plot_trial_points:
              y_lower = np.percentile(y, 25, axis=0).min()
              y_upper = np.percentile(y, 75, axis=0).max()
          else:
              y_lower = np.percentile(
                  y_running_optimum, 25, axis=0
              ).min()
              y_upper = np.percentile(
                  y_running_optimum, 75, axis=0
              ).max()
          if optimum is not None and optimum < y_lower:
              y_lower = optimum
          if optimum is not None and optimum > y_upper:
              y_upper = optimum
          data.extend(
              model_transitions_scatter(
                  model_transitions=model_transitions,
                  y_range=[y_lower, y_upper],
                  generator_change_color=generator_change_color,
              )
          )
  
      layout = go.Layout(
          title=title,
          showlegend=True,
          yaxis={"title": ylabel},
          xaxis={"title": "Iteration"},
      )
      layout_yaxis_range = None
      if autoset_axis_limits and optimization_direction in [
          "minimize",
          "maximize",
      ]:
          layout_yaxis_range = _autoset_axis_limits(
              y=y, optimization_direction=optimization_direction
          )
      return go.Figure(
          layout=layout,
          data=data,
          layout_yaxis_range=layout_yaxis_range,
      )
  
imports: from datetime import datetime, timedelta
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import pandas
  import plotly.graph_objs
  from ax.core.experiment import Experiment
  from ax.plot.base import AxPlotConfig, AxPlotTypes
  from ax.plot.color import COLORS, DISCRETE_COLOR_SCALE, rgba
  from ax.utils.common.timeutils import timestamps_in_range
  from ax.utils.common.typeutils import not_none
  from plotly import express
  from plotly.express.colors import sample_colorscale
label_desc: Use image node_id 8 for calling a global function with example usage: optimization_trace_single_method_plotly(y, optimum, model_transitions, title, ylabel, hover_labels, trace_color, optimum_color, generator_change_color, optimization_direction, plot_trial_points, trial_points_color, autoset_axis_limits) and returns: go