code: def calc_padding(mace_op, mace_net):
      input_dims = NetUtil.get_input_dims(mace_op, mace_net, 0)
      input_height = input_dims[1]
      input_width = input_dims[2]
  
      filter_dims = NetUtil.get_input_dims(mace_op, mace_net, 1)
      kernel_height = filter_dims[1]
      kernel_width = filter_dims[2]
  
      dilations = NetUtil.get_arg(mace_op, "dilations").ints
      strides = NetUtil.get_arg(mace_op, "strides").ints
  
      k_extent_height = (kernel_height - 1) * dilations[0] + 1
      k_extent_width = (kernel_width - 1) * dilations[1] + 1
  
      padding_type = NetUtil.get_arg(mace_op, "padding").i
  
      if padding_type == PaddingMode.VALID.value:
          output_height = (
              int((input_height - k_extent_height) / strides[0]) + 1
          )
          output_width = (
              int((input_width - k_extent_width) / strides[1]) + 1
          )
      elif padding_type == PaddingMode.SAME.value:
          output_height = int((input_height - 1) / strides[0]) + 1
          output_width = int((input_width - 1) / strides[1]) + 1
      elif padding_type == PaddingMode.FULL.value:
          output_height = (
              int((input_height + k_extent_height - 2) / strides[0]) + 1
          )
          output_width = (
              int((input_width + k_extent_width - 2) / strides[1]) + 1
          )
      else:
          mace_check(
              False, "Unsupported padding type: %d" % padding_type
          )
  
      padding0 = max(
          0,
          (output_height - 1) * strides[0]
          + k_extent_height
          - input_height,
      )
      padding1 = max(
          0,
          (output_width - 1) * strides[1]
          + k_extent_width
          - input_width,
      )
  
      padding0 = int(padding0 / 2)
      padding1 = int(padding1 / 2)
  
      return [padding0, padding1]
  
file_path: mace/tools/python/utils/net_util.py
imports: from py_proto import mace_pb2
  from utils.config_parser import DataFormat
  from utils.config_parser import DeviceType
  from utils.config_parser import Platform
  from utils.util import mace_check
  from transform.base_converter import PaddingMode
label_desc: Use image node_id 3 for calling the NetUtil obj's underlying member method code with example usage: obj.calc_padding(mace_op, mace_net) and returns: list