class_docstr: Handle compression of a raw data file.
  
  Constructor
  -----------
  
  chunk_duration : float
      Duration of the chunks, in seconds.
  algorithm : str
      Name of the compression algorithm. Only `zlib` is supported at the moment.
  comp_level : int
      Compression level of the chosen algorithm.
  do_time_diff : bool
      Whether to compute the time-wise diff of the array before compressing.
  do_spatial_diff : bool
      Whether to compute the spatial diff of the array before compressing.
  n_threads : int
      Number of CPUs to use for compression. By default, use all of them.
  before_check : function
      A callback method that could be called just before the integrity check.
  check_after_compress : bool
      Whether to perform the automatic check after compression.
class_docstr_tok: ["Handle","compression","of","a","raw","data","file",".","Constructor","--","--","--","--","--","-","chunk_duration",":","float","Duration","of","the","chunks",",","in","seconds",".","algorithm",":","str","Name","of","the","compression","algorithm",".","Only","`","zlib","`","is","supported","at","the","moment",".","comp_level",":","int","Compression","level","of","the","chosen","algorithm",".","do_time_diff",":","bool","Whether","to","compute","the","time-wise","diff","of","the","array","before","compressing",".","do_spatial_diff",":","bool","Whether","to","compute","the","spatial","diff","of","the","array","before","compressing",".","n_threads",":","int","Number","of","CPUs","to","use","for","compression",".","By","default",",","use","all","of","them",".","before_check",":","function","A","callback","method","that","could","be","called","just","before","the","integrity","check",".","check_after_compress",":","bool","Whether","to","perform","the","automatic","check","after","compression","."]
docstr: Write a given chunk into the output file.
  
  Parameters
  ----------
  
  first_chunk : int
      Index of the first chunk in the batch (included).
  last_chunk : int
      Index of the last chunk in the batch (excluded).
  
  Returns
  -------
  
  chunks : dict
      A dictionary mapping chunk indices to compressed chunks.
docstr_tok: ["Write","a","given","chunk","into","the","output","file",".","Parameters","--","--","--","--","--","first_chunk",":","int","Index","of","the","first","chunk","in","the","batch","(","included",")",".","last_chunk",":","int","Index","of","the","last","chunk","in","the","batch","(","excluded",")",".","Returns","--","--","--","-","chunks",":","dict","A","dictionary","mapping","chunk","indices","to","compressed","chunks","."]
code: def compress_batch(self, first_chunk, last_chunk):
      """Write a given chunk into the output file.
  
      Parameters
      ----------
  
      first_chunk : int
          Index of the first chunk in the batch (included).
      last_chunk : int
          Index of the last chunk in the batch (excluded).
  
      Returns
      -------
  
      chunks : dict
          A dictionary mapping chunk indices to compressed chunks.
  
      """
      assert 0 <= first_chunk < last_chunk <= self.n_chunks
      if self.n_threads == 1:
          chunks = [
              self._compress_chunk(chunk_idx)
              for chunk_idx in range(first_chunk, last_chunk)
          ]
      elif self.n_threads >= 2:
          chunks = self.pool.map(
              self._compress_chunk, range(first_chunk, last_chunk)
          )
      return dict(chunks)
  
imports: import argparse
  import bisect
  from functools import lru_cache
  import hashlib
  import json
  import logging
  import multiprocessing
  from multiprocessing.dummy import Pool
  import os
  import os.path
  from pathlib import Path
  import sys
  from threading import Lock
  import zlib
  from tqdm import tqdm
  import numpy
label_desc: Use image node_id 7 for calling the Writer obj's underlying member method code with example usage: obj.compress_batch(first_chunk, last_chunk) and returns: dict