class_docstr: Helper class that caches model generations
  
  For label ids, if one token sequence is [1, 2, 3] and the next token
  sequence is [1, 2, 4], for the 2nd sequence, the generation will retrieve
  the cached logits for [1, 2] and only generate [4].
  
  Set use_caching=False to disable it, e.g. for debugging.
class_docstr_tok: ["Helper","class","that","caches","model","generations","For","label","ids",",","if","one","token","sequence","is","[","1",",","2",",","3","]","and","the","next","token","sequence","is","[","1",",","2",",","4","]",",","for","the","2nd","sequence",",","the","generation","will","retrieve","the","cached","logits","for","[","1",",","2","]","and","only","generate","[","4","]",".","Set","use_caching=False","to","disable","it",",","e.g",".","for","debugging","."]
code: def generate_logits(self, *, label_id, **kwargs):
      self._total_calls += 1  # mainly for debugging
  
      recorded_logits = []
      logits_cached = self.get_cache(kwargs)
      while logits_cached is not None:
          if label_id[0] == self.tokenizer.eos_token_id:
              # don't extend with eos_token -- it is already there at the end,
              # we don't need it twice
              break
  
          recorded_logits.append(logits_cached)
          kwargs = _extend_inputs(kwargs, label_id[:1])
          label_id = label_id[1:]
          logits_cached = self.get_cache(kwargs)
  
      if not label_id:
          # the whole generation was cached
          return recorded_logits
  
      if label_id[0] == self.tokenizer.pad_token_id:
          # no need to generate on pad tokens
          return recorded_logits
  
      self._uncached_calls += 1  # mainly for debugging
      recorder = _LogitsRecorder(
          label_ids=label_id,
          tokenizer=self.tokenizer,
      )
      self.model.generate(
          logits_processor=[recorder],
          # TODO: should this be the max len of all labels?
          max_new_tokens=len(label_id),
          **kwargs,
      )
      self.set_cache(kwargs, label_id, recorder.recorded_scores)
      return recorded_logits + recorder.recorded_scores[:]
  
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 6 for calling the _CacheModelWrapper obj's underlying member method code with example usage: obj.generate_logits() and returns: unknown, recorded_logits, recorded_logits