code: def df_multiprocess(df, processes, chunk_size, func, dataset_name):
      print("Generating parts...")
      with shelve.open(
          "%s_%s_%s_results.tmp"
          % (dataset_name, func.__name__, chunk_size)
      ) as results:
          pbar = tqdm(total=len(df), position=0)
          # Resume:
          finished_chunks = set([int(k) for k in results.keys()])
          pbar.desc = "Resuming"
          for k in results.keys():
              pbar.update(len(results[str(k)][1]))
  
          pool_data = (
              (index, df[i : i + chunk_size], func)
              for index, i in enumerate(range(0, len(df), chunk_size))
              if index not in finished_chunks
          )
          print(
              int(len(df) / chunk_size),
              "parts.",
              chunk_size,
              "per part.",
              "Using",
              processes,
              "processes",
          )
  
          pbar.desc = "Downloading"
          with Pool(processes) as pool:
              for i, result in enumerate(
                  pool.imap_unordered(_df_split_apply, pool_data, 2)
              ):
                  results[str(result[0])] = result
                  pbar.update(len(result[1]))
          pbar.close()
  
      print("Finished Downloading.")
      return
  
imports: import glob
  from pathlib import Path
  import time
  from omegaconf import OmegaConf
  import pandas
  import numpy
  import requests
  import zlib
  import os
  import io
  import shelve
  from lavis.common.utils import get_abs_path, get_cache_path
  import magic
  import json
  from multiprocessing import Pool
  from tqdm import tqdm
  from PIL import Image
  from torchvision.transforms import functional
label_desc: Use image node_id 2 for calling a global function with example usage: df_multiprocess(df, processes, chunk_size, func, dataset_name) without return types