code: def _array_payload_to_array(
      payload: "PicklableArrayPayload",
  ) -> "pyarrow.Array":
      """Reconstruct an Arrow Array from a possibly nested PicklableArrayPayload."""
      import pyarrow as pa
      from ray.air.util.tensor_extensions.arrow import (
          ArrowTensorType,
          ArrowVariableShapedTensorType,
      )
  
      children = [
          child_payload.to_array() for child_payload in payload.children
      ]
      if pa.types.is_dictionary(payload.type):
          # Dedicated path for reconstructing a DictionaryArray, since
          # Array.from_buffers() doesn't work for DictionaryArrays.
          assert len(children) == 2, len(children)
          indices, dictionary = children
          return pa.DictionaryArray.from_arrays(indices, dictionary)
      elif pa.types.is_map(payload.type) and len(children) > 1:
          # In pyarrow<7.0.0, the underlying map child array is not exposed, so we work
          # with the key and item arrays.
          assert len(children) == 3, len(children)
          offsets, keys, items = children
          return pa.MapArray.from_arrays(offsets, keys, items)
      elif isinstance(payload.type, ArrowTensorType) or isinstance(
          payload.type, ArrowVariableShapedTensorType
      ):
          # Dedicated path for reconstructing an ArrowTensorArray or
          # ArrowVariableShapedTensorArray, both of which can't be reconstructed by the
          # Array.from_buffers() API.
          assert len(children) == 1, len(children)
          storage = children[0]
          return pa.ExtensionArray.from_storage(payload.type, storage)
      else:
          # Common case: use Array.from_buffers() to construct an array of a certain type.
          return pa.Array.from_buffers(
              type=payload.type,
              length=payload.length,
              buffers=payload.buffers,
              null_count=payload.null_count,
              offset=payload.offset,
              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 10 for calling a global function with example usage: _array_payload_to_array(payload) and returns: pa, pa, pa, pa