code: def _prepare_event_broker(event_broker: "EventBroker") -> None:
      """Prepares event broker to export tracker events.
  
      Sets `should_keep_unpublished_messages` flag to `False` if
      `self.event_broker` is a `PikaEventBroker`.
  
      If publishing of events fails, the `PikaEventBroker` instance should not keep a
      list of unpublished messages, so we can retry publishing them. This is because
      the instance is launched as part of this short-lived export script, meaning the
      object is destroyed before it might be published.
  
      In addition, wait until the event broker reports a `ready` state.
  
      """
      if isinstance(event_broker, PikaEventBroker):
          event_broker.should_keep_unpublished_messages = False
          event_broker.raise_on_failure = True
  
      if not event_broker.is_ready():
          rasa.shared.utils.cli.print_error_and_exit(
              f"Event broker of type '{type(event_broker)}' is not ready. Exiting."
          )
  
imports: import argparse
  import asyncio
  import logging
  import typing
  from typing import List, Text, Optional
  from rasa import telemetry
  from rasa.cli import SubParsersAction
  import rasa.core.utils
  import rasa.shared.utils.cli
  import rasa.utils.common
  from rasa.cli.arguments import export
  from rasa.shared.constants import DOCS_URL_EVENT_BROKERS, DOCS_URL_TRACKER_STORES
  from rasa.exceptions import PublishingError
  from rasa.shared.exceptions import RasaException
  from rasa.core.brokers.pika import PikaEventBroker
label_desc: Use image node_id 5 for calling a global function with example usage: _prepare_event_broker(event_broker) without return types