code: def from_spec(cls, spec: int | str | list[int | str]) -> list[int]:
      if not isinstance(spec, (int, str, list)):
          raise TypeError(
              "NVidia GPU device IDs must be int, str or a list specifing the exact GPUs to use."
          )
  
      try:
          if isinstance(spec, int):
              if spec < -1:
                  raise ValueError
              return list(range(spec))
          elif isinstance(spec, str):
              return cls.from_spec(int(spec))
          else:
              return [int(x) for x in spec]
      except ValueError:
          raise BentoMLConfigException(
              f"Invalid NVidia GPU resource limit '{spec}'. "
          )
  
imports: from __future__ import annotations
  import functools
  import logging
  import math
  import os
  import re
  import typing
  from abc import ABC
  from abc import abstractmethod
  import psutil
  from ..exceptions import BentoMLConfigException
label_desc: Use image node_id 1 for calling the NvidiaGpuResource obj's underlying member method code with example usage: obj.from_spec(cls, spec) and returns: list, cls, unknown