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
import torch.nn as nn
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_mean_mul_pow_rsub_sub_sum_0(in_out_ptr0,
    in_ptr0, in_ptr1, 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 + 16 * r0, None, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + 16 * r0), None, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (2 + 16 * r0), None, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (3 + 16 * r0), None, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (4 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp13 = tl.load(in_ptr0 + (5 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp16 = tl.load(in_ptr0 + (6 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp19 = tl.load(in_ptr0 + (7 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp23 = tl.load(in_ptr0 + (8 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp25 = tl.load(in_ptr0 + (9 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp28 = tl.load(in_ptr0 + (10 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp31 = tl.load(in_ptr0 + (11 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp35 = tl.load(in_ptr0 + (12 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp37 = tl.load(in_ptr0 + (13 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp40 = tl.load(in_ptr0 + (14 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp43 = tl.load(in_ptr0 + (15 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp47 = tl.load(in_ptr1 + 16 * r0, None, eviction_policy='evict_last')
    tmp49 = tl.load(in_ptr1 + (1 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp52 = tl.load(in_ptr1 + (2 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp55 = tl.load(in_ptr1 + (3 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp58 = tl.load(in_ptr1 + (4 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp60 = tl.load(in_ptr1 + (5 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp63 = tl.load(in_ptr1 + (6 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp66 = tl.load(in_ptr1 + (7 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp70 = tl.load(in_ptr1 + (8 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp72 = tl.load(in_ptr1 + (9 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp75 = tl.load(in_ptr1 + (10 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp78 = tl.load(in_ptr1 + (11 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp82 = tl.load(in_ptr1 + (12 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp84 = tl.load(in_ptr1 + (13 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp87 = tl.load(in_ptr1 + (14 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp90 = tl.load(in_ptr1 + (15 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp1 = tmp0 * tmp0
    tmp3 = tmp2 * tmp2
    tmp4 = tmp1 + tmp3
    tmp6 = tmp5 * tmp5
    tmp7 = tmp4 + tmp6
    tmp9 = tmp8 * tmp8
    tmp10 = tmp7 + tmp9
    tmp12 = tmp11 * tmp11
    tmp14 = tmp13 * tmp13
    tmp15 = tmp12 + tmp14
    tmp17 = tmp16 * tmp16
    tmp18 = tmp15 + tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp22 = tmp10 + tmp21
    tmp24 = tmp23 * tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp29 = tmp28 * tmp28
    tmp30 = tmp27 + tmp29
    tmp32 = tmp31 * tmp31
    tmp33 = tmp30 + tmp32
    tmp34 = tmp22 + tmp33
    tmp36 = tmp35 * tmp35
    tmp38 = tmp37 * tmp37
    tmp39 = tmp36 + tmp38
    tmp41 = tmp40 * tmp40
    tmp42 = tmp39 + tmp41
    tmp44 = tmp43 * tmp43
    tmp45 = tmp42 + tmp44
    tmp46 = tmp34 + tmp45
    tmp48 = tmp47 * tmp0
    tmp50 = tmp49 * tmp2
    tmp51 = tmp48 + tmp50
    tmp53 = tmp52 * tmp5
    tmp54 = tmp51 + tmp53
    tmp56 = tmp55 * tmp8
    tmp57 = tmp54 + tmp56
    tmp59 = tmp58 * tmp11
    tmp61 = tmp60 * tmp13
    tmp62 = tmp59 + tmp61
    tmp64 = tmp63 * tmp16
    tmp65 = tmp62 + tmp64
    tmp67 = tmp66 * tmp19
    tmp68 = tmp65 + tmp67
    tmp69 = tmp57 + tmp68
    tmp71 = tmp70 * tmp23
    tmp73 = tmp72 * tmp25
    tmp74 = tmp71 + tmp73
    tmp76 = tmp75 * tmp28
    tmp77 = tmp74 + tmp76
    tmp79 = tmp78 * tmp31
    tmp80 = tmp77 + tmp79
    tmp81 = tmp69 + tmp80
    tmp83 = tmp82 * tmp35
    tmp85 = tmp84 * tmp37
    tmp86 = tmp83 + tmp85
    tmp88 = tmp87 * tmp40
    tmp89 = tmp86 + tmp88
    tmp91 = tmp90 * tmp43
    tmp92 = tmp89 + tmp91
    tmp93 = tmp81 + tmp92
    tmp94 = tmp47 * tmp47
    tmp95 = tmp49 * tmp49
    tmp96 = tmp94 + tmp95
    tmp97 = tmp52 * tmp52
    tmp98 = tmp96 + tmp97
    tmp99 = tmp55 * tmp55
    tmp100 = tmp98 + tmp99
    tmp101 = tmp58 * tmp58
    tmp102 = tmp60 * tmp60
    tmp103 = tmp101 + tmp102
    tmp104 = tmp63 * tmp63
    tmp105 = tmp103 + tmp104
    tmp106 = tmp66 * tmp66
    tmp107 = tmp105 + tmp106
    tmp108 = tmp100 + tmp107
    tmp109 = tmp70 * tmp70
    tmp110 = tmp72 * tmp72
    tmp111 = tmp109 + tmp110
    tmp112 = tmp75 * tmp75
    tmp113 = tmp111 + tmp112
    tmp114 = tmp78 * tmp78
    tmp115 = tmp113 + tmp114
    tmp116 = tmp108 + tmp115
    tmp117 = tmp82 * tmp82
    tmp118 = tmp84 * tmp84
    tmp119 = tmp117 + tmp118
    tmp120 = tmp87 * tmp87
    tmp121 = tmp119 + tmp120
    tmp122 = tmp90 * tmp90
    tmp123 = tmp121 + tmp122
    tmp124 = tmp116 + tmp123
    tmp125 = 1e-06
    tmp126 = tmp93 + tmp125
    tmp127 = tmp124 + tmp46
    tmp128 = tmp127 - tmp93
    tmp129 = tmp128 + tmp125
    tmp130 = tmp126 / tmp129
    tmp131 = tl.broadcast_to(tmp130, [XBLOCK, RBLOCK])
    tmp133 = tl.sum(tmp131, 1)[:, None]
    tmp134 = 16.0
    tmp135 = tmp133 / tmp134
    tmp136 = 1.0
    tmp137 = tmp136 - tmp135
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp137, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf4 = empty_strided_cuda((), (), torch.float32)
        buf5 = buf4
        del buf4
        get_raw_stream(0)
        triton_per_fused_add_div_mean_mul_pow_rsub_sub_sum_0[grid(1)](buf5,
            arg1_1, arg0_1, 1, 16, XBLOCK=1, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
    return buf5,


class IoULossNew(nn.Module):
    """
    Intersection over Union Loss.
    IoU = Area of Overlap / Area of Union
    IoU loss is modified to use for heatmaps.
    """

    def __init__(self):
        super(IoULossNew, self).__init__()
        self.EPSILON = 1e-06

    def _op_sum(self, x):
        return x.sum(-1).sum(-1)

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


Measured latency_ms: 0.015335