<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete_agents_bulk(self, payload):
 """Delete a group of agents :param list payload: Contains the informations to delete the agents. It's in the form [{"id": agent_id}]. With id an str containing only characters in "a-zA-Z0-9_-" and must be between 1 and 36 characters. :return: the list of agents deleted which are represented with dictionnaries. :rtype: list of dict. :raises CraftAiBadRequestError: If all of the ids are invalid. """

    # Check all ids, raise an error if all ids are invalid
    valid_indices, invalid_indices, invalid_agents = self._check_agent_id_bulk(payload)

    # Create the json file with the agents with valid id and send it
    valid_agents = self._create_and_send_json_bulk([payload[i] for i in valid_indices],
                                                   "{}/bulk/agents".format(self._base_url),
                                                   "DELETE")

    if invalid_indices == []:
      return valid_agents

    # Put the valid and invalid agents in their original index
    return self._recreate_list_with_indices(valid_indices,
                                            valid_agents,
                                            invalid_indices,
                                            invalid_agents)