# Path: experimental/lo/utils.py
# def get_padding_value(padding, kernel):
#   """Returns padding value for kernel."""
# 
#   if padding == "valid":
#     return 0
#   elif padding == "same":
#     return kernel // 2
#   elif padding == "full":
#     return kernel - 1
# 
#   raise ValueError("accepted paddings are 'valid', 'same' or 'full', found " +
#                    padding)


import math
from .utils import get_padding_value
  o_index = model.layers.index(o_layer)

  for i in range(i_index, o_index+1):
    k_h, k_w = (1, 1)
    s_h, s_w = (1, 1)
    p_h, p_w = (0, 0)

    if hasattr(model.layers[i], "kernel_size"):
      kernel = model.layers[i].kernel_size

      if isinstance(kernel, int):
        kernel = [kernel, kernel]

      k_h, k_w = kernel[0], kernel[1]

    if hasattr(model.layers[i], "strides"):
      strides = model.layers[i].strides

      if isinstance(strides, int):
        strides = [strides, strides]

      s_h, s_w = strides[0], strides[1]

    if hasattr(model.layers[i], "padding"):
      padding = model.layers[i].padding

      if isinstance(padding, str):
        padding = [padding, padding]

      p_h = get_padding_value(padding[0], k_h)

# Path: experimental/lo/utils.py
# def get_padding_value(padding, kernel):
#   """Returns padding value for kernel."""
# 
#   if padding == "valid":
#     return 0
#   elif padding == "same":
#     return kernel // 2
#   elif padding == "full":
#     return kernel - 1
# 
#   raise ValueError("accepted paddings are 'valid', 'same' or 'full', found " +
#                    padding)


# Path: experimental/lo/receptive.py
import math
from .utils import get_padding_value

  o_index = model.layers.index(o_layer)

  for i in range(i_index, o_index+1):
    k_h, k_w = (1, 1)
    s_h, s_w = (1, 1)
    p_h, p_w = (0, 0)

    if hasattr(model.layers[i], "kernel_size"):
      kernel = model.layers[i].kernel_size

      if isinstance(kernel, int):
        kernel = [kernel, kernel]

      k_h, k_w = kernel[0], kernel[1]

    if hasattr(model.layers[i], "strides"):
      strides = model.layers[i].strides

      if isinstance(strides, int):
        strides = [strides, strides]

      s_h, s_w = strides[0], strides[1]

    if hasattr(model.layers[i], "padding"):
      padding = model.layers[i].padding

      if isinstance(padding, str):
        padding = [padding, padding]

      p_h = get_padding_value(padding[0], k_h)

      p_w = get_padding_value(padding[1], k_w)