parameters: (pad_mode, input_spatial_shape, kernel_spatial_shape,
                        strides_spatial)
return_statement: return pad_shape, odd_padd_shape
docstring: return padding shape of conv2d or pooling,
      Args:
          pad_mode: string
          kernel_spatial_shape: list[int]
          strides_spatial: list[int]
      Returns: 
          list[int]
docstring_summary: return padding shape of conv2d or pooling,
      Args:
          pad_mode: string
          kernel_spatial_shape: list[int]
          strides_spatial: list[int]
      Returns: 
          list[int]
docstring_tokens: return padding shape of conv2d or pooling Args : pad_mode : string kernel_spatial_shape : list [ int ] strides_spatial : list [ int ] Returns : list [ int ]
function: def get_padding_shape(pad_mode, input_spatial_shape, kernel_spatial_shape,
                        strides_spatial):
      """
      return padding shape of conv2d or pooling,
      Args:
          pad_mode: string
          kernel_spatial_shape: list[int]
          strides_spatial: list[int]
      Returns: 
          list[int]
      """
      output_spatial_shape = get_output_shape(pad_mode, input_spatial_shape,
                                              kernel_spatial_shape,
                                              strides_spatial)
      pad_shape = [0] * len(input_spatial_shape) * 2  # 2 means left and right
      # the odd paddding is the value that cannot be handled by the tuple padding (w, h) mode
      # so we need to firstly handle the input, then use the nomal padding method.
      odd_padd_shape = [0] * len(input_spatial_shape) * 2
      for i in range(len(input_spatial_shape)):
          whole_pad = (output_spatial_shape[i] - 1) * strides_spatial[i] + \
              kernel_spatial_shape[i] - input_spatial_shape[i]
          pad_shape[2 * i] = pad_shape[2 * i + 1] = whole_pad // 2
          if whole_pad % 2 != 0:
              if pad_mode == "SAME_UPPER":
                  odd_padd_shape[2 * i + 1] += 1
              else:
                  odd_padd_shape[2 * i] += 1
      return pad_shape, odd_padd_shape
function_tokens: def get_padding_shape ( pad_mode , input_spatial_shape , kernel_spatial_shape , strides_spatial ) : output_spatial_shape = get_output_shape ( pad_mode , input_spatial_shape , kernel_spatial_shape , strides_spatial ) pad_shape = [ 0 ] * len ( input_spatial_shape ) * 2 # 2 means left and right # the odd paddding is the value that cannot be handled by the tuple padding (w, h) mode # so we need to firstly handle the input, then use the nomal padding method. odd_padd_shape = [ 0 ] * len ( input_spatial_shape ) * 2 for i in range ( len ( input_spatial_shape ) ) : whole_pad = ( output_spatial_shape [ i ] - 1 ) * strides_spatial [ i ] + kernel_spatial_shape [ i ] - input_spatial_shape [ i ] pad_shape [ 2 * i ] = pad_shape [ 2 * i + 1 ] = whole_pad // 2 if whole_pad % 2 != 0 : if pad_mode == "SAME_UPPER" : odd_padd_shape [ 2 * i + 1 ] += 1 else : odd_padd_shape [ 2 * i ] += 1 return pad_shape , odd_padd_shape