code: def store_predictions_ray(
      boost_rounds_per_train_step: int,
  ) -> Callable:
      """Create a callback that records the predictions of the model on the training data in ``additional_results``
      returned from a LightGBM on Ray model. Only the predictions of the last iteration are stored.
  
      Args:
          boost_rounds_per_train_step: number of boosting rounds per train step, used to compute last iteration.
  
      Returns:
          A callback that records the predictions of the model in ``additional_results``.
      """
  
      def _callback(env: CallbackEnv) -> None:
          if env.iteration < boost_rounds_per_train_step - 1:
              # only store last iteration
              return
  
          from xgboost_ray.session import put_queue
  
          # NOTE: have to copy because the buffer is reused in each iteration
          # NOTE: buffer contains raw logits because we use custom objective functions for binary/multiclass.
          preds = env.model._Booster__inner_predict(data_idx=0).copy()
  
          batch_size = preds.size // env.model._Booster__num_class
          if env.model._Booster__num_class > 1:
              preds = preds.reshape(
                  batch_size, env.model._Booster__num_class, order="F"
              )
          preds = torch.from_numpy(preds)
  
          # put the predictions into the actor's queue
          put_queue(TrainLogits(preds))
  
      return _callback
  
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 7 for calling a global function with example usage: store_predictions_ray(boost_rounds_per_train_step) and returns: _callback