def bytes2hex(bytes_array):
    """
    Converts byte array (output of ``pickle.dumps()``) to spaced hexadecimal string representation.

    Parameters
    ----------
    bytes_array: bytes
        Array of bytes to be converted.

    Returns
    -------
    str
        Hexadecimal representation of the byte array.
    """
    s_hex = bytes_array.hex()
    # Insert spaces between each hex number. It makes YAML file formatting better.
    return " ".join([s_hex[n : n + 2] for n in range(0, len(s_hex), 2)])