class_docstr: Predictor is a class that uses a model to predict and evaluate.
docstr: Batch evaluate model on dataset.
  
  Params:
      dataset (Union[str, dict, pandas.DataFrame]): source containing the entire dataset to be evaluated.
      collect_predictions: Return model predictions.
      collect_logits: Return model logits and final layer activations.
  
  Returns:
      Tuple of dictionaries of (metrics, predictions). The keys of metrics are determined by the metrics in the
      model config. The keys of the predictions dictionary depend on which values are requested by the caller:
      collect_predictions, collect_logits.
docstr_tok: ["Batch","evaluate","model","on","dataset",".","Params",":","dataset","(","Union","[","str",",","dict",",","pandas.DataFrame","]",")",":","source","containing","the","entire","dataset","to","be","evaluated",".","collect_predictions",":","Return","model","predictions",".","collect_logits",":","Return","model","logits","and","final","layer","activations",".","Returns",":","Tuple","of","dictionaries","of","(","metrics",",","predictions",")",".","The","keys","of","metrics","are","determined","by","the","metrics","in","the","model","config",".","The","keys","of","the","predictions","dictionary","depend","on","which","values","are","requested","by","the","caller",":","collect_predictions",",","collect_logits","."]
code: def batch_evaluation(
      self,
      dataset,
      collect_predictions=False,
      collect_logits=False,
      dataset_name=None,
  ):
      """Batch evaluate model on dataset.
  
      Params:
          dataset (Union[str, dict, pandas.DataFrame]): source containing the entire dataset to be evaluated.
          collect_predictions: Return model predictions.
          collect_logits: Return model logits and final layer activations.
  
      Returns:
          Tuple of dictionaries of (metrics, predictions). The keys of metrics are determined by the metrics in the
          model config. The keys of the predictions dictionary depend on which values are requested by the caller:
          collect_predictions, collect_logits.
      """
      self.dist_model = self._distributed.to_device(self.dist_model)
      prev_model_training_mode = (
          self.dist_model.training
      )  # store previous model training mode
      self.dist_model.eval()  # set model to eval mode
  
      with torch.no_grad():
          with dataset.initialize_batcher(
              self._batch_size,
              should_shuffle=False,
              distributed=self._distributed,
          ) as batcher:
              progress_bar_config = {
                  "desc": "Evaluation"
                  if dataset_name is None
                  else f"Evaluation {dataset_name: <5.5}",
                  "total": batcher.steps_per_epoch,
                  "file": sys.stdout,
                  "disable": is_progressbar_disabled(),
                  "position": 0,  # Necessary to disable extra new line artifacts in training logs.
              }
              progress_bar = LudwigProgressBar(
                  self.report_tqdm_to_ray,
                  progress_bar_config,
                  self.is_coordinator(),
              )
  
              predictions = defaultdict(list)
              eval_steps = (
                  self.dist_model.config_obj.trainer.eval_steps
                  if hasattr(self.dist_model, "config_obj")
                  and hasattr(
                      self.dist_model.config_obj.trainer, "eval_steps"
                  )
                  else None
              )
              eval_steps_counter = 0
              while not batcher.last_batch():
                  if eval_steps and eval_steps_counter >= eval_steps:
                      logger.info(
                          f"Reached evaluation step {eval_steps}. Ending evaluation."
                      )
                      break
                  batch = batcher.next_batch()
                  logger.debug(
                      f"evaluation for {dataset_name}: obtained next batch "
                      f"memory used: {psutil.Process(os.getpid()).memory_info()[0] / 1e6:0.2f}MB"
                  )
                  inputs = {
                      i_feat.feature_name: torch.from_numpy(
                          np.array(batch[i_feat.proc_column], copy=True)
                      ).to(self.device)
                      for i_feat in self.model.input_features.values()
                  }
                  targets = {
                      o_feat.feature_name: torch.from_numpy(
                          np.array(batch[o_feat.proc_column], copy=True)
                      ).to(self.device)
                      for o_feat in self.model.output_features.values()
                  }
  
                  outputs = self._predict_on_inputs(inputs)
                  preds = self.model.outputs_to_predictions(outputs)
                  self.model.update_metrics(targets, preds)
  
                  # accumulate predictions from batch for each output feature
                  if collect_predictions:
                      self._accumulate_preds(
                          preds,
                          predictions,
                          exclude_pred_set={LAST_HIDDEN}
                          if collect_logits
                          else EXCLUDE_PRED_SET,
                      )
  
                  progress_bar.update(1)
                  eval_steps_counter += 1
                  if self.is_coordinator():
                      logger.debug(
                          f"evaluation for {dataset_name}: completed batch {progress_bar.total_steps} "
                          f"memory used: {psutil.Process(os.getpid()).memory_info()[0] / 1e6:0.2f}MB"
                      )
              progress_bar.close()
  
          # consolidate predictions from each batch to a single tensor
          if collect_predictions:
              self._concat_preds(predictions)
  
          metrics = self.model.get_metrics()
          self.model.reset_metrics()
  
          self.dist_model.train(
              prev_model_training_mode
          )  # Restores previous model training mode.
  
          return metrics, from_numpy_dataset(predictions)
  
imports: import logging
  import os
  import sys
  from abc import ABC, abstractmethod
  from collections import defaultdict, OrderedDict
  from pprint import pformat
  from typing import Dict, List, Optional, Type
  import numpy
  import pandas
  import psutil
  import torch
  from torch import nn
  from ludwig.constants import COMBINED, LAST_HIDDEN, LOGITS, MODEL_ECD, MODEL_GBM, MODEL_LLM
  from ludwig.data.dataset.base import Dataset
  from ludwig.data.utils import convert_to_dict
  from ludwig.distributed.base import DistributedStrategy, LocalStrategy
  from ludwig.globals import is_progressbar_disabled, PREDICTIONS_PARQUET_FILE_NAME, TEST_STATISTICS_FILE_NAME
  from ludwig.models.base import BaseModel
  from ludwig.progress_bar import LudwigProgressBar
  from ludwig.utils.data_utils import save_csv, save_json
  from ludwig.utils.dataframe_utils import from_numpy_dataset
  from ludwig.utils.print_utils import repr_ordered_dict
  from ludwig.utils.registry import Registry
  from ludwig.utils.strings_utils import make_safe_filename
  from ludwig.utils.torch_utils import get_torch_device
label_desc: Use image node_id 7 for calling the Predictor obj's underlying member method code with example usage: obj.batch_evaluation(dataset, collect_predictions, collect_logits, dataset_name) and returns: metrics,  from_numpy_dataset