class_docstr: Abstract Classifier agent. Only meant to be extended.
  
  TorchClassifierAgent aims to handle much of the bookkeeping any classification
  model.
class_docstr_tok: ["Abstract","Classifier","agent",".","Only","meant","to","be","extended",".","TorchClassifierAgent","aims","to","handle","much","of","the","bookkeeping","any","classification","model","."]
docstr: Evaluate a single batch of examples.
code: def eval_step(self, batch):
      """
      Evaluate a single batch of examples.
      """
      if batch.text_vec is None:
          return
  
      self.model.eval()
      scores = self.score(batch)
      probs = F.softmax(scores, dim=1)
  
      if self.calc_auc:
          self._update_aucs(batch, probs)
  
      if self.threshold is None:
          _, prediction_id = torch.max(probs.cpu(), 1)
      else:
          ref_prob = probs.cpu()[:, 0]
          # choose ref class if Prob(ref class) > threshold
          prediction_id = (ref_prob <= self.threshold).to(torch.int64)
      preds = [self.class_list[idx] for idx in prediction_id]
      if batch.labels is None or self.opt["ignore_labels"]:
          # interactive mode
          if self.opt.get("print_scores", False):
              preds = self._format_interactive_output(
                  probs, prediction_id
              )
      else:
          labels = self._get_labels(batch)
          loss = self.criterion(scores, labels)
          self.record_local_metric("loss", AverageMetric.many(loss))
          loss = loss.mean()
          self._update_confusion_matrix(batch, preds)
  
      if self.opt.get("print_scores", False):
          return Output(
              preds, class_list=[self.class_list], probs=probs.tolist()
          )
      if self.opt.get("return_cand_scores", False):
          sorted_scores, ranks = probs.sort(1, descending=True)
          sorted_scores = sorted_scores.cpu()
          text_cands = []
          for i in range(0, ranks.size(0)):
              ordered_list = [self.class_list[i] for i in ranks[i]]
              text_cands.append(ordered_list)
          return Output(
              preds,
              text_candidates=text_cands,
              sorted_scores=sorted_scores,
          )
      else:
          return Output(preds)
  
imports: from parlai.core.params import ParlaiParser
  from parlai.core.opt import Opt
  from parlai.utils.torch import PipelineHelper, total_parameters, trainable_parameters
  from parlai.core.torch_agent import TorchAgent, Output
  from parlai.utils.misc import round_sigfigs, warn_once
  from parlai.core.metrics import Metric, AverageMetric
  from typing import List, Optional, Tuple, Dict, Union
  from typing import Counter
  from parlai.utils.typing import TScalar
  from parlai.utils.io import PathManager
  from sklearn.metrics import auc
  import parlai.utils.logging
  import torch.nn.functional
  import torch
  import math
label_desc: Use image node_id 10 for calling the TorchClassifierAgent obj's underlying member method code with example usage: obj.eval_step(batch) and returns: Output, Output, Output