code: def smart_truncate_cache(
      cache: shared_caching.ChunkedFilesDataCache,
      max_seq_length: int,
      max_valid_length: int,
      verbose: bool = False,
  ):
      for chunk_i in maybe_trange(
          cache.num_chunks,
          desc="Smart truncate chunks",
          verbose=verbose,
      ):
          chunk = torch.load(cache.get_chunk_path(chunk_i))
          new_chunk = []
          for datum in maybe_tqdm(
              chunk, desc="Smart truncate chunk-datum", verbose=verbose
          ):
              new_chunk.append(
                  smart_truncate_datum(
                      datum=datum,
                      max_seq_length=max_seq_length,
                      max_valid_length=max_valid_length,
                  )
              )
          torch.save(new_chunk, cache.get_chunk_path(chunk_i))
  
file_path: jiant/jiant/proj/main/preprocessing.py
imports: import numpy
  import torch
  import jiant.shared.caching
  import jiant.utils.torch_utils
  from jiant.tasks.core import FeaturizationSpec, TaskTypes
  from jiant.utils.display import maybe_tqdm, maybe_trange
label_desc: Use image node_id 2 for calling a global function with example usage: smart_truncate_cache(cache, max_seq_length, max_valid_length, verbose) without return types