code: def validate_aggregates(aggregates):
      if aggregates is None:
          return {}
      elif isinstance(aggregates, dict):
          for k, v in aggregates.items():
              if isinstance(v, Aggregate):
                  aggregates[k] = v.value
              elif isinstance(v, str):
                  if v not in Aggregate.options():
                      raise PerspectiveError(
                          "Unrecognized aggregate: %s", v
                      )
              elif isinstance(v, list):
                  # Parse weighted mean aggregate in ["weighted mean", "COLUMN"]
                  if len(v) == 2 and v[0] == "weighted mean":
                      continue
                  raise PerspectiveError(
                      "Unrecognized aggregate in incorrect syntax for weighted mean: %s - Syntax should be: ['weighted mean', 'COLUMN']",
                      v,
                  )
              else:
                  raise PerspectiveError(
                      "Cannot parse aggregation of type %s",
                      str(type(v)),
                  )
          return aggregates
      else:
          raise PerspectiveError(
              "Cannot parse aggregates type: %s", str(type(aggregates))
          )
  
file_path: perspective/python/perspective/perspective/viewer/validate.py
imports: from datetime import datetime
  from ..core import ALL_FILTERS, Aggregate, Plugin, Sort
  from ..core.exception import PerspectiveError
label_desc: Use image node_id 6 for calling a global function with example usage: validate_aggregates(aggregates) and returns: dict, aggregates