<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _coerce_client_id(client_id):
 """ Ensure the provided client ID is a byte string. If a text string is provided, it is encoded as UTF-8 bytes. :param client_id: :class:`bytes` or :class:`str` instance """

    if isinstance(client_id, type(u'')):
        client_id = client_id.encode('utf-8')
    if not isinstance(client_id, bytes):
        raise TypeError('{!r} is not a valid consumer group (must be'
                        ' str or bytes)'.format(client_id))
    return client_id