code: def _validate_text_classification(
      *,
      dataset: "TextData",
      predictions: Any = None,
      probabilities: Any = None,
      n_of_classes: Optional[int] = None,
      eps: float = 1e-3,
  ) -> Tuple[
      Optional[np.ndarray],  # predictions
      Optional[np.ndarray],  # probabilities
  ]:
      if predictions is not None:
          format_error_message = (
              f'Check requires predictions for the "{dataset.name}" dataset '
              "to be of a type sequence[str] | sequence[int]"
          )
          if not is_sequence_not_str(predictions):
              raise ValidationError(format_error_message)
          if len(predictions) != dataset.n_samples:
              raise ValidationError(
                  f'Check requires predictions for the "{dataset.name}" dataset '
                  f"to have {dataset.n_samples} rows, same as dataset"
              )
          try:
              predictions = np.array(predictions, dtype="object")
          except ValueError as e:
              raise ValidationError(
                  "Failed to cast predictions to a numpy array. "
                  f"{format_error_message}"
              ) from e
          else:
              if predictions.ndim == 2 and predictions.shape[1] == 1:
                  predictions = predictions[:, 0]
              if predictions.ndim != 1:
                  raise ValidationError(format_error_message)
  
              predictions = np.array(
                  [
                      str(it) if it is not None else None
                      for it in predictions
                  ],
                  dtype="object",
              )
  
      if probabilities is not None:
          format_error_message = (
              f'Check requires classification probabilities for the "{dataset.name}" '
              "dataset to be of a type sequence[sequence[float]] that can be cast to "
              "a 2D numpy array of shape (n_samples, n_classes)"
          )
          if len(probabilities) != dataset.n_samples:
              raise ValidationError(
                  f'Check requires classification probabilities for the "{dataset.name}" '
                  f"dataset to have {dataset.n_samples} rows, same as dataset"
              )
          try:
              probabilities = np.array(probabilities, dtype="float")
          except ValueError as e:
              raise ValidationError(
                  "Failed to cast probabilities to a numpy array. "
                  f"{format_error_message}"
              ) from e
          else:
              if len(probabilities.shape) != 2:
                  raise ValidationError(format_error_message)
              if (
                  n_of_classes is not None
                  and probabilities.shape[1] != n_of_classes
              ):
                  raise ValidationError(
                      f'Check requires classification probabilities for the "{dataset.name}" dataset '
                      f"to have {n_of_classes} columns, same as the number of classes"
                  )
              if any(abs(probabilities.sum(axis=1) - 1) > eps):
                  # TODO: better message
                  raise ValidationError(
                      f'Check requires classification probabilities for the "{dataset.name}" '
                      f"dataset to be probabilities and sum to 1 for each row"
                  )
  
      return predictions, probabilities
  
imports: import collections
  from typing import TYPE_CHECKING, Any, Dict, List, NamedTuple, Optional, Sequence, Set, Tuple, Type, cast
  import numpy
  import pandas
  from deepchecks.core.errors import DeepchecksValueError, ValidationError
  from deepchecks.nlp.task_type import TaskType, TTextLabel
  from deepchecks.utils.logger import get_logger
  from deepchecks.utils.metrics import is_label_none
  from deepchecks.utils.type_inference import infer_categorical_features, infer_numerical_features
  from deepchecks.utils.validation import is_sequence_not_str
label_desc: Use image node_id 8 for calling a global function with example usage: _validate_text_classification() and returns: predictions,  probabilities