class_docstr: Quantitative Testing with Concept Activation Vectors (TCAV).
  
  TCAV is an interpretability method which allows users to define a concept
  by selecting a set of representative examples and trains a classifier at
  different model layers to determine whether that concept has any influence
  over the predictions of the model (https://arxiv.org/pdf/1711.11279.pdf).
  If so, it can be measured as an aggregate score, and also individual points
  can be measured by how much of that concept they contain, at a given layer.
  
  The original implementation can be found at:
  https://github.com/tensorflow/tcav
  
  This component requires that the following fields in the model spec. Field
  names like `layer` are placeholders; you can call them whatever you like,
  and as with other LIT components multiple segments are supported.
    Output:
      - Embeddings (`emb_layer`) to return the input embeddings
          for a layer
      - Gradients (`grad_layer`) to return the gradients w.r.t.
          `emb_layer`
      - Gradients class (`grad_class`) to return the label that gradients
        were computed for. This is usually a CategoryLabel, but can be anything
        since it will just be fed back into the model.
      - MulticlassPreds (`probas`)
  
  **Note: TCAV calls the model multiple times. It is _strongly_ recommended that
  you use a caching model (i.e., wrap your model in a `CachingModelWrapper`) to
  optimize performance.**
code: def _run_default_tcav(
      self,
      grad_layer,
      emb_layer,
      grad_class_key,
      concept_outputs,
      non_concept_outputs,
      dataset_outputs,
      config,
  ):
      concept_results = []
      # If there are more concept set examples than non-concept set examples, we
      # use random splits of the concept examples as the concept set and use the
      # remainder of the dataset as the comparison set. Otherwise, we use random
      # splits of the non-concept examples as the comparison set.
      n = min(len(concept_outputs), len(non_concept_outputs))
  
      # If there are equal numbers of concept and non-concept examples, we
      # decrease n by one so that we also sample a different set in each TCAV run.
      if len(concept_outputs) == len(non_concept_outputs):
          n -= 1
      for _ in range(NUM_SPLITS):
          concept_split_outputs = self._subsample(concept_outputs, n)
          comparison_split_outputs = self._subsample(
              non_concept_outputs, n
          )
          concept_results.append(
              self._run_tcav(
                  concept_split_outputs,
                  comparison_split_outputs,
                  dataset_outputs,
                  config.class_to_explain,
                  emb_layer,
                  grad_layer,
                  grad_class_key,
                  config.test_size,
                  config.random_state,
              )
          )
  
      random_results = []
      # Get tcav scores on random splits.
      for _ in range(NUM_SPLITS):
          concept_split_outputs = self._subsample(dataset_outputs, n)
          comparison_split_outputs = self._subsample(
              non_concept_outputs, n
          )
          random_results.append(
              self._run_tcav(
                  concept_split_outputs,
                  comparison_split_outputs,
                  dataset_outputs,
                  config.class_to_explain,
                  emb_layer,
                  grad_layer,
                  grad_class_key,
                  config.test_size,
                  config.random_state,
              )
          )
  
      cav_scores = [res["score"] for res in concept_results]
      random_scores = [res["score"] for res in random_results]
      p_val = self.hyp_test(cav_scores, random_scores)
  
      random_mean = np.mean(random_scores)
  
      # Get index of CAV result with the highest accuracy.
      accuracies = [res["accuracy"] for res in concept_results]
      index = np.argmax(accuracies)
  
      # Many CAVS are trained and checked for statistical testing to calculate
      # the p-value. The values of the first CAV are returned.
      results = {
          "result": concept_results[index],
          "p_val": p_val,
          "random_mean": random_mean,
      }
      return [results]
  
imports: from collections.abc import Sequence
  import dataclasses
  import math
  import random
  from typing import Any, Optional, cast
  from lit_nlp.api import components
  from lit_nlp.api import dataset
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.lib import utils
  import numpy
  import scipy.stats
  import sklearn.linear_model
  import sklearn.model_selection
label_desc: Use image node_id 6 for calling the TCAV obj's underlying member method code with example usage: obj._run_default_tcav(grad_layer, emb_layer, grad_class_key, concept_outputs, non_concept_outputs, dataset_outputs, config) and returns: list