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 is_compatible(
      self, model: lit_model.Model, dataset: lit_dataset.Dataset
  ) -> bool:
      del dataset  # Unused by TCAV
      output_spec = model.output_spec()
      gradient_fields = utils.find_spec_keys(
          output_spec, types.Gradients
      )
  
      if not gradient_fields:
          return False
  
      for grad_field in gradient_fields:
          field_spec = cast(
              types.Gradients, output_spec.get(grad_field)
          )
          preds = output_spec.get(field_spec.align)
          compat_preds = isinstance(preds, types.MulticlassPreds)
          grad_for = output_spec.get(field_spec.grad_for)
          compat_grad_for = isinstance(grad_for, types.Embeddings)
          # TODO(b/205996131, b/294613507): remove grad_target_field_key and just
          # use the target labels from the input, similar to salience methods.
          grad_target = output_spec.get(
              field_spec.grad_target_field_key
          )
          compat_grad_target = isinstance(
              grad_target, types.CategoryLabel
          )
          if compat_preds and compat_grad_for and compat_grad_target:
              return True
  
      return False
  
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 2 for calling the TCAV obj's underlying member method code with example usage: obj.is_compatible(model, dataset) and returns: False, False, True