code: def greedy_until(self, requests):
      if not requests:
          return []
      res = []
  
      def _collate(x):
          toks = self.tok_encode(x[0])
          return len(toks), x[0]
  
      re_ord = utils.Reorderer(requests, _collate)
  
      def sameuntil_chunks(xs, size):
          ret = []
          lastuntil = xs[0][1]
          for x in xs:
              if len(ret) >= size or x[1] != lastuntil:
                  yield ret, lastuntil
                  ret = []
                  lastuntil = x[1]
              ret.append(x)
  
          if ret:
              yield ret, lastuntil
  
      # todo: more intelligent batching for heterogeneous `until`
      for chunk, until in tqdm(
          list(
              sameuntil_chunks(
                  re_ord.get_reordered(), self.REQ_CHUNK_SIZE
              )
          )
      ):
          inps = []
          for request in chunk:
              context = request[0]
              context_enc = self.tok_encode(context)
              inp = context_enc[
                  -(self.max_length - self.max_gen_toks) :
              ]
              inps.append(inp)
  
          response = oa_completion(
              engine=self.engine,
              prompt=inps,
              max_tokens=self.max_gen_toks,
              temperature=0.0,
              logprobs=10,
              stop=until,
          )
  
          for resp, request in zip(response.choices, chunk):
              context = request[0]
              until_ = request[1]
              s = resp["text"]
  
              for term in until_:
                  s = s.split(term)[0]
  
              # partial caching
              self.cache_hook.add_partial(
                  "greedy_until", (context, until_), s
              )
  
              res.append(s)
  
      return re_ord.get_original(res)
  
imports: import os
  import numpy
  import transformers
  from lm_eval.base import BaseLM
  from lm_eval import utils
  from tqdm import tqdm
  import time
label_desc: Use image node_id 10 for calling the GPT3LM obj's underlying member method code with example usage: obj.greedy_until(requests) and returns: re_ord, list, len,  x