def local_task_array(obj: PhysicalArray | PhysicalStore) -> Any:
    """
    Generate an appropriate local-memory ndarray object, that is backed by the
    portion of a Legate array or store that was passed to a task.

    Parameters
    ----------
    obj : PhysicalArray | PhysicalStore
        A Legate physical array or store to adapt.

    Returns
    -------
    arr : cupy.ndarray or np.ndarray
        If the array or store is located on GPU, then this function will return
        a CuPy array. Otherwise, a NumPy array is returned.

    """
    store = obj.data() if isinstance(obj, PhysicalArray) else obj

    if store.target in {StoreTarget.FBMEM, StoreTarget.ZCMEM}:
        # cupy is only a dependency for GPU packages -- but we should
        # only hit this import in case the store is located on a GPU
        import cupy  # type: ignore [import-untyped,import-not-found]

        return cupy.asarray(store)
    else:
        return np.asarray(store)

    Generate an appropriate local-memory ndarray object, that is backed by the
    portion of a Legate array or store that was passed to a task.

    Parameters
    ----------
    obj : PhysicalArray | PhysicalStore
        A Legate physical array or store to adapt.

    Returns
    -------
    arr : cupy.ndarray or np.ndarray
        If the array or store is located on GPU, then this function will return
        a CuPy array. Otherwise, a NumPy array is returned.

    
cupynumeric/_utils/array.py