# 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/eq/ceqcduq3mwis6hwhx3k2hdrhuh5karhoe7hcdbfinghbpx2xm6ph.py
# Topologically Sorted Source Nodes: [pad], Original ATen: [aten.reflection_pad2d]
# Source node to ATen node mapping:
#   pad => _unsafe_index, _unsafe_index_1
# Graph fragment:
#   %_unsafe_index : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%primals_2, [None, None, %sub_1, None]), kwargs = {})
#   %_unsafe_index_1 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%_unsafe_index, [None, None, None, %sub_1]), kwargs = {})
triton_poi_fused_reflection_pad2d_0 = async_compile.triton('triton_poi_fused_reflection_pad2d_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: '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_reflection_pad2d_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, '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_reflection_pad2d_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 288
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 6
    x1 = (xindex // 6) % 6
    x2 = (xindex // 36)
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (15 + ((-1)*(tl_math.abs((-3) + (tl_math.abs((-1) + x0))))) + ((-4)*(tl_math.abs((-3) + (tl_math.abs((-1) + x1))))) + (16*x2)), xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + (x3), tmp0, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/me/cmeiz3aiel7lbg3fmbh7fgzrkcu4bqoriig554gtrpnvtsxhg45h.py
# Topologically Sorted Source Nodes: [output_1], Original ATen: [aten._native_batch_norm_legit]
# Source node to ATen node mapping:
#   output_1 => add, rsqrt, var_mean
# Graph fragment:
#   %var_mean : [num_users=2] = call_function[target=torch.ops.aten.var_mean.correction](args = (%convolution, [0, 2, 3]), kwargs = {correction: 0, keepdim: True})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%getitem, 1e-05), kwargs = {})
#   %rsqrt : [num_users=2] = call_function[target=torch.ops.aten.rsqrt.default](args = (%add,), kwargs = {})
triton_per_fused__native_batch_norm_legit_1 = async_compile.triton('triton_per_fused__native_batch_norm_legit_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.persistent_reduction(
    size_hints=[2, 16],
    reduction_hint=ReductionHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 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, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__native_batch_norm_legit_1', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 4, '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}
)
@triton.jit
def triton_per_fused__native_batch_norm_legit_1(in_out_ptr0, in_ptr0, out_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 2
    rnumel = 16
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex % 4
    r2 = (rindex // 4)
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + (4*x0) + (8*r2)), xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, 0)
    tmp4 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp6 = tl.where(xmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tmp8 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 / tmp9
    tmp11 = tmp1 - tmp10
    tmp12 = tmp11 * tmp11
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK, RBLOCK])
    tmp15 = tl.where(xmask, tmp13, 0)
    tmp16 = tl.sum(tmp15, 1)[:, None]
    tmp17 = 16.0
    tmp18 = tmp16 / tmp17
    tmp19 = 1e-05
    tmp20 = tmp18 + tmp19
    tmp21 = libdevice.rsqrt(tmp20)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x0), tmp21, xmask)
    tl.store(out_ptr0 + (x0), tmp10, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/sk/cskxoge3n4emzvlb5ys73jxzprcr3gymcp2m4o2xt4glitanjpsn.py
# Topologically Sorted Source Nodes: [output_1, output_2], Original ATen: [aten._native_batch_norm_legit, aten.leaky_relu]
# Source node to ATen node mapping:
#   output_1 => add_1, mul, mul_1, sub_4
#   output_2 => gt, mul_2, where
# Graph fragment:
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%convolution, %getitem_1), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_4, %rsqrt), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%mul, %unsqueeze_1), kwargs = {})
#   %add_1 : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_1, %unsqueeze_3), kwargs = {})
#   %gt : [num_users=1] = call_function[target=torch.ops.aten.gt.Scalar](args = (%add_1, 0), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_1, 0.02), kwargs = {})
#   %where : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%gt, %add_1, %mul_2), kwargs = {})
triton_poi_fused__native_batch_norm_legit_leaky_relu_2 = async_compile.triton('triton_poi_fused__native_batch_norm_legit_leaky_relu_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=[32], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '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, 5, 6), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__native_batch_norm_legit_leaky_relu_2', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 5, '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__native_batch_norm_legit_leaky_relu_2(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, xnumel, XBLOCK : tl.constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = (xindex // 4) % 2
    tmp0 = tl.load(in_ptr0 + (x3), xmask)
    tmp1 = tl.load(in_ptr1 + (x1), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + (x1), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + (x1), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr4 + (x1), xmask, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = tmp2 * tmp3
    tmp6 = tmp4 * tmp5
    tmp8 = tmp6 + tmp7
    tmp9 = 0.0
    tmp10 = tmp8 > tmp9
    tmp11 = 0.02
    tmp12 = tmp8 * tmp11
    tmp13 = tl.where(tmp10, tmp8, tmp12)
    tl.store(in_out_ptr0 + (x3), tmp13, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/6q/c6qif56bwzpszgw5ut3oe77mzt3mf34ct3csishbbvmctu4z3lr5.py
# Topologically Sorted Source Nodes: [output_5], Original ATen: [aten._to_copy]
# Source node to ATen node mapping:
#   output_5 => convert_element_type_1
# Graph fragment:
#   %convert_element_type_1 : [num_users=5] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%view, torch.int64), kwargs = {})
triton_poi_fused__to_copy_3 = async_compile.triton('triton_poi_fused__to_copy_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=[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_3', '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_3(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 * tmp2
    tmp5 = tmp4 - tmp2
    tmp6 = 0.0
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp7.to(tl.int32)
    tl.store(out_ptr0 + (x0), tmp8, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/sr/csro45kj2viw32d3iykp6lm5bmdxalfad5ija3eglyjmmcfzntz3.py
# Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.add, aten.clamp]
# Source node to ATen node mapping:
#   output_5 => add_3, clamp_max
# Graph fragment:
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%convert_element_type_1, 1), kwargs = {})
#   %clamp_max : [num_users=3] = call_function[target=torch.ops.aten.clamp_max.default](args = (%add_3, 0), kwargs = {})
triton_poi_fused_add_clamp_4 = async_compile.triton('triton_poi_fused_add_clamp_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_add_clamp_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_add_clamp_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 * tmp2
    tmp5 = tmp4 - tmp2
    tmp6 = 0.0
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp7.to(tl.int32)
    tmp9 = tl.full([1], 1, tl.int64)
    tmp10 = tmp8 + tmp9
    tmp11 = tl.full([1], 0, tl.int64)
    tmp12 = triton_helpers.minimum(tmp10, tmp11)
    tl.store(out_ptr0 + (x0), tmp12, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/uf/cuf4x43hb53yhj2wmgdljkybgjpp5igcyodhz6fmzuvkntljhi3e.py
# Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.arange, aten._to_copy, aten.add, aten.mul, aten.sub, aten.clamp]
# Source node to ATen node mapping:
#   output_5 => add_2, clamp_max_2, clamp_min, clamp_min_2, convert_element_type, iota_2, mul_3, sub_5, sub_7
# Graph fragment:
#   %iota_2 : [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})
#   %convert_element_type : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%iota_2, torch.float32), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%convert_element_type, 0.5), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_2, 0.5), kwargs = {})
#   %sub_5 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mul_3, 0.5), kwargs = {})
#   %clamp_min : [num_users=3] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_5, 0.0), kwargs = {})
#   %sub_7 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_min, %convert_element_type_3), kwargs = {})
#   %clamp_min_2 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_7, 0.0), kwargs = {})
#   %clamp_max_2 : [num_users=3] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_2, 1.0), kwargs = {})
triton_poi_fused__to_copy_add_arange_clamp_mul_sub_5 = async_compile.triton('triton_poi_fused__to_copy_add_arange_clamp_mul_sub_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=[2], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 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_clamp_mul_sub_5', '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_clamp_mul_sub_5(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 * tmp2
    tmp5 = tmp4 - tmp2
    tmp6 = 0.0
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp7.to(tl.int32)
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 - tmp9
    tmp11 = triton_helpers.maximum(tmp10, tmp6)
    tmp12 = 1.0
    tmp13 = triton_helpers.minimum(tmp11, tmp12)
    tl.store(out_ptr0 + (x0), tmp13, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/e5/ce5uk72pxjyulegzkdkszgmjfgevtrf7j7pmd6m5aelcjmxgzzxm.py
# Topologically Sorted Source Nodes: [output_4, output_5], Original ATen: [aten.avg_pool2d, aten._unsafe_index, aten.sub, aten.mul, aten.add]
# Source node to ATen node mapping:
#   output_4 => avg_pool2d
#   output_5 => _unsafe_index_2, _unsafe_index_3, _unsafe_index_4, _unsafe_index_5, add_6, add_7, mul_5, mul_6, sub_11, sub_8, sub_9
# Graph fragment:
#   %avg_pool2d : [num_users=4] = call_function[target=torch.ops.aten.avg_pool2d.default](args = (%where, [2, 2], [4, 4]), kwargs = {})
#   %_unsafe_index_2 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%avg_pool2d, [None, None, %convert_element_type_1, %convert_element_type_3]), kwargs = {})
#   %_unsafe_index_3 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%avg_pool2d, [None, None, %convert_element_type_1, %clamp_max_1]), kwargs = {})
#   %_unsafe_index_4 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%avg_pool2d, [None, None, %clamp_max, %convert_element_type_3]), kwargs = {})
#   %_unsafe_index_5 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%avg_pool2d, [None, None, %clamp_max, %clamp_max_1]), kwargs = {})
#   %sub_8 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_3, %_unsafe_index_2), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_8, %clamp_max_2), kwargs = {})
#   %add_6 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_2, %mul_5), kwargs = {})
#   %sub_9 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_5, %_unsafe_index_4), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_9, %clamp_max_2), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_4, %mul_6), kwargs = {})
#   %sub_11 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_7, %add_6), kwargs = {})
triton_poi_fused__unsafe_index_add_avg_pool2d_mul_sub_6 = async_compile.triton('triton_poi_fused__unsafe_index_add_avg_pool2d_mul_sub_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=[32], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*i64', 3: '*i64', 4: '*fp32', 5: '*i64', 6: '*i64', 7: '*fp32', 8: '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, 5, 6, 7, 8), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__unsafe_index_add_avg_pool2d_mul_sub_6', 'mutated_arg_names': ['in_out_ptr0', 'in_out_ptr1'], 'no_x_dim': False, 'num_load': 5, '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_add_avg_pool2d_mul_sub_6(in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, xnumel, XBLOCK : tl.constexpr):
    xnumel = 32
    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)
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x1), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp18 = tl.load(in_ptr3 + (x1), xmask, eviction_policy='evict_last')
    tmp30 = tl.load(in_ptr4 + (x0), xmask, eviction_policy='evict_last')
    tmp43 = tl.load(in_ptr5 + (x0), 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)
    tmp9 = tl.load(in_ptr2 + ((4*tmp8) + (4*x2) + (8*tmp4)), xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr2 + (1 + (4*tmp8) + (4*x2) + (8*tmp4)), xmask, eviction_policy='evict_last')
    tmp11 = tmp10 + tmp9
    tmp12 = tl.load(in_ptr2 + (2 + (4*tmp8) + (4*x2) + (8*tmp4)), xmask, eviction_policy='evict_last')
    tmp13 = tmp12 + tmp11
    tmp14 = tl.load(in_ptr2 + (3 + (4*tmp8) + (4*x2) + (8*tmp4)), xmask, eviction_policy='evict_last')
    tmp15 = tmp14 + tmp13
    tmp16 = 0.25
    tmp17 = tmp15 * tmp16
    tmp19 = tmp18 + tmp1
    tmp20 = tmp18 < 0
    tmp21 = tl.where(tmp20, tmp19, tmp18)
    tmp22 = tl.load(in_ptr2 + ((4*tmp8) + (4*x2) + (8*tmp21)), xmask, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr2 + (1 + (4*tmp8) + (4*x2) + (8*tmp21)), xmask, eviction_policy='evict_last')
    tmp24 = tmp23 + tmp22
    tmp25 = tl.load(in_ptr2 + (2 + (4*tmp8) + (4*x2) + (8*tmp21)), xmask, eviction_policy='evict_last')
    tmp26 = tmp25 + tmp24
    tmp27 = tl.load(in_ptr2 + (3 + (4*tmp8) + (4*x2) + (8*tmp21)), xmask, eviction_policy='evict_last')
    tmp28 = tmp27 + tmp26
    tmp29 = tmp28 * tmp16
    tmp31 = tmp30 + tmp1
    tmp32 = tmp30 < 0
    tmp33 = tl.where(tmp32, tmp31, tmp30)
    tmp34 = tl.load(in_ptr2 + ((4*tmp33) + (4*x2) + (8*tmp21)), xmask, eviction_policy='evict_last')
    tmp35 = tl.load(in_ptr2 + (1 + (4*tmp33) + (4*x2) + (8*tmp21)), xmask, eviction_policy='evict_last')
    tmp36 = tmp35 + tmp34
    tmp37 = tl.load(in_ptr2 + (2 + (4*tmp33) + (4*x2) + (8*tmp21)), xmask, eviction_policy='evict_last')
    tmp38 = tmp37 + tmp36
    tmp39 = tl.load(in_ptr2 + (3 + (4*tmp33) + (4*x2) + (8*tmp21)), xmask, eviction_policy='evict_last')
    tmp40 = tmp39 + tmp38
    tmp41 = tmp40 * tmp16
    tmp42 = tmp41 - tmp29
    tmp44 = tmp42 * tmp43
    tmp45 = tmp29 + tmp44
    tmp46 = tl.load(in_ptr2 + ((4*tmp33) + (4*x2) + (8*tmp4)), xmask, eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr2 + (1 + (4*tmp33) + (4*x2) + (8*tmp4)), xmask, eviction_policy='evict_last')
    tmp48 = tmp47 + tmp46
    tmp49 = tl.load(in_ptr2 + (2 + (4*tmp33) + (4*x2) + (8*tmp4)), xmask, eviction_policy='evict_last')
    tmp50 = tmp49 + tmp48
    tmp51 = tl.load(in_ptr2 + (3 + (4*tmp33) + (4*x2) + (8*tmp4)), xmask, eviction_policy='evict_last')
    tmp52 = tmp51 + tmp50
    tmp53 = tmp52 * tmp16
    tmp54 = tmp53 - tmp17
    tmp55 = tmp54 * tmp43
    tmp56 = tmp17 + tmp55
    tmp57 = tmp56 - tmp45
    tl.store(in_out_ptr0 + (x4), tmp45, xmask)
    tl.store(in_out_ptr1 + (x4), tmp57, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/2v/c2vqbwuq7yxh5e3rn6u4lxtfa4ca5a5ijl2omrl6jba6yluz3b2x.py
# Topologically Sorted Source Nodes: [output_5, output_6], Original ATen: [aten.mul, aten.add, aten.mean]
# Source node to ATen node mapping:
#   output_5 => add_8, mul_7
#   output_6 => mean
# Graph fragment:
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_11, %clamp_max_3), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_6, %mul_7), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%add_8, [-1, -2], True), kwargs = {})
triton_poi_fused_add_mean_mul_7 = async_compile.triton('triton_poi_fused_add_mean_mul_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=[8], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_mean_mul_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 10, '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_add_mean_mul_7(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 8
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (4*x0), xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (4*x0), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr2 + (0))
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK])
    tmp6 = tl.load(in_ptr0 + (1 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr1 + (1 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (2 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr1 + (2 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr2 + (1))
    tmp14 = tl.broadcast_to(tmp13, [XBLOCK])
    tmp18 = tl.load(in_ptr0 + (3 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_ptr1 + (3 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp4 = tmp1 * tmp3
    tmp5 = tmp0 + tmp4
    tmp8 = tmp7 * tmp3
    tmp9 = tmp6 + tmp8
    tmp10 = tmp5 + tmp9
    tmp15 = tmp12 * tmp14
    tmp16 = tmp11 + tmp15
    tmp17 = tmp10 + tmp16
    tmp20 = tmp19 * tmp14
    tmp21 = tmp18 + tmp20
    tmp22 = tmp17 + tmp21
    tmp23 = 4.0
    tmp24 = tmp22 / tmp23
    tl.store(out_ptr0 + (x0), tmp24, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (2, 2, 3, 3), (18, 9, 3, 1))
    assert_size_stride(primals_2, (4, 2, 4, 4), (32, 16, 4, 1))
    assert_size_stride(primals_3, (2, ), (1, ))
    assert_size_stride(primals_4, (2, ), (1, ))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 2, 6, 6), (72, 36, 6, 1), torch.float32)
        # Topologically Sorted Source Nodes: [pad], Original ATen: [aten.reflection_pad2d]
        stream0 = get_raw_stream(0)
        triton_poi_fused_reflection_pad2d_0.run(primals_2, buf0, 288, grid=grid(288), stream=stream0)
        del primals_2
        # Topologically Sorted Source Nodes: [output], Original ATen: [aten.convolution]
        buf1 = extern_kernels.convolution(buf0, primals_1, stride=(2, 2), padding=(0, 0), dilation=(1, 1), transposed=False, output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 2, 2, 2), (8, 4, 2, 1))
        buf2 = empty_strided_cuda((1, 2, 1, 1), (2, 1, 1, 1), torch.float32)
        buf3 = empty_strided_cuda((1, 2, 1, 1), (2, 1, 2, 2), torch.float32)
        buf5 = reinterpret_tensor(buf3, (1, 2, 1, 1), (2, 1, 1, 1), 0); del buf3  # reuse
        # Topologically Sorted Source Nodes: [output_1], Original ATen: [aten._native_batch_norm_legit]
        triton_per_fused__native_batch_norm_legit_1.run(buf5, buf1, buf2, 2, 16, grid=grid(2), stream=stream0)
        buf6 = empty_strided_cuda((4, 2, 2, 2), (8, 4, 2, 1), torch.float32)
        buf7 = buf6; del buf6  # reuse
        # Topologically Sorted Source Nodes: [output_1, output_2], Original ATen: [aten._native_batch_norm_legit, aten.leaky_relu]
        triton_poi_fused__native_batch_norm_legit_leaky_relu_2.run(buf7, buf1, buf2, buf5, primals_3, primals_4, 32, grid=grid(32), stream=stream0)
        buf8 = empty_strided_cuda((2, 1), (1, 1), torch.int64)
        # Topologically Sorted Source Nodes: [output_5], Original ATen: [aten._to_copy]
        triton_poi_fused__to_copy_3.run(buf8, 2, grid=grid(2), stream=stream0)
        buf9 = empty_strided_cuda((2, 1), (1, 1), torch.int64)
        # Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.add, aten.clamp]
        triton_poi_fused_add_clamp_4.run(buf9, 2, grid=grid(2), stream=stream0)
        buf10 = empty_strided_cuda((2, ), (1, ), torch.int64)
        # Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.arange, aten._to_copy, aten.add, aten.mul, aten.sub, aten.clamp]
        triton_poi_fused__to_copy_3.run(buf10, 2, grid=grid(2), stream=stream0)
        buf11 = empty_strided_cuda((2, ), (1, ), torch.int64)
        # Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.add, aten.clamp]
        triton_poi_fused_add_clamp_4.run(buf11, 2, grid=grid(2), stream=stream0)
        buf14 = empty_strided_cuda((2, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.arange, aten._to_copy, aten.add, aten.mul, aten.sub, aten.clamp]
        triton_poi_fused__to_copy_add_arange_clamp_mul_sub_5.run(buf14, 2, grid=grid(2), stream=stream0)
        buf13 = empty_strided_cuda((4, 2, 2, 2), (8, 4, 2, 1), torch.float32)
        buf12 = empty_strided_cuda((4, 2, 2, 2), (8, 4, 2, 1), torch.float32)
        buf15 = buf12; del buf12  # reuse
        buf17 = buf13; del buf13  # reuse
        # Topologically Sorted Source Nodes: [output_4, output_5], Original ATen: [aten.avg_pool2d, aten._unsafe_index, aten.sub, aten.mul, aten.add]
        triton_poi_fused__unsafe_index_add_avg_pool2d_mul_sub_6.run(buf15, buf17, buf9, buf10, buf7, buf8, buf11, buf14, 32, grid=grid(32), stream=stream0)
        buf16 = empty_strided_cuda((2, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [output_5], Original ATen: [aten.sub, aten.clamp]
        triton_poi_fused__to_copy_add_arange_clamp_mul_sub_5.run(buf16, 2, grid=grid(2), stream=stream0)
        buf18 = empty_strided_cuda((4, 2, 1, 1), (2, 1, 1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [output_5, output_6], Original ATen: [aten.mul, aten.add, aten.mean]
        triton_poi_fused_add_mean_mul_7.run(buf15, buf17, buf16, buf18, 8, grid=grid(8), stream=stream0)
        del buf15
        del buf17
    return (buf18, primals_1, primals_3, primals_4, buf0, buf1, buf2, buf5, buf7, buf8, buf9, buf10, buf11, buf14, buf16, )


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((2, 2, 3, 3), (18, 9, 3, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, 2, 4, 4), (32, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((2, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((2, ), (1, ), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([primals_1, primals_2, primals_3, primals_4])
    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.functional as F


class RefModel2d(torch.nn.Module):
    """The 2D reference model."""

    def __init__(self):
        super().__init__()
        self.l1 = torch.nn.Conv2d(2, 2, 3, stride=2, bias=False, padding=1,
            padding_mode='reflect')
        self.l2 = torch.nn.BatchNorm2d(2, track_running_stats=False)
        self.l3 = torch.nn.LeakyReLU(0.02)
        self.l4 = torch.nn.Dropout2d(0.5)
        self.l5 = torch.nn.AvgPool2d(2, stride=4)
        self.l7 = torch.nn.AdaptiveAvgPool2d(1)

    def forward(self, x):
        output = self.l1(x)
        output = self.l2(output)
        output = self.l3(output)
        output = self.l4(output)
        output = self.l5(output)
        output = F.interpolate(output, mode='bilinear', scale_factor=2)
        output = self.l7(output)
        return output


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


def get_init_inputs():
    return [[], {}]

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, math as tl_math
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_reflection_pad2d_0(in_ptr0, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 288
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 6
    x1 = xindex // 6 % 6
    x2 = xindex // 36
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (15 + -1 * tl_math.abs(-3 + tl_math.abs(-1 +
        x0)) + -4 * tl_math.abs(-3 + tl_math.abs(-1 + x1)) + 16 * x2),
        xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x3, tmp0, xmask)


@triton.jit
def triton_per_fused__native_batch_norm_legit_1(in_out_ptr0, in_ptr0,
    out_ptr0, xnumel, rnumel, XBLOCK: tl.constexpr):
    xnumel = 2
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex % 4
    r2 = rindex // 4
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 4 * x0 + 8 * r2), xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tl.where(xmask, tmp1, 0)
    tmp4 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp6 = tl.where(xmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tmp8 = tl.full([XBLOCK, 1], 16, tl.int32)
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 / tmp9
    tmp11 = tmp1 - tmp10
    tmp12 = tmp11 * tmp11
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK, RBLOCK])
    tmp15 = tl.where(xmask, tmp13, 0)
    tmp16 = tl.sum(tmp15, 1)[:, None]
    tmp17 = 16.0
    tmp18 = tmp16 / tmp17
    tmp19 = 1e-05
    tmp20 = tmp18 + tmp19
    tmp21 = libdevice.rsqrt(tmp20)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x0, tmp21, xmask)
    tl.store(out_ptr0 + x0, tmp10, xmask)


@triton.jit
def triton_poi_fused__native_batch_norm_legit_leaky_relu_2(in_out_ptr0,
    in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, xnumel, XBLOCK: tl.constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 4 % 2
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x1, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + x1, xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr4 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 - tmp1
    tmp4 = tmp2 * tmp3
    tmp6 = tmp4 * tmp5
    tmp8 = tmp6 + tmp7
    tmp9 = 0.0
    tmp10 = tmp8 > tmp9
    tmp11 = 0.02
    tmp12 = tmp8 * tmp11
    tmp13 = tl.where(tmp10, tmp8, tmp12)
    tl.store(in_out_ptr0 + x3, tmp13, xmask)


@triton.jit
def triton_poi_fused__to_copy_3(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 * tmp2
    tmp5 = tmp4 - tmp2
    tmp6 = 0.0
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp7.to(tl.int32)
    tl.store(out_ptr0 + x0, tmp8, xmask)


@triton.jit
def triton_poi_fused_add_clamp_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 * tmp2
    tmp5 = tmp4 - tmp2
    tmp6 = 0.0
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp7.to(tl.int32)
    tmp9 = tl.full([1], 1, tl.int64)
    tmp10 = tmp8 + tmp9
    tmp11 = tl.full([1], 0, tl.int64)
    tmp12 = triton_helpers.minimum(tmp10, tmp11)
    tl.store(out_ptr0 + x0, tmp12, xmask)


@triton.jit
def triton_poi_fused__to_copy_add_arange_clamp_mul_sub_5(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 * tmp2
    tmp5 = tmp4 - tmp2
    tmp6 = 0.0
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp7.to(tl.int32)
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 - tmp9
    tmp11 = triton_helpers.maximum(tmp10, tmp6)
    tmp12 = 1.0
    tmp13 = triton_helpers.minimum(tmp11, tmp12)
    tl.store(out_ptr0 + x0, tmp13, xmask)


@triton.jit
def triton_poi_fused__unsafe_index_add_avg_pool2d_mul_sub_6(in_out_ptr0,
    in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 32
    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
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp18 = tl.load(in_ptr3 + x1, xmask, eviction_policy='evict_last')
    tmp30 = tl.load(in_ptr4 + x0, xmask, eviction_policy='evict_last')
    tmp43 = tl.load(in_ptr5 + x0, 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)
    tmp9 = tl.load(in_ptr2 + (4 * tmp8 + 4 * x2 + 8 * tmp4), xmask,
        eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr2 + (1 + 4 * tmp8 + 4 * x2 + 8 * tmp4), xmask,
        eviction_policy='evict_last')
    tmp11 = tmp10 + tmp9
    tmp12 = tl.load(in_ptr2 + (2 + 4 * tmp8 + 4 * x2 + 8 * tmp4), xmask,
        eviction_policy='evict_last')
    tmp13 = tmp12 + tmp11
    tmp14 = tl.load(in_ptr2 + (3 + 4 * tmp8 + 4 * x2 + 8 * tmp4), xmask,
        eviction_policy='evict_last')
    tmp15 = tmp14 + tmp13
    tmp16 = 0.25
    tmp17 = tmp15 * tmp16
    tmp19 = tmp18 + tmp1
    tmp20 = tmp18 < 0
    tmp21 = tl.where(tmp20, tmp19, tmp18)
    tmp22 = tl.load(in_ptr2 + (4 * tmp8 + 4 * x2 + 8 * tmp21), xmask,
        eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr2 + (1 + 4 * tmp8 + 4 * x2 + 8 * tmp21), xmask,
        eviction_policy='evict_last')
    tmp24 = tmp23 + tmp22
    tmp25 = tl.load(in_ptr2 + (2 + 4 * tmp8 + 4 * x2 + 8 * tmp21), xmask,
        eviction_policy='evict_last')
    tmp26 = tmp25 + tmp24
    tmp27 = tl.load(in_ptr2 + (3 + 4 * tmp8 + 4 * x2 + 8 * tmp21), xmask,
        eviction_policy='evict_last')
    tmp28 = tmp27 + tmp26
    tmp29 = tmp28 * tmp16
    tmp31 = tmp30 + tmp1
    tmp32 = tmp30 < 0
    tmp33 = tl.where(tmp32, tmp31, tmp30)
    tmp34 = tl.load(in_ptr2 + (4 * tmp33 + 4 * x2 + 8 * tmp21), xmask,
        eviction_policy='evict_last')
    tmp35 = tl.load(in_ptr2 + (1 + 4 * tmp33 + 4 * x2 + 8 * tmp21), xmask,
        eviction_policy='evict_last')
    tmp36 = tmp35 + tmp34
    tmp37 = tl.load(in_ptr2 + (2 + 4 * tmp33 + 4 * x2 + 8 * tmp21), xmask,
        eviction_policy='evict_last')
    tmp38 = tmp37 + tmp36
    tmp39 = tl.load(in_ptr2 + (3 + 4 * tmp33 + 4 * x2 + 8 * tmp21), xmask,
        eviction_policy='evict_last')
    tmp40 = tmp39 + tmp38
    tmp41 = tmp40 * tmp16
    tmp42 = tmp41 - tmp29
    tmp44 = tmp42 * tmp43
    tmp45 = tmp29 + tmp44
    tmp46 = tl.load(in_ptr2 + (4 * tmp33 + 4 * x2 + 8 * tmp4), xmask,
        eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr2 + (1 + 4 * tmp33 + 4 * x2 + 8 * tmp4), xmask,
        eviction_policy='evict_last')
    tmp48 = tmp47 + tmp46
    tmp49 = tl.load(in_ptr2 + (2 + 4 * tmp33 + 4 * x2 + 8 * tmp4), xmask,
        eviction_policy='evict_last')
    tmp50 = tmp49 + tmp48
    tmp51 = tl.load(in_ptr2 + (3 + 4 * tmp33 + 4 * x2 + 8 * tmp4), xmask,
        eviction_policy='evict_last')
    tmp52 = tmp51 + tmp50
    tmp53 = tmp52 * tmp16
    tmp54 = tmp53 - tmp17
    tmp55 = tmp54 * tmp43
    tmp56 = tmp17 + tmp55
    tmp57 = tmp56 - tmp45
    tl.store(in_out_ptr0 + x4, tmp45, xmask)
    tl.store(in_out_ptr1 + x4, tmp57, xmask)


@triton.jit
def triton_poi_fused_add_mean_mul_7(in_ptr0, in_ptr1, in_ptr2, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 8
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr2 + 0)
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK])
    tmp6 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr1 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr1 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp13 = tl.load(in_ptr2 + 1)
    tmp14 = tl.broadcast_to(tmp13, [XBLOCK])
    tmp18 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp19 = tl.load(in_ptr1 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp4 = tmp1 * tmp3
    tmp5 = tmp0 + tmp4
    tmp8 = tmp7 * tmp3
    tmp9 = tmp6 + tmp8
    tmp10 = tmp5 + tmp9
    tmp15 = tmp12 * tmp14
    tmp16 = tmp11 + tmp15
    tmp17 = tmp10 + tmp16
    tmp20 = tmp19 * tmp14
    tmp21 = tmp18 + tmp20
    tmp22 = tmp17 + tmp21
    tmp23 = 4.0
    tmp24 = tmp22 / tmp23
    tl.store(out_ptr0 + x0, tmp24, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (2, 2, 3, 3), (18, 9, 3, 1))
    assert_size_stride(primals_2, (4, 2, 4, 4), (32, 16, 4, 1))
    assert_size_stride(primals_3, (2,), (1,))
    assert_size_stride(primals_4, (2,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 2, 6, 6), (72, 36, 6, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_reflection_pad2d_0[grid(288)](primals_2, buf0, 288,
            XBLOCK=256, num_warps=4, num_stages=1)
        del primals_2
        buf1 = extern_kernels.convolution(buf0, primals_1, stride=(2, 2),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 2, 2, 2), (8, 4, 2, 1))
        buf2 = empty_strided_cuda((1, 2, 1, 1), (2, 1, 1, 1), torch.float32)
        buf3 = empty_strided_cuda((1, 2, 1, 1), (2, 1, 2, 2), torch.float32)
        buf5 = reinterpret_tensor(buf3, (1, 2, 1, 1), (2, 1, 1, 1), 0)
        del buf3
        triton_per_fused__native_batch_norm_legit_1[grid(2)](buf5, buf1,
            buf2, 2, 16, XBLOCK=1, num_warps=2, num_stages=1)
        buf6 = empty_strided_cuda((4, 2, 2, 2), (8, 4, 2, 1), torch.float32)
        buf7 = buf6
        del buf6
        triton_poi_fused__native_batch_norm_legit_leaky_relu_2[grid(32)](buf7,
            buf1, buf2, buf5, primals_3, primals_4, 32, XBLOCK=32,
            num_warps=1, num_stages=1)
        buf8 = empty_strided_cuda((2, 1), (1, 1), torch.int64)
        triton_poi_fused__to_copy_3[grid(2)](buf8, 2, XBLOCK=2, num_warps=1,
            num_stages=1)
        buf9 = empty_strided_cuda((2, 1), (1, 1), torch.int64)
        triton_poi_fused_add_clamp_4[grid(2)](buf9, 2, XBLOCK=2, num_warps=
            1, num_stages=1)
        buf10 = empty_strided_cuda((2,), (1,), torch.int64)
        triton_poi_fused__to_copy_3[grid(2)](buf10, 2, XBLOCK=2, num_warps=
            1, num_stages=1)
        buf11 = empty_strided_cuda((2,), (1,), torch.int64)
        triton_poi_fused_add_clamp_4[grid(2)](buf11, 2, XBLOCK=2, num_warps
            =1, num_stages=1)
        buf14 = empty_strided_cuda((2,), (1,), torch.float32)
        triton_poi_fused__to_copy_add_arange_clamp_mul_sub_5[grid(2)](buf14,
            2, XBLOCK=2, num_warps=1, num_stages=1)
        buf13 = empty_strided_cuda((4, 2, 2, 2), (8, 4, 2, 1), torch.float32)
        buf12 = empty_strided_cuda((4, 2, 2, 2), (8, 4, 2, 1), torch.float32)
        buf15 = buf12
        del buf12
        buf17 = buf13
        del buf13
        triton_poi_fused__unsafe_index_add_avg_pool2d_mul_sub_6[grid(32)](buf15
            , buf17, buf9, buf10, buf7, buf8, buf11, buf14, 32, XBLOCK=32,
            num_warps=1, num_stages=1)
        buf16 = empty_strided_cuda((2, 1), (1, 1), torch.float32)
        triton_poi_fused__to_copy_add_arange_clamp_mul_sub_5[grid(2)](buf16,
            2, XBLOCK=2, num_warps=1, num_stages=1)
        buf18 = empty_strided_cuda((4, 2, 1, 1), (2, 1, 1, 1), torch.float32)
        triton_poi_fused_add_mean_mul_7[grid(8)](buf15, buf17, buf16, buf18,
            8, XBLOCK=8, num_warps=1, num_stages=1)
        del buf15
        del buf17
    return (buf18, primals_1, primals_3, primals_4, buf0, buf1, buf2, buf5,
        buf7, buf8, buf9, buf10, buf11, buf14, buf16)


class RefModel2dNew(torch.nn.Module):
    """The 2D reference model."""

    def __init__(self):
        super().__init__()
        self.l1 = torch.nn.Conv2d(2, 2, 3, stride=2, bias=False, padding=1,
            padding_mode='reflect')
        self.l2 = torch.nn.BatchNorm2d(2, track_running_stats=False)
        self.l3 = torch.nn.LeakyReLU(0.02)
        self.l4 = torch.nn.Dropout2d(0.5)
        self.l5 = torch.nn.AvgPool2d(2, stride=4)
        self.l7 = torch.nn.AdaptiveAvgPool2d(1)

    def forward(self, input_0):
        primals_1 = self.l1.weight
        primals_3 = self.l2.weight
        primals_4 = self.l2.bias
        primals_2 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4])
        return output[0]
