code: def get_resource(
      resources: dict[str, t.Any],
      resource_kind: str,
      validate: bool = True,
  ) -> t.Any:
      if resource_kind not in _RESOURCE_REGISTRY:
          raise BentoMLConfigException(
              f"Unknown resource kind '{resource_kind}'."
          )
  
      resource: t.Type[Resource[t.Any]] = _RESOURCE_REGISTRY[
          resource_kind
      ]
  
      if resource_kind in resources:
          if resources[resource_kind] == "system":
              return resource.from_system()
          else:
              res = resource.from_spec(resources[resource_kind])
              if validate:
                  resource.validate(res)
              return res
      else:
          return None
  
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 a global function with example usage: get_resource(resources, resource_kind, validate) and returns: None, resource, res