code: def copy_array(
      x: Union[ivy.Array, ivy.NativeArray],
      /,
      *,
      to_ivy_array: bool = True,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Copy an array.
  
      Parameters
      ----------
      x
          array, input array containing elements to copy.
      to_ivy_array
          boolean, if True the returned array will be an ivy.Array object otherwise
          returns an ivy.NativeArray object (i.e. a torch.tensor, np.array, etc.,
          depending on the backend), defaults to True.
      out
          optional output array, for writing the result to. It must have a shape that the
          inputs broadcast to.
  
      Returns
      -------
      ret
          a copy of the input array ``x``.
  
      Examples
      --------
      With one :class:`ivy.Array` input:
  
      >>> x = ivy.array([-1, 0, 1])
      >>> y = ivy.copy_array(x)
      >>> print(y)
      ivy.array([-1, 0, 1])
  
      >>> x = ivy.array([1, 0, 1, 1])
      >>> y = ivy.copy_array(x)
      >>> print(y)
      ivy.array([1, 0, 1, 1])
  
      >>> x = ivy.array([1, 0, 1, -1])
      >>> y = ivy.zeros((1, 4))
      >>> ivy.copy_array(x, out=y)
      >>> print(y)
      ivy.array([1, 0, 1, -1])
  
      >>> x = ivy.array([1, 0, 1, 1])
      >>> ivy.copy_array(x, out=x)
      >>> print(x)
      ivy.array([1, 0, 1, 1])
  
      With one :class:`ivy.Container` input:
  
      >>> x = ivy.Container(a=ivy.array([-1, 0, 1]))
      >>> y = ivy.copy_array(x)
      >>> print(y)
      {
          a: ivy.array([-1, 0, 1])
      }
  
      >>> x = ivy.Container(a=ivy.array([-1, 0, 1]),b=ivy.array([-1, 0, 1, 1, 1, 0]))
      >>> y = ivy.copy_array(x)
      >>> print(y)
      {
          a: ivy.array([-1, 0, 1]),
          b: ivy.array([-1, 0, 1, 1, 1, 0])
      }
  
      With one :class:`ivy.Container` static method:
  
      >>> x = ivy.Container(a=ivy.array([-1, 0, 1]),b=ivy.array([-1, 0, 1, 1, 1, 0]))
      >>> y = ivy.Container.static_copy_array(x)
      >>> print(y)
      {
          a: ivy.array([-1, 0, 1]),
          b: ivy.array([-1, 0, 1, 1, 1, 0])
      }
  
      With one :class:`ivy.Array` instance method:
  
      >>> x = ivy.array([-1, 0, 1])
      >>> y = x.copy_array()
      >>> print(y)
      ivy.array([-1, 0, 1])
  
      >>> x = ivy.array([1, 0, 1, 1])
      >>> y = x.copy_array()
      >>> print(y)
      ivy.array([1, 0, 1, 1])
  
      With :class:`ivy.Container` instance method:
  
      >>> x = ivy.Container(a=ivy.array([1, 0, 1]),b=ivy.array([-1, 0, 1, 1]))
      >>> y = x.copy_array()
      >>> print(y)
      {
          a: ivy.array([1, 0, 1]),
          b: ivy.array([-1, 0, 1, 1])
      }
      """
      return current_backend(x).copy_array(
          x, to_ivy_array=to_ivy_array, out=out
      )
  
imports: from __future__ import annotations
  import functools
  from numbers import Number
  from typing import Union, Tuple, Optional, List, Sequence, Callable, Protocol, TypeVar, Iterable
  import numpy
  import ivy
  from ivy import to_ivy
  from ivy.utils.exceptions import handle_exceptions
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, infer_dtype, handle_out_argument, outputs_to_ivy_arrays, inputs_to_native_arrays, inputs_to_native_shapes, to_native_arrays_and_back, handle_nestable, handle_array_like_without_promotion, handle_device, handle_backend_invalid, temp_asarray_wrapper
label_desc: Use image node_id 27 for calling a global function with example usage: copy_array() and returns: current_backend