class_docstr: The label model by `Snorkel <https://github.com/snorkel-team/snorkel/>`__.
  
  .. note:: It is not suited for multi-label classification and does not support it!
  
  Args:
      weak_labels: A `WeakLabels` object containing the weak labels and records.
      verbose: Whether to show print statements
      device: What device to place the model on ('cpu' or 'cuda:0', for example).
          Passed on to the `torch.Tensor.to()` calls.
  
  Examples:
      >>> from argilla.labeling.text_classification import WeakLabels
      >>> weak_labels = WeakLabels(dataset="my_dataset")
      >>> label_model = Snorkel(weak_labels)
      >>> label_model.fit()
      >>> records = label_model.predict()
class_docstr_tok: ["The","label","model","by","`","Snorkel","<","https",":","\/\/github.com\/snorkel-team\/snorkel\/",">","`","__",".","..","note",":",":","It","is","not","suited","for","multi-label","classification","and","does","not","support","it","!","Args",":","weak_labels",":","A","`","WeakLabels","`","object","containing","the","weak","labels","and","records",".","verbose",":","Whether","to","show","print","statements","device",":","What","device","to","place","the","model","on","(","'cpu","'","or","'cuda:0","'",",","for","example",")",".","Passed","on","to","the","`","torch.Tensor.to","(",")","`","calls",".","Examples",":",">",">",">","from","argilla.labeling.text_classification","import","WeakLabels",">",">",">","weak_labels","=","WeakLabels","(","dataset=","''","my_dataset","''",")",">",">",">","label_model","=","Snorkel","(","weak_labels",")",">",">",">","label_model.fit","(",")",">",">",">","records","=","label_model.predict","(",")"]
docstr: Returns a list of records that contain the predictions of the label model
  
  Args:
      include_annotated_records: Whether to include annotated records.
      include_abstentions: Whether to include records in the output, for which the label model abstained.
      prediction_agent: String used for the ``prediction_agent`` in the returned records.
      tie_break_policy: Policy to break ties. You can choose among three policies:
  
          - `abstain`: Do not provide any prediction
          - `random`: randomly choose among tied option using deterministic hash
          - `true-random`: randomly choose among the tied options. NOTE: repeated runs may have slightly different results due to differences in broken ties
  
          The last two policies can introduce quite a bit of noise, especially when the tie is among many labels,
          as is the case when all the labeling functions (rules) abstained.
  
  Returns:
      A dataset of records that include the predictions of the label model.
docstr_tok: ["Returns","a","list","of","records","that","contain","the","predictions","of","the","label","model","Args",":","include_annotated_records",":","Whether","to","include","annotated","records",".","include_abstentions",":","Whether","to","include","records","in","the","output",",","for","which","the","label","model","abstained",".","prediction_agent",":","String","used","for","the","``","prediction_agent","``","in","the","returned","records",".","tie_break_policy",":","Policy","to","break","ties",".","You","can","choose","among","three","policies",":","-","`","abstain","`",":","Do","not","provide","any","prediction","-","`","random","`",":","randomly","choose","among","tied","option","using","deterministic","hash","-","`","true-random","`",":","randomly","choose","among","the","tied","options",".","NOTE",":","repeated","runs","may","have","slightly","different","results","due","to","differences","in","broken","ties","The","last","two","policies","can","introduce","quite","a","bit","of","noise",",","especially","when","the","tie","is","among","many","labels",",","as","is","the","case","when","all","the","labeling","functions","(","rules",")","abstained",".","Returns",":","A","dataset","of","records","that","include","the","predictions","of","the","label","model","."]
code: def predict(
      self,
      include_annotated_records: bool = False,
      include_abstentions: bool = False,
      prediction_agent: str = "Snorkel",
      tie_break_policy: Union[TieBreakPolicy, str] = "abstain",
  ) -> DatasetForTextClassification:
      """Returns a list of records that contain the predictions of the label model
  
      Args:
          include_annotated_records: Whether to include annotated records.
          include_abstentions: Whether to include records in the output, for which the label model abstained.
          prediction_agent: String used for the ``prediction_agent`` in the returned records.
          tie_break_policy: Policy to break ties. You can choose among three policies:
  
              - `abstain`: Do not provide any prediction
              - `random`: randomly choose among tied option using deterministic hash
              - `true-random`: randomly choose among the tied options. NOTE: repeated runs may have slightly different results due to differences in broken ties
  
              The last two policies can introduce quite a bit of noise, especially when the tie is among many labels,
              as is the case when all the labeling functions (rules) abstained.
  
      Returns:
          A dataset of records that include the predictions of the label model.
      """
      if isinstance(tie_break_policy, str):
          tie_break_policy = TieBreakPolicy(tie_break_policy)
  
      l_pred = self._weak_labels.matrix(
          has_annotation=None if include_annotated_records else False
      )
      if self._need_remap:
          l_pred = self._copy_and_remap(l_pred)
  
      # get predictions and probabilities
      predictions, probabilities = self._model.predict(
          L=l_pred,
          return_probs=True,
          tie_break_policy=tie_break_policy.value,
      )
  
      # add predictions to records
      records_with_prediction = []
      for rec, pred, prob in zip(
          self._weak_labels.records(
              has_annotation=None
              if include_annotated_records
              else False
          ),
          predictions,
          probabilities,
      ):
          if not include_abstentions and pred == -1:
              continue
  
          records_with_prediction.append(rec.copy(deep=True))
  
          # set predictions to None if model abstained
          pred_for_rec = None
          if pred != -1:
              # If we have a tie, increase a bit the probability of the random winner (see tie_break_policy)
              # 1.e-8 is taken from the abs tolerance of np.isclose
              equal_prob_idx = np.nonzero(
                  np.abs(prob.max() - prob) < 1.0e-8
              )[0]
              if len(equal_prob_idx) > 1:
                  for idx in equal_prob_idx:
                      if idx == pred:
                          prob[
                              idx
                          ] += self._PROBABILITY_INCREASE_ON_TIE_BREAK
                      else:
                          prob[idx] -= (
                              self._PROBABILITY_INCREASE_ON_TIE_BREAK
                              / (len(equal_prob_idx) - 1)
                          )
  
              pred_for_rec = [
                  (
                      self._weak_labels.int2label[
                          self._snorkelInt2weaklabelsInt[snorkel_idx]
                      ],
                      prob[snorkel_idx],
                  )
                  for snorkel_idx in np.argsort(prob)[::-1]
              ]
  
          records_with_prediction[-1].prediction = pred_for_rec
          records_with_prediction[
              -1
          ].prediction_agent = prediction_agent
  
      return DatasetForTextClassification(records_with_prediction)
  
imports: import hashlib
  import logging
  from enum import Enum
  from typing import Dict, List, Tuple, Union
  import numpy
  from argilla import DatasetForTextClassification, TextClassificationRecord
  from argilla.labeling.text_classification.weak_labels import WeakLabels, WeakMultiLabels
  from argilla.utils.dependency import requires_dependencies
label_desc: Use image node_id 4 for calling the Snorkel obj's underlying member method code with example usage: obj.predict(include_annotated_records, include_abstentions, prediction_agent, tie_break_policy) and returns: DatasetForTextClassification