docstr: Tests top token results (doesn't apply for LIME with a test model).
docstr_tok: ["Tests","top","token","results","(","does","n't","apply","for","LIME","with","a","test","model",")","."]
code: def test_top_tokens(self):
      """Tests top token results (doesn't apply for LIME with a test model)."""
      config = {
          salience_clustering.SALIENCE_MAPPER_KEY: "Grad L2 Norm",
          salience_clustering.N_CLUSTERS_KEY: 2,
          salience_clustering.TOP_K_TOKENS_KEY: 2,
          salience_clustering.N_TOKENS_TO_DISPLAY_KEY: 2,
      }
      result, *_ = self._call_classification_model_on_standard_input(
          config, "input_embs_grad"
      )
      # Clustering isn't deterministic so we don't know if examples 1 and 2 are
      # in cluster 0 or 1.
      top_token_results = result[salience_clustering.TOP_TOKEN_KEY][
          "input_embs_grad"
      ]
      for cluster_id in range(
          config[salience_clustering.N_CLUSTERS_KEY]
      ):
          top_tokens_with_weights = top_token_results[cluster_id][
              : config[salience_clustering.N_TOKENS_TO_DISPLAY_KEY]
          ]
          top_tokens = [
              token_with_weight[0]
              for token_with_weight in top_tokens_with_weights
          ]
          subset_cd = ["c", "d"]
          subset_ef = ["e", "f"]
          top_tokens_are_set_cd = subset_cd == top_tokens
          top_tokens_are_set_ef = subset_ef == top_tokens
          self.assertTrue(
              top_tokens_are_set_cd or top_tokens_are_set_ef
          )
  
imports: from absl.testing import absltest
  from absl.testing import parameterized
  from lit_nlp.api import dataset
  from lit_nlp.api import dtypes
  from lit_nlp.components import gradient_maps
  from lit_nlp.components import lime_explainer
  from lit_nlp.components import salience_clustering
  from lit_nlp.lib import testing_utils
  import numpy
label_desc: Use image node_id 8 for calling the SalienceClusteringTest obj's underlying member method code with example usage: obj.test_top_tokens() without return types