def get_service(model_name: str, **config: Unpack[ServiceConfig]) -> Service[t.Any]:
    """
    Get a BentoML service instance from a LightGBM model.

    Args:
        model_name (``str``):
            The name of the model to get the service for.
        **config (``Unpack[ServiceConfig]``):
            Configuration options for the service.
    Returns:
        A BentoML service instance that wraps the LightGBM model.
    Example:

    .. code-block:: python

        import bentoml

        service = bentoml.lightgbm.get_service("my_lightgbm_model")
    """

    @bentoml.service(**config)
    class LightGBMService:
        bento_model = bentoml.models.get(model_name)

        def __init__(self) -> None:
            self.model = load_model(self.bento_model)

        @bentoml.api
        def predict(
            self,
            data: np.ndarray,
            start_iteration: int = 0,
            num_iteration: t.Optional[int] = None,
            raw_score: bool = False,
            pred_leaf: bool = False,
            pred_contrib: bool = False,
            data_has_header: bool = False,
            validate_features: bool = False,
            kwargs: dict[str, t.Any] | None = None,
        ) -> np.ndarray:
            from scipy.sparse import isspmatrix

            preds = self.model.predict(
                data=data,
                start_iteration=start_iteration,
                num_iteration=num_iteration,
                raw_score=raw_score,
                pred_leaf=pred_leaf,
                pred_contrib=pred_contrib,
                data_has_header=data_has_header,
                validate_features=validate_features,
                **(kwargs or {}),
            )
            if isinstance(preds, list):
                return np.asarray([m.toarray() for m in preds])
            elif isspmatrix(preds):
                return preds.toarray()
            return np.asarray(preds)

    return LightGBMService
Get a BentoML service instance from a LightGBM model.

Args:
model_name (``str``):
The name of the model to get the service for.
**config (``Unpack[ServiceConfig]``):
Configuration options for the service.
Returns:
A BentoML service instance that wraps the LightGBM model.
Example:

.. code-block:: python

import bentoml

service = bentoml.lightgbm.get_service("my_lightgbm_model")
src/_bentoml_impl/frameworks/lightgbm.py