def METHOD_NAME(
    payload: Dict[str, Any], private_key: Union[HexStr, bytes]
) -> bytes:
    """
    Given a bytes object and a private key, return a signature suitable for
    EIP712 and EIP191 messages.
    """
    if isinstance(payload, (list, tuple)):
        payload = b"".join(payload)
    if isinstance(private_key, str) and private_key.startswith("0x"):
        private_key = private_key[2:]
    elif isinstance(private_key, bytes):
        private_key = bytes.hex()
    account = Account.from_key(private_key)
    hashed_payload = fast_keccak(payload)
    return account.signHash(hashed_payload)["signature"]