code: def partial_dependencies(
      experiment,
      with_evc_tree=True,
      params=None,
      smoothing=0.85,
      n_grid_points=10,
      n_samples=50,
      colorscale="Blues",
      model="RandomForestRegressor",
      model_kwargs=None,
      verbose_hover=True,
  ):
      """Plotly implementation of `orion.plotting.partial_dependencies`"""
  
      def build_data():
          """Builds the dataframe for the plot"""
          df = experiment.to_pandas(with_evc_tree=with_evc_tree)
  
          names = list(experiment.space.keys())
          df["params"] = df[names].apply(
              _format_hyperparameters, args=(names,), axis=1
          )
  
          df = df.loc[df["status"] == "completed"]
          data = orion.analysis.partial_dependency(
              df,
              experiment.space,
              params=params,
              model=model,
              n_grid_points=n_grid_points,
              n_samples=n_samples,
              **model_kwargs,
          )
          df = _flatten_dims(df, experiment.space)
          return (df, data)
  
      def _set_scale(figure, dims, x, y):
          for axis, dim in zip("xy", dims):
              if (
                  "reciprocal" in dim.prior_name
                  or dim.type == "fidelity"
              ):
                  getattr(figure, f"update_{axis}axes")(
                      type="log", row=y, col=x
                  )
  
      def _plot_marginalized_avg(data, x_name):
          return go.Scatter(
              x=data[0][x_name],
              y=data[1],
              mode="lines",
              name=None,
              showlegend=False,
              line=dict(
                  color=px.colors.qualitative.D3[0],
              ),
          )
  
      def _plot_marginalized_std(data, x_name):
          return go.Scatter(
              x=list(data[0][x_name]) + list(data[0][x_name])[::-1],
              y=list(data[1] - data[2]) + list(data[1] + data[2])[::-1],
              mode="lines",
              name=None,
              fill="toself",
              showlegend=False,
              line=dict(
                  color=px.colors.qualitative.D3[0],
                  width=0,
              ),
          )
  
      def _plot_contour(data, x_name, y_name):
          return go.Contour(
              x=data[0][x_name],
              y=data[0][y_name],
              z=data[1],
              connectgaps=True,
              # Share the same color range across contour plots
              coloraxis="coloraxis",
              line_smoothing=smoothing,
              # To show labels
              contours=dict(
                  coloring="heatmap",
                  showlabels=True,  # show labels on contours
                  labelfont=dict(  # label font properties
                      size=12,
                      color="white",
                  ),
              ),
          )
  
      def _plot_scatter(x, y, df):
          return go.Scatter(
              x=x,
              y=y,
              marker={
                  "line": {"width": 0.5, "color": "Grey"},
                  "color": "black",
                  "size": 5,
              },
              mode="markers",
              opacity=0.5,
              showlegend=False,
              customdata=list(
                  zip(df["id"], df["suggested"], df["params"])
              ),
              hovertemplate=_template_trials(verbose_hover),
          )
  
      if model_kwargs is None:
          model_kwargs = {}
  
      df, data = build_data()
  
      if not data:
          return go.Figure()
  
      params = [
          param_names
          for param_names in data.keys()
          if isinstance(param_names, str)
      ]
  
      flattened_space = build_required_space(
          experiment.space,
          shape_requirement="flattened",
      )
  
      fig = make_subplots(
          rows=len(params),
          cols=len(params),
          shared_xaxes=True,
          shared_yaxes=False,
      )
  
      fig.update_layout(
          paper_bgcolor="rgba(0,0,0,0)", plot_bgcolor="rgba(0,0,0,0)"
      )
      cmin = float("inf")
      cmax = -float("inf")
  
      for x_i in range(len(params)):
          x_name = params[x_i]
          fig.add_trace(
              _plot_marginalized_avg(data[x_name], x_name),
              row=x_i + 1,
              col=x_i + 1,
          )
          fig.add_trace(
              _plot_marginalized_std(data[x_name], x_name),
              row=x_i + 1,
              col=x_i + 1,
          )
          fig.add_trace(
              _plot_scatter(df[x_name], df["objective"], df),
              row=x_i + 1,
              col=x_i + 1,
          )
  
          _set_scale(fig, [flattened_space[x_name]], x_i + 1, x_i + 1)
  
          fig.update_xaxes(
              title_text=x_name, row=len(params), col=x_i + 1
          )
          if x_i > 0:
              fig.update_yaxes(title_text=x_name, row=x_i + 1, col=1)
          else:
              fig.update_yaxes(
                  title_text="Objective", row=x_i + 1, col=x_i + 1
              )
  
          for y_i in range(x_i + 1, len(params)):
              y_name = params[y_i]
              fig.add_trace(
                  _plot_contour(
                      data[(x_name, y_name)],
                      x_name,
                      y_name,
                  ),
                  row=y_i + 1,
                  col=x_i + 1,
              )
              fig.add_trace(
                  _plot_scatter(df[x_name], df[y_name], df),
                  row=y_i + 1,
                  col=x_i + 1,
              )
  
              cmin = min(cmin, data[(x_name, y_name)][1].min())
              cmax = max(cmax, data[(x_name, y_name)][1].max())
  
              _set_scale(
                  fig,
                  [flattened_space[name] for name in [x_name, y_name]],
                  x_i + 1,
                  y_i + 1,
              )
  
      for x_i in range(len(params)):
          plot_id = len(params) * x_i + x_i + 1
          if plot_id > 1:
              key = f"yaxis{plot_id}_range"
          else:
              key = "yaxis_range"
          fig.update_layout(**{key: [cmin, cmax]})
  
      fig.update_layout(
          title=f"Partial dependencies for experiment '{experiment.name}'",
      )
      fig.layout.coloraxis.colorbar.title = "Objective"
  
      fig.update_layout(
          coloraxis=dict(colorscale=colorscale), showlegend=False
      )
  
      return fig
  
imports: import functools
  from collections.abc import Iterable
  import numpy
  import pandas
  import plotly.express
  import plotly.graph_objects
  from plotly.subplots import make_subplots
  import orion.analysis
  import orion.analysis.base
  from orion.algo.space import Categorical, Fidelity
  from orion.core.worker.transformer import build_required_space
label_desc: Use image node_id 4 for calling a global function with example usage: partial_dependencies(experiment, with_evc_tree, params, smoothing, n_grid_points, n_samples, colorscale, model, model_kwargs, verbose_hover) and returns: fig, df,  data, go, go, go, go, go