code: def copy_cache(
      cache_dir: str,
      mongo_host: str,
      organization: str,
      dry_run: bool,
      range_start: Optional[int] = None,
      range_end: Optional[int] = None,
  ):
      if dry_run:
          hlog("Dry run mode, skipping writing to mongo")
      if range_start:
          hlog(f"Start of range: {range_start}")
      if range_end:
          hlog(f"End of range: {range_end}")
      num_items = 0
      num_written = 0
      num_skipped = 0
      num_failed = 0
      cache_path = os.path.join(cache_dir, f"{organization}.sqlite")
      hlog(f"Opening Sqlite cache {cache_path}")
      with SqliteDict(cache_path) as source_cache:
          hlog(f"Copying to MongoDB {mongo_host}")
          with _MongoKeyValueStore(
              mongo_host, collection_name=organization
          ) as target_cache:
              for key, value in source_cache.items():
                  if not dry_run and (
                      not range_start or num_items >= range_start
                  ):
                      try:
                          target_cache.put(json.loads(key), value)
                          num_written += 1
                      except Exception:
                          num_failed += 1
                  else:
                      num_skipped += 1
                  num_items += 1
                  if num_items % 1000 == 0:
                      hlog(f"Processed {num_items} items so far")
                      hlog(
                          f"Copied {num_written} and skipped {num_skipped} and "
                          + f"failed {num_failed} items from {cache_path} so far"
                      )
                  if range_end and num_items >= range_end:
                      break
  
              hlog(
                  f"Processed {num_items} total items from {cache_path}"
              )
              hlog(
                  f"Copied {num_written} and skipped {num_skipped} and failed "
                  + f"{num_failed} total items from {cache_path}"
              )
      hlog(
          f"Finished copying Sqlite cache {cache_path} to MongoDB {mongo_host}"
      )
  
file_path: H2O/h2o_hf/helm/scripts/cache/copy_cache.py
imports: import argparse
  import json
  import os
  from sqlitedict import SqliteDict
  from helm.common.cache import _MongoKeyValueStore
  from helm.common.hierarchical_logger import hlog, htrack
  from typing import Optional
label_desc: Use image node_id 2 for calling a global function with example usage: copy_cache(cache_dir, mongo_host, organization, dry_run, range_start, range_end) without return types