<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def aes_encrypt(mode, aes_key, aes_iv, *data):
 """Encrypt data with AES in specified mode."""

    encryptor = Cipher(
        algorithms.AES(aes_key),
        mode(aes_iv),
        backend=default_backend()).encryptor()

    result = None
    for value in data:
        result = encryptor.update(value)
    encryptor.finalize()

    return result, None if not hasattr(encryptor, 'tag') else encryptor.tag