code: def test_similarities_collection_for_label_ids(self):
      label_ids = np.array([[0, 1], [1, -1], [2, -1]])
      outputs = {
          "similarities": np.array(
              [[[1.2, 0.3, 0.2]], [[0.5, 0.2, 1.6]], [[0.01, 0.1, 1.7]]]
          )
      }
      label_id_similarities = (
          UnexpecTEDIntentPolicy._collect_label_id_grouped_scores(
              outputs, label_ids
          )
      )
  
      # Should contain similarities for all label ids except padding token.
      assert sorted(list(label_id_similarities.keys())) == [0, 1, 2]
  
      # Cross-check that the collected similarities are correct for each label id.
      assert label_id_similarities[0] == {
          POSITIVE_SCORES_KEY: [1.2],
          NEGATIVE_SCORES_KEY: [0.5, 0.01],
      }
      assert label_id_similarities[1] == {
          POSITIVE_SCORES_KEY: [0.3, 0.2],
          NEGATIVE_SCORES_KEY: [0.1],
      }
      assert label_id_similarities[2] == {
          POSITIVE_SCORES_KEY: [1.7],
          NEGATIVE_SCORES_KEY: [0.2, 1.6],
      }
  
imports: import json
  from pathlib import Path
  from typing import Optional, List, Dict, Type
  import tensorflow
  import numpy
  import pytest
  from _pytest.monkeypatch import MonkeyPatch
  from _pytest.logging import LogCaptureFixture
  import logging
  from rasa.core.featurizers.single_state_featurizer import IntentTokenizerSingleStateFeaturizer
  from rasa.core.featurizers.tracker_featurizers import TrackerFeaturizer
  from rasa.core.featurizers.tracker_featurizers import IntentMaxHistoryTrackerFeaturizer
  from rasa.nlu.classifiers import LABEL_RANKING_LENGTH
  from rasa.shared.constants import LATEST_TRAINING_DATA_FORMAT_VERSION
  from rasa.shared.core.generator import TrackerWithCachedStates
  from rasa.core.policies.ted_policy import PREDICTION_FEATURES
  from rasa.core.policies.unexpected_intent_policy import UnexpecTEDIntentPolicy, RankingCandidateMetadata
  from rasa.engine.graph import ExecutionContext
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.shared.core.constants import ACTION_UNLIKELY_INTENT_NAME, ACTION_LISTEN_NAME
  from rasa.shared.core.domain import Domain
  from rasa.shared.core.events import ActionExecuted, UserUttered, EntitiesAdded, SlotSet, ActionExecutionRejected, ActiveLoop
  from rasa.shared.core.trackers import DialogueStateTracker
  from rasa.utils.tensorflow.constants import IGNORE_INTENTS_LIST, LABEL, MASK, SENTENCE, IDS, POSITIVE_SCORES_KEY, NEGATIVE_SCORES_KEY, RANKING_KEY, RANKING_LENGTH
  from rasa.shared.nlu.constants import INTENT
  from rasa.shared.core.events import Event
  from rasa.utils.tensorflow import model_data_utils
  from tests.core.test_policies import train_trackers
  from tests.core.policies.test_ted_policy import TestTEDPolicy
label_desc: Use image node_id 9 for calling the TestUnexpecTEDIntentPolicy obj's underlying member method code with example usage: obj.test_similarities_collection_for_label_ids() without return types