# Path: deep_architect/helpers/pytorch_support.py
# def siso_pytorch_module(name, compile_fn, name_to_hyperp, scope=None):
#     return PyTorchModule(name, compile_fn, name_to_hyperp, ['in'], ['out'],
#                          scope).get_io()


from math import ceil
from deep_architect.helpers.pytorch_support import siso_pytorch_module
import torch
import torch.nn as nn
import torch.nn.functional as F
    pad_bottom = pad_along_height - pad_top
    pad_left = pad_along_width // 2
    pad_right = pad_along_width - pad_left
    return (pad_left, pad_right, pad_top, pad_bottom)


def conv2d(h_num_filters,
           h_filter_width,
           h_stride=1,
           h_dilation_rate=1,
           h_use_bias=True):

    def compile_fn(di, dh):
        (_, channels, height, width) = di['in'].size()
        padding = nn.ZeroPad2d(
            calculate_same_padding(height, width, dh['stride'],
                                   dh['filter_width']))
        conv = nn.Conv2d(channels,
                         dh['num_filters'],
                         dh['filter_width'],
                         stride=dh['stride'],
                         dilation=dh['dilation_rate'],
                         bias=dh['use_bias'])

        def fn(di):
            x = padding(di['in'])
            return {'out': conv(x)}

        return fn, [conv, padding]


# Path: deep_architect/helpers/pytorch_support.py
# def siso_pytorch_module(name, compile_fn, name_to_hyperp, scope=None):
#     return PyTorchModule(name, compile_fn, name_to_hyperp, ['in'], ['out'],
#                          scope).get_io()


# Path: deep_architect/contrib/deep_learning_backend/pytorch_ops.py
from math import ceil
from deep_architect.helpers.pytorch_support import siso_pytorch_module
import torch
import torch.nn as nn
import torch.nn.functional as F

    pad_bottom = pad_along_height - pad_top
    pad_left = pad_along_width // 2
    pad_right = pad_along_width - pad_left
    return (pad_left, pad_right, pad_top, pad_bottom)


def conv2d(h_num_filters,
           h_filter_width,
           h_stride=1,
           h_dilation_rate=1,
           h_use_bias=True):

    def compile_fn(di, dh):
        (_, channels, height, width) = di['in'].size()
        padding = nn.ZeroPad2d(
            calculate_same_padding(height, width, dh['stride'],
                                   dh['filter_width']))
        conv = nn.Conv2d(channels,
                         dh['num_filters'],
                         dh['filter_width'],
                         stride=dh['stride'],
                         dilation=dh['dilation_rate'],
                         bias=dh['use_bias'])

        def fn(di):
            x = padding(di['in'])
            return {'out': conv(x)}

        return fn, [conv, padding]


    return siso_pytorch_module(