code: def from_keras(
      cls,
      model,
      model_name,
      keras_history=None,
      language=None,
      license=None,
      tags=None,
      finetuned_from=None,
      tasks=None,
      dataset_tags=None,
      dataset=None,
      dataset_args=None,
  ):
      # Infer default from dataset
      if dataset is not None:
          if is_hf_dataset(dataset) and (
              dataset_tags is None or dataset_args is None
          ):
              default_tag = dataset.builder_name
              # Those are not real datasets from the Hub so we exclude them.
              if default_tag not in [
                  "csv",
                  "json",
                  "pandas",
                  "parquet",
                  "text",
              ]:
                  if dataset_tags is None:
                      dataset_tags = [default_tag]
                  if dataset_args is None:
                      dataset_args = [dataset.config_name]
  
      if dataset is None and dataset_tags is not None:
          dataset = dataset_tags
  
      # Infer default finetuned_from
      if (
          finetuned_from is None
          and hasattr(model.config, "_name_or_path")
          and not os.path.isdir(model.config._name_or_path)
      ):
          finetuned_from = model.config._name_or_path
  
      # Infer default task tag:
      if tasks is None:
          model_class_name = model.__class__.__name__
          for task, mapping in TASK_MAPPING.items():
              if model_class_name in _get_mapping_values(mapping):
                  tasks = task
  
      # Add `generated_from_keras_callback` to the tags
      if tags is None:
          tags = ["generated_from_keras_callback"]
      elif (
          isinstance(tags, str)
          and tags != "generated_from_keras_callback"
      ):
          tags = [tags, "generated_from_keras_callback"]
      elif "generated_from_keras_callback" not in tags:
          tags.append("generated_from_keras_callback")
  
      if keras_history is not None:
          _, eval_lines, eval_results = parse_keras_history(
              keras_history
          )
      else:
          eval_lines = []
          eval_results = dict()
      hyperparameters = extract_hyperparameters_from_keras(model)
  
      return cls(
          language=language,
          license=license,
          tags=tags,
          model_name=model_name,
          finetuned_from=finetuned_from,
          tasks=tasks,
          dataset_tags=dataset_tags,
          dataset=dataset,
          dataset_args=dataset_args,
          eval_results=eval_results,
          eval_lines=eval_lines,
          hyperparameters=hyperparameters,
          source="keras",
      )
  
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
  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 6 for calling the TrainingSummary obj's underlying member method code with example usage: obj.from_keras(cls, model, model_name, keras_history, language, license, tags, finetuned_from, tasks, dataset_tags, dataset, dataset_args) and returns: cls