code: def write_predictions(
      example_ids: np.ndarray,
      predictions_to_write: np.ndarray,
      file_prefix: str,
      model_type: str,
      label_list: List[LabelType],
      append: bool = False,
  ):
      """
      Write example IDs and predictions to a tab-separated file with given prefix.
  
      Parameters
      ----------
      example_ids : numpy.ndarray
          The IDs of the examples for which the predictions have been generated.
      predictions_to_write : numpy.ndarray
          The predictions to write out to the file.
      file_prefix : str
          The prefix for the output file. The output file will be named
          "<file_prefix>_predictions.tsv".
      model_type : str
          One of "classifier" or "regressor".
      label_list : List[:class:`skll.types.LabelType`]
          List of class labels, required if ``probability`` is ``True``.
      append : bool, default=False
          Should we append the current predictions to the file if it exists?
      """
      # create a new file starting with the given prefix
      prediction_file = f"{file_prefix}_predictions.tsv"
      with open(
          prediction_file, mode="w" if not append else "a", newline=""
      ) as predictionfh:
          # create a DictWriter with the appropriate field names
          if predictions_to_write.ndim > 1 and label_list:
              fieldnames = ["id"] + [label for label in label_list]
          else:
              fieldnames = ["id", "prediction"]
          writer = DictWriter(
              predictionfh, fieldnames=fieldnames, dialect=excel_tab
          )
  
          # write out the header unless we are appending
          if not append:
              writer.writeheader()
  
          # explicitly declare some types
          row: Dict[LabelType, Any]
  
          for example_id, pred in zip(
              example_ids, predictions_to_write
          ):
              # for regressors, we just write out the prediction as-is
              if model_type == "regressor":
                  row = {"id": example_id, "prediction": pred}
  
              # if we have an array as a prediction, it must be
              # a list of probabilities and if not, then it's
              # either a class label or an index
              else:
                  if isinstance(pred, np.ndarray):
                      row = {"id": example_id}
                      row.update(dict(zip(label_list, pred)))  # type: ignore
                  else:
                      row = {"id": example_id, "prediction": pred}
  
              # write out the row
              writer.writerow(row)
  
imports: from __future__ import annotations
  import inspect
  import logging
  import sys
  import time
  from collections import Counter, defaultdict
  from csv import DictWriter, excel_tab
  from functools import wraps
  from importlib import import_module
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Set, Tuple, Type, Union
  import joblib
  import numpy
  import scipy.sparse
  from sklearn.base import BaseEstimator, TransformerMixin
  from sklearn.feature_selection import SelectKBest
  from sklearn.metrics import accuracy_score, confusion_matrix, precision_recall_fscore_support
  from sklearn.model_selection import KFold, LeaveOneGroupOut, ShuffleSplit, StratifiedKFold
  from skll.data import FeatureSet
  from skll.metrics import _CUSTOM_METRICS, _PREDEFINED_CUSTOM_METRICS, use_score_func
  from skll.types import ComputeEvalMetricsResults, ConfusionMatrix, FeaturesetIterator, FoldMapping, IdType, IndexIterator, LabelType, PathOrStr, SparseFeatureMatrix
  from skll.utils.constants import CLASSIFICATION_ONLY_METRICS, CORRELATION_METRICS, REGRESSION_ONLY_METRICS, UNWEIGHTED_KAPPA_METRICS, WEIGHTED_KAPPA_METRICS
  from skll.version import VERSION
label_desc: Use image node_id 13 for calling a global function with example usage: write_predictions(example_ids, predictions_to_write, file_prefix, model_type, label_list, append) without return types