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
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_mse_loss_mul_0(in_out_ptr0, in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r0 = rindex % 64
    r2 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + r2, None)
    tmp3 = tl.load(in_ptr2 + r2, None)
    tmp10 = tl.load(in_ptr0 + (128 + r0), None, eviction_policy='evict_last')
    tmp17 = tl.load(in_ptr0 + (256 + r0), None, eviction_policy='evict_last')
    tmp24 = tl.load(in_ptr0 + (384 + r0), None, eviction_policy='evict_last')
    tmp31 = tl.load(in_ptr0 + (512 + r0), None, eviction_policy='evict_last')
    tmp38 = tl.load(in_ptr0 + (640 + r0), None, eviction_policy='evict_last')
    tmp45 = tl.load(in_ptr0 + (64 + r0), None, eviction_policy='evict_last')
    tmp46 = tl.load(in_ptr3 + r2, None)
    tmp48 = tl.load(in_ptr4 + r2, None)
    tmp55 = tl.load(in_ptr0 + (192 + r0), None, eviction_policy='evict_last')
    tmp62 = tl.load(in_ptr0 + (320 + r0), None, eviction_policy='evict_last')
    tmp69 = tl.load(in_ptr0 + (448 + r0), None, eviction_policy='evict_last')
    tmp76 = tl.load(in_ptr0 + (576 + r0), None, eviction_policy='evict_last')
    tmp83 = tl.load(in_ptr0 + (704 + r0), None, eviction_policy='evict_last')
    tmp2 = tmp0 * tmp1
    tmp4 = tmp3 * tmp1
    tmp5 = tmp2 - tmp4
    tmp6 = tmp5 * tmp5
    tmp7 = tl.broadcast_to(tmp6, [RBLOCK])
    tmp9 = triton_helpers.promote_to_tensor(tl.sum(tmp7, 0))
    tmp11 = tmp10 * tmp1
    tmp12 = tmp11 - tmp4
    tmp13 = tmp12 * tmp12
    tmp14 = tl.broadcast_to(tmp13, [RBLOCK])
    tmp16 = triton_helpers.promote_to_tensor(tl.sum(tmp14, 0))
    tmp18 = tmp17 * tmp1
    tmp19 = tmp18 - tmp4
    tmp20 = tmp19 * tmp19
    tmp21 = tl.broadcast_to(tmp20, [RBLOCK])
    tmp23 = triton_helpers.promote_to_tensor(tl.sum(tmp21, 0))
    tmp25 = tmp24 * tmp1
    tmp26 = tmp25 - tmp4
    tmp27 = tmp26 * tmp26
    tmp28 = tl.broadcast_to(tmp27, [RBLOCK])
    tmp30 = triton_helpers.promote_to_tensor(tl.sum(tmp28, 0))
    tmp32 = tmp31 * tmp1
    tmp33 = tmp32 - tmp4
    tmp34 = tmp33 * tmp33
    tmp35 = tl.broadcast_to(tmp34, [RBLOCK])
    tmp37 = triton_helpers.promote_to_tensor(tl.sum(tmp35, 0))
    tmp39 = tmp38 * tmp1
    tmp40 = tmp39 - tmp4
    tmp41 = tmp40 * tmp40
    tmp42 = tl.broadcast_to(tmp41, [RBLOCK])
    tmp44 = triton_helpers.promote_to_tensor(tl.sum(tmp42, 0))
    tmp47 = tmp45 * tmp46
    tmp49 = tmp48 * tmp46
    tmp50 = tmp47 - tmp49
    tmp51 = tmp50 * tmp50
    tmp52 = tl.broadcast_to(tmp51, [RBLOCK])
    tmp54 = triton_helpers.promote_to_tensor(tl.sum(tmp52, 0))
    tmp56 = tmp55 * tmp46
    tmp57 = tmp56 - tmp49
    tmp58 = tmp57 * tmp57
    tmp59 = tl.broadcast_to(tmp58, [RBLOCK])
    tmp61 = triton_helpers.promote_to_tensor(tl.sum(tmp59, 0))
    tmp63 = tmp62 * tmp46
    tmp64 = tmp63 - tmp49
    tmp65 = tmp64 * tmp64
    tmp66 = tl.broadcast_to(tmp65, [RBLOCK])
    tmp68 = triton_helpers.promote_to_tensor(tl.sum(tmp66, 0))
    tmp70 = tmp69 * tmp46
    tmp71 = tmp70 - tmp49
    tmp72 = tmp71 * tmp71
    tmp73 = tl.broadcast_to(tmp72, [RBLOCK])
    tmp75 = triton_helpers.promote_to_tensor(tl.sum(tmp73, 0))
    tmp77 = tmp76 * tmp46
    tmp78 = tmp77 - tmp49
    tmp79 = tmp78 * tmp78
    tmp80 = tl.broadcast_to(tmp79, [RBLOCK])
    tmp82 = triton_helpers.promote_to_tensor(tl.sum(tmp80, 0))
    tmp84 = tmp83 * tmp46
    tmp85 = tmp84 - tmp49
    tmp86 = tmp85 * tmp85
    tmp87 = tl.broadcast_to(tmp86, [RBLOCK])
    tmp89 = triton_helpers.promote_to_tensor(tl.sum(tmp87, 0))
    tmp90 = 256.0
    tmp91 = tmp9 / tmp90
    tmp92 = tmp54 / tmp90
    tmp93 = tmp91 + tmp92
    tmp94 = 0.0
    tmp95 = tmp93 + tmp94
    tmp96 = tmp16 / tmp90
    tmp97 = tmp61 / tmp90
    tmp98 = tmp96 + tmp97
    tmp99 = tmp95 + tmp98
    tmp100 = tmp23 / tmp90
    tmp101 = tmp68 / tmp90
    tmp102 = tmp100 + tmp101
    tmp103 = tmp99 + tmp102
    tmp104 = tmp30 / tmp90
    tmp105 = tmp75 / tmp90
    tmp106 = tmp104 + tmp105
    tmp107 = tmp103 + tmp106
    tmp108 = tmp37 / tmp90
    tmp109 = tmp82 / tmp90
    tmp110 = tmp108 + tmp109
    tmp111 = tmp107 + tmp110
    tmp112 = tmp44 / tmp90
    tmp113 = tmp89 / tmp90
    tmp114 = tmp112 + tmp113
    tmp115 = tmp111 + tmp114
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([1], 0, tl.int32), tmp115, None)


def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1, arg4_1 = args
    args.clear()
    assert_size_stride(arg0_1, (12, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg2_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg3_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg4_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((), (), torch.float32)
        buf10 = buf0
        del buf0
        buf13 = buf10
        del buf10
        get_raw_stream(0)
        triton_per_fused_add_mse_loss_mul_0[grid(1)](buf13, arg0_1, arg1_1,
            arg2_1, arg3_1, arg4_1, 1, 256, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
        del arg2_1
        del arg3_1
        del arg4_1
    return buf13,


class OpenPoseLossNew(nn.Module):

    def __init__(self):
        super(OpenPoseLossNew, self).__init__()

    def forward(self, input_0, input_1, input_2, input_3, input_4):
        arg0_1 = input_0
        arg1_1 = input_1
        arg2_1 = input_2
        arg3_1 = input_3
        arg4_1 = input_4
        output = call([arg0_1, arg1_1, arg2_1, arg3_1, arg4_1])
        return output[0]


Measured latency_ms: 0.017497