code: def convert_images_to_uint8(
      images,
      drange=[-1, 1],
      nchw_to_nhwc=False,
      shrink=1,
      uint8_cast=True,
  ):
      """Convert a minibatch of images from float32 to uint8 with configurable dynamic range.
      Can be used as an output transformation for Network.run().
      """
      images = tf.cast(images, tf.float32)
      if shrink > 1:
          ksize = [1, 1, shrink, shrink]
          images = tf.nn.avg_pool(
              images,
              ksize=ksize,
              strides=ksize,
              padding="VALID",
              data_format="NCHW",
          )
      if nchw_to_nhwc:
          images = tf.transpose(images, [0, 2, 3, 1])
      scale = 255 / (drange[1] - drange[0])
      images = images * scale + (0.5 - drange[0] * scale)
      if uint8_cast:
          images = tf.saturate_cast(images, tf.uint8)
      return images
  
imports: import os
  import numpy
  import tensorflow
  import logging
  import tensorflow.contrib
  from typing import Any, Iterable, List, Union
label_desc: Use image node_id 19 for calling a global function with example usage: convert_images_to_uint8(images, drange, nchw_to_nhwc, shrink, uint8_cast) and returns: images