code: def test_apply(
      self,
      monkeypatch,
      log_dataset,
      rules,
      label2int,
      expected_label2int,
      expected_matrix,
      expected_annotation_array,
  ):
      if label2int == {}:
          with pytest.raises(
              MissingLabelError, match="required abstention label"
          ):
              WeakLabels(
                  rules=rules, dataset=log_dataset, label2int=label2int
              )
          return
      elif label2int == {None: -1}:
          with pytest.raises(
              MissingLabelError, match="annotation label"
          ):
              WeakLabels(
                  rules=rules, dataset=log_dataset, label2int=label2int
              )
          return
      elif label2int == {None: -1, "negative": 0}:
          with pytest.raises(MissingLabelError, match="weak label"):
              WeakLabels(
                  rules=rules, dataset=log_dataset, label2int=label2int
              )
          return
  
      weak_labels = WeakLabels(
          rules=rules, dataset=log_dataset, label2int=label2int
      )
  
      # check that all `Rule.apply`s are called
      assert weak_labels._rules[-1]._matching_ids == {1: None, 2: None}
  
      assert weak_labels.label2int == expected_label2int
      assert weak_labels.int2label == {
          v: k for k, v in expected_label2int.items()
      }
      assert (weak_labels.matrix() == expected_matrix).all()
      assert (
          weak_labels._annotation == expected_annotation_array
      ).all()
  
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 2 for calling the TestWeakLabels obj's underlying member method code with example usage: obj.test_apply(monkeypatch, log_dataset, rules, label2int, expected_label2int, expected_matrix, expected_annotation_array) without return types