code: def get_datasets_for_scope(
      vega_spec: dict, scope: Scope
  ) -> List[str]:
      """Get the names of the datasets that are defined at a given scope
  
      Parameters
      ----------
      vega_spec : dict
          Top-leve Vega specification
      scope : tuple of int
          Scope tuple. If empty, the names of top-level datasets are returned
          Otherwise, the names of the datasets defined in the nested group mark
          at the specified scope are returned.
  
      Returns
      -------
      list of str
          List of the names of the datasets defined at the specified scope
  
      Examples
      --------
      >>> spec = {
      ...     "data": [
      ...         {"name": "data1"}
      ...     ],
      ...     "marks": [
      ...         {
      ...             "type": "group",
      ...             "data": [
      ...                 {"name": "data2"}
      ...             ],
      ...             "marks": [{"type": "symbol"}]
      ...         },
      ...         {
      ...             "type": "group",
      ...             "data": [
      ...                 {"name": "data3"},
      ...                 {"name": "data4"},
      ...             ],
      ...             "marks": [{"type": "rect"}]
      ...         }
      ...     ]
      ... }
  
      >>> get_datasets_for_scope(spec, ())
      ['data1']
  
      >>> get_datasets_for_scope(spec, (0,))
      ['data2']
  
      >>> get_datasets_for_scope(spec, (1,))
      ['data3', 'data4']
  
      Returns empty when no group mark exists at scope
      >>> get_datasets_for_scope(spec, (1, 3))
      []
      """
      group = get_group_mark_for_scope(vega_spec, scope) or {}
  
      # get datasets from group
      datasets = []
      for dataset in group.get("data", []):
          datasets.append(dataset["name"])
  
      # Add facet dataset
      facet_dataset = (
          group.get("from", {}).get("facet", {}).get("name", None)
      )
      if facet_dataset:
          datasets.append(facet_dataset)
      return datasets
  
file_path: altair/altair/utils/_transformed_data.py
imports: from typing import List, Optional, Tuple, Dict, Iterable, overload, Union
  from altair import Chart, FacetChart, LayerChart, HConcatChart, VConcatChart, ConcatChart, TopLevelUnitSpec, FacetedUnitSpec, UnitSpec, UnitSpecWithFrame, NonNormalizedSpec, TopLevelLayerSpec, LayerSpec, TopLevelConcatSpec, ConcatSpecGenericSpec, TopLevelHConcatSpec, HConcatSpecGenericSpec, TopLevelVConcatSpec, VConcatSpecGenericSpec, TopLevelFacetSpec, FacetSpec, data_transformers
  from altair.utils._vegafusion_data import get_inline_tables, import_vegafusion
  from altair.utils.core import DataFrameLike
  from altair.utils.schemapi import Undefined
label_desc: Use image node_id 6 for calling a global function with example usage: get_datasets_for_scope(vega_spec, scope) and returns: datasets