code: def padtype_to_pads(
      in_shape: jnp.ndarray,
      window_shape: Tuple[int, ...],
      window_strides: Tuple[int, ...],
      padding: str,
  ) -> jnp.ndarray:
      """Convert padding string to list of pairs of pad values.
  
      Args:
        in_shape: Input (lhs) shapes for which the padding should be inferred as
          array with dimensions (batch, spatial_dims).
        window_shape: Window (kernel; rhs) shape of the convolution.
        window_strides: Window (kernel; rhs) convolution strides.
        padding: Convlution (rhs) padding.
  
      Returns:
        Inferred lhs paddings as array with dimensions
        (batch, len(spatial_dims), 2).
      """
      xc = jax.lib.xla_client
      if isinstance(padding, str):
          mapping = {
              "VALID": xc.PaddingType.VALID,
              "SAME": xc.PaddingType.SAME,
          }  # pytype: disable=module-attr  # gen-stub-imports
          try:
              padding = mapping[padding.upper()]
          except KeyError as err:
              msg = "Unrecognized padding type: expected 'VALID' or 'SAME', got {}."
              raise RuntimeError(msg.format(padding)) from err
  
      if (
          padding == xc.PaddingType.SAME
      ):  # pytype: disable=module-attr  # gen-stub-imports
          window_shape = jnp.array(window_shape)
          window_strides = jnp.array(window_strides)
          out_shape = _ceil_divide(in_shape, window_strides)
          pad_sizes = jnp.maximum(
              (out_shape - 1) * window_strides
              + window_shape
              - in_shape,
              0,
          )
          pad_sizes = jnp.stack(
              [pad_sizes // 2, pad_sizes - pad_sizes // 2], axis=1
          )
          return pad_sizes
      elif (
          padding == xc.PaddingType.VALID
      ):  # pytype: disable=module-attr  # gen-stub-imports
          return jnp.zeros(
              (in_shape.shape[0], len(window_shape), 2), dtype=jnp.int32
          )
      raise TypeError(f"Unknown padding type: {padding}.")
  
imports: import functools
  from typing import Optional, Tuple, Union, Callable, Any, Sequence, List, Iterable
  import flax.linen
  import jax
  from jax import lax
  import jax.numpy
  import numpy
label_desc: Use image node_id 10 for calling a global function with example usage: padtype_to_pads(in_shape, window_shape, window_strides, padding) and returns: pad_sizes, jnp