code: def multiclass_objective(
      y_true: npt.NDArray,
      y_pred: npt.NDArray,
      weight: npt.NDArray = None,
  ) -> Tuple[npt.NDArray, npt.NDArray]:
      """Multi-class objective function for LightGBM. Computes the softmax cross-entropy loss.
  
      Args:
          y_true: 1D array of true labels of shape (n_samples,).
          y_pred: 1D array of raw predictions of shape (n_samples * n_classes,).
          weight: 1D array of weights of shape (n_samples,).
  
      Returns:
          1D array of gradients of shape (n_samples * n_classes,) and 1D array of hessians
          of shape (n_samples * n_classes,).
  
      References:
      - https://github.com/microsoft/LightGBM/blob/9afd8b/tests/python_package_test/test_sklearn.py#L1296
      - https://github.com/microsoft/LightGBM/blob/9afd8b/tests/python_package_test/utils.py#L142
      """
      # TODO: remove reshaping once https://github.com/microsoft/LightGBM/pull/4925 is released
      y_pred = y_pred.reshape(y_true.shape[0], -1, order="F")
  
      num_rows, num_class = y_pred.shape
      prob = softmax(y_pred)
      grad_update = np.zeros_like(prob)
      grad_update[np.arange(num_rows), y_true.astype(np.int32)] = -1.0
      grad = prob + grad_update
      factor = num_class / (num_class - 1)
      hess = factor * prob * (1 - prob)
      if weight is not None:
          weight2d = weight.reshape(-1, 1)
          grad *= weight2d
          hess *= weight2d
  
      # TODO: remove ravel once https://github.com/microsoft/LightGBM/pull/4925 is released
      grad = grad.ravel(order="F")
      hess = hess.ravel(order="F")
  
      return grad, hess
  
imports: from dataclasses import dataclass
  from typing import Callable, Dict, Tuple, Union
  import lightgbm
  import numpy
  import torch
  from lightgbm.callback import CallbackEnv
  from numpy import typing
  from ludwig.constants import NUMBER
  from ludwig.features.base_feature import BaseFeatureMixin, OutputFeature
  from ludwig.features.category_feature import CategoryOutputFeature
  from ludwig.models.base import BaseModel
label_desc: Use image node_id 5 for calling a global function with example usage: multiclass_objective(y_true, y_pred, weight) and returns: grad,  hess