code: def preprocess_schema(plotly_schema):
      """
      Central location to make changes to schema before it's seen by the
      PlotlyNode classes
      """
  
      # Update template
      # ---------------
      layout = plotly_schema["layout"]["layoutAttributes"]
  
      # Create codegen-friendly template scheme
      template = {
          "data": {
              trace + "s": {"items": {trace: {}}, "role": "object"}
              for trace in plotly_schema["traces"]
          },
          "layout": {},
          "description": """\
  Default attributes to be applied to the plot.
  This should be a dict with format: `{'layout': layoutTemplate, 'data':
  {trace_type: [traceTemplate, ...], ...}}` where `layoutTemplate` is a dict
  matching the structure of `figure.layout` and `traceTemplate` is a dict
  matching the structure of the trace with type `trace_type` (e.g. 'scatter').
  Alternatively, this may be specified as an instance of
  plotly.graph_objs.layout.Template.
  
  Trace templates are applied cyclically to
  traces of each type. Container arrays (eg `annotations`) have special
  handling: An object ending in `defaults` (eg `annotationdefaults`) is
  applied to each array item. But if an item has a `templateitemname`
  key we look in the template array for an item with matching `name` and
  apply that instead. If no matching `name` is found we mark the item
  invisible. Any named template item not referenced is appended to the
  end of the array, so this can be used to add a watermark annotation or a
  logo image, for example. To omit one of these items on the plot, make
  an item with matching `templateitemname` and `visible: false`.""",
      }
  
      layout["template"] = template
  
      # Rename concentrationscales to colorscale to match conventions
      items = plotly_schema["traces"]["sankey"]["attributes"]["link"][
          "colorscales"
      ]["items"]
  
      if "concentrationscales" in items:
          items["colorscale"] = items.pop("concentrationscales")
  
file_path: plotly.py/packages/python/plotly/codegen/__init__.py
imports: import json
  import os
  import os.path
  import shutil
  import subprocess
  from codegen.datatypes import build_datatype_py, write_datatype_py
  from codegen.compatibility import write_deprecated_datatypes, write_graph_objs_graph_objs, DEPRECATED_DATATYPES
  from codegen.figure import write_figure_classes
  from codegen.utils import TraceNode, PlotlyNode, LayoutNode, FrameNode, write_init_py, ElementDefaultsNode, build_from_imports_py
  from codegen.validators import write_validator_py, write_data_validator_py, get_data_validator_instance
label_desc: Use image node_id 1 for calling a global function with example usage: preprocess_schema(plotly_schema) without return types