code: def _get_legacy_format_default(use_legacy_format, options):
      if use_legacy_format is not None and options is not None:
          raise ValueError(
              "Can provide at most one of options and use_legacy_format"
          )
      elif options:
          if not isinstance(options, IpcWriteOptions):
              raise TypeError(
                  "expected IpcWriteOptions, got {}".format(
                      type(options)
                  )
              )
          return options
  
      metadata_version = MetadataVersion.V5
      if use_legacy_format is None:
          use_legacy_format = bool(
              int(os.environ.get("ARROW_PRE_0_15_IPC_FORMAT", "0"))
          )
      if bool(
          int(os.environ.get("ARROW_PRE_1_0_METADATA_VERSION", "0"))
      ):
          metadata_version = MetadataVersion.V4
      return IpcWriteOptions(
          use_legacy_format=use_legacy_format,
          metadata_version=metadata_version,
      )
  
imports: import os
  import pyarrow
  from pyarrow.lib import IpcReadOptions, IpcWriteOptions, ReadStats, WriteStats, Message, MessageReader, RecordBatchReader, _ReadPandasMixin, MetadataVersion, read_message, read_record_batch, read_schema, read_tensor, write_tensor, get_record_batch_size, get_tensor_size
  import pyarrow.lib
label_desc: Use image node_id 1 for calling a global function with example usage: _get_legacy_format_default(use_legacy_format, options) and returns: IpcWriteOptions, options