<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_operations_bulk(self, payload):
 """Add operations to a group of agents. :param list payload: contains the informations necessary for the action. It's in the form [{"id": agent_id, "operations": operations}] With id that is an str containing only characters in "a-zA-Z0-9_-" and must be between 1 and 36 characters. It must referenced an existing agent. With operations a list containing dictionnaries that has the form given in the craftai documentation and the configuration of the agent. :return: list of agents containing a message about the added operations. :rtype: list if dict. :raises CraftAiBadRequestError: if all of the ids are invalid or referenced non existing agents or one of the operations is invalid. """

    # Check all ids, raise an error if all ids are invalid
    valid_indices, _, _ = self._check_agent_id_bulk(payload)
    valid_payload = [payload[i] for i in valid_indices]

    chunked_data = []
    current_chunk = []
    current_chunk_size = 0

    for agent in valid_payload:
      if (agent["operations"] and isinstance(agent["operations"], list)):
        if current_chunk_size + len(agent["operations"]) > self.config["operationsChunksSize"]:
          chunked_data.append(current_chunk)
          current_chunk_size = 0
          current_chunk = []
        if len(agent["operations"]) > self.config["operationsChunksSize"]:
          chunked_data.append([agent])
          current_chunk_size = 0
        else:
          current_chunk_size += len(agent["operations"])
          current_chunk.append(agent)

    if current_chunk:
      chunked_data.append(current_chunk)

    return self._add_operations_bulk(chunked_data)