sequince.utils.copying
======================

.. py:module:: sequince.utils.copying


Functions
---------

.. autoapisummary::

   sequince.utils.copying.array_safe_copy


Module Contents
---------------

.. py:function:: array_safe_copy(value)

   Recursively copy a value while preserving array backends.

   Array leaves are copied using :func:`sequince.array_api.copy`. This avoids
   calling :func:`copy.deepcopy` on backend arrays, which is unsupported for
   some arrays such as non-leaf PyTorch tensors. Mappings, lists, and tuples
   are copied recursively; other values use :func:`copy.deepcopy`.

   :param value: The value to copy.

   :returns: An independent copy of ``value`` where supported by its array backend.
   :rtype: Any


