code: def get_runnable(
      bento_model: bentoml.Model,
  ) -> t.Type[bentoml.Runnable]:
      """
      Private API: use :obj:`~bentoml.Model.to_runnable` instead.
      """
  
      class XGBoostRunnable(bentoml.Runnable):
          SUPPORTED_RESOURCES = ("nvidia.com/gpu", "cpu")
          SUPPORTS_CPU_MULTI_THREADING = True
  
          def __init__(self):
              super().__init__()
              self.model = load_model(bento_model)
  
              self.booster = (
                  self.model
                  if isinstance(self.model, xgb.Booster)
                  else self.model.get_booster()
              )
  
              # check for resources
              if os.getenv("CUDA_VISIBLE_DEVICES") not in (
                  None,
                  "",
                  "-1",
              ):
                  self.booster.set_param({"predictor": "gpu_predictor", "gpu_id": 0})  # type: ignore (incomplete XGBoost types)
              else:
                  nthreads = os.getenv("OMP_NUM_THREADS")
                  if nthreads is not None and nthreads != "":
                      nthreads = max(int(nthreads), 1)
                  else:
                      nthreads = 1
                  self.booster.set_param({"predictor": "cpu_predictor", "nthread": nthreads})  # type: ignore (incomplete XGBoost types)
  
              self.predict_fns: dict[str, t.Callable[..., t.Any]] = {}
              for method_name in bento_model.info.signatures:
                  try:
                      self.predict_fns[method_name] = getattr(
                          self.model, method_name
                      )
                  except AttributeError:
                      raise InvalidArgument(
                          f"No method with name {method_name} found for XGBoost model of type {self.model.__class__}"
                      )
  
      def add_runnable_method(
          method_name: str, options: ModelSignature
      ):
          def _run(
              self: XGBoostRunnable,
              input_data: ext.NpNDArray
              | ext.PdDataFrame,  # TODO: add support for DMatrix
              *args: t.Any,
              **kwargs: t.Any,
          ) -> ext.NpNDArray:
              if isinstance(self.model, xgb.Booster):
                  inp = xgb.DMatrix(input_data)
              else:
                  inp = input_data
  
              res = self.predict_fns[method_name](inp, *args, **kwargs)
              return np.asarray(res)  # type: ignore (incomplete np types)
  
          XGBoostRunnable.add_method(
              _run,
              name=method_name,
              batchable=options.batchable,
              batch_dim=options.batch_dim,
              input_spec=options.input_spec,
              output_spec=options.output_spec,
          )
  
      for method_name, options in bento_model.info.signatures.items():
          add_runnable_method(method_name, options)
  
      return XGBoostRunnable
  
imports: from __future__ import annotations
  import logging
  import os
  import typing
  from types import ModuleType
  from typing import TYPE_CHECKING
  import attr
  import numpy
  import bentoml
  from bentoml import Tag
  from bentoml.exceptions import BentoMLException
  from bentoml.exceptions import InvalidArgument
  from bentoml.exceptions import MissingDependencyException
  from bentoml.exceptions import NotFound
  from bentoml.models import ModelOptions
  from ..models.model import ModelContext
  from ..utils.pkg import get_pkg_version
label_desc: Use image node_id 4 for calling a global function with example usage: get_runnable(bento_model) and returns: XGBoostRunnable, np