class_docstr: Stores the explanations for a single row of input data.
  
  Contains the feature attributions for each label in the target feature's vocab.
class_docstr_tok: ["Stores","the","explanations","for","a","single","row","of","input","data",".","Contains","the","feature","attributions","for","each","label","in","the","target","feature","'s","vocab","."]
docstr: Add the feature attributions for a single label.
docstr_tok: ["Add","the","feature","attributions","for","a","single","label","."]
code: def add(
      self,
      feat_names: List[str],
      feat_attributions: npt.NDArray[np.float64],
      feat_to_token_attributions: Dict[
          str, List[Tuple[str, float]]
      ] = None,
      prepend: bool = False,
  ):
      """Add the feature attributions for a single label."""
      assert len(feat_names) == len(
          feat_attributions
      ), f"Expected {len(feat_names)} feature attributions, got {len(feat_attributions)}"
      if len(self.label_explanations) > 0:
          # Check that the feature attributions are the same shape as existing explanations.
          assert (
              self.label_explanations[0].to_array().shape
              == feat_attributions.shape
          ), (
              f"Expected feature attributions of shape {self.label_explanations[0].to_array().shape}, "
              f"got {feat_attributions.shape}"
          )
  
      le = LabelExplanation()
      for i, feat_name in enumerate(feat_names):
          le.add(
              feat_name,
              feat_attributions[i],
              feat_to_token_attributions.get(feat_name)
              if feat_to_token_attributions
              else None,
          )
      self.label_explanations.insert(
          0, le
      ) if prepend else self.label_explanations.append(le)
  
file_path: ludwig/ludwig/explain/explanation.py
imports: from dataclasses import dataclass, field
  from typing import Dict, List, Tuple
  import numpy
  import numpy.typing
  from ludwig.api_annotations import DeveloperAPI, PublicAPI
label_desc: Use image node_id 1 for calling the Explanation obj's underlying member method code with example usage: obj.add(feat_names, feat_attributions, feat_to_token_attributions, prepend) without return types