code: def _sanitize_schema(schema, flavor):
      if "spark" in flavor:
          sanitized_fields = []
  
          schema_changed = False
  
          for field in schema:
              name = field.name
              sanitized_name = _sanitized_spark_field_name(name)
  
              if sanitized_name != name:
                  schema_changed = True
                  sanitized_field = pa.field(
                      sanitized_name,
                      field.type,
                      field.nullable,
                      field.metadata,
                  )
                  sanitized_fields.append(sanitized_field)
              else:
                  sanitized_fields.append(field)
  
          new_schema = pa.schema(
              sanitized_fields, metadata=schema.metadata
          )
          return new_schema, schema_changed
      else:
          return schema, False
  
imports: from collections import defaultdict
  from contextlib import nullcontext
  from functools import reduce
  import inspect
  import json
  import os
  import re
  import operator
  import warnings
  import pyarrow
  from pyarrow._parquet import ParquetReader, Statistics, FileMetaData, RowGroupMetaData, ColumnChunkMetaData, ParquetSchema, ColumnSchema, ParquetLogicalType, FileEncryptionProperties, FileDecryptionProperties, SortingColumn
  from pyarrow.fs import LocalFileSystem, FileSystem, FileType, _resolve_filesystem_and_path, _ensure_filesystem
  from pyarrow import filesystem
  from pyarrow.util import guid, _is_path_like, _stringify_path, _deprecate_api
label_desc: Use image node_id 5 for calling a global function with example usage: _sanitize_schema(schema, flavor) and returns: new_schema,  schema_changed, schema,  False