code: def name_chart(chart, i=0, exclude=None):
      """
      Rename charts (and subcharts) with unique names that we can look up
      later in the compiled Vega spec
  
      :param chart: Chart instance
      :param i: starting name index
      :return:
      """
      exclude = exclude or []
      if isinstance(chart, (Chart, FacetChart)):
          # Perform shallow copy of chart so that we can change
          # the name
          if chart.name not in exclude:
              if chart.name in (None, Undefined):
                  name = make_magic_mark_name(i)
                  chart.name = name
              return [chart.name]
          else:
              return []
      else:
          if isinstance(chart, LayerChart):
              subcharts = chart.layer
          elif isinstance(chart, HConcatChart):
              subcharts = chart.hconcat
          elif isinstance(chart, VConcatChart):
              subcharts = chart.vconcat
          elif isinstance(chart, ConcatChart):
              subcharts = chart.concat
          else:
              raise ValueError(
                  "transformed_data accepts an instance of "
                  "Chart, FacetChart, LayerChart, HConcatChart, VConcatChart, or ConcatChart\n"
                  f"Received value of type: {type(chart)}"
              )
  
          chart_names = []
          for subchart in subcharts:
              for name in name_chart(
                  subchart, i=i + len(chart_names), exclude=exclude
              ):
                  chart_names.append(name)
          return chart_names
  
file_path: vegafusion/python/vegafusion/vegafusion/evaluation.py
imports: from altair import data_transformers, Chart, FacetChart, LayerChart, HConcatChart, VConcatChart, ConcatChart
  from altair.utils.schemapi import Undefined
label_desc: Use image node_id 3 for calling a global function with example usage: name_chart(chart, i, exclude) and returns: chart_names, list, list