code: def save_all_xarrays(
      xarray_filename_pairs: List[Tuple],
      ray_scheduler,
      dirpath: str,
      batch_size: int,
  ):
      def chunks(lst, n):
          """Yield successive n-sized chunks from lst."""
          for i in range(0, len(lst), n):
              yield lst[i : i + n]
  
      for batch_idx, batch in enumerate(
          chunks(xarray_filename_pairs, batch_size)
      ):
          delayed_tasks = list()
          for xarray_filename_pair in batch:
              delayed_tasks.append(
                  dask.delayed(SaveRoutines.save_xarray)(
                      xarray_dataset=xarray_filename_pair[0],
                      filename=xarray_filename_pair[1],
                      dirpath=dirpath,
                  )
              )
  
          logging.info(
              "[Batch Index {}] Batch size {}: Sending work to Ray Cluster.".format(
                  batch_idx, batch_size
              )
          )
  
          res = []
          try:
              res = dask.compute(delayed_tasks, scheduler=ray_scheduler)
          except Exception:
              logging.warning(
                  "[Batch Index {}] Exception while computing batch!".format(
                      batch_idx
                  )
              )
          finally:
              logging.info(
                  "[Batch Index {}], Result = {}".format(batch_idx, res)
              )
  
imports: import argparse
  import json
  import logging
  import math
  import os
  import random
  import time
  from copy import copy, deepcopy
  from typing import List, Tuple
  import dask.array
  import numpy
  import xarray
  import ray
  from ray._private.test_utils import monitor_memory_usage
  from ray.util.dask import ray_dask_get
label_desc: Use image node_id 2 for calling the SaveRoutines obj's underlying member method code with example usage: obj.save_all_xarrays(xarray_filename_pairs, ray_scheduler, dirpath, batch_size) without return types