code: def _construct_s_and_psx(
      records: List[TextClassificationRecord],
  ) -> Tuple[np.ndarray, np.ndarray]:
      """Helper function to construct the s array and psx matrix.
  
      Args:
          records: List of records.
  
      Returns:
          A tuple containing the s array and the psx matrix.
  
      Raises:
          MissingPredictionError: If predictions are missing for certain labels.
      """
      predictions = []
      labels = set()  # use a dict to preserve the order
      for rec in records:
          predictions.append(
              {pred[0]: pred[1] for pred in rec.prediction}
          )
          labels.update(predictions[-1].keys())
      labels_mapping = {
          label: i for i, label in enumerate(sorted(labels))
      }
  
      s = (
          np.empty(len(records), dtype=object)
          if records[0].multi_label
          else np.zeros(len(records), dtype=np.short)
      )
      psx = np.zeros((len(records), len(labels)), dtype=float)
  
      for i, rec, pred in zip(
          range(len(records)), records, predictions
      ):
          try:
              psx[i] = [pred[label] for label in labels_mapping]
          except KeyError as error:
              raise MissingPredictionError(
                  f"It seems a prediction for {error} is missing in the following record: {rec}"
              )
  
          try:
              s[i] = (
                  [labels_mapping[label] for label in rec.annotation]
                  if rec.multi_label
                  else labels_mapping[rec.annotation]
              )
          except KeyError as error:
              raise MissingPredictionError(
                  f"It seems predictions are missing for the label {error}!"
              )
  
      return s, psx
  
imports: import logging
  import warnings
  from enum import Enum
  from typing import Dict, List, Optional, Tuple, Union
  import numpy
  from pkg_resources import parse_version
  from argilla.client.datasets import DatasetForTextClassification
  from argilla.client.models import TextClassificationRecord
  from argilla.utils.dependency import requires_dependencies
label_desc: Use image node_id 3 for calling a global function with example usage: _construct_s_and_psx(records) and returns: s,  psx