# AOT ID: ['0_forward']
from ctypes import c_void_p, c_long, c_int
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align
from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_7/inductor_cache/lv/clvzx25732myfrqodtzxlp67aysmsqlfjxnea3ltyyfkdsanjiqr.py
# Topologically Sorted Source Nodes: [x], Original ATen: [aten.cat]
# Source node to ATen node mapping:
#   x => cat
# Graph fragment:
#   %cat : [num_users=2] = call_function[target=torch.ops.aten.cat.default](args = ([%primals_1, %full_default, %primals_2], 1), kwargs = {})
triton_poi_fused_cat_0 = async_compile.triton('triton_poi_fused_cat_0', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[512], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_cat_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    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
    tmp14 = tl.full([1], 6, tl.int64)
    tmp15 = tmp0 < tmp14
    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)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/7r/c7rmcz7d66c7acqsst3ljub72usieb7gow6csu7nmp55tklmjx2e.py
# Topologically Sorted Source Nodes: [x_1, x_2], Original ATen: [aten.convolution, aten.elu]
# Source node to ATen node mapping:
#   x_1 => convolution
#   x_2 => expm1, gt, mul, mul_2, where
# Graph fragment:
#   %convolution : [num_users=2] = call_function[target=torch.ops.aten.convolution.default](args = (%cat, %primals_3, %primals_4, [1, 1], [2, 2], [1, 1], False, [0, 0], 1), kwargs = {})
#   %gt : [num_users=1] = call_function[target=torch.ops.aten.gt.Scalar](args = (%convolution, 0), kwargs = {})
#   %mul : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%convolution, 1.0), kwargs = {})
#   %expm1 : [num_users=1] = call_function[target=torch.ops.aten.expm1.default](args = (%mul,), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%expm1, 1.0), kwargs = {})
#   %where : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%gt, %mul, %mul_2), kwargs = {})
triton_poi_fused_convolution_elu_1 = async_compile.triton('triton_poi_fused_convolution_elu_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_convolution_elu_1', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/u3/cu3cfmubkiyk5dbvvj5zq466dahopzbjdxq5qozb6sk66stjzue3.py
# Topologically Sorted Source Nodes: [x_3, x_4], Original ATen: [aten.convolution, aten.elu]
# Source node to ATen node mapping:
#   x_3 => convolution_1
#   x_4 => expm1_1, gt_1, mul_3, mul_5, where_1
# Graph fragment:
#   %convolution_1 : [num_users=2] = call_function[target=torch.ops.aten.convolution.default](args = (%where, %primals_5, %primals_6, [2, 2], [1, 1], [1, 1], False, [0, 0], 1), kwargs = {})
#   %gt_1 : [num_users=1] = call_function[target=torch.ops.aten.gt.Scalar](args = (%convolution_1, 0), kwargs = {})
#   %mul_3 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%convolution_1, 1.0), kwargs = {})
#   %expm1_1 : [num_users=1] = call_function[target=torch.ops.aten.expm1.default](args = (%mul_3,), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%expm1_1, 1.0), kwargs = {})
#   %where_1 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%gt_1, %mul_3, %mul_5), kwargs = {})
triton_poi_fused_convolution_elu_2 = async_compile.triton('triton_poi_fused_convolution_elu_2', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[128], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_convolution_elu_2', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/wl/cwljbdsy4glorpim7lyllouexxwjzmezgaylwqv5k3dyfpske6by.py
# Topologically Sorted Source Nodes: [x_7, x_8], Original ATen: [aten.convolution, aten.elu]
# Source node to ATen node mapping:
#   x_7 => convolution_3
#   x_8 => expm1_3, gt_3, mul_11, mul_9, where_3
# Graph fragment:
#   %convolution_3 : [num_users=2] = call_function[target=torch.ops.aten.convolution.default](args = (%where_2, %primals_9, %primals_10, [2, 2], [1, 1], [1, 1], False, [0, 0], 1), kwargs = {})
#   %gt_3 : [num_users=1] = call_function[target=torch.ops.aten.gt.Scalar](args = (%convolution_3, 0), kwargs = {})
#   %mul_9 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%convolution_3, 1.0), kwargs = {})
#   %expm1_3 : [num_users=1] = call_function[target=torch.ops.aten.expm1.default](args = (%mul_9,), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%expm1_3, 1.0), kwargs = {})
#   %where_3 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%gt_3, %mul_9, %mul_11), kwargs = {})
triton_poi_fused_convolution_elu_3 = async_compile.triton('triton_poi_fused_convolution_elu_3', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_convolution_elu_3', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/5b/c5bqzi3g5f7nghcfqcv454wosnrwzctdwbje6lvx3qpl6ubh3sql.py
# Topologically Sorted Source Nodes: [x_25], Original ATen: [aten.arange, aten.add, aten.mul, aten._to_copy]
# Source node to ATen node mapping:
#   x_25 => add, add_1, convert_element_type, convert_element_type_1, iota, mul_36, mul_37
# Graph fragment:
#   %iota : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (2,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %mul_36 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%iota, 1), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_36, 0), kwargs = {})
#   %convert_element_type : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add, torch.float32), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%convert_element_type, 0.0), kwargs = {})
#   %mul_37 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_1, 0.5), kwargs = {})
#   %convert_element_type_1 : [num_users=3] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%mul_37, torch.int64), kwargs = {})
triton_poi_fused__to_copy_add_arange_mul_4 = async_compile.triton('triton_poi_fused__to_copy_add_arange_mul_4', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[2], 
    filename=__file__,
    triton_meta={'signature': {0: '*i64', 1: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0,), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_add_arange_mul_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 0, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/cq/ccqpryhwsrachhalpzgnopkw5bvxpi7yqo2irz7ojg77kntzngn3.py
# Topologically Sorted Source Nodes: [x_25], Original ATen: [aten._unsafe_index]
# Source node to ATen node mapping:
#   x_25 => _unsafe_index
# Graph fragment:
#   %_unsafe_index : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%where_11, [None, None, %unsqueeze, %convert_element_type_1]), kwargs = {})
triton_poi_fused__unsafe_index_5 = async_compile.triton('triton_poi_fused__unsafe_index_5', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*i64', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__unsafe_index_5', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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
    tmp4 = tl.where(tmp3, tmp2, tmp0)
    tmp6 = tmp5 + tmp1
    tmp7 = tmp5 < 0
    tmp8 = tl.where(tmp7, tmp6, tmp5)
    tl.store(out_ptr0 + (x3), tmp9, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/lg/clgj3izqijchiiji4d5tfyf4ehzsalcydgsfhylp5el7o5g6x3ds.py
# Topologically Sorted Source Nodes: [x_30], Original ATen: [aten.arange, aten.add, aten.mul, aten._to_copy]
# Source node to ATen node mapping:
#   x_30 => add_4, add_5, convert_element_type_4, convert_element_type_5, iota_2, mul_46, mul_47
# Graph fragment:
#   %iota_2 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %mul_46 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%iota_2, 1), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_46, 0), kwargs = {})
#   %convert_element_type_4 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%add_4, torch.float32), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%convert_element_type_4, 0.0), kwargs = {})
#   %mul_47 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_5, 0.5), kwargs = {})
#   %convert_element_type_5 : [num_users=3] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%mul_47, torch.int64), kwargs = {})
triton_poi_fused__to_copy_add_arange_mul_6 = async_compile.triton('triton_poi_fused__to_copy_add_arange_mul_6', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[4], 
    filename=__file__,
    triton_meta={'signature': {0: '*i64', 1: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0,), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_add_arange_mul_6', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 0, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/zm/czmjyxqjgevalme5oxvvxivamiul3cpcvrf47mtpw35jsvgzpptn.py
# Topologically Sorted Source Nodes: [x_30], Original ATen: [aten._unsafe_index]
# Source node to ATen node mapping:
#   x_30 => _unsafe_index_1
# Graph fragment:
#   %_unsafe_index_1 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%where_13, [None, None, %unsqueeze_1, %convert_element_type_5]), kwargs = {})
triton_poi_fused__unsafe_index_7 = async_compile.triton('triton_poi_fused__unsafe_index_7', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[512], 
    filename=__file__,
    triton_meta={'signature': {0: '*i64', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__unsafe_index_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/pp/cpp6kcd5yfg2fi72pjgrk5r4tb4i5m5wqt6u3b7kowhuovtzflax.py
# Topologically Sorted Source Nodes: [x_33, x_34], Original ATen: [aten.convolution, aten.elu]
# Source node to ATen node mapping:
#   x_33 => convolution_15
#   x_34 => expm1_15, gt_15, mul_53, mul_55, where_15
# Graph fragment:
#   %convolution_15 : [num_users=2] = call_function[target=torch.ops.aten.convolution.default](args = (%where_14, %primals_33, %primals_34, [1, 1], [1, 1], [1, 1], False, [0, 0], 1), kwargs = {})
#   %gt_15 : [num_users=1] = call_function[target=torch.ops.aten.gt.Scalar](args = (%convolution_15, 0), kwargs = {})
#   %mul_53 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%convolution_15, 1.0), kwargs = {})
#   %expm1_15 : [num_users=1] = call_function[target=torch.ops.aten.expm1.default](args = (%mul_53,), kwargs = {})
#   %mul_55 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%expm1_15, 1.0), kwargs = {})
#   %where_15 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%gt_15, %mul_53, %mul_55), kwargs = {})
triton_poi_fused_convolution_elu_8 = async_compile.triton('triton_poi_fused_convolution_elu_8', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[128], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_convolution_elu_8', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/q5/cq5x27y6tu5romybgwnjhwixbemixfdplu6ajniojitbychtbep4.py
# Topologically Sorted Source Nodes: [x_35, x_stage1], Original ATen: [aten.convolution, aten.clamp, aten.ge, aten.le, aten.logical_and]
# Source node to ATen node mapping:
#   x_35 => convolution_16
#   x_stage1 => clamp_max, clamp_min
# Graph fragment:
#   %convolution_16 : [num_users=3] = call_function[target=torch.ops.aten.convolution.default](args = (%where_15, %primals_35, %primals_36, [1, 1], [1, 1], [1, 1], False, [0, 0], 1), kwargs = {})
#   %clamp_min : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%convolution_16, -1.0), kwargs = {})
#   %clamp_max : [num_users=1] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min, 1.0), kwargs = {})
#   %ge : [num_users=1] = call_function[target=torch.ops.aten.ge.Scalar](args = (%convolution_16, -1.0), kwargs = {})
#   %le : [num_users=1] = call_function[target=torch.ops.aten.le.Scalar](args = (%convolution_16, 1.0), kwargs = {})
#   %logical_and : [num_users=1] = call_function[target=torch.ops.aten.logical_and.default](args = (%ge, %le), kwargs = {})
triton_poi_fused_clamp_convolution_ge_le_logical_and_9 = async_compile.triton('triton_poi_fused_clamp_convolution_ge_le_logical_and_9', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*i1', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clamp_convolution_ge_le_logical_and_9', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@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)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

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)
        # Topologically Sorted Source Nodes: [x], Original ATen: [aten.cat]
        stream0 = get_raw_stream(0)
        triton_poi_fused_cat_0.run(primals_1, primals_2, buf0, 384, grid=grid(384), stream=stream0)
        del primals_1
        del primals_2
        # Topologically Sorted Source Nodes: [x_1], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_1, x_2], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_1.run(buf2, primals_4, 256, grid=grid(256), stream=stream0)
        del primals_4
        # Topologically Sorted Source Nodes: [x_3], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_3, x_4], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_2.run(buf4, primals_6, 128, grid=grid(128), stream=stream0)
        del primals_6
        # Topologically Sorted Source Nodes: [x_5], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_5, x_6], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_2.run(buf6, primals_8, 128, grid=grid(128), stream=stream0)
        del primals_8
        # Topologically Sorted Source Nodes: [x_7], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_7, x_8], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf8, primals_10, 64, grid=grid(64), stream=stream0)
        del primals_10
        # Topologically Sorted Source Nodes: [x_9], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_9, x_10], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf10, primals_12, 64, grid=grid(64), stream=stream0)
        del primals_12
        # Topologically Sorted Source Nodes: [x_11], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_11, x_12], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf12, primals_14, 64, grid=grid(64), stream=stream0)
        del primals_14
        # Topologically Sorted Source Nodes: [x_13], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_13, x_14], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf14, primals_16, 64, grid=grid(64), stream=stream0)
        del primals_16
        # Topologically Sorted Source Nodes: [x_15], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_15, x_16], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf16, primals_18, 64, grid=grid(64), stream=stream0)
        del primals_18
        # Topologically Sorted Source Nodes: [x_17], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_17, x_18], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf18, primals_20, 64, grid=grid(64), stream=stream0)
        del primals_20
        # Topologically Sorted Source Nodes: [x_19], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_19, x_20], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf20, primals_22, 64, grid=grid(64), stream=stream0)
        del primals_22
        # Topologically Sorted Source Nodes: [x_21], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_21, x_22], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf22, primals_24, 64, grid=grid(64), stream=stream0)
        del primals_24
        # Topologically Sorted Source Nodes: [x_23], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_23, x_24], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_3.run(buf24, primals_26, 64, grid=grid(64), stream=stream0)
        del primals_26
        buf25 = empty_strided_cuda((2, ), (1, ), torch.int64)
        # Topologically Sorted Source Nodes: [x_25], Original ATen: [aten.arange, aten.add, aten.mul, aten._to_copy]
        triton_poi_fused__to_copy_add_arange_mul_4.run(buf25, 2, grid=grid(2), stream=stream0)
        buf26 = empty_strided_cuda((4, 16, 2, 2), (64, 4, 2, 1), torch.float32)
        # Topologically Sorted Source Nodes: [x_25], Original ATen: [aten._unsafe_index]
        triton_poi_fused__unsafe_index_5.run(buf25, buf24, buf26, 256, grid=grid(256), stream=stream0)
        # Topologically Sorted Source Nodes: [x_26], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_26, x_27], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_2.run(buf28, primals_28, 128, grid=grid(128), stream=stream0)
        del primals_28
        # Topologically Sorted Source Nodes: [x_28], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_28, x_29], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_2.run(buf30, primals_30, 128, grid=grid(128), stream=stream0)
        del primals_30
        buf31 = empty_strided_cuda((4, ), (1, ), torch.int64)
        # Topologically Sorted Source Nodes: [x_30], Original ATen: [aten.arange, aten.add, aten.mul, aten._to_copy]
        triton_poi_fused__to_copy_add_arange_mul_6.run(buf31, 4, grid=grid(4), stream=stream0)
        buf32 = empty_strided_cuda((4, 8, 4, 4), (128, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [x_30], Original ATen: [aten._unsafe_index]
        triton_poi_fused__unsafe_index_7.run(buf31, buf30, buf32, 512, grid=grid(512), stream=stream0)
        # Topologically Sorted Source Nodes: [x_31], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_31, x_32], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_1.run(buf34, primals_32, 256, grid=grid(256), stream=stream0)
        del primals_32
        # Topologically Sorted Source Nodes: [x_33], Original ATen: [aten.convolution]
        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  # reuse
        # Topologically Sorted Source Nodes: [x_33, x_34], Original ATen: [aten.convolution, aten.elu]
        triton_poi_fused_convolution_elu_8.run(buf36, primals_34, 128, grid=grid(128), stream=stream0)
        del primals_34
        # Topologically Sorted Source Nodes: [x_35], Original ATen: [aten.convolution]
        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)
        # Topologically Sorted Source Nodes: [x_35, x_stage1], Original ATen: [aten.convolution, aten.clamp, aten.ge, aten.le, aten.logical_and]
        triton_poi_fused_clamp_convolution_ge_le_logical_and_9.run(buf37, primals_36, buf38, buf39, 256, grid=grid(256), stream=stream0)
        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 benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    primals_1 = rand_strided((4, 1, 4, 4), (16, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((4, 6, 5, 5), (150, 25, 5, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((8, 4, 3, 3), (36, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((8, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_7 = rand_strided((8, 8, 3, 3), (72, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_8 = rand_strided((8, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_9 = rand_strided((16, 8, 3, 3), (72, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_10 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_11 = rand_strided((16, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_12 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_13 = rand_strided((16, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_14 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_15 = rand_strided((16, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_16 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_17 = rand_strided((16, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_18 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_19 = rand_strided((16, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_20 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_21 = rand_strided((16, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_22 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_23 = rand_strided((16, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_24 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_25 = rand_strided((16, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_26 = rand_strided((16, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_27 = rand_strided((8, 16, 3, 3), (144, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_28 = rand_strided((8, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_29 = rand_strided((8, 8, 3, 3), (72, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_30 = rand_strided((8, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_31 = rand_strided((4, 8, 3, 3), (72, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_32 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_33 = rand_strided((2, 4, 3, 3), (36, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_34 = rand_strided((2, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_35 = rand_strided((4, 2, 3, 3), (18, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_36 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    fn = lambda: 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 print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils import spectral_norm as spectral_norm_fn
from torch.nn.utils import weight_norm as weight_norm_fn


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 CoarseGenerator(nn.Module):

    def __init__(self, input_dim, cnum, gated=False, use_cuda=True, device=0):
        super(CoarseGenerator, 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, x, mask):
        ones = torch.ones(x.size(0), 1, x.size(2), x.size(3), device=x.device)
        x = torch.cat([x, ones, mask], dim=1)
        x = self.conv1(x)
        x = self.conv2_downsample(x)
        x = self.conv3(x)
        x = self.conv4_downsample(x)
        x = self.conv5(x)
        x = self.conv6(x)
        x = self.conv7_atrous(x)
        x = self.conv8_atrous(x)
        x = self.conv9_atrous(x)
        x = self.conv10_atrous(x)
        x = self.conv11(x)
        x = self.conv12(x)
        x = F.interpolate(x, scale_factor=2, mode='nearest')
        x = self.conv13(x)
        x = self.conv14(x)
        x = F.interpolate(x, scale_factor=2, mode='nearest')
        x = self.conv15(x)
        x = self.conv16(x)
        x = self.conv17(x)
        x_stage1 = torch.clamp(x, -1.0, 1.0)
        return x_stage1


def get_inputs():
    return [torch.rand([4, 1, 4, 4]), torch.rand([4, 4, 4, 4])]


def get_init_inputs():
    return [[], {'input_dim': 4, 'cnum': 4}]

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]
