docstr: Evaluate model on a test dataset.
  
  Parameters
  ----------
  data
      A dataframe, containing the same columns as the training data.
  metrics
      A list of metric names to report.
      If None, we only return the score for the stored `_eval_metric_name`.
  return_pred
      Whether to return the prediction result of each row.
  realtime
      Whether to do realtime inference, which is efficient for small data (default False).
      If provided None, we would infer it on based on the data modalities
      and sample number.
  
  Returns
  -------
  A dictionary with the metric names and their corresponding scores.
  Optionally return a dataframe of prediction results.
docstr_tok: ["Evaluate","model","on","a","test","dataset",".","Parameters","--","--","--","--","--","data","A","dataframe",",","containing","the","same","columns","as","the","training","data",".","metrics","A","list","of","metric","names","to","report",".","If","None",",","we","only","return","the","score","for","the","stored","`","_eval_metric_name","`",".","return_pred","Whether","to","return","the","prediction","result","of","each","row",".","realtime","Whether","to","do","realtime","inference",",","which","is","efficient","for","small","data","(","default","False",")",".","If","provided","None",",","we","would","infer","it","on","based","on","the","data","modalities","and","sample","number",".","Returns","--","--","--","-","A","dictionary","with","the","metric","names","and","their","corresponding","scores",".","Optionally","return","a","dataframe","of","prediction","results","."]
code: def evaluate(
      self,
      data: Union[pd.DataFrame, dict, list, str],
      metrics: Optional[Union[str, List[str]]] = None,
      return_pred: Optional[bool] = False,
      realtime: Optional[bool] = False,
      **kwargs,
  ):
      """
      Evaluate model on a test dataset.
  
      Parameters
      ----------
      data
          A dataframe, containing the same columns as the training data.
      metrics
          A list of metric names to report.
          If None, we only return the score for the stored `_eval_metric_name`.
      return_pred
          Whether to return the prediction result of each row.
      realtime
          Whether to do realtime inference, which is efficient for small data (default False).
          If provided None, we would infer it on based on the data modalities
          and sample number.
  
      Returns
      -------
      A dictionary with the metric names and their corresponding scores.
      Optionally return a dataframe of prediction results.
      """
      self.ensure_predict_ready()
      outputs = self.predict_per_run(
          data=data,
          realtime=realtime,
          requires_label=True,
      )
      logits = extract_from_output(ret_type=NER_RET, outputs=outputs)
      metric_data = {}
      y_pred = self._df_preprocessor.transform_prediction(
          y_pred=logits,
          inverse_categorical=False,
      )
      y_pred_inv = self._df_preprocessor.transform_prediction(
          y_pred=logits,
          inverse_categorical=True,
      )
      y_true = self._df_preprocessor.transform_label_for_metric(
          df=data,
          tokenizer=self._model.tokenizer,
      )
      metric_data.update(
          {
              Y_PRED: y_pred,
              Y_TRUE: y_true,
          }
      )
      metrics_is_none = False
      if metrics is None:
          metrics_is_none = True
          if self._eval_metric_func:
              metrics = [self._eval_metric_func]
          else:
              metrics = [self._eval_metric_name]
      if isinstance(metrics, str) or isinstance(metrics, Scorer):
          metrics = [metrics]
  
      results = {}
      score = compute_score(
          metric_data=metric_data,
          metric=self._eval_metric_name.lower(),
      )
      score = {k.lower(): v for k, v in score.items()}
      if metrics_is_none:
          results = score
      else:
          for per_metric in metrics:
              if per_metric.lower() in score:
                  results.update(
                      {per_metric: score[per_metric.lower()]}
                  )
              else:
                  warnings.warn(
                      f"Warning: {per_metric} is not a supported evaluation metric!"
                  )
          if not results:
              results = score  # If the results dict is empty, return all scores.
  
      if return_pred:
          return results, self._as_pandas(
              data=data, to_be_converted=y_pred_inv
          )
      else:
          return results
  
imports: import json
  import logging
  import os
  import warnings
  from datetime import timedelta
  from typing import Callable, Dict, List, Optional, Union
  import lightning.pytorch
  import pandas
  from omegaconf import DictConfig, OmegaConf
  from torch import nn
  from autogluon.core.metrics import Scorer
  from ..constants import NER, NER_RET, Y_PRED, Y_TRUE
  from ..data import MultiModalFeaturePreprocessor
  from ..optimization import NerLitModule, get_metric
  from ..utils import compute_score, create_fusion_model, extract_from_output, merge_bio_format
  from .base import BaseLearner
label_desc: Use image node_id 12 for calling the NERLearner obj's underlying member method code with example usage: obj.evaluate(data, metrics, return_pred, realtime) and returns: results,  self, results