class_docstr: Base class for the weak label classes.
  
  Tries to facilitate the implementations, avoids code duplications.
  
  Args:
      dataset: Name of the dataset to which the rules will be applied.
      rules: A list of rules (labeling functions). They must return a string, or ``None`` in case of abstention.
          If None, we will use the rules of the dataset (Default).
      ids: An optional list of record ids to filter the dataset before applying the rules.
      query: An optional ElasticSearch query with the
          `query string syntax <https://docs.argilla.io/en/latest/practical_guides/filter_dataset.html>`_
          to filter the dataset before applying the rules.
  
  Raises:
      NoRulesFoundError: When you do not provide rules, and the dataset has no rules either.
      DuplicatedRuleNameError: When you provided multiple rules with the same name.
      NoRecordsFoundError: When the filtered dataset is empty.
class_docstr_tok: ["Base","class","for","the","weak","label","classes",".","Tries","to","facilitate","the","implementations",",","avoids","code","duplications",".","Args",":","dataset",":","Name","of","the","dataset","to","which","the","rules","will","be","applied",".","rules",":","A","list","of","rules","(","labeling","functions",")",".","They","must","return","a","string",",","or","``","None","``","in","case","of","abstention",".","If","None",",","we","will","use","the","rules","of","the","dataset","(","Default",")",".","ids",":","An","optional","list","of","record","ids","to","filter","the","dataset","before","applying","the","rules",".","query",":","An","optional","ElasticSearch","query","with","the","`","query","string","syntax","<","https",":","\/\/docs.argilla.io\/en\/latest\/practical_guides\/filter_dataset.html",">","`","_","to","filter","the","dataset","before","applying","the","rules",".","Raises",":","NoRulesFoundError",":","When","you","do","not","provide","rules",",","and","the","dataset","has","no","rules","either",".","DuplicatedRuleNameError",":","When","you","provided","multiple","rules","with","the","same","name",".","NoRecordsFoundError",":","When","the","filtered","dataset","is","empty","."]
code: def __init__(
      self,
      dataset: str,
      rules: Optional[List[Callable]] = None,
      ids: Optional[List[Union[int, str]]] = None,
      query: Optional[str] = None,
  ):
      if not isinstance(dataset, str):
          raise TypeError(
              f"The name of the dataset must be a string, but you provided: {dataset}"
          )
      self._dataset = dataset
  
      self._rules = rules or load_rules(dataset)
      if not self._rules:
          raise NoRulesFoundError(
              f"No rules were found in the given dataset '{dataset}'"
          )
  
      self._rules_index2name = {
          # covers our Rule class, snorkel's LabelingFunction class and arbitrary methods
          index: (
              getattr(rule, "name", None)
              or (
                  getattr(rule, "__name__", None)
                  # allow multiple lambda functions
                  if getattr(rule, "__name__", None) != "<lambda>"
                  else None
              )
              or f"rule_{index}"
          )
          for index, rule in enumerate(self._rules)
      }
      # raise error if there are duplicates
      counts = Counter(self._rules_index2name.values())
      if len(counts.keys()) < len(self._rules):
          raise DuplicatedRuleNameError(
              f"Following rule names are duplicated x times: { {key: val for key, val in counts.items() if val > 1} }"
              " Please make sure to provide unique rule names."
          )
      self._rules_name2index = {
          val: key for key, val in self._rules_index2name.items()
      }
  
      # load records and check compatibility
      self._records: DatasetForTextClassification = load(
          dataset, query=query, ids=ids, include_vectors=False
      )
      if not self._records:
          raise NoRecordsFoundError(
              f"No records found in dataset '{dataset}'"
              + (f" with query '{query}'" if query else "")
              + (" and" if query and ids else "")
              + (f" with ids {ids}." if ids else ".")
          )
  
      self._matrix = (
          self._extended_matrix
      ) = self._extension_queries = None
  
imports: import warnings
  from collections import Counter
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import pandas
  from tqdm.auto import tqdm
  from argilla import load
  from argilla.client.datasets import DatasetForTextClassification
  from argilla.client.models import TextClassificationRecord
  from argilla.labeling.text_classification.rule import Rule, load_rules
label_desc: Use image node_id 1 to create a new WeakLabelsBase object  with example: obj = WeakLabelsBase(dataset, rules, ids, query)