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
import torch.nn as nn
import torch.nn.parallel
import torch.utils.data
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_0(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 12
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (x2 + 16 * y3), xmask & ymask, eviction_policy
        ='evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x2 + 48 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 384
    xnumel = 9
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x2 + 27 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 9
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 128
    y1 = yindex // 128
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask, eviction_policy='evict_last'
        )
    tl.store(out_ptr0 + (y0 + 128 * x2 + 1152 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_add_div_3(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 48
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 3
    x1 = xindex // 3 % 2
    x2 = xindex // 6
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 6 * x1 + 24 * x2), xmask)
    tmp1 = tl.load(in_ptr0 + (12 + x0 + 6 * x1 + 24 * x2), xmask)
    tmp3 = tl.load(in_ptr0 + (3 + x0 + 6 * x1 + 24 * x2), xmask)
    tmp5 = tl.load(in_ptr0 + (15 + x0 + 6 * x1 + 24 * x2), xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 0.25
    tmp8 = tmp6 * tmp7
    tl.store(out_ptr0 + x3, tmp8, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_4(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_add_convolution_div_relu_5(in_out_ptr0, in_ptr0,
    in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 128
    x1 = xindex // 128 % 2
    x2 = xindex // 256
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 256 * x1 + 1024 * x2), None)
    tmp1 = tl.load(in_ptr1 + x0, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (512 + x0 + 256 * x1 + 1024 * x2), None)
    tmp6 = tl.load(in_ptr0 + (128 + x0 + 256 * x1 + 1024 * x2), None)
    tmp9 = tl.load(in_ptr0 + (640 + x0 + 256 * x1 + 1024 * x2), None)
    tmp14 = tl.load(in_out_ptr0 + x3, None)
    tmp15 = tl.load(in_ptr2 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp4 = tmp3 + tmp1
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 + tmp1
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 + tmp1
    tmp11 = tmp8 + tmp10
    tmp12 = 0.25
    tmp13 = tmp11 * tmp12
    tmp16 = tmp14 + tmp15
    tmp17 = tmp13 + tmp16
    tmp18 = tl.full([1], 0, tl.int32)
    tmp19 = triton_helpers.maximum(tmp18, tmp17)
    tl.store(in_out_ptr0 + x3, tmp17, None)
    tl.store(out_ptr0 + x3, tmp19, None)


@triton.jit
def triton_poi_fused_convolution_relu_6(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_add_div_relu_7(in_ptr0, in_ptr1, in_ptr2, in_ptr3,
    out_ptr0, out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 128
    x1 = xindex // 128
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 512 * x1), xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (256 + x0 + 512 * x1), xmask)
    tmp6 = tl.load(in_ptr0 + (128 + x0 + 512 * x1), xmask)
    tmp9 = tl.load(in_ptr0 + (384 + x0 + 512 * x1), xmask)
    tmp14 = tl.load(in_ptr2 + (x0 + 512 * x1), xmask)
    tmp15 = tl.load(in_ptr3 + x0, xmask, eviction_policy='evict_last')
    tmp17 = tl.load(in_ptr2 + (256 + x0 + 512 * x1), xmask)
    tmp20 = tl.load(in_ptr2 + (128 + x0 + 512 * x1), xmask)
    tmp23 = tl.load(in_ptr2 + (384 + x0 + 512 * x1), xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp3 + tmp1
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 + tmp1
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 + tmp1
    tmp11 = tmp8 + tmp10
    tmp12 = 0.25
    tmp13 = tmp11 * tmp12
    tmp16 = tmp14 + tmp15
    tmp18 = tmp17 + tmp15
    tmp19 = tmp16 + tmp18
    tmp21 = tmp20 + tmp15
    tmp22 = tmp19 + tmp21
    tmp24 = tmp23 + tmp15
    tmp25 = tmp22 + tmp24
    tmp26 = tmp25 * tmp12
    tmp27 = tmp13 + tmp26
    tmp28 = tl.full([1], 0, tl.int32)
    tmp29 = triton_helpers.maximum(tmp28, tmp27)
    tl.store(out_ptr0 + x2, tmp27, xmask)
    tl.store(out_ptr1 + x2, tmp29, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_8(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, xmask)


@triton.jit
def triton_poi_fused_add_convolution_relu_9(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x2, xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp5 = tl.full([1], 0, tl.int32)
    tmp6 = triton_helpers.maximum(tmp5, tmp4)
    tl.store(out_ptr0 + x2, tmp6, xmask)


@triton.jit
def triton_poi_fused_add_convolution_mean_relu_threshold_backward_10(
    in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, out_ptr1,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x2, xmask)
    tmp4 = tl.load(in_ptr3 + x0, xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_out_ptr0 + x2, xmask)
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp2 + tmp7
    tmp9 = tl.full([1], 0, tl.int32)
    tmp10 = triton_helpers.maximum(tmp9, tmp8)
    tmp11 = 1.0
    tmp12 = tmp10 / tmp11
    tmp13 = tmp12 / tmp11
    tmp14 = 0.0
    tmp15 = tmp10 <= tmp14
    tl.store(out_ptr0 + x2, tmp13, xmask)
    tl.store(out_ptr1 + x2, tmp15, 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) = args
    args.clear()
    assert_size_stride(primals_1, (4, 3, 4, 4), (48, 16, 4, 1))
    assert_size_stride(primals_2, (128, 3, 1, 1), (3, 1, 1, 1))
    assert_size_stride(primals_3, (128,), (1,))
    assert_size_stride(primals_4, (128, 3, 3, 3), (27, 9, 3, 1))
    assert_size_stride(primals_5, (128,), (1,))
    assert_size_stride(primals_6, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_7, (128,), (1,))
    assert_size_stride(primals_8, (128, 128, 1, 1), (128, 1, 1, 1))
    assert_size_stride(primals_9, (128,), (1,))
    assert_size_stride(primals_10, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_11, (128,), (1,))
    assert_size_stride(primals_12, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_13, (128,), (1,))
    assert_size_stride(primals_14, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_15, (128,), (1,))
    assert_size_stride(primals_16, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_17, (128,), (1,))
    assert_size_stride(primals_18, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_19, (128,), (1,))
    assert_size_stride(primals_20, (128, 128, 3, 3), (1152, 9, 3, 1))
    assert_size_stride(primals_21, (128,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 3, 4, 4), (48, 1, 12, 3), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_0[grid(12, 16)](primals_1, buf0, 12, 16, XBLOCK=16,
            YBLOCK=16, num_warps=4, num_stages=1)
        del primals_1
        buf1 = empty_strided_cuda((128, 3, 3, 3), (27, 1, 9, 3), torch.float32)
        triton_poi_fused_1[grid(384, 9)](primals_4, buf1, 384, 9, XBLOCK=16,
            YBLOCK=64, num_warps=4, num_stages=1)
        del primals_4
        buf2 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_6, buf2, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_6
        buf3 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_10, buf3, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_10
        buf4 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_12, buf4, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_12
        buf5 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_14, buf5, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_14
        buf6 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_16, buf6, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_16
        buf7 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_18, buf7, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_18
        buf8 = empty_strided_cuda((128, 128, 3, 3), (1152, 1, 384, 128),
            torch.float32)
        triton_poi_fused_2[grid(16384, 9)](primals_20, buf8, 16384, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_20
        buf9 = empty_strided_cuda((4, 3, 2, 2), (12, 1, 6, 3), torch.float32)
        triton_poi_fused_add_div_3[grid(48)](buf0, buf9, 48, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf10 = extern_kernels.convolution(buf9, primals_2, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 128, 2, 2), (512, 1, 256, 128))
        buf11 = extern_kernels.convolution(buf0, buf1, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf11, (4, 128, 4, 4), (2048, 1, 512, 128))
        buf12 = buf11
        del buf11
        triton_poi_fused_convolution_relu_4[grid(8192)](buf12, primals_5, 
            8192, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_5
        buf13 = extern_kernels.convolution(buf12, buf2, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf13, (4, 128, 4, 4), (2048, 1, 512, 128))
        buf14 = buf10
        del buf10
        buf16 = empty_strided_cuda((4, 128, 2, 2), (512, 1, 256, 128),
            torch.float32)
        triton_poi_fused_add_convolution_div_relu_5[grid(2048)](buf14,
            buf13, primals_7, primals_3, buf16, 2048, XBLOCK=256, num_warps
            =4, num_stages=1)
        del buf13
        del primals_3
        del primals_7
        buf15 = extern_kernels.convolution(buf14, primals_8, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf15, (4, 128, 2, 2), (512, 1, 256, 128))
        buf17 = extern_kernels.convolution(buf16, buf3, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf17, (4, 128, 2, 2), (512, 1, 256, 128))
        buf18 = buf17
        del buf17
        triton_poi_fused_convolution_relu_6[grid(2048)](buf18, primals_11, 
            2048, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_11
        buf19 = extern_kernels.convolution(buf18, buf4, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf19, (4, 128, 2, 2), (512, 1, 256, 128))
        buf20 = empty_strided_cuda((4, 128, 1, 1), (128, 1, 512, 512),
            torch.float32)
        buf21 = empty_strided_cuda((4, 128, 1, 1), (128, 1, 128, 128),
            torch.float32)
        triton_poi_fused_add_div_relu_7[grid(512)](buf19, primals_13, buf15,
            primals_9, buf20, buf21, 512, XBLOCK=256, num_warps=4, num_stages=1
            )
        del buf15
        del buf19
        del primals_13
        del primals_9
        buf22 = extern_kernels.convolution(buf21, buf5, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf22, (4, 128, 1, 1), (128, 1, 128, 128))
        buf23 = buf22
        del buf22
        triton_poi_fused_convolution_relu_8[grid(512)](buf23, primals_15, 
            512, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_15
        buf24 = extern_kernels.convolution(buf23, buf6, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf24, (4, 128, 1, 1), (128, 1, 128, 128))
        buf25 = empty_strided_cuda((4, 128, 1, 1), (128, 1, 128, 128),
            torch.float32)
        triton_poi_fused_add_convolution_relu_9[grid(512)](buf24,
            primals_17, buf20, buf25, 512, XBLOCK=128, num_warps=4,
            num_stages=1)
        buf26 = extern_kernels.convolution(buf25, buf7, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf26, (4, 128, 1, 1), (128, 1, 128, 128))
        buf27 = buf26
        del buf26
        triton_poi_fused_convolution_relu_8[grid(512)](buf27, primals_19, 
            512, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_19
        buf28 = extern_kernels.convolution(buf27, buf8, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf28, (4, 128, 1, 1), (128, 1, 128, 128))
        buf29 = buf20
        del buf20
        buf30 = empty_strided_cuda((4, 128), (128, 1), torch.float32)
        buf31 = empty_strided_cuda((4, 128, 1, 1), (128, 1, 128, 128),
            torch.bool)
        triton_poi_fused_add_convolution_mean_relu_threshold_backward_10[grid
            (512)](buf29, buf28, primals_21, buf24, primals_17, buf30,
            buf31, 512, XBLOCK=256, num_warps=4, num_stages=1)
        del buf24
        del buf28
        del buf29
        del primals_17
        del primals_21
    return (buf30, buf0, primals_2, buf1, buf2, primals_8, buf3, buf4, buf5,
        buf6, buf7, buf8, buf9, buf12, buf14, buf16, buf18, buf21, buf23,
        buf25, buf27, buf31)


class avgpool(nn.Module):
    """
    Mean pooling class - downsampling
    """

    def __init__(self, up_size=0):
        super(avgpool, self).__init__()

    def forward(self, x):
        out_man = (x[:, :, ::2, ::2] + x[:, :, 1::2, ::2] + x[:, :, ::2, 1:
            :2] + x[:, :, 1::2, 1::2]) / 4
        return out_man


class ResidualBlock(nn.Module):
    """
    Residual block class
    3 types: upsample, downsample, None 
    """

    def __init__(self, in_dim, out_dim, resample=None, up_size=0):
        super(ResidualBlock, self).__init__()
        if resample == 'up':
            self.bn1 = nn.BatchNorm2d(in_dim)
            self.conv1 = nn.Conv2d(in_dim, out_dim, 3, 1, 1, bias=True)
            self.upsample = torch.nn.Upsample(up_size, 2)
            self.upsample = torch.nn.Upsample(scale_factor=2)
            self.upsample_conv = nn.Conv2d(in_dim, out_dim, 1, 1, 0, bias=True)
            self.conv2 = nn.Conv2d(out_dim, out_dim, 3, 1, 1, bias=True)
            self.bn2 = nn.BatchNorm2d(out_dim)
        elif resample == 'down':
            self.conv1 = nn.Conv2d(in_dim, out_dim, 3, 1, 1, bias=True)
            self.conv2 = nn.Conv2d(out_dim, out_dim, 3, 1, 1, bias=True)
            self.pool = avgpool()
            self.pool_conv = nn.Conv2d(in_dim, out_dim, 1, 1, 0, bias=True)
        elif resample is None:
            self.conv1 = nn.Conv2d(in_dim, out_dim, 3, 1, 1, bias=True)
            self.conv2 = nn.Conv2d(out_dim, out_dim, 3, 1, 1, bias=True)
        self.resample = resample

    def forward(self, x):
        if self.resample is None:
            shortcut = x
            output = x
            output = nn.functional.relu(output)
            output = self.conv1(output)
            output = nn.functional.relu(output)
            output = self.conv2(output)
        elif self.resample == 'up':
            shortcut = x
            output = x
            shortcut = self.upsample(shortcut)
            shortcut = self.upsample_conv(shortcut)
            output = self.bn1(output)
            output = nn.functional.relu(output)
            output = self.conv1(output)
            output = self.bn2(output)
            output = nn.functional.relu(output)
            output = self.upsample(output)
            output = self.conv2(output)
        elif self.resample == 'down':
            shortcut = x
            output = x
            shortcut = self.pool_conv(shortcut)
            shortcut = self.pool(shortcut)
            output = nn.functional.relu(output)
            output = self.conv1(output)
            output = nn.functional.relu(output)
            output = self.conv2(output)
            output = self.pool(output)
        return output + shortcut


class ResidualBlock_thefirstone(nn.Module):
    """
    First residual block class 
    """

    def __init__(self, in_dim, out_dim, resample=None, up_size=0):
        super(ResidualBlock_thefirstone, self).__init__()
        self.conv1 = nn.Conv2d(in_dim, out_dim, 3, 1, 1, bias=True)
        self.conv2 = nn.Conv2d(out_dim, out_dim, 3, 1, 1, bias=True)
        self.pool = avgpool()
        self.pool_conv = nn.Conv2d(in_dim, out_dim, 1, 1, 0, bias=True)

    def forward(self, x):
        shortcut = x
        output = x
        shortcut = self.pool(shortcut)
        shortcut = self.pool_conv(shortcut)
        output = self.conv1(output)
        output = nn.functional.relu(output)
        output = self.conv2(output)
        output = self.pool(output)
        return output + shortcut


class discriminatorNew(nn.Module):
    """
    First part of discriminator network D class
    4 residual blocks, 1 downsampling 
    """

    def __init__(self):
        super(discriminatorNew, self).__init__()
        self.layer_down_1 = ResidualBlock_thefirstone(3, 128)
        self.layer_down_2 = ResidualBlock(128, 128, 'down')
        self.layer_none_1 = ResidualBlock(128, 128, None)
        self.layer_none_2 = ResidualBlock(128, 128, None)

    def forward(self, input_0):
        primals_4 = self.layer_down_1.conv1.weight
        primals_3 = self.layer_down_1.conv1.bias
        primals_6 = self.layer_down_1.conv2.weight
        primals_5 = self.layer_down_1.conv2.bias
        primals_2 = self.layer_down_1.pool_conv.weight
        primals_7 = self.layer_down_1.pool_conv.bias
        primals_10 = self.layer_down_2.conv1.weight
        primals_9 = self.layer_down_2.conv1.bias
        primals_12 = self.layer_down_2.conv2.weight
        primals_11 = self.layer_down_2.conv2.bias
        primals_8 = self.layer_down_2.pool_conv.weight
        primals_13 = self.layer_down_2.pool_conv.bias
        primals_14 = self.layer_none_1.conv1.weight
        primals_15 = self.layer_none_1.conv1.bias
        primals_16 = self.layer_none_1.conv2.weight
        primals_17 = self.layer_none_1.conv2.bias
        primals_18 = self.layer_none_2.conv1.weight
        primals_19 = self.layer_none_2.conv1.bias
        primals_20 = self.layer_none_2.conv2.weight
        primals_21 = self.layer_none_2.conv2.bias
        primals_1 = input_0
        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])
        return output[0]


Measured latency_ms: 0.013901