class_docstr: A test model for testing tabular hot-flips on classification tasks.
class_docstr_tok: ["A","test","model","for","testing","tabular","hot-flips","on","classification","tasks","."]
code: def predict_minibatch(
      self, inputs: list[lit_types.JsonDict], **unused
  ) -> list[lit_types.JsonDict]:
      output = []
  
      def predict_example(ex: lit_types.JsonDict) -> lit_types.JsonDict:
          """Returns model predictions for a given example.
  
          The method uses the animal test dataset as the ground truth. The method
          compares the given example features to the dataset features for all
          animals. The closer the feature values are, the higher the contribution to
          the corresponding class logit is.
  
          Args:
            ex: an example to run prediction for.
  
          Returns:
            The softmax values for the animal class prediction.
          """
          # Logit values for ['unknown', 'elephant', 'ant', 'whale'].
          logits = np.zeros((len(ANIMALS),))
          for db_rec in self._dataset.examples:
              animal_index = ANIMALS.index(db_rec["animal"])
              for field_name in self._dataset.spec():
                  if (
                      ex[field_name] is None
                      or db_rec[field_name] is None
                  ):
                      continue
                  if field_name == "animal":
                      continue
                  field_spec_value = self._dataset.spec()[field_name]
                  if (
                      isinstance(
                          field_spec_value, lit_types.CategoryLabel
                      )
                      or isinstance(field_spec_value, lit_types.Boolean)
                  ) and (ex[field_name] == db_rec[field_name]):
                      logits[animal_index] += 1
                  if isinstance(field_spec_value, lit_types.Scalar):
                      logits[animal_index] += 1.0 - abs(
                          ex[field_name] - db_rec[field_name]
                      )
          return scipy_special.softmax(logits)
  
      for example in inputs:
          output.append({"preds": predict_example(example)})
      return output
  
imports: from unittest import mock
  from absl.testing import absltest
  from lit_nlp.api import dataset
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.components import minimal_targeted_counterfactuals
  from lit_nlp.lib import caching
  import numpy
  import scipy.special
label_desc: Use image node_id 5 for calling the ClassificationTestModel obj's underlying member method code with example usage: obj.predict_minibatch(inputs) and returns: output, scipy_special