code: def downscale(images, scale):
      """Box downscaling of images.
  
      Args:
        images: A 4D `Tensor` in NHWC format.
        scale: A positive integer scale.
  
      Returns:
        A 4D `Tensor` of `images` down scaled by a factor `scale`.
  
      Raises:
        ValueError: If `scale` is not a positive integer.
      """
      scale = _get_validated_scale(scale)
      if scale == 1:
          return images
      return tf.nn.avg_pool(
          images,
          ksize=[1, scale, scale, 1],
          strides=[1, scale, scale, 1],
          padding="VALID",
      )
  
file_path: magenta/magenta/models/gansynth/lib/layers.py
imports: import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling a global function with example usage: downscale(images, scale) and returns: tf, images