import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
import torch.nn as nn
from torch.nn.utils import spectral_norm as spectral_norm_fn
from torch.nn.utils import weight_norm as weight_norm_fn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused_cat_0(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 384
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16 % 6
    x0 = xindex % 16
    x2 = xindex // 96
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 16 * x2), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 2, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = 1.0
    tmp11 = tl.full(tmp10.shape, 0.0, tmp10.dtype)
    tmp12 = tl.where(tmp9, tmp10, tmp11)
    tmp13 = tmp0 >= tmp7
    tl.full([1], 6, tl.int64)
    tmp16 = tl.load(in_ptr1 + (x0 + 16 * (-2 + x1) + 64 * x2), tmp13 &
        xmask, other=0.0)
    tmp17 = tl.where(tmp9, tmp12, tmp16)
    tmp18 = tl.where(tmp4, tmp5, tmp17)
    tl.store(out_ptr0 + x3, tmp18, xmask)


@triton.jit
def triton_poi_fused_convolution_elu_1(in_out_ptr0, in_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 4
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tmp5 = 1.0
    tmp6 = tmp2 * tmp5
    tmp7 = libdevice.expm1(tmp6)
    tmp8 = tmp7 * tmp5
    tmp9 = tl.where(tmp4, tmp6, tmp8)
    tl.store(in_out_ptr0 + x3, tmp9, xmask)


@triton.jit
def triton_poi_fused_convolution_elu_2(in_out_ptr0, in_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 4 % 8
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tmp5 = 1.0
    tmp6 = tmp2 * tmp5
    tmp7 = libdevice.expm1(tmp6)
    tmp8 = tmp7 * tmp5
    tmp9 = tl.where(tmp4, tmp6, tmp8)
    tl.store(in_out_ptr0 + x3, tmp9, xmask)


@triton.jit
def triton_poi_fused_convolution_elu_3(in_out_ptr0, in_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tmp5 = 1.0
    tmp6 = tmp2 * tmp5
    tmp7 = libdevice.expm1(tmp6)
    tmp8 = tmp7 * tmp5
    tmp9 = tl.where(tmp4, tmp6, tmp8)
    tl.store(in_out_ptr0 + x2, tmp9, xmask)


@triton.jit
def triton_poi_fused__to_copy_add_arange_mul_4(out_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 2
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 * tmp2
    tmp4 = tmp3.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp4, xmask)


@triton.jit
def triton_poi_fused__unsafe_index_5(in_ptr0, in_ptr1, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 2 % 2
    x0 = xindex % 2
    x2 = xindex // 4
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr1 + x2, xmask, eviction_policy='evict_last')
    tmp1 = tl.full([XBLOCK], 1, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tl.where(tmp3, tmp2, tmp0)
    tmp6 = tmp5 + tmp1
    tmp7 = tmp5 < 0
    tl.where(tmp7, tmp6, tmp5)
    tl.store(out_ptr0 + x3, tmp9, xmask)


@triton.jit
def triton_poi_fused__to_copy_add_arange_mul_6(out_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.5
    tmp3 = tmp1 * tmp2
    tmp4 = tmp3.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp4, xmask)


@triton.jit
def triton_poi_fused__unsafe_index_7(in_ptr0, in_ptr1, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4 % 4
    x0 = xindex % 4
    x2 = xindex // 16
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.full([XBLOCK], 2, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tmp4 = tl.where(tmp3, tmp2, tmp0)
    tmp6 = tmp5 + tmp1
    tmp7 = tmp5 < 0
    tmp8 = tl.where(tmp7, tmp6, tmp5)
    tmp9 = tl.load(in_ptr1 + (tmp8 + 2 * tmp4 + 4 * x2), xmask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + x4, tmp9, xmask)


@triton.jit
def triton_poi_fused_convolution_elu_8(in_out_ptr0, in_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 2
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tmp5 = 1.0
    tmp6 = tmp2 * tmp5
    tmp7 = libdevice.expm1(tmp6)
    tmp8 = tmp7 * tmp5
    tmp9 = tl.where(tmp4, tmp6, tmp8)
    tl.store(in_out_ptr0 + x3, tmp9, xmask)


@triton.jit
def triton_poi_fused_clamp_convolution_ge_le_logical_and_9(in_ptr0, in_ptr1,
    out_ptr0, out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 4
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = -1.0
    tmp4 = triton_helpers.maximum(tmp2, tmp3)
    tmp5 = 1.0
    tmp6 = triton_helpers.minimum(tmp4, tmp5)
    tmp7 = tmp2 >= tmp3
    tmp8 = tmp2 <= tmp5
    tmp9 = tmp7 & tmp8
    tl.store(out_ptr0 + x3, tmp6, xmask)
    tl.store(out_ptr1 + x3, tmp9, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19, primals_20, primals_21, primals_22,
        primals_23, primals_24, primals_25, primals_26, primals_27,
        primals_28, primals_29, primals_30, primals_31, primals_32,
        primals_33, primals_34, primals_35, primals_36) = args
    args.clear()
    assert_size_stride(primals_1, (4, 1, 4, 4), (16, 16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_3, (4, 6, 5, 5), (150, 25, 5, 1))
    assert_size_stride(primals_4, (4,), (1,))
    assert_size_stride(primals_5, (8, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_6, (8,), (1,))
    assert_size_stride(primals_7, (8, 8, 3, 3), (72, 9, 3, 1))
    assert_size_stride(primals_8, (8,), (1,))
    assert_size_stride(primals_9, (16, 8, 3, 3), (72, 9, 3, 1))
    assert_size_stride(primals_10, (16,), (1,))
    assert_size_stride(primals_11, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_12, (16,), (1,))
    assert_size_stride(primals_13, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_14, (16,), (1,))
    assert_size_stride(primals_15, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_16, (16,), (1,))
    assert_size_stride(primals_17, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_18, (16,), (1,))
    assert_size_stride(primals_19, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_20, (16,), (1,))
    assert_size_stride(primals_21, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_22, (16,), (1,))
    assert_size_stride(primals_23, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_24, (16,), (1,))
    assert_size_stride(primals_25, (16, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_26, (16,), (1,))
    assert_size_stride(primals_27, (8, 16, 3, 3), (144, 9, 3, 1))
    assert_size_stride(primals_28, (8,), (1,))
    assert_size_stride(primals_29, (8, 8, 3, 3), (72, 9, 3, 1))
    assert_size_stride(primals_30, (8,), (1,))
    assert_size_stride(primals_31, (4, 8, 3, 3), (72, 9, 3, 1))
    assert_size_stride(primals_32, (4,), (1,))
    assert_size_stride(primals_33, (2, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_34, (2,), (1,))
    assert_size_stride(primals_35, (4, 2, 3, 3), (18, 9, 3, 1))
    assert_size_stride(primals_36, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 6, 4, 4), (96, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(384)](primals_1, primals_2, buf0, 384,
            XBLOCK=256, num_warps=4, num_stages=1)
        del primals_1
        del primals_2
        buf1 = extern_kernels.convolution(buf0, primals_3, stride=(1, 1),
            padding=(2, 2), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 4, 4, 4), (64, 16, 4, 1))
        buf2 = buf1
        del buf1
        triton_poi_fused_convolution_elu_1[grid(256)](buf2, primals_4, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_4
        buf3 = extern_kernels.convolution(buf2, primals_5, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf3, (4, 8, 2, 2), (32, 4, 2, 1))
        buf4 = buf3
        del buf3
        triton_poi_fused_convolution_elu_2[grid(128)](buf4, primals_6, 128,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_6
        buf5 = extern_kernels.convolution(buf4, primals_7, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf5, (4, 8, 2, 2), (32, 4, 2, 1))
        buf6 = buf5
        del buf5
        triton_poi_fused_convolution_elu_2[grid(128)](buf6, primals_8, 128,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_8
        buf7 = extern_kernels.convolution(buf6, primals_9, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 16, 1, 1), (16, 1, 1, 1))
        buf8 = buf7
        del buf7
        triton_poi_fused_convolution_elu_3[grid(64)](buf8, primals_10, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_10
        buf9 = extern_kernels.convolution(buf8, primals_11, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf9, (4, 16, 1, 1), (16, 1, 1, 1))
        buf10 = buf9
        del buf9
        triton_poi_fused_convolution_elu_3[grid(64)](buf10, primals_12, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_12
        buf11 = extern_kernels.convolution(buf10, primals_13, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf11, (4, 16, 1, 1), (16, 1, 1, 1))
        buf12 = buf11
        del buf11
        triton_poi_fused_convolution_elu_3[grid(64)](buf12, primals_14, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_14
        buf13 = extern_kernels.convolution(buf12, primals_15, stride=(1, 1),
            padding=(2, 2), dilation=(2, 2), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf13, (4, 16, 1, 1), (16, 1, 1, 1))
        buf14 = buf13
        del buf13
        triton_poi_fused_convolution_elu_3[grid(64)](buf14, primals_16, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_16
        buf15 = extern_kernels.convolution(buf14, primals_17, stride=(1, 1),
            padding=(4, 4), dilation=(4, 4), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf15, (4, 16, 1, 1), (16, 1, 1, 1))
        buf16 = buf15
        del buf15
        triton_poi_fused_convolution_elu_3[grid(64)](buf16, primals_18, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_18
        buf17 = extern_kernels.convolution(buf16, primals_19, stride=(1, 1),
            padding=(8, 8), dilation=(8, 8), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf17, (4, 16, 1, 1), (16, 1, 1, 1))
        buf18 = buf17
        del buf17
        triton_poi_fused_convolution_elu_3[grid(64)](buf18, primals_20, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_20
        buf19 = extern_kernels.convolution(buf18, primals_21, stride=(1, 1),
            padding=(16, 16), dilation=(16, 16), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf19, (4, 16, 1, 1), (16, 1, 1, 1))
        buf20 = buf19
        del buf19
        triton_poi_fused_convolution_elu_3[grid(64)](buf20, primals_22, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_22
        buf21 = extern_kernels.convolution(buf20, primals_23, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf21, (4, 16, 1, 1), (16, 1, 1, 1))
        buf22 = buf21
        del buf21
        triton_poi_fused_convolution_elu_3[grid(64)](buf22, primals_24, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_24
        buf23 = extern_kernels.convolution(buf22, primals_25, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf23, (4, 16, 1, 1), (16, 1, 1, 1))
        buf24 = buf23
        del buf23
        triton_poi_fused_convolution_elu_3[grid(64)](buf24, primals_26, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_26
        buf25 = empty_strided_cuda((2,), (1,), torch.int64)
        triton_poi_fused__to_copy_add_arange_mul_4[grid(2)](buf25, 2,
            XBLOCK=2, num_warps=1, num_stages=1)
        buf26 = empty_strided_cuda((4, 16, 2, 2), (64, 4, 2, 1), torch.float32)
        triton_poi_fused__unsafe_index_5[grid(256)](buf25, buf24, buf26, 
            256, XBLOCK=256, num_warps=4, num_stages=1)
        buf27 = extern_kernels.convolution(buf26, primals_27, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf27, (4, 8, 2, 2), (32, 4, 2, 1))
        buf28 = buf27
        del buf27
        triton_poi_fused_convolution_elu_2[grid(128)](buf28, primals_28, 
            128, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_28
        buf29 = extern_kernels.convolution(buf28, primals_29, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf29, (4, 8, 2, 2), (32, 4, 2, 1))
        buf30 = buf29
        del buf29
        triton_poi_fused_convolution_elu_2[grid(128)](buf30, primals_30, 
            128, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_30
        buf31 = empty_strided_cuda((4,), (1,), torch.int64)
        triton_poi_fused__to_copy_add_arange_mul_6[grid(4)](buf31, 4,
            XBLOCK=4, num_warps=1, num_stages=1)
        buf32 = empty_strided_cuda((4, 8, 4, 4), (128, 16, 4, 1), torch.float32
            )
        triton_poi_fused__unsafe_index_7[grid(512)](buf31, buf30, buf32, 
            512, XBLOCK=256, num_warps=4, num_stages=1)
        buf33 = extern_kernels.convolution(buf32, primals_31, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf33, (4, 4, 4, 4), (64, 16, 4, 1))
        buf34 = buf33
        del buf33
        triton_poi_fused_convolution_elu_1[grid(256)](buf34, primals_32, 
            256, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_32
        buf35 = extern_kernels.convolution(buf34, primals_33, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf35, (4, 2, 4, 4), (32, 16, 4, 1))
        buf36 = buf35
        del buf35
        triton_poi_fused_convolution_elu_8[grid(128)](buf36, primals_34, 
            128, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_34
        buf37 = extern_kernels.convolution(buf36, primals_35, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf37, (4, 4, 4, 4), (64, 16, 4, 1))
        buf38 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        buf39 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        triton_poi_fused_clamp_convolution_ge_le_logical_and_9[grid(256)](buf37
            , primals_36, buf38, buf39, 256, XBLOCK=256, num_warps=4,
            num_stages=1)
        del buf37
        del primals_36
    return (buf38, primals_3, primals_5, primals_7, primals_9, primals_11,
        primals_13, primals_15, primals_17, primals_19, primals_21,
        primals_23, primals_25, primals_27, primals_29, primals_31,
        primals_33, primals_35, buf0, buf2, buf4, buf6, buf8, buf10, buf12,
        buf14, buf16, buf18, buf20, buf22, buf24, buf25, buf26, buf28,
        buf30, buf31, buf32, buf34, buf36, buf39)


def gen_conv(input_dim, output_dim, kernel_size=3, stride=1, padding=0,
    rate=1, activation='elu', gated=False):
    """ 
    Convolutions used in the generator.
    
    Args:
        input_dim (int): number of input channels.
        output_dim (int): number of output features.
        kernel_size (int): kernel size of convolutional filters.
        stride (int): convolutional stride.
        padding (int): padding for convolution.
        rate (int): dilation rate of dilated convolution.
        activation (string): activation on computed features.
        gated (bool): boolean deciding on making convolutions "gated".
        
    Return:
        (tensor): result from convolution
    """
    if gated:
        conv2 = Conv2dBlockGated(input_dim, output_dim, kernel_size, stride,
            conv_padding=padding, dilation=rate, activation=activation)
    else:
        conv2 = Conv2dBlock(input_dim, output_dim, kernel_size, stride,
            conv_padding=padding, dilation=rate, activation=activation)
    return conv2


class Conv2dBlock(nn.Module):

    def __init__(self, input_dim, output_dim, kernel_size, stride, padding=
        0, conv_padding=0, dilation=1, weight_norm='none', norm='none',
        activation='relu', pad_type='zero', transpose=False):
        super(Conv2dBlock, self).__init__()
        self.use_bias = True
        if pad_type == 'reflect':
            self.pad = nn.ReflectionPad2d(padding)
        elif pad_type == 'replicate':
            self.pad = nn.ReplicationPad2d(padding)
        elif pad_type == 'zero':
            self.pad = nn.ZeroPad2d(padding)
        elif pad_type == 'none':
            self.pad = None
        else:
            assert 0, 'Unsupported padding type: {}'.format(pad_type)
        norm_dim = output_dim
        if norm == 'bn':
            self.norm = nn.BatchNorm2d(norm_dim)
        elif norm == 'in':
            self.norm = nn.InstanceNorm2d(norm_dim)
        elif norm == 'none':
            self.norm = None
        else:
            assert 0, 'Unsupported normalization: {}'.format(norm)
        if weight_norm == 'sn':
            self.weight_norm = spectral_norm_fn
        elif weight_norm == 'wn':
            self.weight_norm = weight_norm_fn
        elif weight_norm == 'none':
            self.weight_norm = None
        else:
            assert 0, 'Unsupported normalization: {}'.format(weight_norm)
        if activation == 'relu':
            self.activation = nn.ReLU(inplace=True)
        elif activation == 'elu':
            self.activation = nn.ELU(inplace=True)
        elif activation == 'lrelu':
            self.activation = nn.LeakyReLU(0.2, inplace=True)
        elif activation == 'prelu':
            self.activation = nn.PReLU()
        elif activation == 'selu':
            self.activation = nn.SELU(inplace=True)
        elif activation == 'tanh':
            self.activation = nn.Tanh()
        elif activation == 'none':
            self.activation = None
        else:
            assert 0, 'Unsupported activation: {}'.format(activation)
        if transpose:
            self.conv = nn.ConvTranspose2d(input_dim, output_dim,
                kernel_size, stride, padding=conv_padding, output_padding=
                conv_padding, dilation=dilation, bias=self.use_bias)
        else:
            self.conv = nn.Conv2d(input_dim, output_dim, kernel_size,
                stride, padding=conv_padding, dilation=dilation, bias=self.
                use_bias)
        if self.weight_norm:
            self.conv = self.weight_norm(self.conv)

    def forward(self, x):
        if self.pad:
            x = self.conv(self.pad(x))
        else:
            x = self.conv(x)
        if self.norm:
            x = self.norm(x)
        if self.activation:
            x = self.activation(x)
        return x


class Conv2dBlockGated(nn.Module):

    def __init__(self, input_dim, output_dim, kernel_size, stride, padding=
        0, conv_padding=0, dilation=1, weight_norm='none', norm='none',
        activation='relu', pad_type='zero', transpose=False):
        super(Conv2dBlockGated, self).__init__()
        self.use_bias = True
        self._output_dim = output_dim
        if pad_type == 'reflect':
            self.pad = nn.ReflectionPad2d(padding)
        elif pad_type == 'replicate':
            self.pad = nn.ReplicationPad2d(padding)
        elif pad_type == 'zero':
            self.pad = nn.ZeroPad2d(padding)
        elif pad_type == 'none':
            self.pad = None
        else:
            assert 0, 'Unsupported padding type: {}'.format(pad_type)
        norm_dim = output_dim
        if norm == 'bn':
            self.norm = nn.BatchNorm2d(norm_dim)
        elif norm == 'in':
            self.norm = nn.InstanceNorm2d(norm_dim)
        elif norm == 'none':
            self.norm = None
        else:
            assert 0, 'Unsupported normalization: {}'.format(norm)
        if weight_norm == 'sn':
            self.weight_norm = spectral_norm_fn
        elif weight_norm == 'wn':
            self.weight_norm = weight_norm_fn
        elif weight_norm == 'none':
            self.weight_norm = None
        else:
            assert 0, 'Unsupported normalization: {}'.format(weight_norm)
        if activation == 'relu':
            self.activation = nn.ReLU(inplace=True)
        elif activation == 'elu':
            self.activation = nn.ELU(inplace=True)
        elif activation == 'lrelu':
            self.activation = nn.LeakyReLU(0.2, inplace=True)
        elif activation == 'prelu':
            self.activation = nn.PReLU()
        elif activation == 'selu':
            self.activation = nn.SELU(inplace=True)
        elif activation == 'tanh':
            self.activation = nn.Tanh()
        elif activation == 'none':
            self.activation = None
        else:
            assert 0, 'Unsupported activation: {}'.format(activation)
        if transpose:
            self.conv = nn.ConvTranspose2d(input_dim, output_dim,
                kernel_size, stride, padding=conv_padding, output_padding=
                conv_padding, dilation=dilation, bias=self.use_bias)
            self.gate = nn.ConvTranspose2d(input_dim, output_dim,
                kernel_size, stride, padding=conv_padding, output_padding=
                conv_padding, dilation=dilation, bias=self.use_bias)
        else:
            self.conv = nn.Conv2d(input_dim, output_dim, kernel_size,
                stride, padding=conv_padding, dilation=dilation, bias=self.
                use_bias)
            self.gate = nn.Conv2d(input_dim, output_dim, kernel_size,
                stride, padding=conv_padding, dilation=dilation, bias=self.
                use_bias)
        if self.weight_norm:
            self.conv = self.weight_norm(self.conv)
            self.gate = self.weight_norm(self.gate)

    def forward(self, x):
        if self.pad:
            feat = self.conv(self.pad(x))
            gate = self.gate(self.pad(x))
        else:
            feat = self.conv(x)
            gate = self.gate(x)
        if self.norm:
            feat = self.norm(feat)
            gate = self.norm(gate)
        if self.activation is None or self._output_dim == 3:
            return feat
        feat = self.activation(feat)
        gate = torch.sigmoid(gate)
        return feat * gate


class CoarseGeneratorNew(nn.Module):

    def __init__(self, input_dim, cnum, gated=False, use_cuda=True, device=0):
        super(CoarseGeneratorNew, self).__init__()
        self.use_cuda = use_cuda
        self.device = device
        self.conv1 = gen_conv(input_dim + 2, cnum, 5, 1, 2, gated=gated)
        self.conv2_downsample = gen_conv(cnum, cnum * 2, 3, 2, 1, gated=gated)
        self.conv3 = gen_conv(cnum * 2, cnum * 2, 3, 1, 1, gated=gated)
        self.conv4_downsample = gen_conv(cnum * 2, cnum * 4, 3, 2, 1, gated
            =gated)
        self.conv5 = gen_conv(cnum * 4, cnum * 4, 3, 1, 1, gated=gated)
        self.conv6 = gen_conv(cnum * 4, cnum * 4, 3, 1, 1, gated=gated)
        self.conv7_atrous = gen_conv(cnum * 4, cnum * 4, 3, 1, 2, rate=2,
            gated=gated)
        self.conv8_atrous = gen_conv(cnum * 4, cnum * 4, 3, 1, 4, rate=4,
            gated=gated)
        self.conv9_atrous = gen_conv(cnum * 4, cnum * 4, 3, 1, 8, rate=8,
            gated=gated)
        self.conv10_atrous = gen_conv(cnum * 4, cnum * 4, 3, 1, 16, rate=16,
            gated=gated)
        self.conv11 = gen_conv(cnum * 4, cnum * 4, 3, 1, 1, gated=gated)
        self.conv12 = gen_conv(cnum * 4, cnum * 4, 3, 1, 1, gated=gated)
        self.conv13 = gen_conv(cnum * 4, cnum * 2, 3, 1, 1, gated=gated)
        self.conv14 = gen_conv(cnum * 2, cnum * 2, 3, 1, 1, gated=gated)
        self.conv15 = gen_conv(cnum * 2, cnum, 3, 1, 1, gated=gated)
        self.conv16 = gen_conv(cnum, cnum // 2, 3, 1, 1, gated=gated)
        self.conv17 = gen_conv(cnum // 2, input_dim, 3, 1, 1, activation=
            'none', gated=gated)

    def forward(self, input_0, input_1):
        primals_3 = self.conv1.conv.weight
        primals_4 = self.conv1.conv.bias
        primals_5 = self.conv2_downsample.conv.weight
        primals_6 = self.conv2_downsample.conv.bias
        primals_7 = self.conv3.conv.weight
        primals_8 = self.conv3.conv.bias
        primals_9 = self.conv4_downsample.conv.weight
        primals_10 = self.conv4_downsample.conv.bias
        primals_11 = self.conv5.conv.weight
        primals_12 = self.conv5.conv.bias
        primals_13 = self.conv6.conv.weight
        primals_14 = self.conv6.conv.bias
        primals_15 = self.conv7_atrous.conv.weight
        primals_16 = self.conv7_atrous.conv.bias
        primals_17 = self.conv8_atrous.conv.weight
        primals_18 = self.conv8_atrous.conv.bias
        primals_19 = self.conv9_atrous.conv.weight
        primals_20 = self.conv9_atrous.conv.bias
        primals_21 = self.conv10_atrous.conv.weight
        primals_22 = self.conv10_atrous.conv.bias
        primals_23 = self.conv11.conv.weight
        primals_24 = self.conv11.conv.bias
        primals_25 = self.conv12.conv.weight
        primals_26 = self.conv12.conv.bias
        primals_27 = self.conv13.conv.weight
        primals_28 = self.conv13.conv.bias
        primals_29 = self.conv14.conv.weight
        primals_30 = self.conv14.conv.bias
        primals_31 = self.conv15.conv.weight
        primals_32 = self.conv15.conv.bias
        primals_33 = self.conv16.conv.weight
        primals_34 = self.conv16.conv.bias
        primals_35 = self.conv17.conv.weight
        primals_36 = self.conv17.conv.bias
        primals_1 = input_0
        primals_2 = input_1
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19,
            primals_20, primals_21, primals_22, primals_23, primals_24,
            primals_25, primals_26, primals_27, primals_28, primals_29,
            primals_30, primals_31, primals_32, primals_33, primals_34,
            primals_35, primals_36])
        return output[0]


Measured latency_ms: 0.084623