code: def _grad_op(self, out_grad):
      orig_input = self._get_input_activation_vars()
  
      if self.data_format == DataFormat.channels_first:
          orig_input = tf.transpose(a=orig_input, perm=(0, 2, 3, 1))
          out_grad = tf.transpose(a=out_grad, perm=(0, 2, 3, 1))
  
      to_return = nn_grad.gen_nn_ops.avg_pool_grad(
          orig_input_shape=tf.shape(orig_input),
          grad=out_grad,
          ksize=[1] + list(self.pool_size) + [1],
          strides=[1] + list(self.strides) + [1],
          padding=self.padding,
      )
  
      if self.data_format == DataFormat.channels_first:
          to_return = tf.transpose(a=to_return, perm=(0, 3, 1, 2))
  
      return to_return
  
imports: from __future__ import division
  from __future__ import print_function
  from __future__ import absolute_import
  from .core import *
  from .helper_functions import conv1d_transpose_via_conv2d
  from .convolutional import PaddingMode, DataFormat
  from .None import helper_functions
  import tensorflow
  from tensorflow.python.ops import nn_grad
label_desc: Use image node_id 4 for calling the AvgPool2D obj's underlying member method code with example usage: obj._grad_op(out_grad) and returns: to_return