code: def get_metadata(model_dir: str) -> Metadata:
      """Get metadata from the model directory and validate the integrity of the model
  
      Args:
          model_dir (str) : Argument
  
      Returns:
          ( Metadata ) :
  
      """
      metadata = Metadata()
      metadata_file = Path(model_dir).joinpath("metadata.yaml")
      if metadata_file.exists():
          with open(str(metadata_file), "r") as f:
              metadata = Metadata(
                  **yaml.load(f)
              )  # pylint: disable=E1120
          if metadata.model_type == "XGBoostModel":
              metadata = XGBoostMetadata(
                  **yaml.load(f)
              )  # pylint: disable=E1120
          elif metadata.model_type == "PyTorchModel":
              metadata = PyTorchMetadata(
                  **yaml.load(f)
              )  # pylint: disable=E1120
          return metadata
      return None
  
file_path: sagemaker-python-sdk/src/sagemaker/serve/save_retrive/version_1_0_0/metadata/metadata.py
imports: from __future__ import absolute_import
  from typing import Optional
  from dataclasses import dataclass, field
  from pathlib import Path
  import platform
  import yaml
label_desc: Use image node_id 1 for calling a global function with example usage: get_metadata(model_dir) and returns: None, metadata