code: def spec_to_mime_bundle(
      spec,
      mimetype="html",
      row_limit=None,
      embed_options=None,
      html_template="universal",
      full_html=False,
      scale=1,
  ):
      from . import (
          transformer,
          runtime,
          local_tz,
          vegalite_compilers,
          altair_vl_version,
      )
  
      vega_spec = vegalite_compilers.get()(spec)
  
      inline_datasets = transformer.get_inline_datasets_for_spec(
          vega_spec
      )
      tx_vega_spec, warnings = runtime.pre_transform_spec(
          vega_spec,
          local_tz.get_local_tz(),
          row_limit=row_limit,
          inline_datasets=inline_datasets,
      )
  
      for warning in warnings:
          if warning.get("type", "") == "RowLimitExceeded":
              raise RowLimitError(row_limit)
  
      # Handle default embed options
      embed_options = embed_options or {}
      embed_options = dict({"mode": "vega"}, **embed_options)
  
      if mimetype == "vega":
          vega_mimetype = "application/vnd.vega.v5+json"
          return (
              {vega_mimetype: tx_vega_spec},
              {vega_mimetype: {"embed_options": embed_options}},
          )
      elif mimetype == "html":
          output_div = f"altair-viz-{uuid4().hex}"
          html = spec_to_html(
              tx_vega_spec,
              mode="vega",
              vega_version="5",
              vegalite_version=altair_vl_version(),
              vegaembed_version="6",
              fullhtml=full_html,
              output_div=output_div,
              template=html_template,
              embed_options=embed_options,
          )
          return {"text/html": html}
      elif mimetype == "svg":
          import vl_convert as vlc
  
          svg = vlc.vega_to_svg(tx_vega_spec)
          return {"image/svg+xml": svg}
      elif mimetype == "png":
          import vl_convert as vlc
  
          png = vlc.vega_to_png(tx_vega_spec, scale=scale)
          return {"image/png": png}
      else:
          raise ValueError(f"Unsupported mimetype: {mimetype}")
  
file_path: vegafusion/python/vegafusion/vegafusion/renderer.py
imports: from uuid import uuid4
  import altair
  from altair.utils.html import spec_to_html
label_desc: Use image node_id 2 for calling a global function with example usage: spec_to_mime_bundle(spec, mimetype, row_limit, embed_options, html_template, full_html, scale) and returns: dict,  dict, dict, dict, dict