code: def test_compression_level():
      arr = pa.array(list(map(int, range(1000))))
      data = [arr, arr]
      table = pa.Table.from_arrays(data, names=["a", "b"])
  
      # Check one compression level.
      _check_roundtrip(
          table, expected=table, compression="gzip", compression_level=1
      )
  
      # Check another one to make sure that compression_level=1 does not
      # coincide with the default one in Arrow.
      _check_roundtrip(
          table, expected=table, compression="gzip", compression_level=5
      )
  
      # Check that the user can provide a compression per column
      _check_roundtrip(
          table,
          expected=table,
          compression={"a": "gzip", "b": "snappy"},
      )
  
      # Check that the user can provide a compression level per column
      _check_roundtrip(
          table,
          expected=table,
          compression="gzip",
          compression_level={"a": 2, "b": 3},
      )
  
      # Check if both LZ4 compressors are working
      # (level < 3 -> fast, level >= 3 -> HC)
      _check_roundtrip(
          table, expected=table, compression="lz4", compression_level=1
      )
  
      _check_roundtrip(
          table, expected=table, compression="lz4", compression_level=9
      )
  
      # Check that specifying a compression level for a codec which does allow
      # specifying one, results into an error.
      # Uncompressed, snappy and lzo do not support specifying a compression
      # level.
      # GZIP (zlib) allows for specifying a compression level but as of up
      # to version 1.2.11 the valid range is [-1, 9].
      invalid_combinations = [
          ("snappy", 4),
          ("gzip", -1337),
          ("None", 444),
          ("lzo", 14),
      ]
      buf = io.BytesIO()
      for codec, level in invalid_combinations:
          with pytest.raises((ValueError, OSError)):
              _write_table(
                  table, buf, compression=codec, compression_level=level
              )
  
imports: from collections import OrderedDict
  import io
  import warnings
  from shutil import copytree
  import numpy
  import pytest
  import pyarrow
  from pyarrow import fs
  from pyarrow.filesystem import LocalFileSystem, FileSystem
  from pyarrow.tests import util
  from pyarrow.tests.parquet.common import _check_roundtrip, _roundtrip_table, _test_dataframe
label_desc: Use image node_id 22 for calling a global function with example usage: test_compression_level() without return types