code: def _struct_array_to_array_payload(
      a: "pyarrow.StructArray",
  ) -> "PicklableArrayPayload":
      """Serialize struct arrays to PicklableArrayPayload."""
      # Dedicated path for StructArrays.
      # StructArrays have a top-level bitmap buffer and one or more children arrays.
      # Buffer scheme: [bitmap, None, child_bitmap, child_data, ...]
      buffers = a.buffers()
      assert len(buffers) >= 1, len(buffers)
  
      # Copy bitmap buffer, if needed.
      if a.null_count > 0:
          bitmap_buf = _copy_bitpacked_buffer_if_needed(
              buffers[0], a.offset, len(a)
          )
      else:
          bitmap_buf = None
  
      # Get field children payload.
      # Offsets and truncations are already propagated to the field arrays, so we can
      # serialize them as-is.
      children = [
          _array_to_array_payload(a.field(i))
          for i in range(a.type.num_fields)
      ]
      return PicklableArrayPayload(
          type=a.type,
          length=len(a),
          buffers=[bitmap_buf],
          null_count=a.null_count,
          offset=0,
          children=children,
      )
  
imports: from dataclasses import dataclass
  import logging
  import os
  import sys
  from typing import List, Tuple, Optional, TYPE_CHECKING
label_desc: Use image node_id 19 for calling a global function with example usage: _struct_array_to_array_payload(a) and returns: PicklableArrayPayload