code: def test_summary(self, monkeypatch, rules):
      def mock_load(*args, **kwargs):
          return [TextClassificationRecord(text="test")] * 4
  
      monkeypatch.setattr(
          "argilla.labeling.text_classification.weak_labels.load",
          mock_load,
      )
  
      def mock_apply(self, *args, **kwargs):
          weak_label_matrix = np.array(
              [[0, 1, -1], [-1, 0, -1], [-1, -1, -1], [1, 1, -1]],
              dtype=np.short,
          )
          # weak_label_matrix = np.random.randint(-1, 30, (int(1e5), 50), dtype=np.short)
          annotation_array = np.array([-1, -1, -1, -1], dtype=np.short)
          # annotation_array = np.random.randint(-1, 30, int(1e5), dtype=np.short)
          label2int = {None: -1, "negative": 0, "positive": 1}
          # label2int = {k: v for k, v in zip(["None"]+list(range(30)), list(range(-1, 30)))}
          return weak_label_matrix, annotation_array, label2int
  
      monkeypatch.setattr(WeakLabels, "_apply_rules", mock_apply)
  
      weak_labels = WeakLabels(rules=rules, dataset="mock")
  
      summary = weak_labels.summary()
      expected = pd.DataFrame(
          {
              "label": [
                  {"negative", "positive"},
                  {"negative", "positive"},
                  set(),
                  {"negative", "positive"},
              ],
              "coverage": [2.0 / 4, 3.0 / 4, 0, 3.0 / 4],
              "overlaps": [2.0 / 4, 2.0 / 4, 0, 2.0 / 4],
              "conflicts": [1.0 / 4, 1.0 / 4, 0, 1.0 / 4],
          },
          index=["first_rule", "rule_1", "argilla_rule", "total"],
      )
      assert_frame_equal(summary, expected)
  
      summary = weak_labels.summary(normalize_by_coverage=True)
      expected = pd.DataFrame(
          {
              "label": [
                  {"negative", "positive"},
                  {"negative", "positive"},
                  set(),
                  {"negative", "positive"},
              ],
              "coverage": [2.0 / 4, 3.0 / 4, 0, 3.0 / 4],
              "overlaps": [2.0 / 2, 2.0 / 3, 0, 2.0 / 3],
              "conflicts": [1.0 / 2, 1.0 / 3, 0, 1.0 / 3],
          },
          index=["first_rule", "rule_1", "argilla_rule", "total"],
      )
      assert_frame_equal(summary, expected)
  
      summary = weak_labels.summary(annotation=np.array([1, -1, 0, 1]))
      expected = pd.DataFrame(
          {
              "label": [
                  {"negative", "positive"},
                  {"negative", "positive"},
                  set(),
                  {"negative", "positive"},
              ],
              "coverage": [2.0 / 4, 3.0 / 4, 0, 3.0 / 4],
              "annotated_coverage": [2.0 / 3, 2.0 / 3, 0, 2.0 / 3],
              "overlaps": [2.0 / 4, 2.0 / 4, 0, 2.0 / 4],
              "conflicts": [1.0 / 4, 1.0 / 4, 0, 1.0 / 4],
              "correct": [1, 2, 0, 3],
              "incorrect": [1, 0, 0, 1],
              "precision": [1.0 / 2, 2 / 2, np.nan, 3.0 / 4],
          },
          index=["first_rule", "rule_1", "argilla_rule", "total"],
      )
      # The "correct" and "incorrect" columns from `expected_summary` may infer a different
      # dtype than `weak_multi_labels.summary()` returns.
      assert_frame_equal(summary, expected, check_dtype=False)
  
imports: import sys
  from typing import Callable, List, Optional, Union
  import numpy
  import pandas
  import pytest
  from argilla.client.models import TextClassificationRecord
  from argilla.client.sdk.text_classification.models import CreationTextClassificationRecord, TextClassificationBulkData
  from argilla.labeling.text_classification import WeakLabels, WeakMultiLabels
  from argilla.labeling.text_classification.rule import Rule
  from argilla.labeling.text_classification.weak_labels import DuplicatedRuleNameError, MissingLabelError, MultiLabelError, NoRecordsFoundError, NoRulesFoundError, WeakLabelsBase
  from argilla.server.commons.models import TaskType
  from pandas.testing import assert_frame_equal
  from tests.integration.helpers import SecuredClient
label_desc: Use image node_id 5 for calling the TestWeakLabels obj's underlying member method code with example usage: obj.test_summary(monkeypatch, rules) and returns: unknown, weak_label_matrix,  annotation_array,  label2int