class_docstr: Stats for AMD GPU devices.
docstr: Parse stats from rocm-smi output.
docstr_tok: ["Parse","stats","from","rocm-smi","output","."]
code: def parse_stats(stats: Dict[str, str]) -> _Stats:
      """Parse stats from rocm-smi output."""
      parsed_stats: _Stats = {}
  
      try:
          parsed_stats["gpu"] = float(stats.get("GPU use (%)"))  # type: ignore
      except (TypeError, ValueError):
          logger.warning("Could not parse GPU usage as float")
      try:
          parsed_stats["memoryAllocated"] = float(stats.get("GPU memory use (%)"))  # type: ignore
      except (TypeError, ValueError):
          logger.warning(
              "Could not parse GPU memory allocation as float"
          )
      try:
          parsed_stats["temp"] = float(stats.get("Temperature (Sensor memory) (C)"))  # type: ignore
      except (TypeError, ValueError):
          logger.warning("Could not parse GPU temperature as float")
      try:
          parsed_stats["powerWatts"] = float(
              stats.get("Average Graphics Package Power (W)")  # type: ignore
          )
      except (TypeError, ValueError):
          logger.warning("Could not parse GPU power as float")
      try:
          parsed_stats["powerPercent"] = (
              float(stats.get("Average Graphics Package Power (W)"))  # type: ignore
              / float(stats.get("Max Graphics Package Power (W)"))  # type: ignore
              * 100
          )
      except (TypeError, ValueError):
          logger.warning(
              "Could not parse GPU average/max power as float"
          )
  
      return parsed_stats
  
imports: import json
  import logging
  import shutil
  import subprocess
  import sys
  import threading
  from collections import deque
  from typing import TYPE_CHECKING, Any, Dict, List, Union
  from wandb.sdk.lib import telemetry
  from .aggregators import aggregate_mean
  from .asset_registry import asset_registry
  from .interfaces import Interface, Metric, MetricsMonitor
label_desc: Use image node_id 2 for calling the GPUAMDStats obj's underlying member method code with example usage: obj.parse_stats(stats) and returns: parsed_stats