code: def pool_direct(
      input,  # pylint: disable=redefined-builtin
      window_shape,
      pooling_type,
      padding,  # pylint: disable=redefined-builtin
      dilation_rate,
      strides,
      data_format=None,
  ):
      """Numpy implementation of pooling.
  
      This is intended for testing only, and therefore isn't particularly efficient.
  
      See tensorflow.nn.pool.
  
      Args:
        input: numpy array of rank N+2.
        window_shape: Sequence of N ints >= 1.
        pooling_type: either "MAX" or "AVG".
        padding: either "SAME" or "VALID".
        dilation_rate: Sequence of N ints >= 1.
        strides: Sequence of N ints >= 1.
        data_format: If specified and starts with "NC", indicates that second
          dimension, rather than the last dimension, specifies the channel.
  
      Returns:
        pooling output array of rank N+2.
  
      Raises:
        ValueError: if arguments are invalid.
      """
      if data_format is None or not data_format.startswith("NC"):
          spatial_start_dim = 1
      else:
          spatial_start_dim = 2
      output = input
      for i in range(len(window_shape)):
          output = pool_direct_single_axis(
              input=output,
              axis=i + spatial_start_dim,
              window_size=window_shape[i],
              pooling_type=pooling_type,
              padding=padding,
              dilation_rate=dilation_rate[i],
              stride=strides[i],
          )
      return output
  
imports: import math
  import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import gradient_checker
  from tensorflow.python.ops import nn_ops
  import tensorflow.python.ops.nn_grad
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling a global function with example usage: pool_direct(input, window_shape, pooling_type, padding, dilation_rate, strides, data_format) and returns: output