def METHOD_NAME(array, mask=None):
    cls = type(array)
    if Jax.is_tracer_type(cls):
        raise TypeError("Jax tracers cannot be used with `ak.from_arraylib`")
    if regulararray and len(array.shape) > 1:
        new_shape = (-1,) + array.shape[2:]
        return RegularArray(
            METHOD_NAME(nplike.reshape(array, new_shape), mask),
            array.shape[1],
            array.shape[0],
        )
    if len(array.shape) == 0:
        array = nplike.reshape(array, (1,))
    if array.dtype.kind == "S":
        assert nplike is numpy
        asbytes = array.reshape(-1)
        itemsize = asbytes.dtype.itemsize
        starts = numpy.arange(0, len(asbytes) * itemsize, itemsize, dtype=np.int64)
        stops = numpy.add(starts, numpy.char.str_len(asbytes))
        data = ListArray(
            Index64(starts),
            Index64(stops),
            NumpyArray(
                asbytes.view("u1"),
                parameters={"__array__": "byte"},
                backend=numpy_backend,
            ),
            parameters={"__array__": "bytestring"},
        )
        for i in range(len(array.shape) - 1, 0, -1):
            data = RegularArray(data, array.shape[i], array.shape[i - 1])
    elif array.dtype.kind == "U":
        assert nplike is numpy
        asbytes = numpy.char.encode(array.reshape(-1), "utf-8", "surrogateescape")
        itemsize = asbytes.dtype.itemsize
        starts = numpy.arange(0, len(asbytes) * itemsize, itemsize, dtype=np.int64)
        stops = numpy.add(starts, numpy.char.str_len(asbytes))
        data = ListArray(
            Index64(starts),
            Index64(stops),
            NumpyArray(
                asbytes.view("u1"),
                parameters={"__array__": "char"},
                backend=numpy_backend,
            ),
            parameters={"__array__": "string"},
        )
        for i in range(len(array.shape) - 1, 0, -1):
            data = RegularArray(data, array.shape[i], array.shape[i - 1])
    else:
        data = NumpyArray(array)
    if mask is None:
        return data
    elif mask is False or (isinstance(mask, np.bool_) and not mask):
        # NumPy's MaskedArray with mask == False is an UnmaskedArray
        if len(array.shape) == 1:
            return UnmaskedArray(data)
        else:
            def attach(x):
                if isinstance(x, NumpyArray):
                    return UnmaskedArray(x)
                else:
                    return RegularArray(attach(x.content), x.size, len(x))
            return attach(data.to_RegularArray())
    else:
        # NumPy's MaskedArray is a ByteMaskedArray with valid_when=False
        return ByteMaskedArray(Index8(mask), data, valid_when=False)