code: def marshall(
      proto: ArrowVegaLiteChartProto,
      data: Data = None,
      spec: Optional[Dict[str, Any]] = None,
      use_container_width: bool = False,
      theme: Union[None, Literal["streamlit"]] = "streamlit",
      **kwargs,
  ):
      """Construct a Vega-Lite chart object.
  
      See DeltaGenerator.vega_lite_chart for docs.
      """
      # Support passing data inside spec['datasets'] and spec['data'].
      # (The data gets pulled out of the spec dict later on.)
      if isinstance(data, dict) and spec is None:
          spec = data
          data = None
  
      # Support passing no spec arg, but filling it with kwargs.
      # Example:
      #   marshall(proto, baz='boz')
      if spec is None:
          spec = dict()
      else:
          # Clone the spec dict, since we may be mutating it.
          spec = dict(spec)
  
      # Support passing in kwargs. Example:
      #   marshall(proto, {foo: 'bar'}, baz='boz')
      if len(kwargs):
          # Merge spec with unflattened kwargs, where kwargs take precedence.
          # This only works for string keys, but kwarg keys are strings anyways.
          spec = dict(spec, **dicttools.unflatten(kwargs, _CHANNELS))
  
      if len(spec) == 0:
          raise ValueError(
              "Vega-Lite charts require a non-empty spec dict."
          )
  
      if "autosize" not in spec:
          spec["autosize"] = {"type": "fit", "contains": "padding"}
  
      # Pull data out of spec dict when it's in a 'datasets' key:
      #   marshall(proto, {datasets: {foo: df1, bar: df2}, ...})
      if "datasets" in spec:
          for k, v in spec["datasets"].items():
              dataset = proto.datasets.add()
              dataset.name = str(k)
              dataset.has_name = True
              arrow.marshall(dataset.data, v)
          del spec["datasets"]
  
      # Pull data out of spec dict when it's in a top-level 'data' key:
      #   marshall(proto, {data: df})
      #   marshall(proto, {data: {values: df, ...}})
      #   marshall(proto, {data: {url: 'url'}})
      #   marshall(proto, {data: {name: 'foo'}})
      if "data" in spec:
          data_spec = spec["data"]
  
          if isinstance(data_spec, dict):
              if "values" in data_spec:
                  data = data_spec["values"]
                  del spec["data"]
          else:
              data = data_spec
              del spec["data"]
  
      proto.spec = json.dumps(spec)
      proto.use_container_width = use_container_width
      proto.theme = theme or ""
  
      if data is not None:
          arrow.marshall(proto.data, data)
  
file_path: streamlit/lib/streamlit/elements/arrow_vega_lite.py
imports: from __future__ import annotations
  import json
  from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast
  from typing_extensions import Final, Literal
  import streamlit.elements.lib.dicttools
  from streamlit.elements import arrow
  from streamlit.elements.arrow import Data
  from streamlit.errors import StreamlitAPIException
  from streamlit.logger import get_logger
  from streamlit.proto.ArrowVegaLiteChart_pb2 import ArrowVegaLiteChart
  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, data, spec, use_container_width, theme) without return types