code: def test_tcav_sample_from_positive(self):
      random.seed(
          0
      )  # Sets seed since create_comparison_splits() uses random.
  
      # Tests the case where more concept examples are passed than non-concept
      # examples, so the concept set is sampled from the concept examples.
      config = {
          "concept_set_ids": [
              _ALPHABET_EXAMPLES[0]["_id"],
              _ALPHABET_EXAMPLES[2]["_id"],
              _ALPHABET_EXAMPLES[3]["_id"],
              _ALPHABET_EXAMPLES[4]["_id"],
              _ALPHABET_EXAMPLES[7]["_id"],
          ],
          "class_to_explain": "1",
          "grad_layer": "cls_grad",
          "random_state": 0,
      }
  
      result = self.tcav.run(
          _ALPHABET_EXAMPLES[:8],
          self.model,
          self.alphabet_dataset,
          config=config,
      )
      self.assertLen(result, 1)
  
      expected = {
          "p_val": 0.80489,
          "random_mean": 0.53333,
          "result": {
              "score": 0.8,
              "cos_sim": [
                  0.09527,
                  -0.20442,
                  0.05141,
                  0.14985,
                  0.06750,
                  -0.28244,
                  -0.11022,
                  -0.14479,
              ],
              "dot_prods": [
                  152.48776,
                  -335.64998,
                  82.99588,
                  247.80113,
                  109.53684,
                  -461.81805,
                  -181.29095,
                  -239.47817,
              ],
              "accuracy": 1.0,
              "cav": [
                  [
                      -9.18092006e00,
                      -3.25423105e00,
                      -1.95599351e01,
                      7.90544869e00,
                      2.71945760e-01,
                      9.21655507e00,
                      -7.10360094e-01,
                      1.06792122e01,
                      -4.22297728e00,
                      -5.88364071e00,
                      -5.90468259e00,
                      3.02462186e-01,
                      2.73947077e01,
                      -4.21289488e00,
                      4.10535370e00,
                      2.90032257e00,
                      -1.15293947e01,
                      -6.05013625e00,
                      -9.63492785e00,
                      -1.24673936e01,
                      -7.16846202e00,
                      1.65560561e01,
                      3.91797282e00,
                      9.43190766e00,
                      1.13459987e01,
                      -3.52568932e00,
                      9.13124442e-01,
                      9.91573080e-01,
                      -3.25439546e00,
                      -9.93854182e-01,
                      -1.07992122e01,
                      3.11628229e00,
                      6.59499537e00,
                      -1.36178363e01,
                      1.29858952e01,
                      1.03866086e01,
                      1.59031300e01,
                      -5.56392889e00,
                      -3.77058407e00,
                      -9.32599755e00,
                      -9.47891226e-01,
                      2.05803580e01,
                      -1.37954357e01,
                      -7.73649342e00,
                      -9.07151538e00,
                      9.29099926e-01,
                      -1.08088474e01,
                      -7.80737270e-01,
                      2.40018316e00,
                      1.09211064e01,
                      -3.27414948e01,
                      -2.34077057e01,
                      1.17713587e01,
                      1.81635854e00,
                      2.31977099e01,
                      1.61744777e00,
                      1.17686967e00,
                      -3.88545806e00,
                      2.46277754e00,
                      -4.51580108e01,
                      9.32061903e00,
                      -1.73902286e01,
                      -3.66235470e00,
                      3.26925824e01,
                      3.21295843e00,
                      -1.79316338e01,
                      2.01011182e01,
                      3.49235823e00,
                      1.52195300e01,
                      -5.04835360e00,
                      1.45131574e01,
                      1.59716750e01,
                      -2.96747872e00,
                      5.25282201e00,
                      -1.98576797e01,
                      -1.46852052e00,
                      1.58219867e00,
                      -5.74221070e-01,
                      1.16208072e01,
                      5.11250274e-01,
                      5.52448443e00,
                      1.11949046e01,
                      -6.93072443e-02,
                      -7.17318663e00,
                      -8.48821209e00,
                      -8.71016927e00,
                      -1.05849366e01,
                      8.71665351e00,
                      1.24408289e01,
                      4.21549502e00,
                      -2.07208098e01,
                      1.56304334e01,
                      -4.81732341e00,
                      3.20792625e01,
                      -1.20141017e01,
                      -1.73165977e01,
                      -6.54369967e00,
                      3.16826359e00,
                      -1.19574116e01,
                      -5.90525906e00,
                      1.08200571e-01,
                      -9.32849433e00,
                      -1.29775955e00,
                      -1.20217051e01,
                      1.30472736e01,
                      2.25283409e01,
                      7.04978975e-02,
                      5.09369848e-01,
                      1.27449879e01,
                      -2.16621823e00,
                      -8.19007901e00,
                      -4.16839353e00,
                      9.41498786e00,
                      6.79635008e00,
                      4.88519035e00,
                      2.63718274e00,
                      -5.28336147e-03,
                      1.26470921e00,
                      -3.35551546e-01,
                      8.26617183e00,
                      2.58916933e00,
                      -8.54040920e00,
                      -1.18897963e00,
                      -5.09214401e00,
                      7.85278007e00,
                      -1.26074616e01,
                      -3.05422845e00,
                      3.79508590e00,
                  ]
              ],
          },
      }
      testing_utils.assert_deep_almost_equal(self, expected, result[0])
  
file_path: lit/lit_nlp/components/tcav_int_test.py
imports: import random
  from absl.testing import absltest
  from absl.testing import parameterized
  from lit_nlp.api import dataset
  from lit_nlp.components import tcav
  from lit_nlp.examples.models import glue_models
  from lit_nlp.lib import caching
  from lit_nlp.lib import testing_utils
  from lit_nlp.lib import file_cache
label_desc: Use image node_id 5 for calling the ModelBasedTCAVTest obj's underlying member method code with example usage: obj.test_tcav_sample_from_positive() without return types