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.**
docstr: Returns the tcav score given the class to explain directional derivs.
docstr_tok: ["Returns","the","tcav","score","given","the","class","to","explain","directional","derivs","."]
code: def compute_tcav_score(self, dir_derivs):
      """Returns the tcav score given the class to explain directional derivs."""
      # Maps positive derivatives to 1 and non-positive derivatives to 0.
      positive_dirs = [int(dir > 0) for dir in dir_derivs]
  
      # Divides the number of examples in the class_to_explain with directional
      # derivative > 0 by the total number of examples in the class_to_explain
      # to compute TCAV score.
      num_positive_dirs = sum(positive_dirs)
      return num_positive_dirs / len(dir_derivs)
  
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 13 for calling the TCAV obj's underlying member method code with example usage: obj.compute_tcav_score(dir_derivs) and returns: unknown