code: def write_metadata(
      schema, where, metadata_collector=None, filesystem=None, **kwargs
  ):
      """
      Write metadata-only Parquet file from schema. This can be used with
      `write_to_dataset` to generate `_common_metadata` and `_metadata` sidecar
      files.
  
      Parameters
      ----------
      schema : pyarrow.Schema
      where : string or pyarrow.NativeFile
      metadata_collector : list
          where to collect metadata information.
      filesystem : FileSystem, default None
          If nothing passed, will be inferred from `where` if path-like, else
          `where` is already a file-like object so no filesystem is needed.
      **kwargs : dict,
          Additional kwargs for ParquetWriter class. See docstring for
          `ParquetWriter` for more information.
  
      Examples
      --------
      Generate example data:
  
      >>> import pyarrow as pa
      >>> table = pa.table({'n_legs': [2, 2, 4, 4, 5, 100],
      ...                   'animal': ["Flamingo", "Parrot", "Dog", "Horse",
      ...                              "Brittle stars", "Centipede"]})
  
      Write a dataset and collect metadata information.
  
      >>> metadata_collector = []
      >>> import pyarrow.parquet as pq
      >>> pq.write_to_dataset(
      ...     table, 'dataset_metadata',
      ...      metadata_collector=metadata_collector)
  
      Write the `_common_metadata` parquet file without row groups statistics.
  
      >>> pq.write_metadata(
      ...     table.schema, 'dataset_metadata/_common_metadata')
  
      Write the `_metadata` parquet file with row groups statistics.
  
      >>> pq.write_metadata(
      ...     table.schema, 'dataset_metadata/_metadata',
      ...     metadata_collector=metadata_collector)
      """
      filesystem, where = _resolve_filesystem_and_path(
          where, filesystem
      )
  
      if hasattr(where, "seek"):  # file-like
          cursor_position = where.tell()
  
      writer = ParquetWriter(where, schema, filesystem, **kwargs)
      writer.close()
  
      if metadata_collector is not None:
          # ParquetWriter doesn't expose the metadata until it's written. Write
          # it and read it again.
          metadata = read_metadata(where, filesystem=filesystem)
          if hasattr(where, "seek"):
              where.seek(cursor_position)  # file-like, set cursor back.
  
          for m in metadata_collector:
              metadata.append_row_groups(m)
          if filesystem is not None:
              with filesystem.open_output_stream(where) as f:
                  metadata.write_metadata_file(f)
          else:
              metadata.write_metadata_file(where)
  
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 13 for calling a global function with example usage: write_metadata(schema, where, metadata_collector, filesystem) without return types