def send_notification_batch(self, notifications, topic=None, priority=NotificationPriority.Immediate,<EOL>expiration=None, collapse_id=None):
notification_iterator = iter(notifications)<EOL>next_notification = next(notification_iterator, None)<EOL>self.connect()<EOL>results = {}<EOL>open_streams = collections.deque()<EOL>while len(open_streams) > <NUM_LIT:0> or next_notification is not None:<EOL><INDENT>self.update_max_concurrent_streams()<EOL>if self.should_send_notification(next_notification, open_streams):<EOL><INDENT>logger.info('<STR_LIT>', next_notification.token)<EOL>stream_id = self.send_notification_async(next_notification.token, next_notification.payload, topic,<EOL>priority, expiration, collapse_id)<EOL>open_streams.append(RequestStream(stream_id, next_notification.token))<EOL>next_notification = next(notification_iterator, None)<EOL>if next_notification is None:<EOL><INDENT>logger.info('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pending_stream = open_streams.popleft()<EOL>result = self.get_notification_result(pending_stream.stream_id)<EOL>logger.info('<STR_LIT>', pending_stream.token, result)<EOL>results[pending_stream.token] = result<EOL><DEDENT><DEDENT>return results<EOL>
Send a notification to a list of tokens in batch. Instead of sending a synchronous request
for each token, send multiple requests concurrently. This is done on the same connection,
using HTTP/2 streams (one request per stream).

APNs allows many streams simultaneously, but the number of streams can vary depending on
server load. This method reads the SETTINGS frame sent by the server to figure out the
maximum number of concurrent streams. Typically, APNs reports a maximum of 500.

The function returns a dictionary mapping each token to its result. The result is "Success"
if the token was sent successfully, or the string returned by APNs in the 'reason' field of
the response, if the token generated an error.