<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _mutate_rows_request(table_name, rows, app_profile_id=None):
 """Creates a request to mutate rows in a table. :type table_name: str :param table_name: The name of the table to write to. :type rows: list :param rows: List or other iterable of :class:`.DirectRow` instances. :type: app_profile_id: str :param app_profile_id: (Optional) The unique name of the AppProfile. :rtype: :class:`data_messages_v2_pb2.MutateRowsRequest` :returns: The ``MutateRowsRequest`` protobuf corresponding to the inputs. :raises: :exc:`~.table.TooManyMutationsError` if the number of mutations is greater than 100,000 """

    request_pb = data_messages_v2_pb2.MutateRowsRequest(
        table_name=table_name, app_profile_id=app_profile_id
    )
    mutations_count = 0
    for row in rows:
        _check_row_table_name(table_name, row)
        _check_row_type(row)
        mutations = row._get_mutations()
        request_pb.entries.add(row_key=row.row_key, mutations=mutations)
        mutations_count += len(mutations)
    if mutations_count > _MAX_BULK_MUTATIONS:
        raise TooManyMutationsError(
            "Maximum number of mutations is %s" % (_MAX_BULK_MUTATIONS,)
        )
    return request_pb