code: def compute_tf_same_padding(
      input_shape, kernel_shape, strides, data_format="NHWC"
  ):
      """Convert [SAME] padding in tensorflow, keras to onnx pads,
      i.e. [x1_begin, x2_begin...x1_end, x2_end,...]"""
      # print (input_shape)
      # print (kernel_shape)
      # print (strides)
      if data_format.startswith("NC"):
          # Not tested
          input_shape = input_shape[2:]
          remove_dim = len(strides) - len(input_shape)
          if remove_dim > 0:
              strides = strides[remove_dim::]
  
      else:
          input_shape = input_shape[1:-1]
          remove_dim = len(input_shape) - len(strides) + 1
          if remove_dim < 0:
              strides = strides[1:remove_dim]
  
      # print (input_shape)
      # print (kernel_shape)
      # print (strides)
  
      up_list = [0]
      down_list = [0]
  
      for idx in range(0, len(input_shape)):
          # kernel_shape[idx] = (kernel_shape[idx] - 1) * dilation_rate + 1
          output_shape = (
              input_shape[idx] + strides[idx] - 1
          ) // strides[idx]
          this_padding = (
              (output_shape - 1) * strides[idx]
              + kernel_shape[idx]
              - input_shape[idx]
          )
          this_padding = max(0, this_padding)
          up_list.append(this_padding // 2)
          down_list.append(this_padding - this_padding // 2)
  
      # print ([0] + up_list + [0] + down_list if data_format.startswith('NC') else up_list + [0] + down_list + [0])
      # print ('-----------------------------------------------------')
      return (
          [0] + up_list + [0] + down_list
          if data_format.startswith("NC")
          else up_list + [0] + down_list + [0]
      )
  
file_path: MMdnn/mmdnn/conversion/common/utils.py
imports: from __future__ import division
  import os
  import sys
  import numpy
  from six import text_type, binary_type, integer_types
  import mmdnn.conversion.common.IR.graph_pb2
label_desc: Use image node_id 8 for calling a global function with example usage: compute_tf_same_padding(input_shape, kernel_shape, strides, data_format) and returns: unknown