code: def test_NvidiaGpuResource():
      assert (
          len(NvidiaGpuResource.from_system()) >= 0
      )  # TODO: real from_system tests
  
      with pytest.raises(BentoMLConfigException):
          NvidiaGpuResource.validate(
              NvidiaGpuResource.from_system() + [1]
          )
      with pytest.raises(BentoMLConfigException):
          NvidiaGpuResource.validate([-2])
      with pytest.raises(BentoMLConfigException):
          NvidiaGpuResource.validate([-1])
  
      NvidiaGpuResource.validate([])
      # NvidiaGpuResource.validate(1)  # TODO: work out how to skip this on systems with no GPU
  
      assert NvidiaGpuResource.from_spec(1) == [0]
      assert NvidiaGpuResource.from_spec("5") == [0, 1, 2, 3, 4]
      assert NvidiaGpuResource.from_spec(1) == [0]
      assert NvidiaGpuResource.from_spec(2) == [0, 1]
      assert NvidiaGpuResource.from_spec("3") == [0, 1, 2]
      assert NvidiaGpuResource.from_spec([1, 3]) == [1, 3]
      assert NvidiaGpuResource.from_spec(["1", "3"]) == [1, 3]
      assert NvidiaGpuResource.from_spec(-1) == []
      assert NvidiaGpuResource.from_spec("-1") == []
  
      with pytest.raises(BentoMLConfigException):
          # Currently this is not supported and is considered invalid
          assert NvidiaGpuResource.from_spec("[1, 2, 3]") == [1, 2, 3]
  
      with pytest.raises(TypeError):
          NvidiaGpuResource.from_spec((1, 2, 3))
  
      with pytest.raises(BentoMLConfigException):
          NvidiaGpuResource.from_spec("100m")
  
      with pytest.raises(BentoMLConfigException):
          assert NvidiaGpuResource.from_spec(-2)
  
      with pytest.raises(BentoMLConfigException):
          assert NvidiaGpuResource.from_spec("-2")
  
      with pytest.raises(TypeError):
          NvidiaGpuResource.from_spec(1.5)
  
file_path: BentoML/tests/unit/_internal/test_resource.py
imports: import math
  import pytest
  import bentoml
  import bentoml.exceptions
  from bentoml._internal.resource import CpuResource
  from bentoml._internal.resource import NvidiaGpuResource
  from bentoml._internal.resource import Resource
  from bentoml._internal.resource import get_resource
  from bentoml._internal.resource import system_resources
  from bentoml.exceptions import BentoMLConfigException
label_desc: Use image node_id 4 for calling a global function with example usage: test_NvidiaGpuResource() without return types