code: def cache_generator(self, key, generator):
          
          results = []
          for result in generator:
              results.append(result)
              yield result
  
          self.inferred[key] = tuple(results)
docs: Cache result of generator into dictionary
  
          Used to cache inference results