code: def factorized_reduction(
      net, output_filters, stride, data_format=INVALID
  ):
      """Reduces the shape of net without information loss due to striding."""
      assert data_format != INVALID
      if stride == 1:
          net = slim.conv2d(net, output_filters, 1, scope="path_conv")
          net = slim.batch_norm(net, scope="path_bn")
          return net
      if data_format == "NHWC":
          stride_spec = [1, stride, stride, 1]
      else:
          stride_spec = [1, 1, stride, stride]
  
      # Skip path 1
      path1 = tf.nn.avg_pool(
          net,
          [1, 1, 1, 1],
          stride_spec,
          "VALID",
          data_format=data_format,
      )
      path1 = slim.conv2d(
          path1, int(output_filters / 2), 1, scope="path1_conv"
      )
  
      # Skip path 2
      # First pad with 0's on the right and bottom, then shift the filter to
      # include those 0's that were added.
      if data_format == "NHWC":
          pad_arr = [[0, 0], [0, 1], [0, 1], [0, 0]]
          path2 = tf.pad(net, pad_arr)[:, 1:, 1:, :]
          concat_axis = 3
      else:
          pad_arr = [[0, 0], [0, 0], [0, 1], [0, 1]]
          path2 = tf.pad(net, pad_arr)[:, :, 1:, 1:]
          concat_axis = 1
  
      path2 = tf.nn.avg_pool(
          path2,
          [1, 1, 1, 1],
          stride_spec,
          "VALID",
          data_format=data_format,
      )
  
      # If odd number of filters, add an additional one to the second path.
      final_filter_size = int(output_filters / 2) + int(
          output_filters % 2
      )
      path2 = slim.conv2d(
          path2, final_filter_size, 1, scope="path2_conv"
      )
  
      # Concat and apply BN
      final_path = tf.concat(values=[path1, path2], axis=concat_axis)
      final_path = slim.batch_norm(final_path, scope="final_path_bn")
      return final_path
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow.compat.v1
label_desc: Use image node_id 5 for calling a global function with example usage: factorized_reduction(net, output_filters, stride, data_format) and returns: final_path, net