code: def write_validator_py(outdir, node: PlotlyNode):
      """
      Build validator source code and write to a file
  
      Parameters
      ----------
      outdir : str
          Root outdir in which the validators package should reside
      node : PlotlyNode
          The datatype node (node.is_datatype must evaluate to true) for which
          to build a validator class
      Returns
      -------
      None
      """
      if node.is_mapped:
          # No validator written for mapped nodes
          # e.g. no validator for layout.titlefont since ths is mapped to
          # layout.title.font
          return
  
      # Generate source code
      # --------------------
      validator_source = build_validator_py(node)
  
      # Write file
      # ----------
      # filepath = opath.join(outdir, "validators", *node.parent_path_parts, "__init__.py")
      filepath = opath.join(
          outdir,
          "validators",
          *node.parent_path_parts,
          "_" + node.name_property + ".py",
      )
  
      write_source_py(validator_source, filepath, leading_newlines=2)
  
file_path: plotly.py/packages/python/plotly/codegen/validators.py
imports: import os.path
  from io import StringIO
  import _plotly_utils.basevalidators
  from codegen.utils import PlotlyNode, TraceNode, write_source_py
label_desc: Use image node_id 2 for calling a global function with example usage: write_validator_py(outdir, node) without return types