code: def to_model_card(self):
      model_card = ""
  
      metadata = yaml.dump(self.create_metadata(), sort_keys=False)
      if len(metadata) > 0:
          model_card = f"---\n{metadata}---\n"
  
      # Now the model card for realsies.
      if self.source == "trainer":
          model_card += AUTOGENERATED_TRAINER_COMMENT
      else:
          model_card += AUTOGENERATED_KERAS_COMMENT
  
      model_card += f"\n# {self.model_name}\n\n"
  
      if self.finetuned_from is None:
          model_card += "This model was trained from scratch on "
      else:
          model_card += (
              "This model is a fine-tuned version of"
              f" [{self.finetuned_from}](https://huggingface.co/{self.finetuned_from}) on "
          )
  
      if self.dataset is None:
          model_card += "an unknown dataset."
      else:
          if isinstance(self.dataset, str):
              model_card += f"the {self.dataset} dataset."
          elif (
              isinstance(self.dataset, (tuple, list))
              and len(self.dataset) == 1
          ):
              model_card += f"the {self.dataset[0]} dataset."
          else:
              model_card += (
                  ", ".join([f"the {ds}" for ds in self.dataset[:-1]])
                  + f" and the {self.dataset[-1]} datasets."
              )
  
      if self.eval_results is not None:
          model_card += "\nIt achieves the following results on the evaluation set:\n"
          model_card += "\n".join(
              [
                  f"- {name}: {_maybe_round(value)}"
                  for name, value in self.eval_results.items()
              ]
          )
      model_card += "\n"
  
      model_card += (
          "\n## Model description\n\nMore information needed\n"
      )
      model_card += "\n## Intended uses & limitations\n\nMore information needed\n"
      model_card += "\n## Training and evaluation data\n\nMore information needed\n"
  
      model_card += "\n## Training procedure\n"
      model_card += "\n### Training hyperparameters\n"
      if self.hyperparameters is not None:
          model_card += "\nThe following hyperparameters were used during training:\n"
          model_card += "\n".join(
              [
                  f"- {name}: {value}"
                  for name, value in self.hyperparameters.items()
              ]
          )
          model_card += "\n"
      else:
          model_card += "\nMore information needed\n"
  
      if self.eval_lines is not None:
          model_card += "\n### Training results\n\n"
          model_card += make_markdown_table(self.eval_lines)
          model_card += "\n"
  
      model_card += "\n### Framework versions\n\n"
      model_card += f"- Transformers {__version__}\n"
  
      if self.source == "trainer" and is_torch_available():
          import torch
  
          model_card += f"- Pytorch {torch.__version__}\n"
      elif self.source == "keras" and is_tf_available():
          import tensorflow as tf
  
          model_card += f"- TensorFlow {tf.__version__}\n"
      if is_datasets_available():
          import datasets
  
          model_card += f"- Datasets {datasets.__version__}\n"
      if is_tokenizers_available():
          import tokenizers
  
          model_card += f"- Tokenizers {tokenizers.__version__}\n"
  
      return model_card
  
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 4 for calling the TrainingSummary obj's underlying member method code with example usage: obj.to_model_card() and returns: model_card