code: def logged_batches(
      specs: Iterable[ht.JobSpec], limit: int
  ) -> Iterable[Iterable[ht.JobSpec]]:
      """Accepts an iterable of specs and a 'chunk limit'; returns an iterable of
      iterable of JobSpec, each of which is guaranteed to contain at most 'chunk
      limit' items.
  
      The subsequences don't pull contiguous chunks off of the original input
      sequence, but the set of the union of the subsequences is the set of all
      original items.
  
      As you realize the generator you'll trigger:
  
      - a logging side-effect at the beginning of each batch
      - a logging effect between each item in each batch
  
      These logging effects will track the index of each batch and each item within
      the batch.
  
      """
      # Realize the input generator to get a count for logging.
      spec_list = list(specs)
      total_specs = len(spec_list)
  
      # Build N chunks such that each chunk contains <= items than the supplied
      # limit.
      chunked_seq = u.chunks_below_limit(spec_list, limit=limit)
      total_chunks = len(chunked_seq)
  
      # Go the extra mile.
      plural_batch = "batch" if total_chunks == 1 else "batches"
      plural_job = "job" if total_specs == 1 else "jobs"
      logging.info(
          "Generating {} {} for {} {}.".format(
              total_chunks, plural_batch, total_specs, plural_job
          )
      )
      for i, chunk in enumerate(chunked_seq, 1):
          logging.info("Batch {} of {}:".format(i, total_chunks))
          yield logged_specs(chunk)
  
imports: from __future__ import absolute_import, division, print_function
  import datetime
  import traceback
  from copy import deepcopy
  from pprint import pformat
  from typing import Any, Dict, Iterable, List, Optional, Tuple
  import tqdm
  from absl import logging
  from blessings import Terminal
  from googleapiclient import discovery
  from googleapiclient.errors import HttpError
  import caliban.config
  import caliban.config.experiment
  import caliban.docker.build
  import caliban.docker.push
  import caliban.history.types
  import caliban.platform.cloud.types
  import caliban.platform.cloud.util
  import caliban.util
  import caliban.util.auth
  import caliban.util.metrics
  import caliban.util.tqdm
  from caliban.history.util import create_experiments, generate_container_spec, get_mem_engine, get_sql_engine, session_scope
label_desc: Use image node_id 9 for calling a global function with example usage: logged_batches(specs, limit) without return types