code: def test_default_combine_predictions(
      default_ensemble: DefaultPolicyPredictionEnsemble,
      predictions_and_expected_winner_idx: Tuple[
          List[PolicyPrediction], int
      ],
      last_action_was_action_listen: bool,
  ):
      domain = Domain.load("data/test_domains/default.yml")
      (
          predictions,
          expected_winner_idx,
      ) = predictions_and_expected_winner_idx
  
      # add mandatory and optional events to every prediction
      for prediction in predictions:
          prediction.events = [
              ActionExecuted(action_name=prediction.policy_name)
          ]
          prediction.optional_events = [
              ActionExecuted(
                  action_name=f"optional-{prediction.policy_name}"
              )
          ]
  
      # expected events
      expected_events = set(
          event
          for prediction in predictions
          for event in prediction.events
      )
      expected_events.update(
          predictions[expected_winner_idx].optional_events
      )
      if last_action_was_action_listen:
          expected_events.add(
              DefinePrevUserUtteredFeaturization(
                  predictions[
                      expected_winner_idx
                  ].is_end_to_end_prediction
              )
          )
  
      # construct tracker
      evts = (
          [ActionExecuted(action_name=ACTION_LISTEN_NAME)]
          if last_action_was_action_listen
          else []
      )
      tracker = DialogueStateTracker.from_events(
          sender_id="arbitrary", evts=evts
      )
  
      # get the best prediction!
      best_prediction = (
          default_ensemble.combine_predictions_from_kwargs(
              tracker,
              domain=domain,
              **{
                  prediction.policy_name: prediction
                  for prediction in predictions
              },
          )
      )
  
      # compare events first ...
      assert set(best_prediction.events) == expected_events
      assert not best_prediction.optional_events
  
      # ... then drop events and compare the rest
      best_prediction.events = []
      best_prediction.optional_events = []
      predictions[expected_winner_idx].events = []
      predictions[expected_winner_idx].optional_events = []
  
      # ... not quite there yet, because old implementation creates a policy with
      # best_policy.priority as priority and the first one is a tuple which then
      # becomes a tuple with a tuple with an int, so...
      predictions[expected_winner_idx].policy_priority = predictions[
          expected_winner_idx
      ].policy_priority
  
      # now, we can compare:
      assert best_prediction == predictions[expected_winner_idx]
  
file_path: rasa/tests/core/test_ensemble.py
imports: from rasa.shared.exceptions import InvalidConfigException
  import pytest
  import itertools
  from typing import List, Tuple
  from rasa.engine.graph import ExecutionContext
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.core.policies.policy import PolicyPrediction
  from rasa.core.policies.ensemble import DefaultPolicyPredictionEnsemble
  from rasa.shared.core.domain import Domain
  from rasa.shared.core.trackers import DialogueStateTracker
  from rasa.shared.core.events import ActionExecutionRejected, UserUttered
  from rasa.shared.core.events import ActionExecuted, DefinePrevUserUtteredFeaturization
  from rasa.shared.core.constants import ACTION_LISTEN_NAME
label_desc: Use image node_id 5 for calling a global function with example usage: test_default_combine_predictions(default_ensemble, predictions_and_expected_winner_idx, last_action_was_action_listen) without return types