# AOT ID: ['0_inference']
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_4/inductor_cache/o5/co5jkqyvwvljd5gniaxw3e5tv76zqkpue4b4bnkkbf7haycaxfte.py
# Topologically Sorted Source Nodes: [a, mul_2, sub_1, mul_3, exp_1, add_1, b, dot, add_2, sum_1, div, a_1, mul_5, sub_2, mul_6, exp_2, add_3, b_1, dot_1, add_4, sum_2, div_1, a_2, mul_8, sub_3, mul_9, exp_3, add_5, b_2, dot_2, add_6, sum_3, div_2, a_3, mul_11, sub_4, mul_12, exp_4, add_7, b_3, dot_3, add_8, sum_4, div_3], Original ATen: [aten.minimum, aten.mul, aten.sub, aten.exp, aten.add, aten.reciprocal, aten.dot, aten.sum, aten.div]
# Source node to ATen node mapping:
#   a => minimum_1
#   a_1 => minimum_2
#   a_2 => minimum_3
#   a_3 => minimum_4
#   add_1 => add_1
#   add_2 => add_2
#   add_3 => add_3
#   add_4 => add_4
#   add_5 => add_5
#   add_6 => add_6
#   add_7 => add_7
#   add_8 => add_8
#   b => mul_5, reciprocal_1
#   b_1 => mul_10, reciprocal_2
#   b_2 => mul_15, reciprocal_3
#   b_3 => mul_20, reciprocal_4
#   div => div
#   div_1 => div_1
#   div_2 => div_2
#   div_3 => div_3
#   dot => mul_6, sum_1
#   dot_1 => mul_11, sum_3
#   dot_2 => mul_16, sum_5
#   dot_3 => mul_21, sum_7
#   exp_1 => exp_1
#   exp_2 => exp_2
#   exp_3 => exp_3
#   exp_4 => exp_4
#   mul_11 => mul_18
#   mul_12 => mul_19
#   mul_2 => mul_3
#   mul_3 => mul_4
#   mul_5 => mul_8
#   mul_6 => mul_9
#   mul_8 => mul_13
#   mul_9 => mul_14
#   sub_1 => sub_1
#   sub_2 => sub_2
#   sub_3 => sub_3
#   sub_4 => sub_4
#   sum_1 => sum_2
#   sum_2 => sum_4
#   sum_3 => sum_6
#   sum_4 => sum_8
# Graph fragment:
#   %minimum_1 : [num_users=1] = call_function[target=torch.ops.aten.minimum.default](args = (%select_2, %select_1), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select, 0.55), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_1, %mul_3), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_1, -100), kwargs = {})
#   %exp_1 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%mul_4,), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%exp_1, 1), kwargs = {})
#   %reciprocal_1 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%add_1,), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%reciprocal_1, 1), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%minimum_1, %mul_5), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%mul_6,), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_2, %arg1_1), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%add_2, [-1]), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sum_1, %sum_2), kwargs = {})
#   %minimum_2 : [num_users=1] = call_function[target=torch.ops.aten.minimum.default](args = (%select_5, %select_4), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_3, 0.55), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_4, %mul_8), kwargs = {})
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_2, -100), kwargs = {})
#   %exp_2 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%mul_9,), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%exp_2, 1), kwargs = {})
#   %reciprocal_2 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%add_3,), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%reciprocal_2, 1), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%minimum_2, %mul_10), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%mul_11,), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_5, %arg1_1), kwargs = {})
#   %sum_4 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%add_4, [-1]), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sum_3, %sum_4), kwargs = {})
#   %minimum_3 : [num_users=1] = call_function[target=torch.ops.aten.minimum.default](args = (%select_8, %select_7), kwargs = {})
#   %mul_13 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_6, 0.55), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_7, %mul_13), kwargs = {})
#   %mul_14 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_3, -100), kwargs = {})
#   %exp_3 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%mul_14,), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%exp_3, 1), kwargs = {})
#   %reciprocal_3 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%add_5,), kwargs = {})
#   %mul_15 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%reciprocal_3, 1), kwargs = {})
#   %mul_16 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%minimum_3, %mul_15), kwargs = {})
#   %sum_5 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%mul_16,), kwargs = {})
#   %add_6 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_8, %arg1_1), kwargs = {})
#   %sum_6 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%add_6, [-1]), kwargs = {})
#   %div_2 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sum_5, %sum_6), kwargs = {})
#   %minimum_4 : [num_users=1] = call_function[target=torch.ops.aten.minimum.default](args = (%select_11, %select_10), kwargs = {})
#   %mul_18 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_9, 0.55), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_10, %mul_18), kwargs = {})
#   %mul_19 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_4, -100), kwargs = {})
#   %exp_4 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%mul_19,), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%exp_4, 1), kwargs = {})
#   %reciprocal_4 : [num_users=1] = call_function[target=torch.ops.aten.reciprocal.default](args = (%add_7,), kwargs = {})
#   %mul_20 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%reciprocal_4, 1), kwargs = {})
#   %mul_21 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%minimum_4, %mul_20), kwargs = {})
#   %sum_7 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%mul_21,), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_11, %arg1_1), kwargs = {})
#   %sum_8 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%add_8, [-1]), kwargs = {})
#   %div_3 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sum_7, %sum_8), kwargs = {})
triton_per_fused_add_div_dot_exp_minimum_mul_reciprocal_sub_sum_0 = async_compile.triton('triton_per_fused_add_div_dot_exp_minimum_mul_reciprocal_sub_sum_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.persistent_reduction(
    size_hints=[1, 4],
    reduction_hint=ReductionHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32', 7: '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': {6: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5), equal_to_1=(6,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_div_dot_exp_minimum_mul_reciprocal_sub_sum_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 44, '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_add_div_dot_exp_minimum_mul_reciprocal_sub_sum_0(in_ptr0, in_ptr1, out_ptr4, out_ptr5, out_ptr6, out_ptr7, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 4
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (12 + r0), None)
    tmp1 = tl.load(in_ptr1 + (12 + r0), None)
    tmp3 = tl.load(in_ptr1 + (3))
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp5 = tl.load(in_ptr1 + (7))
    tmp6 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp8 = tl.load(in_ptr1 + (11))
    tmp9 = tl.broadcast_to(tmp8, [XBLOCK, RBLOCK])
    tmp11 = tl.load(in_ptr1 + (15))
    tmp12 = tl.broadcast_to(tmp11, [XBLOCK, RBLOCK])
    tmp29 = tl.load(in_ptr0 + (8 + r0), None)
    tmp30 = tl.load(in_ptr1 + (8 + r0), None)
    tmp32 = tl.load(in_ptr1 + (2))
    tmp33 = tl.broadcast_to(tmp32, [XBLOCK, RBLOCK])
    tmp34 = tl.load(in_ptr1 + (6))
    tmp35 = tl.broadcast_to(tmp34, [XBLOCK, RBLOCK])
    tmp37 = tl.load(in_ptr1 + (10))
    tmp38 = tl.broadcast_to(tmp37, [XBLOCK, RBLOCK])
    tmp40 = tl.load(in_ptr1 + (14))
    tmp41 = tl.broadcast_to(tmp40, [XBLOCK, RBLOCK])
    tmp54 = tl.load(in_ptr0 + (4 + r0), None)
    tmp55 = tl.load(in_ptr1 + (4 + r0), None)
    tmp57 = tl.load(in_ptr1 + (1))
    tmp58 = tl.broadcast_to(tmp57, [XBLOCK, RBLOCK])
    tmp59 = tl.load(in_ptr1 + (5))
    tmp60 = tl.broadcast_to(tmp59, [XBLOCK, RBLOCK])
    tmp62 = tl.load(in_ptr1 + (9))
    tmp63 = tl.broadcast_to(tmp62, [XBLOCK, RBLOCK])
    tmp65 = tl.load(in_ptr1 + (13))
    tmp66 = tl.broadcast_to(tmp65, [XBLOCK, RBLOCK])
    tmp79 = tl.load(in_ptr0 + (r0), None)
    tmp80 = tl.load(in_ptr1 + (r0), None)
    tmp82 = tl.load(in_ptr1 + (0))
    tmp83 = tl.broadcast_to(tmp82, [XBLOCK, RBLOCK])
    tmp84 = tl.load(in_ptr1 + (4))
    tmp85 = tl.broadcast_to(tmp84, [XBLOCK, RBLOCK])
    tmp87 = tl.load(in_ptr1 + (8))
    tmp88 = tl.broadcast_to(tmp87, [XBLOCK, RBLOCK])
    tmp90 = tl.load(in_ptr1 + (12))
    tmp91 = tl.broadcast_to(tmp90, [XBLOCK, RBLOCK])
    tmp104 = tl.load(in_ptr0 + (0))
    tmp105 = tl.broadcast_to(tmp104, [XBLOCK, RBLOCK])
    tmp106 = tl.load(in_ptr1 + (4*r0), None, eviction_policy='evict_last')
    tmp108 = tl.load(in_ptr0 + (1))
    tmp109 = tl.broadcast_to(tmp108, [XBLOCK, RBLOCK])
    tmp110 = tl.load(in_ptr1 + (1 + (4*r0)), None, eviction_policy='evict_last')
    tmp113 = tl.load(in_ptr0 + (2))
    tmp114 = tl.broadcast_to(tmp113, [XBLOCK, RBLOCK])
    tmp115 = tl.load(in_ptr1 + (2 + (4*r0)), None, eviction_policy='evict_last')
    tmp118 = tl.load(in_ptr0 + (3))
    tmp119 = tl.broadcast_to(tmp118, [XBLOCK, RBLOCK])
    tmp120 = tl.load(in_ptr1 + (3 + (4*r0)), None, eviction_policy='evict_last')
    tmp124 = tl.load(in_ptr0 + (4))
    tmp125 = tl.broadcast_to(tmp124, [XBLOCK, RBLOCK])
    tmp127 = tl.load(in_ptr0 + (5))
    tmp128 = tl.broadcast_to(tmp127, [XBLOCK, RBLOCK])
    tmp131 = tl.load(in_ptr0 + (6))
    tmp132 = tl.broadcast_to(tmp131, [XBLOCK, RBLOCK])
    tmp135 = tl.load(in_ptr0 + (7))
    tmp136 = tl.broadcast_to(tmp135, [XBLOCK, RBLOCK])
    tmp140 = tl.load(in_ptr0 + (8))
    tmp141 = tl.broadcast_to(tmp140, [XBLOCK, RBLOCK])
    tmp143 = tl.load(in_ptr0 + (9))
    tmp144 = tl.broadcast_to(tmp143, [XBLOCK, RBLOCK])
    tmp147 = tl.load(in_ptr0 + (10))
    tmp148 = tl.broadcast_to(tmp147, [XBLOCK, RBLOCK])
    tmp151 = tl.load(in_ptr0 + (11))
    tmp152 = tl.broadcast_to(tmp151, [XBLOCK, RBLOCK])
    tmp156 = tl.load(in_ptr0 + (12))
    tmp157 = tl.broadcast_to(tmp156, [XBLOCK, RBLOCK])
    tmp159 = tl.load(in_ptr0 + (13))
    tmp160 = tl.broadcast_to(tmp159, [XBLOCK, RBLOCK])
    tmp163 = tl.load(in_ptr0 + (14))
    tmp164 = tl.broadcast_to(tmp163, [XBLOCK, RBLOCK])
    tmp167 = tl.load(in_ptr0 + (15))
    tmp168 = tl.broadcast_to(tmp167, [XBLOCK, RBLOCK])
    tmp2 = triton_helpers.minimum(tmp0, tmp1)
    tmp7 = triton_helpers.maximum(tmp4, tmp6)
    tmp10 = triton_helpers.maximum(tmp7, tmp9)
    tmp13 = triton_helpers.maximum(tmp10, tmp12)
    tmp14 = 0.55
    tmp15 = tmp13 * tmp14
    tmp16 = tmp1 - tmp15
    tmp17 = -100.0
    tmp18 = tmp16 * tmp17
    tmp19 = tl_math.exp(tmp18)
    tmp20 = 1.0
    tmp21 = tmp19 + tmp20
    tmp22 = tl.full([1, 1], 1, tl.int32)
    tmp23 = tmp22 / tmp21
    tmp24 = tmp23 * tmp20
    tmp25 = tmp2 * tmp24
    tmp26 = tl.broadcast_to(tmp25, [XBLOCK, RBLOCK])
    tmp28 = tl.sum(tmp26, 1)[:, None]
    tmp31 = triton_helpers.minimum(tmp29, tmp30)
    tmp36 = triton_helpers.maximum(tmp33, tmp35)
    tmp39 = triton_helpers.maximum(tmp36, tmp38)
    tmp42 = triton_helpers.maximum(tmp39, tmp41)
    tmp43 = tmp42 * tmp14
    tmp44 = tmp30 - tmp43
    tmp45 = tmp44 * tmp17
    tmp46 = tl_math.exp(tmp45)
    tmp47 = tmp46 + tmp20
    tmp48 = tmp22 / tmp47
    tmp49 = tmp48 * tmp20
    tmp50 = tmp31 * tmp49
    tmp51 = tl.broadcast_to(tmp50, [XBLOCK, RBLOCK])
    tmp53 = tl.sum(tmp51, 1)[:, None]
    tmp56 = triton_helpers.minimum(tmp54, tmp55)
    tmp61 = triton_helpers.maximum(tmp58, tmp60)
    tmp64 = triton_helpers.maximum(tmp61, tmp63)
    tmp67 = triton_helpers.maximum(tmp64, tmp66)
    tmp68 = tmp67 * tmp14
    tmp69 = tmp55 - tmp68
    tmp70 = tmp69 * tmp17
    tmp71 = tl_math.exp(tmp70)
    tmp72 = tmp71 + tmp20
    tmp73 = tmp22 / tmp72
    tmp74 = tmp73 * tmp20
    tmp75 = tmp56 * tmp74
    tmp76 = tl.broadcast_to(tmp75, [XBLOCK, RBLOCK])
    tmp78 = tl.sum(tmp76, 1)[:, None]
    tmp81 = triton_helpers.minimum(tmp79, tmp80)
    tmp86 = triton_helpers.maximum(tmp83, tmp85)
    tmp89 = triton_helpers.maximum(tmp86, tmp88)
    tmp92 = triton_helpers.maximum(tmp89, tmp91)
    tmp93 = tmp92 * tmp14
    tmp94 = tmp80 - tmp93
    tmp95 = tmp94 * tmp17
    tmp96 = tl_math.exp(tmp95)
    tmp97 = tmp96 + tmp20
    tmp98 = tmp22 / tmp97
    tmp99 = tmp98 * tmp20
    tmp100 = tmp81 * tmp99
    tmp101 = tl.broadcast_to(tmp100, [XBLOCK, RBLOCK])
    tmp103 = tl.sum(tmp101, 1)[:, None]
    tmp107 = tmp105 + tmp106
    tmp111 = tmp109 + tmp110
    tmp112 = tmp107 + tmp111
    tmp116 = tmp114 + tmp115
    tmp117 = tmp112 + tmp116
    tmp121 = tmp119 + tmp120
    tmp122 = tmp117 + tmp121
    tmp123 = tmp103 / tmp122
    tmp126 = tmp125 + tmp106
    tmp129 = tmp128 + tmp110
    tmp130 = tmp126 + tmp129
    tmp133 = tmp132 + tmp115
    tmp134 = tmp130 + tmp133
    tmp137 = tmp136 + tmp120
    tmp138 = tmp134 + tmp137
    tmp139 = tmp78 / tmp138
    tmp142 = tmp141 + tmp106
    tmp145 = tmp144 + tmp110
    tmp146 = tmp142 + tmp145
    tmp149 = tmp148 + tmp115
    tmp150 = tmp146 + tmp149
    tmp153 = tmp152 + tmp120
    tmp154 = tmp150 + tmp153
    tmp155 = tmp53 / tmp154
    tmp158 = tmp157 + tmp106
    tmp161 = tmp160 + tmp110
    tmp162 = tmp158 + tmp161
    tmp165 = tmp164 + tmp115
    tmp166 = tmp162 + tmp165
    tmp169 = tmp168 + tmp120
    tmp170 = tmp166 + tmp169
    tmp171 = tmp28 / tmp170
    tl.store(out_ptr4 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp123, None)
    tl.store(out_ptr5 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp139, None)
    tl.store(out_ptr6 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp155, None)
    tl.store(out_ptr7 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp171, None)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/pd/cpdke6scsojcjiseffjq2rccky6wpkjfkayjnletpzhsryazuo4c.py
# Topologically Sorted Source Nodes: [sums], Original ATen: [aten.stack]
# Source node to ATen node mapping:
#   sums => cat
# Graph fragment:
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%mul_7, %mul_12, %mul_17, %mul_22],), kwargs = {})
triton_poi_fused_stack_1 = async_compile.triton('triton_poi_fused_stack_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=[16], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_stack_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, '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_stack_1(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0), tmp4 & xmask, eviction_policy='evict_last', other=0.0)
    tmp6 = 2.0
    tmp7 = tmp5 * tmp6
    tmp8 = tl.full(tmp7.shape, 0.0, tmp7.dtype)
    tmp9 = tl.where(tmp4, tmp7, tmp8)
    tmp10 = tmp0 >= tmp3
    tmp11 = tl.full([1], 8, tl.int64)
    tmp12 = tmp0 < tmp11
    tmp13 = tmp10 & tmp12
    tmp14 = tl.load(in_ptr1 + ((-4) + x0), tmp13 & xmask, eviction_policy='evict_last', other=0.0)
    tmp15 = tmp14 * tmp6
    tmp16 = tl.full(tmp15.shape, 0.0, tmp15.dtype)
    tmp17 = tl.where(tmp13, tmp15, tmp16)
    tmp18 = tmp0 >= tmp11
    tmp19 = tl.full([1], 12, tl.int64)
    tmp20 = tmp0 < tmp19
    tmp21 = tmp18 & tmp20
    tmp22 = tl.load(in_ptr2 + ((-8) + x0), tmp21 & xmask, eviction_policy='evict_last', other=0.0)
    tmp23 = tmp22 * tmp6
    tmp24 = tl.full(tmp23.shape, 0.0, tmp23.dtype)
    tmp25 = tl.where(tmp21, tmp23, tmp24)
    tmp26 = tmp0 >= tmp19
    tmp27 = tl.full([1], 16, tl.int64)
    tmp28 = tmp0 < tmp27
    tmp29 = tl.load(in_ptr3 + ((-12) + x0), tmp26 & xmask, eviction_policy='evict_last', other=0.0)
    tmp30 = tmp29 * tmp6
    tmp31 = tl.full(tmp30.shape, 0.0, tmp30.dtype)
    tmp32 = tl.where(tmp26, tmp30, tmp31)
    tmp33 = tl.where(tmp21, tmp25, tmp32)
    tmp34 = tl.where(tmp13, tmp17, tmp33)
    tmp35 = tl.where(tmp4, tmp9, tmp34)
    tl.store(out_ptr0 + (x0), tmp35, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/sy/csyklj4uv2s23rzfh7b6nk4ezlhjwpn4xxwzmfyehwsr2vie47pe.py
# Topologically Sorted Source Nodes: [setitem, mean], Original ATen: [aten.lift_fresh, aten.index_put, aten.mean]
# Source node to ATen node mapping:
#   mean => mean
#   setitem => full_default, index_put
# Graph fragment:
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put : [num_users=1] = call_function[target=torch.ops.aten.index_put_.default](args = (%view, [%isnan], %full_default), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%index_put,), kwargs = {})
triton_per_fused_index_put_lift_fresh_mean_2 = async_compile.triton('triton_per_fused_index_put_lift_fresh_mean_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.persistent_reduction(
    size_hints=[1, 16],
    reduction_hint=ReductionHint.INNER,
    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': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 4), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_index_put_lift_fresh_mean_2', 'mutated_arg_names': ['in_out_ptr0', 'in_ptr0', 'out_ptr0'], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 1, '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_index_put_lift_fresh_mean_2(in_out_ptr0, in_ptr0, out_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 16
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (r0), None)
    tmp1 = libdevice.isnan(tmp0).to(tl.int1)
    tmp2 = 0.0
    tmp3 = tl.where(tmp1, tmp2, tmp0)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.sum(tmp4, 1)[:, None]
    tmp7 = 16.0
    tmp8 = tmp6 / tmp7
    tl.store(out_ptr0 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp3, None)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp8, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4), (4, 1))
    assert_size_stride(arg1_1, (4, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf1 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf3 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf5 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf7 = empty_strided_cuda((4, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [a, mul_2, sub_1, mul_3, exp_1, add_1, b, dot, add_2, sum_1, div, a_1, mul_5, sub_2, mul_6, exp_2, add_3, b_1, dot_1, add_4, sum_2, div_1, a_2, mul_8, sub_3, mul_9, exp_3, add_5, b_2, dot_2, add_6, sum_3, div_2, a_3, mul_11, sub_4, mul_12, exp_4, add_7, b_3, dot_3, add_8, sum_4, div_3], Original ATen: [aten.minimum, aten.mul, aten.sub, aten.exp, aten.add, aten.reciprocal, aten.dot, aten.sum, aten.div]
        stream0 = get_raw_stream(0)
        triton_per_fused_add_div_dot_exp_minimum_mul_reciprocal_sub_sum_0.run(arg0_1, arg1_1, buf1, buf3, buf5, buf7, 1, 4, grid=grid(1), stream=stream0)
        del arg0_1
        del arg1_1
        buf8 = empty_strided_cuda((16, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [sums], Original ATen: [aten.stack]
        triton_poi_fused_stack_1.run(buf1, buf3, buf5, buf7, buf8, 16, grid=grid(16), stream=stream0)
        del buf1
        del buf3
        del buf5
        del buf7
        buf11 = empty_strided_cuda((), (), torch.float32)
        buf12 = buf11; del buf11  # reuse
        # Topologically Sorted Source Nodes: [setitem, mean], Original ATen: [aten.lift_fresh, aten.index_put, aten.mean]
        triton_per_fused_index_put_lift_fresh_mean_2.run(buf12, buf8, buf8, 1, 16, grid=grid(1), stream=stream0)
        del buf8
    return (buf12, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    arg0_1 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_1])
    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.hub


class MaskLoss(nn.Module):

    def __init__(self, size_average=None, reduce=None, reduction='mean'):
        super(MaskLoss, self).__init__()
        self.reduction = reduction

    def forward(self, input, target):
        N, _W = input.size()
        torch.min(input, target)
        values, index = torch.max(target, 0)
        1 / (1 + torch.exp(-100 * (target - 0.55 * values)))
        sums = []
        for n in range(N):
            value = values[n]
            index[n]
            tar = target[n]
            inp = input[n]
            a = torch.min(inp, tar)
            b = 1 / (1 + torch.exp(-100 * (tar - 0.55 * value)))
            sums.append(2 * torch.div(torch.dot(a, b), torch.sum(inp +
                target, axis=-1)))
        sums = torch.stack(sums)
        sums[torch.isnan(sums)] = 0.0
        return sums.mean()


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


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

import torch
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
import torch.nn as nn
import torch.hub
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_per_fused_add_div_dot_exp_minimum_mul_reciprocal_sub_sum_0(in_ptr0,
    in_ptr1, out_ptr4, out_ptr5, out_ptr6, out_ptr7, xnumel, rnumel, XBLOCK:
    tl.constexpr):
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (12 + r0), None)
    tmp1 = tl.load(in_ptr1 + (12 + r0), None)
    tmp3 = tl.load(in_ptr1 + 3)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp5 = tl.load(in_ptr1 + 7)
    tmp6 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp8 = tl.load(in_ptr1 + 11)
    tmp9 = tl.broadcast_to(tmp8, [XBLOCK, RBLOCK])
    tmp11 = tl.load(in_ptr1 + 15)
    tmp12 = tl.broadcast_to(tmp11, [XBLOCK, RBLOCK])
    tmp29 = tl.load(in_ptr0 + (8 + r0), None)
    tmp30 = tl.load(in_ptr1 + (8 + r0), None)
    tmp32 = tl.load(in_ptr1 + 2)
    tmp33 = tl.broadcast_to(tmp32, [XBLOCK, RBLOCK])
    tmp34 = tl.load(in_ptr1 + 6)
    tmp35 = tl.broadcast_to(tmp34, [XBLOCK, RBLOCK])
    tmp37 = tl.load(in_ptr1 + 10)
    tmp38 = tl.broadcast_to(tmp37, [XBLOCK, RBLOCK])
    tmp40 = tl.load(in_ptr1 + 14)
    tmp41 = tl.broadcast_to(tmp40, [XBLOCK, RBLOCK])
    tmp54 = tl.load(in_ptr0 + (4 + r0), None)
    tmp55 = tl.load(in_ptr1 + (4 + r0), None)
    tmp57 = tl.load(in_ptr1 + 1)
    tmp58 = tl.broadcast_to(tmp57, [XBLOCK, RBLOCK])
    tmp59 = tl.load(in_ptr1 + 5)
    tmp60 = tl.broadcast_to(tmp59, [XBLOCK, RBLOCK])
    tmp62 = tl.load(in_ptr1 + 9)
    tmp63 = tl.broadcast_to(tmp62, [XBLOCK, RBLOCK])
    tmp65 = tl.load(in_ptr1 + 13)
    tmp66 = tl.broadcast_to(tmp65, [XBLOCK, RBLOCK])
    tmp79 = tl.load(in_ptr0 + r0, None)
    tmp80 = tl.load(in_ptr1 + r0, None)
    tmp82 = tl.load(in_ptr1 + 0)
    tmp83 = tl.broadcast_to(tmp82, [XBLOCK, RBLOCK])
    tmp84 = tl.load(in_ptr1 + 4)
    tmp85 = tl.broadcast_to(tmp84, [XBLOCK, RBLOCK])
    tmp87 = tl.load(in_ptr1 + 8)
    tmp88 = tl.broadcast_to(tmp87, [XBLOCK, RBLOCK])
    tmp90 = tl.load(in_ptr1 + 12)
    tmp91 = tl.broadcast_to(tmp90, [XBLOCK, RBLOCK])
    tmp104 = tl.load(in_ptr0 + 0)
    tmp105 = tl.broadcast_to(tmp104, [XBLOCK, RBLOCK])
    tmp106 = tl.load(in_ptr1 + 4 * r0, None, eviction_policy='evict_last')
    tmp108 = tl.load(in_ptr0 + 1)
    tmp109 = tl.broadcast_to(tmp108, [XBLOCK, RBLOCK])
    tmp110 = tl.load(in_ptr1 + (1 + 4 * r0), None, eviction_policy='evict_last'
        )
    tmp113 = tl.load(in_ptr0 + 2)
    tmp114 = tl.broadcast_to(tmp113, [XBLOCK, RBLOCK])
    tmp115 = tl.load(in_ptr1 + (2 + 4 * r0), None, eviction_policy='evict_last'
        )
    tmp118 = tl.load(in_ptr0 + 3)
    tmp119 = tl.broadcast_to(tmp118, [XBLOCK, RBLOCK])
    tmp120 = tl.load(in_ptr1 + (3 + 4 * r0), None, eviction_policy='evict_last'
        )
    tmp124 = tl.load(in_ptr0 + 4)
    tmp125 = tl.broadcast_to(tmp124, [XBLOCK, RBLOCK])
    tmp127 = tl.load(in_ptr0 + 5)
    tmp128 = tl.broadcast_to(tmp127, [XBLOCK, RBLOCK])
    tmp131 = tl.load(in_ptr0 + 6)
    tmp132 = tl.broadcast_to(tmp131, [XBLOCK, RBLOCK])
    tmp135 = tl.load(in_ptr0 + 7)
    tmp136 = tl.broadcast_to(tmp135, [XBLOCK, RBLOCK])
    tmp140 = tl.load(in_ptr0 + 8)
    tmp141 = tl.broadcast_to(tmp140, [XBLOCK, RBLOCK])
    tmp143 = tl.load(in_ptr0 + 9)
    tmp144 = tl.broadcast_to(tmp143, [XBLOCK, RBLOCK])
    tmp147 = tl.load(in_ptr0 + 10)
    tmp148 = tl.broadcast_to(tmp147, [XBLOCK, RBLOCK])
    tmp151 = tl.load(in_ptr0 + 11)
    tmp152 = tl.broadcast_to(tmp151, [XBLOCK, RBLOCK])
    tmp156 = tl.load(in_ptr0 + 12)
    tmp157 = tl.broadcast_to(tmp156, [XBLOCK, RBLOCK])
    tmp159 = tl.load(in_ptr0 + 13)
    tmp160 = tl.broadcast_to(tmp159, [XBLOCK, RBLOCK])
    tmp163 = tl.load(in_ptr0 + 14)
    tmp164 = tl.broadcast_to(tmp163, [XBLOCK, RBLOCK])
    tmp167 = tl.load(in_ptr0 + 15)
    tmp168 = tl.broadcast_to(tmp167, [XBLOCK, RBLOCK])
    tmp2 = triton_helpers.minimum(tmp0, tmp1)
    tmp7 = triton_helpers.maximum(tmp4, tmp6)
    tmp10 = triton_helpers.maximum(tmp7, tmp9)
    tmp13 = triton_helpers.maximum(tmp10, tmp12)
    tmp14 = 0.55
    tmp15 = tmp13 * tmp14
    tmp16 = tmp1 - tmp15
    tmp17 = -100.0
    tmp18 = tmp16 * tmp17
    tmp19 = tl_math.exp(tmp18)
    tmp20 = 1.0
    tmp21 = tmp19 + tmp20
    tmp22 = tl.full([1, 1], 1, tl.int32)
    tmp23 = tmp22 / tmp21
    tmp24 = tmp23 * tmp20
    tmp25 = tmp2 * tmp24
    tmp26 = tl.broadcast_to(tmp25, [XBLOCK, RBLOCK])
    tmp28 = tl.sum(tmp26, 1)[:, None]
    tmp31 = triton_helpers.minimum(tmp29, tmp30)
    tmp36 = triton_helpers.maximum(tmp33, tmp35)
    tmp39 = triton_helpers.maximum(tmp36, tmp38)
    tmp42 = triton_helpers.maximum(tmp39, tmp41)
    tmp43 = tmp42 * tmp14
    tmp44 = tmp30 - tmp43
    tmp45 = tmp44 * tmp17
    tmp46 = tl_math.exp(tmp45)
    tmp47 = tmp46 + tmp20
    tmp48 = tmp22 / tmp47
    tmp49 = tmp48 * tmp20
    tmp50 = tmp31 * tmp49
    tmp51 = tl.broadcast_to(tmp50, [XBLOCK, RBLOCK])
    tmp53 = tl.sum(tmp51, 1)[:, None]
    tmp56 = triton_helpers.minimum(tmp54, tmp55)
    tmp61 = triton_helpers.maximum(tmp58, tmp60)
    tmp64 = triton_helpers.maximum(tmp61, tmp63)
    tmp67 = triton_helpers.maximum(tmp64, tmp66)
    tmp68 = tmp67 * tmp14
    tmp69 = tmp55 - tmp68
    tmp70 = tmp69 * tmp17
    tmp71 = tl_math.exp(tmp70)
    tmp72 = tmp71 + tmp20
    tmp73 = tmp22 / tmp72
    tmp74 = tmp73 * tmp20
    tmp75 = tmp56 * tmp74
    tmp76 = tl.broadcast_to(tmp75, [XBLOCK, RBLOCK])
    tmp78 = tl.sum(tmp76, 1)[:, None]
    tmp81 = triton_helpers.minimum(tmp79, tmp80)
    tmp86 = triton_helpers.maximum(tmp83, tmp85)
    tmp89 = triton_helpers.maximum(tmp86, tmp88)
    tmp92 = triton_helpers.maximum(tmp89, tmp91)
    tmp93 = tmp92 * tmp14
    tmp94 = tmp80 - tmp93
    tmp95 = tmp94 * tmp17
    tmp96 = tl_math.exp(tmp95)
    tmp97 = tmp96 + tmp20
    tmp98 = tmp22 / tmp97
    tmp99 = tmp98 * tmp20
    tmp100 = tmp81 * tmp99
    tmp101 = tl.broadcast_to(tmp100, [XBLOCK, RBLOCK])
    tmp103 = tl.sum(tmp101, 1)[:, None]
    tmp107 = tmp105 + tmp106
    tmp111 = tmp109 + tmp110
    tmp112 = tmp107 + tmp111
    tmp116 = tmp114 + tmp115
    tmp117 = tmp112 + tmp116
    tmp121 = tmp119 + tmp120
    tmp122 = tmp117 + tmp121
    tmp123 = tmp103 / tmp122
    tmp126 = tmp125 + tmp106
    tmp129 = tmp128 + tmp110
    tmp130 = tmp126 + tmp129
    tmp133 = tmp132 + tmp115
    tmp134 = tmp130 + tmp133
    tmp137 = tmp136 + tmp120
    tmp138 = tmp134 + tmp137
    tmp139 = tmp78 / tmp138
    tmp142 = tmp141 + tmp106
    tmp145 = tmp144 + tmp110
    tmp146 = tmp142 + tmp145
    tmp149 = tmp148 + tmp115
    tmp150 = tmp146 + tmp149
    tmp153 = tmp152 + tmp120
    tmp154 = tmp150 + tmp153
    tmp155 = tmp53 / tmp154
    tmp158 = tmp157 + tmp106
    tmp161 = tmp160 + tmp110
    tmp162 = tmp158 + tmp161
    tmp165 = tmp164 + tmp115
    tmp166 = tmp162 + tmp165
    tmp169 = tmp168 + tmp120
    tmp170 = tmp166 + tmp169
    tmp171 = tmp28 / tmp170
    tl.store(out_ptr4 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp123, None)
    tl.store(out_ptr5 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp139, None)
    tl.store(out_ptr6 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp155, None)
    tl.store(out_ptr7 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp171, None)


@triton.jit
def triton_poi_fused_stack_1(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + x0, tmp4 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp6 = 2.0
    tmp7 = tmp5 * tmp6
    tmp8 = tl.full(tmp7.shape, 0.0, tmp7.dtype)
    tmp9 = tl.where(tmp4, tmp7, tmp8)
    tmp10 = tmp0 >= tmp3
    tmp11 = tl.full([1], 8, tl.int64)
    tmp12 = tmp0 < tmp11
    tmp13 = tmp10 & tmp12
    tmp14 = tl.load(in_ptr1 + (-4 + x0), tmp13 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp15 = tmp14 * tmp6
    tmp16 = tl.full(tmp15.shape, 0.0, tmp15.dtype)
    tmp17 = tl.where(tmp13, tmp15, tmp16)
    tmp18 = tmp0 >= tmp11
    tmp19 = tl.full([1], 12, tl.int64)
    tmp20 = tmp0 < tmp19
    tmp21 = tmp18 & tmp20
    tmp22 = tl.load(in_ptr2 + (-8 + x0), tmp21 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp23 = tmp22 * tmp6
    tmp24 = tl.full(tmp23.shape, 0.0, tmp23.dtype)
    tmp25 = tl.where(tmp21, tmp23, tmp24)
    tmp26 = tmp0 >= tmp19
    tl.full([1], 16, tl.int64)
    tmp29 = tl.load(in_ptr3 + (-12 + x0), tmp26 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp30 = tmp29 * tmp6
    tmp31 = tl.full(tmp30.shape, 0.0, tmp30.dtype)
    tmp32 = tl.where(tmp26, tmp30, tmp31)
    tmp33 = tl.where(tmp21, tmp25, tmp32)
    tmp34 = tl.where(tmp13, tmp17, tmp33)
    tmp35 = tl.where(tmp4, tmp9, tmp34)
    tl.store(out_ptr0 + x0, tmp35, xmask)


@triton.jit
def triton_per_fused_index_put_lift_fresh_mean_2(in_out_ptr0, in_ptr0,
    out_ptr0, xnumel, rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp1 = libdevice.isnan(tmp0).to(tl.int1)
    tmp2 = 0.0
    tmp3 = tl.where(tmp1, tmp2, tmp0)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.sum(tmp4, 1)[:, None]
    tmp7 = 16.0
    tmp8 = tmp6 / tmp7
    tl.store(out_ptr0 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp3, None)
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp8, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4), (4, 1))
    assert_size_stride(arg1_1, (4, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf1 = empty_strided_cuda((4,), (1,), torch.float32)
        buf3 = empty_strided_cuda((4,), (1,), torch.float32)
        buf5 = empty_strided_cuda((4,), (1,), torch.float32)
        buf7 = empty_strided_cuda((4,), (1,), torch.float32)
        get_raw_stream(0)
        triton_per_fused_add_div_dot_exp_minimum_mul_reciprocal_sub_sum_0[grid
            (1)](arg0_1, arg1_1, buf1, buf3, buf5, buf7, 1, 4, XBLOCK=1,
            num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
        buf8 = empty_strided_cuda((16,), (1,), torch.float32)
        triton_poi_fused_stack_1[grid(16)](buf1, buf3, buf5, buf7, buf8, 16,
            XBLOCK=16, num_warps=1, num_stages=1)
        del buf1
        del buf3
        del buf5
        del buf7
        buf11 = empty_strided_cuda((), (), torch.float32)
        buf12 = buf11
        del buf11
        triton_per_fused_index_put_lift_fresh_mean_2[grid(1)](buf12, buf8,
            buf8, 1, 16, XBLOCK=1, num_warps=2, num_stages=1)
        del buf8
    return buf12,


class MaskLossNew(nn.Module):

    def __init__(self, size_average=None, reduce=None, reduction='mean'):
        super(MaskLossNew, self).__init__()
        self.reduction = reduction

    def forward(self, input_0, input_1):
        arg0_1 = input_0
        arg1_1 = input_1
        output = call([arg0_1, arg1_1])
        return output[0]
