code: def _confusion_matrix_validate_predictions(
      y_true, y_pred, target_names
  ):
      """Validate input prediction data for a confusion matrix"""
      if any((val is None for val in (y_true, y_pred))):
          raise ValueError(
              "y_true and y_pred are needed to plot confusion " "matrix"
          )
  
      # calculate how many names you expect
      values = set(y_true).union(set(y_pred))
      expected_len = len(values)
  
      if target_names and (expected_len != len(target_names)):
          raise ValueError(
              (
                  "Data cointains {} different values, but target"
                  " names contains {} values.".format(
                      expected_len, len(target_names)
                  )
              )
          )
  
      if not target_names:
          values = list(values)
          values.sort()
          target_names = ["Class {}".format(v) for v in values]
  
      return target_names
  
imports: import json
  from pathlib import Path
  import numpy
  import matplotlib.pyplot
  from sklearn.metrics import confusion_matrix
  from sklearn_evaluation import __version__
  from ..telemetry import SKLearnEvaluationLogger
  from ..plot.matplotlib import bar
  from ..metrics import precision_at
  from ..None import compute
  from ..util import is_column_vector, is_row_vector, default_heatmap
  from sklearn_evaluation.plot.plot import AbstractPlot, AbstractComposedPlot
  from ..plot import _matrix
  from ploomber_core.exceptions import modify_exceptions
label_desc: Use image node_id 3 for calling a global function with example usage: _confusion_matrix_validate_predictions(y_true, y_pred, target_names) and returns: target_names