def array_to_hex(arr, sep=" "):
    """Inverse of `hex_to_array()`."""
    # Or: binascii.hexlify(bytearray(out.swapaxes(0, 1).flat)).decode("ascii")
    if arr.ndim == 1:
        return sep.join(map("{:02x}".format, arr))
    return sep.join(map("{:02x}".format, arr.swapaxes(0, 1).flat))