code: def _get_same_padding_conv_nd(
      image_size: list[int],
      kernel_size: tuple[int, ...],
      dilation: tuple[int, ...],
      stride: tuple[int, ...],
  ) -> list[int]:
      """
      Helper for getting padding (nn.ConstantPadNd) to be used to get SAME padding
      conv operations similar to Tensorflow's SAME padding.
  
      This function is generalized for MONAI's N-Dimensional spatial operations (e.g. Conv1D, Conv2D, Conv3D)
  
      Args:
          image_size: input image/feature spatial size.
          kernel_size: conv kernel's spatial size.
          dilation: conv dilation rate for Atrous conv.
          stride: stride for conv operation.
  
      Returns:
          paddings for ConstantPadNd padder to be used on input tensor to conv op.
      """
      # get number of spatial dimensions, corresponds to kernel size length
      num_dims = len(kernel_size)
  
      # additional checks to populate dilation and stride (in case they are single entry tuples)
      if len(dilation) == 1:
          dilation = dilation * num_dims
  
      if len(stride) == 1:
          stride = stride * num_dims
  
      # equation to calculate (pad^+ + pad^-) size
      _pad_size: list[int] = [
          max(
              (math.ceil(_i_s / _s) - 1) * _s
              + (_k_s - 1) * _d
              + 1
              - _i_s,
              0,
          )
          for _i_s, _k_s, _d, _s in zip(
              image_size, kernel_size, dilation, stride
          )
      ]
      # distribute paddings into pad^+ and pad^- following Tensorflow's same padding strategy
      _paddings: list[tuple[int, int]] = [
          (_p // 2, _p - _p // 2) for _p in _pad_size
      ]
  
      # unroll list of tuples to tuples, and then to list
      # reversed as nn.ConstantPadNd expects paddings starting with last dimension
      _paddings_ret: list[int] = [
          outer for inner in reversed(_paddings) for outer in inner
      ]
      return _paddings_ret
  
imports: from __future__ import annotations
  import math
  import operator
  import re
  from functools import reduce
  from typing import NamedTuple
  import torch
  from torch import nn
  from torch.utils import model_zoo
  from monai.networks.blocks import BaseEncoder
  from monai.networks.layers.factories import Act, Conv, Pad, Pool
  from monai.networks.layers.utils import get_norm_layer
  from monai.utils.module import look_up_option
label_desc: Use image node_id 4 for calling a global function with example usage: _get_same_padding_conv_nd(image_size, kernel_size, dilation, stride) and returns: _paddings_ret