def to_deferred_array(self, read_only: bool) -> DeferredArray:
        """
        Convert this EagerArray into a DeferredArray.

        If `read_only` is `False`, the EagerArray's buffer is donated to
        initialize the DeferredArray, and the returned DeferredArray is used
        in place of the EagerArray going forward.
        """
        if self.deferred is not None:
            return self.deferred
        if read_only:
            deferred = cast(
                DeferredArray,
                runtime.find_or_create_array_thunk(
                    self.array,
                    transfer=TransferType.MAKE_COPY,
                    read_only=True,
                    defer=True,
                ),
            )
        else:
            self._convert_tree()
            deferred = cast(DeferredArray, self.deferred)
        return deferred

        Convert this EagerArray into a DeferredArray.

        If `read_only` is `False`, the EagerArray's buffer is donated to
        initialize the DeferredArray, and the returned DeferredArray is used
        in place of the EagerArray going forward.
        
cupynumeric/_thunk/eager.py