parameters: (y_pred, y, skip_channel=True)
return_statement: return np.stack([tp, fp, tn, fn], axis=-1)
docstring: The confusion matrix is calculated. An array of shape [BC4] is returned. The third dimension represents each channel
      of each sample in the input batch.Where B is the batch size and C is the number of classes to be calculated.
  
      Args:
          y_pred (ndarray): input data to compute. It must be one-hot format and first dim is batch.
                               The values should be binarized.
          y (ndarray): ground truth to compute the metric. It must be one-hot format and first dim is batch.
                      The values should be binarized.
          skip_channel (bool): whether to skip metric computation on the first channel of the predicted output.
                              Default: True.
  
      Raises:
          ValueError: when `y_pred` and `y` have different shapes.
docstring_summary: The confusion matrix is calculated. An array of shape [BC4] is returned. The third dimension represents each channel
      of each sample in the input batch.Where B is the batch size and C is the number of classes to be calculated.
docstring_tokens: The confusion matrix is calculated . An array of shape [ BC4 ] is returned . The third dimension represents each channel of each sample in the input batch . Where B is the batch size and C is the number of classes to be calculated .
function: def _get_confusion_matrix(y_pred, y, skip_channel=True):
      """
      The confusion matrix is calculated. An array of shape [BC4] is returned. The third dimension represents each channel
      of each sample in the input batch.Where B is the batch size and C is the number of classes to be calculated.
  
      Args:
          y_pred (ndarray): input data to compute. It must be one-hot format and first dim is batch.
                               The values should be binarized.
          y (ndarray): ground truth to compute the metric. It must be one-hot format and first dim is batch.
                      The values should be binarized.
          skip_channel (bool): whether to skip metric computation on the first channel of the predicted output.
                              Default: True.
  
      Raises:
          ValueError: when `y_pred` and `y` have different shapes.
      """
  
      if not skip_channel:
          y = y[:, 1:] if y.shape[1] > 1 else y
          y_pred = y_pred[:, 1:] if y_pred.shape[1] > 1 else y_pred
  
      y = y.astype(float)
      y_pred = y_pred.astype(float)
      validator.check('y_shape', y.shape, 'y_pred_shape', y_pred.shape)
      batch_size, n_class = y_pred.shape[:2]
      y_pred = y_pred.reshape(batch_size, n_class, -1)
      y = y.reshape(batch_size, n_class, -1)
      tp = ((y_pred + y) == 2).astype(float)
      tn = ((y_pred + y) == 0).astype(float)
      tp = tp.sum(axis=2)
      tn = tn.sum(axis=2)
      p = y.sum(axis=2)
      n = y.shape[-1] - p
      fn = p - tp
      fp = n - tn
  
      return np.stack([tp, fp, tn, fn], axis=-1)
function_tokens: def _get_confusion_matrix ( y_pred , y , skip_channel = True ) : if not skip_channel : y = y [ : , 1 : ] if y . shape [ 1 ] > 1 else y y_pred = y_pred [ : , 1 : ] if y_pred . shape [ 1 ] > 1 else y_pred y = y . astype ( float ) y_pred = y_pred . astype ( float ) validator . check ( 'y_shape' , y . shape , 'y_pred_shape' , y_pred . shape ) batch_size , n_class = y_pred . shape [ : 2 ] y_pred = y_pred . reshape ( batch_size , n_class , - 1 ) y = y . reshape ( batch_size , n_class , - 1 ) tp = ( ( y_pred + y ) == 2 ) . astype ( float ) tn = ( ( y_pred + y ) == 0 ) . astype ( float ) tp = tp . sum ( axis = 2 ) tn = tn . sum ( axis = 2 ) p = y . sum ( axis = 2 ) n = y . shape [ - 1 ] - p fn = p - tp fp = n - tn return np . stack ( [ tp , fp , tn , fn ] , axis = - 1 )