code: def stack(
      arrays: Union[Tuple[paddle.Tensor], List[paddle.Tensor]],
      /,
      *,
      axis: int = 0,
      out: Optional[paddle.Tensor] = None,
  ) -> paddle.Tensor:
      dtype_list = set(map(lambda x: x.dtype, arrays))
      dtype = dtype_list.pop()
      if len(dtype_list) > 0:
          for d in dtype_list:
              dtype = ivy.promote_types(dtype, d)
  
      arrays = list(map(lambda x: x.cast(dtype), arrays))
  
      first_shape = arrays[0].shape
      if any(arr.shape != first_shape for arr in arrays):
          raise ValueError("Shapes of all inputs must match")
      if 0 in first_shape:
          return ivy.empty(
              first_shape[:axis] + [len(arrays)] + first_shape[axis:],
              dtype=dtype,
          )
  
      if dtype in [
          paddle.int8,
          paddle.int16,
          paddle.uint8,
          paddle.float16,
          paddle.bool,
      ]:
          arrays = list(map(lambda x: x.cast("float32"), arrays))
          return paddle.stack(arrays, axis=axis).cast(dtype)
  
      elif dtype in [
          paddle.complex64,
          paddle.complex128,
      ]:
          arrays = list(map(lambda x: x.cast(dtype), arrays))
          real_list = list(map(lambda x: x.real(), arrays))
          imag_list = list(map(lambda x: x.imag(), arrays))
          re_stacked = paddle.stack(real_list, axis=axis)
          imag_stacked = paddle.stack(imag_list, axis=axis)
          return paddle.complex(re_stacked, imag_stacked)
      else:
          return paddle.stack(arrays, axis=axis)
  
imports: from numbers import Number
  from typing import Union, Optional, Tuple, List, Sequence, Iterable
  import math
  import paddle
  import ivy
  import ivy.functional.backends.paddle
  from ivy.func_wrapper import with_unsupported_device_and_dtypes, with_unsupported_dtypes, with_supported_dtypes
  from .None import backend_version
  from ...ivy.manipulation import _calculate_out_shape
label_desc: Use image node_id 9 for calling a global function with example usage: stack() and returns: ivy, paddle, paddle, paddle