<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def did_to_id_bytes(did):
 """ Return an Ocean DID to it's correspondng hex id in bytes. So did:op:<hex>, will return <hex> in byte format """

    if isinstance(did, str):
        if re.match('^[0x]?[0-9A-Za-z]+$', did):
            raise ValueError(f'{did} must be a DID not a hex string')
        else:
            did_result = did_parse(did)
            if not did_result:
                raise ValueError(f'{did} is not a valid did')
            if not did_result['id']:
                raise ValueError(f'{did} is not a valid ocean did')
            id_bytes = Web3.toBytes(hexstr=did_result['id'])
    elif isinstance(did, bytes):
        id_bytes = did
    else:
        raise TypeError(
            f'Unknown did format, expected str or bytes, got {did} of type {type(did)}')
    return id_bytes