code: def save_vega(
      chart,
      file,
      pretty=True,
  ):
      """
      Save an Altair Chart to a Vega JSON file after pre-applying data transformations
      and removing unused columns
  
      :param chart: alt.Chart
          The Altair chart to save
      :param file: str, pathlib.Path, or file-like object
          The file path to write the Vega JSON file to, or a file-like object to write to
      :param pretty: boolean (default True)
          If True, pretty-print the resulting JSON file. If False, write the smallest file possible
      """
      from . import enable
  
      with enable():
          vegalite_spec = chart.to_dict()
  
      (bundle, _) = spec_to_mime_bundle(
          spec=vegalite_spec,
          mimetype="vega",
      )
  
      vega_dict = bundle["application/vnd.vega.v5+json"]
      if pretty:
          vega_str = json.dumps(vega_dict, indent=2)
      else:
          vega_str = json.dumps(vega_dict)
  
      write_file_or_filename(file, vega_str)
  
file_path: vegafusion/python/vegafusion/vegafusion/save.py
imports: import json
  import pathlib
  from .renderer import spec_to_mime_bundle
label_desc: Use image node_id 2 for calling a global function with example usage: save_vega(chart, file, pretty) without return types