docstr: Evaluate supported transforms in an input Vega specification and produce a new
  specification with pre-transformed datasets included inline.
  
  :param spec: A Vega specification dict or JSON string
  :param local_tz: Name of timezone to be considered local. E.g. 'America/New_York'.
      Defaults to the value of vf.get_local_tz(), which defaults to the system timezone
      if one can be determined.
  :param default_input_tz: Name of timezone (e.g. 'America/New_York') that naive datetime
      strings should be interpreted in. Defaults to `local_tz`.
  :param row_limit: Maximum number of dataset rows to include in the returned
      specification. If exceeded, datasets will be truncated to this number of rows
      and a RowLimitExceeded warning will be included in the resulting warnings list
  :param preserve_interactivity: If True (default) then the interactive behavior of
      the chart will pre preserved. This requires that all the data that participates
      in interactions be included in the resulting spec rather than being pre-transformed.
      If False, then all possible data transformations are applied even if they break
      the original interactive behavior of the chart.
  :param inline_datasets: A dict from dataset names to pandas DataFrames or pyarrow
      Tables. Inline datasets may be referenced by the input specification using
      the following url syntax 'vegafusion+dataset://{dataset_name}' or
      'table://{dataset_name}'.
  :param keep_signals: Signals from the input spec that must be included in the
      pre-transformed spec. A list with elements that are either:
        - The name of a top-level signal as a string
        - A two-element tuple where the first element is the name of a signal as a string
          and the second element is the nested scope of the dataset as a list of integers
  :param keep_datasets: Datasets from the input spec that must be included in the
      pre-transformed spec. A list with elements that are either:
        - The name of a top-level dataset as a string
        - A two-element tuple where the first element is the name of a dataset as a string
          and the second element is the nested scope of the dataset as a list of integers
  :param data_encoding_threshold: threshold for encoding datasets
      When length of pre-transformed datasets exceeds data_encoding_threshold, datasets
      are encoded into an alternative format (as determined by the data_encoding_format
      argument). When None (the default), pre-transformed datasets are never encoded and
      are always included as JSON compatible lists of dictionaries.
  :param data_encoding_format: format of encoded datasets
      Format to use to encode datasets with length exceeding the data_encoding_threshold
      argument.
          - "pyarrow": Encode datasets as pyarrow Tables. Not JSON compatible.
          - "arrow-ipc": Encode datasets as bytes in Arrow IPC format. Not JSON compatible.
          - "arrow-ipc-base64": Encode datasets as strings in base64 encoded Arrow IPC format.
              JSON compatible.
  :return:
      Two-element tuple:
          0. A string containing the JSON representation of a Vega specification
             with pre-transformed datasets included inline
          1. A list of warnings as dictionaries. Each warning dict has a 'type'
             key indicating the warning type, and a 'message' key containing
             a description of the warning. Potential warning types include:
              'RowLimitExceeded': Some datasets in resulting Vega specification
                  have been truncated to the provided row limit
              'BrokenInteractivity': Some interactive features may have been
                  broken in the resulting Vega specification
              'Unsupported': No transforms in the provided Vega specification were
                  eligible for pre-transforming
