code: def _parse_unit(value, target_unit, all_units):
      if not isinstance(value, str):
          return value
      value = value.lower()
      for unit, factor in all_units.items():
          if value.endswith(unit):
              number = value[: -len(unit)]
              value = float(number) * factor
              return math.ceil(value / all_units[target_unit])
      supported_units = ", ".join(all_units.keys())
      raise ValueError(
          f'Bad unit in "{value}", supported units are {supported_units}'
      )
  
file_path: nni/nni/experiment/config/utils/public.py
imports: import dataclasses
  import math
  from pathlib import Path
  from typing import Union
label_desc: Use image node_id 6 for calling a global function with example usage: _parse_unit(value, target_unit, all_units) and returns: value, math