code: def __init__(
      self,
      where,
      schema,
      filesystem=None,
      flavor=None,
      version="2.6",
      use_dictionary=True,
      compression="snappy",
      write_statistics=True,
      use_deprecated_int96_timestamps=None,
      compression_level=None,
      use_byte_stream_split=False,
      column_encoding=None,
      writer_engine_version=None,
      data_page_version="1.0",
      use_compliant_nested_type=True,
      encryption_properties=None,
      write_batch_size=None,
      dictionary_pagesize_limit=None,
      store_schema=True,
      write_page_index=False,
      write_page_checksum=False,
      sorting_columns=None,
      **options,
  ):
      if use_deprecated_int96_timestamps is None:
          # Use int96 timestamps for Spark
          if flavor is not None and "spark" in flavor:
              use_deprecated_int96_timestamps = True
          else:
              use_deprecated_int96_timestamps = False
  
      self.flavor = flavor
      if flavor is not None:
          schema, self.schema_changed = _sanitize_schema(schema, flavor)
      else:
          self.schema_changed = False
  
      self.schema = schema
      self.where = where
  
      # If we open a file using a filesystem, store file handle so we can be
      # sure to close it when `self.close` is called.
      self.file_handle = None
  
      filesystem, path = _resolve_filesystem_and_path(
          where, filesystem, allow_legacy_filesystem=True
      )
      if filesystem is not None:
          if isinstance(filesystem, legacyfs.FileSystem):
              # legacy filesystem (eg custom subclass)
              # TODO deprecate
              sink = self.file_handle = filesystem.open(path, "wb")
          else:
              # ARROW-10480: do not auto-detect compression.  While
              # a filename like foo.parquet.gz is nonconforming, it
              # shouldn't implicitly apply compression.
              sink = self.file_handle = filesystem.open_output_stream(
                  path, compression=None
              )
      else:
          sink = where
      self._metadata_collector = options.pop("metadata_collector", None)
      engine_version = "V2"
      self.writer = _parquet.ParquetWriter(
          sink,
          schema,
          version=version,
          compression=compression,
          use_dictionary=use_dictionary,
          write_statistics=write_statistics,
          use_deprecated_int96_timestamps=use_deprecated_int96_timestamps,
          compression_level=compression_level,
          use_byte_stream_split=use_byte_stream_split,
          column_encoding=column_encoding,
          writer_engine_version=engine_version,
          data_page_version=data_page_version,
          use_compliant_nested_type=use_compliant_nested_type,
          encryption_properties=encryption_properties,
          write_batch_size=write_batch_size,
          dictionary_pagesize_limit=dictionary_pagesize_limit,
          store_schema=store_schema,
          write_page_index=write_page_index,
          write_page_checksum=write_page_checksum,
          sorting_columns=sorting_columns,
          **options,
      )
      self.is_open = True
  
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 1 to create a new ParquetWriter object  with example: obj = ParquetWriter(where, schema, filesystem, flavor, version, use_dictionary, compression, write_statistics, use_deprecated_int96_timestamps, compression_level, use_byte_stream_split, column_encoding, writer_engine_version, data_page_version, use_compliant_nested_type, encryption_properties, write_batch_size, dictionary_pagesize_limit, store_schema, write_page_index, write_page_checksum, sorting_columns)