code: def aggregated_pad(
      pad_type,
      kernel_shape,
      input_shape=None,
      strides=None,
      dilations=None,
      custom_pad=None,
  ):
      """
      Args
          pad_type: string. Must be one of ('same', 'same_lower', 'valid', 'custom')
  
          kernel_shape: [kH, kW, ...]: spatial kernel dims (excluding channels)
  
          input_shape: [iH, iW, ...]: spatial input dims (excluding channels)
              Required iff pad_type in ['same', 'same_lower']
  
          strides: [sH, sW, ...]: spatial strides (excluding channels)
              Required iff pad_type in ['same', 'same_lower']
  
          dilations: [dH, dW, ...]: dilations (excluding channels)
              If not provided, defaults to [1, 1, ...], effectively no dilation.
  
          custom_pad: Required iff pad_type == 'custom'.
              custom_pad[2*i], custom_pad[2*i+1] are before/after custom padding
              for spatial dim i.
  
  
      Returns:
          A tuple of total (before + after) padding for each spatial dimension in kernel_shape.
      """
      num_spatial_dims = len(kernel_shape)
      if dilations is None:
          dilations = [1] * num_spatial_dims
      elif len(dilations) != num_spatial_dims:
          raise ValueError(
              f"dilations must have same length as kernel_shape "
              f"({num_spatial_dims}, but got {len(dilations)})"
          )
      if pad_type in ["same", "same_lower"]:
          if (
              input_shape is None
              or len(input_shape) != num_spatial_dims
          ):
              raise ValueError(
                  "For SAME padding input_shape must not be None and must have "
                  "same length as kernel_shape ({}, but got {})".format(
                      num_spatial_dims,
                      len(input_shape)
                      if input_shape is not None
                      else "None",
                  )
              )
          if strides is None or len(strides) != num_spatial_dims:
              raise ValueError(
                  "For SAME padding strides must not be None and must have "
                  "same length as kernel_shape ({}, but got {})".format(
                      num_spatial_dims,
                      len(strides) if strides is not None else "None",
                  )
              )
          effective_ks = effective_kernel(kernel_shape, dilations)
          return tuple(
              [
                  int(
                      max(
                          0,
                          s * math.ceil(float(i) / float(s))
                          - i
                          + k
                          - s,
                      )
                  )
                  if not is_symbolic(i)
                  else get_new_symbol()
                  for i, k, s in zip(input_shape, effective_ks, strides)
              ]
          )
      if pad_type == "valid":
          return tuple([0] * num_spatial_dims)
      if pad_type == "custom":
          if (
              custom_pad is None
              or len(custom_pad) != 2 * num_spatial_dims
          ):
              raise ValueError("Invalid custom_pad.")
          return tuple(
              [
                  custom_pad[2 * d] + custom_pad[2 * d + 1]
                  for d in range(num_spatial_dims)
              ]
          )
      raise ValueError('Invalid padding pad_type "{}"'.format(pad_type))
  
imports: import math
  import numbers
  from typing import List, Tuple
  import numpy
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Var, get_new_symbol, types
  from coremltools.converters.mil.mil.ops.defs.iOS15.elementwise_unary import cast
  from coremltools.converters.mil.mil.types import builtin_to_string, promote_dtypes
  from coremltools.converters.mil.mil.types.symbolic import is_symbolic
label_desc: Use image node_id 5 for calling a global function with example usage: aggregated_pad(pad_type, kernel_shape, input_shape, strides, dilations, custom_pad) and returns: tuple, tuple, tuple