code: def parse_keras_history(logs):
      """
      Parse the `logs` of either a `tf.keras.History` object returned by `model.fit()` or an accumulated logs `dict`
      passed to the `PushToHubCallback`. Returns lines and logs compatible with those returned by `parse_log_history`.
      """
      if hasattr(logs, "history"):
          # This looks like a `History` object
          if not hasattr(logs, "epoch"):
              # This history looks empty, return empty results
              return None, [], {}
          logs.history["epoch"] = logs.epoch
          logs = logs.history
      else:
          # Training logs is a list of dicts, let's invert it to a dict of lists to match a History object
          logs = {
              log_key: [single_dict[log_key] for single_dict in logs]
              for log_key in logs[0]
          }
  
      lines = []
      for i in range(len(logs["epoch"])):
          epoch_dict = {
              log_key: log_value_list[i]
              for log_key, log_value_list in logs.items()
          }
          values = {}
          for k, v in epoch_dict.items():
              if k.startswith("val_"):
                  k = "validation_" + k[4:]
              elif k != "epoch":
                  k = "train_" + k
              splits = k.split("_")
              name = " ".join([part.capitalize() for part in splits])
              values[name] = v
          lines.append(values)
  
      eval_results = lines[-1]
  
      return logs, lines, eval_results
  
imports: import copy
  import json
  import os
  import warnings
  from dataclasses import dataclass
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Union
  import requests
  import yaml
  from huggingface_hub import model_info
  from huggingface_hub.utils import HFValidationError
  from .None import __version__
  from .models.auto.modeling_auto import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES, MODEL_FOR_CAUSAL_LM_MAPPING_NAMES, MODEL_FOR_CTC_MAPPING_NAMES, MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES, MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES, MODEL_FOR_MASKED_LM_MAPPING_NAMES, MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES, MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES, MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES, MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES, MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES, MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING_NAMES, MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES, MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING_NAMES
  from .training_args import ParallelMode
  from .utils import MODEL_CARD_NAME, cached_file, is_datasets_available, is_offline_mode, is_tf_available, is_tokenizers_available, is_torch_available, logging
label_desc: Use image node_id 7 for calling a global function with example usage: parse_keras_history(logs) and returns: logs,  lines,  eval_results, None,  list,  dict