code: def plot_to_figure(
      plot,
      reset_nclicks=0,
      layout_ranges=None,
      responsive=True,
      use_ranges=True,
  ):
      """
      Convert a HoloViews plotly plot to a plotly.py Figure.
  
      Args:
          plot: A HoloViews plotly plot object
          reset_nclicks: Number of times a reset button associated with the plot has been
              clicked
  
      Returns:
          A plotly.py Figure
      """
      fig_dict = plot.state
      clean_internal_figure_properties(fig_dict)
  
      # Enable uirevision to preserve user-interaction state
      # Don't use reset_nclicks directly because 0 is treated as no revision
      fig_dict["layout"]["uirevision"] = "reset-" + str(reset_nclicks)
  
      # Remove range specification so plotly.js autorange + uirevision is in control
      if layout_ranges and use_ranges:
          for k in fig_dict["layout"]:
              if k.startswith(("xaxis", "yaxis")):
                  fig_dict["layout"][k].pop("range", None)
              if k.startswith("mapbox"):
                  fig_dict["layout"][k].pop("zoom", None)
                  fig_dict["layout"][k].pop("center", None)
  
      # Remove figure width height, let container decide
      if responsive:
          fig_dict["layout"].pop("autosize", None)
  
      if responsive is True or responsive == "width":
          fig_dict["layout"].pop("width", None)
  
      if responsive is True or responsive == "height":
          fig_dict["layout"].pop("height", None)
  
      # Pass to figure constructor to expand magic underscore notation
      fig = go.Figure(fig_dict)
  
      if layout_ranges and use_ranges:
          fig.update_layout(layout_ranges)
  
      return fig
  
imports: import base64
  import copy
  import pickle
  import uuid
  from collections import namedtuple
  from dash.exceptions import PreventUpdate
  import holoviews
  from holoviews.core.decollate import expr_to_fn_of_stream_contents, initialize_dynamic, to_expr_extract_streams
  from holoviews.plotting.plotly import DynamicMap, PlotlyRenderer
  from holoviews.plotting.plotly.callbacks import BoundsXCallback, BoundsXYCallback, BoundsYCallback, RangeXCallback, RangeXYCallback, RangeYCallback, Selection1DCallback
  from holoviews.plotting.plotly.util import clean_internal_figure_properties
  from holoviews.streams import Derived, History
  import plotly.graph_objects
  from dash import callback_context
  from dash.dependencies import Input, Output, State
label_desc: Use image node_id 2 for calling a global function with example usage: plot_to_figure(plot, reset_nclicks, layout_ranges, responsive, use_ranges) and returns: fig