code: def test_condition_misclassified_samples_lower_than_fails(
      tweet_emotion_train_test_textdata,
      tweet_emotion_train_test_predictions,
  ):
      # Arrange
      _, test_ds = tweet_emotion_train_test_textdata
      _, test_preds = tweet_emotion_train_test_predictions
  
      threshold = 0.01
      thresh_samples = round(np.ceil(threshold * len(test_ds)))
  
      check = ConfusionMatrixReport().add_condition_misclassified_samples_lower_than_condition(
          misclassified_samples_threshold=threshold
      )
  
      # Act
      result = check.run(test_ds, predictions=test_preds)
  
      class_names = result.value.columns
      confusion_matrix = result.value.to_numpy()
      m, n = confusion_matrix.shape[0], confusion_matrix.shape[1]
  
      n_cells_above_thresh = 0
      max_misclassified_cell_idx = (0, 1)
  
      # Looping over the confusion matrix and checking only the misclassified cells
      for i in range(m):
          for j in range(n):
              # omitting the principal axis of the confusion matrix
              if i != j:
                  n_samples = confusion_matrix[i][j]
  
                  if n_samples > thresh_samples:
                      n_cells_above_thresh += 1
  
                      x, y = max_misclassified_cell_idx
                      max_misclassified_samples = confusion_matrix[x][y]
                      if n_samples > max_misclassified_samples:
                          max_misclassified_cell_idx = (i, j)
  
      x, y = max_misclassified_cell_idx
      max_misclassified_samples = confusion_matrix[x][y]
      max_misclassified_samples_ratio = max_misclassified_samples / len(
          test_ds
      )
  
      # Assert
      assert_that(
          result.conditions_results[0],
          equal_condition_result(
              is_pass=False,
              name=f"Misclassified cell size lower than {format_percent(threshold)} of the total samples",
              details=f"Detected {n_cells_above_thresh} misclassified confusion matrix cell(s) each one "
              f"containing more than {format_percent(threshold)} of the data. "
              f"Largest misclassified cell ({format_percent(max_misclassified_samples_ratio)} of the data) "
              f'is samples with a true value of "{class_names[x]}" and a predicted value of "{class_names[y]}".',
          ),
      )
  
file_path: deepchecks/tests/nlp/checks/model_evaluation/confusion_matrix_test.py
imports: import numpy
  from hamcrest import assert_that, close_to, equal_to
  from deepchecks.core.condition import ConditionCategory
  from deepchecks.nlp.checks.model_evaluation import ConfusionMatrixReport
  from deepchecks.utils.strings import format_number, format_percent
  from tests.base.utils import equal_condition_result
label_desc: Use image node_id 7 for calling a global function with example usage: test_condition_misclassified_samples_lower_than_fails(tweet_emotion_train_test_textdata, tweet_emotion_train_test_predictions) without return types