class_docstr: Base class for LLM models
  
  This class handles a few of the checks, as well as the whole prediction
  machinery.
  
  Required attributes are:
  
  - model_name
  - model
  - tokenizer
  - prompt
  - probas_sum_to_1
  - device
  - error_low_prob
  - threshold_low_prob
  - use_caching
class_docstr_tok: ["Base","class","for","LLM","models","This","class","handles","a","few","of","the","checks",",","as","well","as","the","whole","prediction","machinery",".","Required","attributes","are",":","-","model_name","-","model","-","tokenizer","-","prompt","-","probas_sum_to_1","-","device","-","error_low_prob","-","threshold_low_prob","-","use_caching"]
docstr: Return the probabilities predicted by the LLM.
  
  Predictions will be forced to be one of the labels the model learned
  during ``fit``. Each column in ``y_proba`` corresponds to one class. The
  order of the classes can be checked in the ``.classes_`` attribute. In
  general, it is alphabetic. So the first column is the probability for
  the first class in ``.classes_``, the second column is the probability
  for the second class in ``.classes_``, etc.
  
  If ``error_low_prob`` is set to ``'warn'``, then a warning is given if,
  for at least one sample, the sum of the probabilities for all classes is
  below the threshold set in ``threshold_low_prob``. If ``error_low_prob``
  is set to ``'raise'``, then an error is raised instead.
  
  Parameters
  ----------
  X : input data
    Typically, this is a list/array of strings. E.g., this could be a list
    of reviews and the target is the sentiment. Technically, however, this
    can also contain numerical or categorical data, although it is
    unlikely that the LLM will generate good predictions for those.
  
  Returns
  -------
  y_proba : numpy ndarray
    The probabilities for each class. If ``probas_sum_to_1`` is set to
    ``False``, then the sum of the probabilities for each sample will not
    add up to 1
docstr_tok: ["Return","the","probabilities","predicted","by","the","LLM",".","Predictions","will","be","forced","to","be","one","of","the","labels","the","model","learned","during","``","fit","``",".","Each","column","in","``","y_proba","``","corresponds","to","one","class",".","The","order","of","the","classes","can","be","checked","in","the","``",".classes_","``","attribute",".","In","general",",","it","is","alphabetic",".","So","the","first","column","is","the","probability","for","the","first","class","in","``",".classes_","``",",","the","second","column","is","the","probability","for","the","second","class","in","``",".classes_","``",",","etc",".","If","``","error_low_prob","``","is","set","to","``","'warn","'","``",",","then","a","warning","is","given","if",",","for","at","least","one","sample",",","the","sum","of","the","probabilities","for","all","classes","is","below","the","threshold","set","in","``","threshold_low_prob","``",".","If","``","error_low_prob","``","is","set","to","``","'raise","'","``",",","then","an","error","is","raised","instead",".","Parameters","--","--","--","--","--","X",":","input","data","Typically",",","this","is","a","list\/array","of","strings",".","E.g.",",","this","could","be","a","list","of","reviews","and","the","target","is","the","sentiment",".","Technically",",","however",",","this","can","also","contain","numerical","or","categorical","data",",","although","it","is","unlikely","that","the","LLM","will","generate","good","predictions","for","those",".","Returns","--","--","--","-","y_proba",":","numpy","ndarray","The","probabilities","for","each","class",".","If","``","probas_sum_to_1","``","is","set","to","``","False","``",",","then","the","sum","of","the","probabilities","for","each","sample","will","not","add","up","to","1"]
code: def predict_proba(self, X):
      """Return the probabilities predicted by the LLM.
  
      Predictions will be forced to be one of the labels the model learned
      during ``fit``. Each column in ``y_proba`` corresponds to one class. The
      order of the classes can be checked in the ``.classes_`` attribute. In
      general, it is alphabetic. So the first column is the probability for
      the first class in ``.classes_``, the second column is the probability
      for the second class in ``.classes_``, etc.
  
      If ``error_low_prob`` is set to ``'warn'``, then a warning is given if,
      for at least one sample, the sum of the probabilities for all classes is
      below the threshold set in ``threshold_low_prob``. If ``error_low_prob``
      is set to ``'raise'``, then an error is raised instead.
  
      Parameters
      ----------
      X : input data
        Typically, this is a list/array of strings. E.g., this could be a list
        of reviews and the target is the sentiment. Technically, however, this
        can also contain numerical or categorical data, although it is
        unlikely that the LLM will generate good predictions for those.
  
      Returns
      -------
      y_proba : numpy ndarray
        The probabilities for each class. If ``probas_sum_to_1`` is set to
        ``False``, then the sum of the probabilities for each sample will not
        add up to 1
  
      """
      # y_proba not normalized here
      y_proba = self._predict_proba(X)
  
      if self.probas_sum_to_1:
          # normalizing here is okay because we already checked earlier that
          # the sum is not 0
          y_proba /= y_proba.sum(1, keepdims=True)
  
      return y_proba
  
imports: import importlib
  import warnings
  from string import Formatter
  import numpy
  import torch
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.utils import check_random_state
  from sklearn.utils.validation import check_is_fitted
  from transformers import AutoConfig, AutoTokenizer, LogitsProcessor
  from skorch.exceptions import LowProbabilityError
  from skorch.llm.prompts import DEFAULT_PROMPT_FEW_SHOT, DEFAULT_PROMPT_ZERO_SHOT, DELIM
label_desc: Use image node_id 13 for calling the _LlmBase obj's underlying member method code with example usage: obj.predict_proba(X) and returns: y_proba