<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ensure_bytes(data: Union[str, bytes]) -> bytes: """ Convert data in bytes if data is a string :param data: Data :rtype bytes: """

    if isinstance(data, str):
        return bytes(data, 'utf-8')

    return data