code: def process_sheep(self, sheep, history):
      parts = super().process_sheep(sheep, history)
  
      track_by = {
          "ppl": "lower"
      }  # values should be in ['lower', 'higher']
      best_metrics = {
          k: (1 if v == "lower" else -1) * float("inf")
          for k, v in track_by.items()
      }
  
      def comparator(mode, a, b):
          return a < b if mode == "lower" else a > b
  
      for metrics in history:
          for key, sub in metrics.items():
              for metric in track_by:
                  # for the validation set, keep track of best metrics (ppl in this example)
                  # this is so we can conveniently compare metrics between runs in the grid
                  if (
                      key == "valid"
                      and metric in sub
                      and comparator(
                          track_by[metric],
                          sub[metric],
                          best_metrics[metric],
                      )
                  ):
                      best_metrics[metric] = sub[metric]
  
      if "valid" in parts:
          parts["valid"].update(
              {f"best_{k}": v for k, v in best_metrics.items()}
          )
      return parts
  
file_path: audiocraft/audiocraft/grids/musicgen/_explorers.py
imports: import typing
  import treetable
  from .._base_explorers import BaseExplorer
label_desc: Use image node_id 3 for calling the LMExplorer obj's underlying member method code with example usage: obj.process_sheep(sheep, history) and returns: parts, unknown