code: def dump_dataflow_images(
      df,
      index=0,
      batched=True,
      number=1000,
      output_dir=None,
      scale=1,
      resize=None,
      viz=None,
      flipRGB=False,
  ):
      """
      Dump or visualize images of a :class:`DataFlow`.
  
      Args:
          df (DataFlow): the DataFlow.
          index (int): the index of the image component.
          batched (bool): whether the component contains batched images (NHW or
              NHWC) or not (HW or HWC).
          number (int): how many datapoint to take from the DataFlow.
          output_dir (str): output directory to save images, default to not save.
          scale (float): scale the value, usually either 1 or 255.
          resize (tuple or None): tuple of (h, w) to resize the images to.
          viz (tuple or None): tuple of (h, w) determining the grid size to use
              with :func:`gen_stack_patches` for visualization. No visualization will happen by
              default.
          flipRGB (bool): apply a RGB<->BGR conversion or not.
      """
      if output_dir:
          mkdir_p(output_dir)
      if viz is not None:
          viz = shape2d(viz)
          vizsize = viz[0] * viz[1]
      if resize is not None:
          resize = tuple(shape2d(resize))
      vizlist = []
  
      df.reset_state()
      cnt = 0
      while True:
          for dp in df:
              if not batched:
                  imgbatch = [dp[index]]
              else:
                  imgbatch = dp[index]
              for img in imgbatch:
                  cnt += 1
                  if cnt == number:
                      return
                  if scale != 1:
                      img = img * scale
                  if resize is not None:
                      img = cv2.resize(img, resize)
                  if flipRGB:
                      img = img[:, :, ::-1]
                  if output_dir:
                      fname = os.path.join(
                          output_dir, "{:03d}.jpg".format(cnt)
                      )
                      cv2.imwrite(fname, img)
                  if viz is not None:
                      vizlist.append(img)
              if viz is not None and len(vizlist) >= vizsize:
                  stack_patches(
                      vizlist[:vizsize],
                      nr_row=viz[0],
                      nr_col=viz[1],
                      viz=True,
                  )
                  vizlist = vizlist[vizsize:]
  
file_path: tensorpack/tensorpack/utils/viz.py
imports: import numpy
  import os
  import sys
  from ..utils.develop import create_dummy_func
  from .argtools import shape2d
  from .fs import mkdir_p
label_desc: Use image node_id 6 for calling a global function with example usage: dump_dataflow_images(df, index, batched, number, output_dir, scale, resize, viz, flipRGB) without return types