code: def _calc_preds(
      model, X, pred_func, from_model, predict_kwds=None, chunk_size=-1
  ):
      """
      Calculate model predictions with an optional chunk size.
  
      Parameters
      ----------
      model : object
          Trained model object.
      X : array-like
          Input data to make predictions on.
      pred_func : callable
          Function to make predictions using the model.
      from_model : bool
          Whether the pred_func is obtained from the model or provided by the user.
      predict_kwds : dict
          Additional keyword arguments to pass to pred_func.
      chunk_size : int, optional, default=-1
          Number of samples to predict at a time. If -1, predict all samples at once.
  
      Returns
      -------
      np.array
          Predictions made by the model.
      """
      total = len(X)
      if predict_kwds is None:
          predict_kwds = {}
  
      if 0 < chunk_size < total:
          preds = np.concatenate(
              [
                  _calc_preds_each(
                      model,
                      X[i : i + chunk_size],
                      pred_func,
                      from_model,
                      predict_kwds,
                  )
                  for i in range(0, total, chunk_size)
              ]
          )
      else:
          preds = _calc_preds_each(
              model, X, pred_func, from_model, predict_kwds
          )
  
      return preds
  
imports: import numpy
  import pandas
  import psutil
label_desc: Use image node_id 18 for calling a global function with example usage: _calc_preds(model, X, pred_func, from_model, predict_kwds, chunk_size) and returns: preds