code: def arrow_serialize(obj: np.ndarray) -> bytes:
      original_dtype = obj.dtype
      apache_arrow = pa.Tensor.from_numpy(obj=obj)
      sink = pa.BufferOutputStream()
      pa.ipc.write_tensor(apache_arrow, sink)
      buffer = sink.getvalue()
      if flags.APACHE_ARROW_COMPRESSION is ApacheArrowCompression.NONE:
          numpy_bytes = buffer.to_pybytes()
      else:
          numpy_bytes = pa.compress(
              buffer,
              asbytes=True,
              codec=flags.APACHE_ARROW_COMPRESSION.value,
          )
      dtype = original_dtype.name
  
      return cast(
          bytes,
          _serialize((numpy_bytes, buffer.size, dtype), to_bytes=True),
      )
  
file_path: PySyft/packages/syft/src/syft/serde/arrow.py
imports: from typing import Union
  from typing import cast
  import numpy
  import pyarrow
  from ..util.experimental_flags import ApacheArrowCompression
  from ..util.experimental_flags import flags
  from .deserialize import _deserialize
  from .serialize import _serialize
label_desc: Use image node_id 1 for calling a global function with example usage: arrow_serialize(obj) and returns: cast