from typing import Union


def to_bytes(str_or_bytes: Union[bytes, str]) -> bytes:
    """
    This function takes a bytes or string instance and always returns a bytes
    :param str_or_bytes: str or bytes instance
    :return: bytes instance
    """
    if isinstance(str_or_bytes, str):
        result = str_or_bytes.encode("utf-8")
    else:
        result = str_or_bytes
    return result