code: def to_parquet(
      df,
      path,
      engine="cudf",
      compression="snappy",
      index=None,
      partition_cols=None,
      partition_file_name=None,
      partition_offsets=None,
      statistics="ROWGROUP",
      metadata_file_path=None,
      int96_timestamps=False,
      row_group_size_bytes=ioutils._ROW_GROUP_SIZE_BYTES_DEFAULT,
      row_group_size_rows=None,
      max_page_size_bytes=None,
      max_page_size_rows=None,
      storage_options=None,
      return_metadata=False,
      force_nullable_schema=False,
      header_version="1.0",
      use_dictionary=True,
      *args,
      **kwargs,
  ):
      """{docstring}"""
  
      if engine == "cudf":
          if kwargs:
              raise ValueError(
                  "cudf engine doesn't support the "
                  f"following keyword arguments: {list(kwargs.keys())}"
              )
          if args:
              raise ValueError(
                  "cudf engine doesn't support the "
                  f"following positional arguments: {list(args)}"
              )
          # Ensure that no columns dtype is 'category'
          for col in df._column_names:
              if partition_cols is None or col not in partition_cols:
                  if df[col].dtype.name == "category":
                      raise ValueError(
                          "'category' column dtypes are currently not "
                          + "supported by the gpu accelerated parquet writer"
                      )
  
          if partition_cols:
              if metadata_file_path is not None:
                  warnings.warn(
                      "metadata_file_path will be ignored/overwritten when "
                      "partition_cols are provided. To request returning the "
                      "metadata binary blob, pass `return_metadata=True`"
                  )
  
              return write_to_dataset(
                  df,
                  filename=partition_file_name,
                  partition_cols=partition_cols,
                  root_path=path,
                  preserve_index=index,
                  compression=compression,
                  statistics=statistics,
                  int96_timestamps=int96_timestamps,
                  row_group_size_bytes=row_group_size_bytes,
                  row_group_size_rows=row_group_size_rows,
                  max_page_size_bytes=max_page_size_bytes,
                  max_page_size_rows=max_page_size_rows,
                  return_metadata=return_metadata,
                  storage_options=storage_options,
                  force_nullable_schema=force_nullable_schema,
              )
  
          partition_info = (
              [
                  (i, j - i)
                  for i, j in zip(
                      partition_offsets, partition_offsets[1:]
                  )
              ]
              if partition_offsets is not None
              else None
          )
          return _write_parquet(
              df,
              paths=path if is_list_like(path) else [path],
              compression=compression,
              index=index,
              statistics=statistics,
              metadata_file_path=metadata_file_path,
              int96_timestamps=int96_timestamps,
              row_group_size_bytes=row_group_size_bytes,
              row_group_size_rows=row_group_size_rows,
              max_page_size_bytes=max_page_size_bytes,
              max_page_size_rows=max_page_size_rows,
              partitions_info=partition_info,
              storage_options=storage_options,
              force_nullable_schema=force_nullable_schema,
              header_version=header_version,
              use_dictionary=use_dictionary,
          )
  
      else:
          import pyarrow.parquet as pq
  
          if partition_offsets is not None:
              warnings.warn(
                  "partition_offsets will be ignored when engine is not cudf"
              )
  
          # If index is empty set it to the expected default value of True
          if index is None:
              index = True
  
          # Convert partition_file_name to a call back
          if partition_file_name:
              partition_file_name = (
                  lambda x: partition_file_name
              )  # noqa: E731
  
          pa_table = df.to_arrow(preserve_index=index)
          return pq.write_to_dataset(
              pa_table,
              root_path=path,
              partition_filename_cb=partition_file_name,
              partition_cols=partition_cols,
              *args,
              **kwargs,
          )
  
imports: from __future__ import annotations
  import itertools
  import math
  import operator
  import shutil
  import tempfile
  import warnings
  from collections import defaultdict
  from contextlib import ExitStack
  from functools import partial, reduce
  from typing import Callable, Dict, List, Optional, Tuple
  from uuid import uuid4
  import numpy
  import pandas
  from pyarrow import dataset
  import cudf
  from cudf._lib import parquet
  from cudf.api.types import is_list_like
  from cudf.core.column import build_categorical_column, column_empty, full
  from cudf.utils import ioutils
  from cudf.utils.nvtx_annotation import _cudf_nvtx_annotate
label_desc: Use image node_id 10 for calling a global function with example usage: to_parquet(df, path, engine, compression, index, partition_cols, partition_file_name, partition_offsets, statistics, metadata_file_path, int96_timestamps, row_group_size_bytes, row_group_size_rows, max_page_size_bytes, max_page_size_rows, storage_options, return_metadata, force_nullable_schema, header_version, use_dictionary) and returns: _write_parquet, pq, write_to_dataset