<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _encode_batched_op_msg( operation, command, docs, check_keys, ack, opts, ctx):
 """Encode the next batched insert, update, or delete operation as OP_MSG. """

    buf = StringIO()

    to_send, _ = _batched_op_msg_impl(
        operation, command, docs, check_keys, ack, opts, ctx, buf)
    return buf.getvalue(), to_send