code: def pre_transform_spec(
      self,
      spec,
      local_tz=None,
      default_input_tz=None,
      row_limit=None,
      preserve_interactivity=True,
      inline_datasets=None,
      keep_signals=None,
      keep_datasets=None,
      data_encoding_threshold=None,
      data_encoding_format="pyarrow",
  ):
      """
      Evaluate supported transforms in an input Vega specification and produce a new
      specification with pre-transformed datasets included inline.
  
      :param spec: A Vega specification dict or JSON string
      :param local_tz: Name of timezone to be considered local. E.g. 'America/New_York'.
          Defaults to the value of vf.get_local_tz(), which defaults to the system timezone
          if one can be determined.
      :param default_input_tz: Name of timezone (e.g. 'America/New_York') that naive datetime
          strings should be interpreted in. Defaults to `local_tz`.
      :param row_limit: Maximum number of dataset rows to include in the returned
          specification. If exceeded, datasets will be truncated to this number of rows
          and a RowLimitExceeded warning will be included in the resulting warnings list
      :param preserve_interactivity: If True (default) then the interactive behavior of
          the chart will pre preserved. This requires that all the data that participates
          in interactions be included in the resulting spec rather than being pre-transformed.
          If False, then all possible data transformations are applied even if they break
          the original interactive behavior of the chart.
      :param inline_datasets: A dict from dataset names to pandas DataFrames or pyarrow
          Tables. Inline datasets may be referenced by the input specification using
          the following url syntax 'vegafusion+dataset://{dataset_name}' or
          'table://{dataset_name}'.
      :param keep_signals: Signals from the input spec that must be included in the
          pre-transformed spec. A list with elements that are either:
            - The name of a top-level signal as a string
            - A two-element tuple where the first element is the name of a signal as a string
              and the second element is the nested scope of the dataset as a list of integers
      :param keep_datasets: Datasets from the input spec that must be included in the
          pre-transformed spec. A list with elements that are either:
            - The name of a top-level dataset as a string
            - A two-element tuple where the first element is the name of a dataset as a string
              and the second element is the nested scope of the dataset as a list of integers
      :param data_encoding_threshold: threshold for encoding datasets
          When length of pre-transformed datasets exceeds data_encoding_threshold, datasets
          are encoded into an alternative format (as determined by the data_encoding_format
          argument). When None (the default), pre-transformed datasets are never encoded and
          are always included as JSON compatible lists of dictionaries.
      :param data_encoding_format: format of encoded datasets
          Format to use to encode datasets with length exceeding the data_encoding_threshold
          argument.
              - "pyarrow": Encode datasets as pyarrow Tables. Not JSON compatible.
              - "arrow-ipc": Encode datasets as bytes in Arrow IPC format. Not JSON compatible.
              - "arrow-ipc-base64": Encode datasets as strings in base64 encoded Arrow IPC format.
                  JSON compatible.
      :return:
          Two-element tuple:
              0. A string containing the JSON representation of a Vega specification
                 with pre-transformed datasets included inline
              1. A list of warnings as dictionaries. Each warning dict has a 'type'
                 key indicating the warning type, and a 'message' key containing
                 a description of the warning. Potential warning types include:
                  'RowLimitExceeded': Some datasets in resulting Vega specification
                      have been truncated to the provided row limit
                  'BrokenInteractivity': Some interactive features may have been
                      broken in the resulting Vega specification
                  'Unsupported': No transforms in the provided Vega specification were
                      eligible for pre-transforming
      """
      if self._grpc_channel:
          raise ValueError(
              "pre_transform_spec not yet supported over gRPC"
          )
      else:
          local_tz = local_tz or get_local_tz()
          imported_inline_dataset = (
              self._import_or_register_inline_datasets(inline_datasets)
          )
  
          # Parse input keep signals and datasets
          keep_signals = parse_variables(keep_signals)
          keep_datasets = parse_variables(keep_datasets)
          try:
              if data_encoding_threshold is None:
                  (
                      new_spec,
                      warnings,
                  ) = self.embedded_runtime.pre_transform_spec(
                      spec,
                      local_tz=local_tz,
                      default_input_tz=default_input_tz,
                      row_limit=row_limit,
                      preserve_interactivity=preserve_interactivity,
                      inline_datasets=imported_inline_dataset,
                      keep_signals=keep_signals,
                      keep_datasets=keep_datasets,
                  )
              else:
                  # Use pre_transform_extract to extract large datasets
                  (
                      new_spec,
                      datasets,
                      warnings,
                  ) = self.embedded_runtime.pre_transform_extract(
                      spec,
                      local_tz=local_tz,
                      default_input_tz=default_input_tz,
                      preserve_interactivity=preserve_interactivity,
                      extract_threshold=data_encoding_threshold,
                      extracted_format=data_encoding_format,
                      inline_datasets=imported_inline_dataset,
                      keep_signals=keep_signals,
                      keep_datasets=keep_datasets,
                  )
  
                  # Insert encoded datasets back into spec
                  for name, scope, tbl in datasets:
                      group = get_mark_group_for_scope(new_spec, scope)
                      for data in group.get("data", []):
                          if data.get("name", None) == name:
                              data["values"] = tbl
  
          finally:
              # Clean up temporary tables
              if self._connection is not None:
                  self._connection.unregister_temporary_tables()
  
          return new_spec, warnings
  
imports: import pandas
  import psutil
  import pyarrow
  from typing import Union
  from .connection import SqlConnection
  from .dataset import SqlDataset, DataFrameDataset
  from .datasource import PandasDatasource, DfiDatasource
  from .evaluation import get_mark_group_for_scope
  from .transformer import import_pyarrow_interchange, to_arrow_table
  from .local_tz import get_local_tz
  from typing import TypedDict, List, Literal, Any
label_desc: Use image node_id 10 for calling the VegaFusionRuntime obj's underlying member method code with example usage: obj.pre_transform_spec(spec, local_tz, default_input_tz, row_limit, preserve_interactivity, inline_datasets, keep_signals, keep_datasets, data_encoding_threshold, data_encoding_format) and returns: new_spec,  warnings