code: def marshall(
      proto: PlotlyChartProto,
      figure_or_data: FigureOrData,
      use_container_width: bool,
      sharing: SharingMode,
      theme: Union[None, Literal["streamlit"]],
      **kwargs: Any,
  ) -> None:
      """Marshall a proto with a Plotly spec.
  
      See DeltaGenerator.plotly_chart for docs.
      """
      # NOTE: "figure_or_data" is the name used in Plotly's .plot() method
      # for their main parameter. I don't like the name, but its best to keep
      # it in sync with what Plotly calls it.
  
      import plotly.tools
  
      if type_util.is_type(figure_or_data, "matplotlib.figure.Figure"):
          figure = plotly.tools.mpl_to_plotly(figure_or_data)
  
      else:
          figure = plotly.tools.return_figure_from_figure_or_data(
              figure_or_data, validate_figure=True
          )
  
      if (
          not isinstance(sharing, str)
          or sharing.lower() not in SHARING_MODES
      ):
          raise ValueError(
              "Invalid sharing mode for Plotly chart: %s" % sharing
          )
  
      proto.use_container_width = use_container_width
  
      if sharing == "streamlit":
          import plotly.io
  
          config = dict(kwargs.get("config", {}))
          # Copy over some kwargs to config dict. Plotly does the same in plot().
          config.setdefault("showLink", kwargs.get("show_link", False))
          config.setdefault("linkText", kwargs.get("link_text", False))
  
          proto.figure.spec = plotly.io.to_json(figure, validate=False)
          proto.figure.config = json.dumps(config)
  
      else:
          url = _plot_to_url_or_load_cached_url(
              figure, sharing=sharing, auto_open=False, **kwargs
          )
          proto.url = _get_embed_url(url)
      proto.theme = theme or ""
  
file_path: streamlit/lib/streamlit/elements/plotly_chart.py
imports: import json
  import urllib.parse
  from typing import TYPE_CHECKING, Any, Dict, List, Set, Union, cast
  from typing_extensions import Final, Literal, TypeAlias
  from streamlit import type_util
  from streamlit.errors import StreamlitAPIException
  from streamlit.logger import get_logger
  from streamlit.proto.PlotlyChart_pb2 import PlotlyChart
  from streamlit.runtime.legacy_caching import caching
  from streamlit.runtime.metrics_util import gather_metrics
label_desc: Use image node_id 1 for calling a global function with example usage: marshall(proto, figure_or_data, use_container_width, sharing, theme) without return types