class_docstr: Cache for model outputs.
docstr: Save cache data to disk.
code: def save_to_disk(self):
      """Save cache data to disk."""
      # No cache loader is created if no cache directory was provided, in which
      # case this is a no-op.
      cache_loader = self._cache_loader
      if not cache_loader:
          return
      if self._num_persisted == len(self._d):
          logging.info(
              "No need to re-save cache to %s", self._cache_dir
          )
          return
      logging.info(
          "Saving cache (%d entries) to %s",
          len(self._d),
          self._cache_dir,
      )
      cache_loader.save(self._d)
      self._num_persisted = len(self._d)
  
imports: from collections.abc import Callable, Iterable
  import os
  import pickle
  import threading
  from typing import Any, Optional, Union
  from absl import logging
  from lit_nlp.api import dataset
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.lib import serialize
label_desc: Use image node_id 10 for calling the PredsCache obj's underlying member method code with example usage: obj.save_to_disk() without return types