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
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_mul_rsub_sub_sum_0(in_out_ptr0, in_ptr0,
    in_ptr1, xnumel, rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    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)
    tmp4 = tl.load(in_ptr1 + r0, None)
    tmp12 = tl.load(in_ptr0 + (64 + r0), None)
    tmp16 = tl.load(in_ptr1 + (64 + r0), None)
    tmp24 = tl.load(in_ptr0 + (128 + r0), None)
    tmp28 = tl.load(in_ptr1 + (128 + r0), None)
    tmp36 = tl.load(in_ptr0 + (192 + r0), None)
    tmp40 = tl.load(in_ptr1 + (192 + r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.sum(tmp1, 1)[:, None]
    tmp5 = tl.broadcast_to(tmp4, [XBLOCK, RBLOCK])
    tmp7 = tl.sum(tmp5, 1)[:, None]
    tmp8 = tmp0 * tmp4
    tmp9 = tl.broadcast_to(tmp8, [XBLOCK, RBLOCK])
    tmp11 = tl.sum(tmp9, 1)[:, None]
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK, RBLOCK])
    tmp15 = tl.sum(tmp13, 1)[:, None]
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp19 = tl.sum(tmp17, 1)[:, None]
    tmp20 = tmp12 * tmp16
    tmp21 = tl.broadcast_to(tmp20, [XBLOCK, RBLOCK])
    tmp23 = tl.sum(tmp21, 1)[:, None]
    tmp25 = tl.broadcast_to(tmp24, [XBLOCK, RBLOCK])
    tmp27 = tl.sum(tmp25, 1)[:, None]
    tmp29 = tl.broadcast_to(tmp28, [XBLOCK, RBLOCK])
    tmp31 = tl.sum(tmp29, 1)[:, None]
    tmp32 = tmp24 * tmp28
    tmp33 = tl.broadcast_to(tmp32, [XBLOCK, RBLOCK])
    tmp35 = tl.sum(tmp33, 1)[:, None]
    tmp37 = tl.broadcast_to(tmp36, [XBLOCK, RBLOCK])
    tmp39 = tl.sum(tmp37, 1)[:, None]
    tmp41 = tl.broadcast_to(tmp40, [XBLOCK, RBLOCK])
    tmp43 = tl.sum(tmp41, 1)[:, None]
    tmp44 = tmp36 * tmp40
    tmp45 = tl.broadcast_to(tmp44, [XBLOCK, RBLOCK])
    tmp47 = tl.sum(tmp45, 1)[:, None]
    tmp48 = tmp3 + tmp7
    tmp49 = tmp48 - tmp11
    tmp50 = tmp11 / tmp49
    tmp51 = 1.0
    tmp52 = tmp51 - tmp50
    tmp53 = 0.0
    tmp54 = tmp52 + tmp53
    tmp55 = tmp15 + tmp19
    tmp56 = tmp55 - tmp23
    tmp57 = tmp23 / tmp56
    tmp58 = tmp51 - tmp57
    tmp59 = tmp54 + tmp58
    tmp60 = tmp27 + tmp31
    tmp61 = tmp60 - tmp35
    tmp62 = tmp35 / tmp61
    tmp63 = tmp51 - tmp62
    tmp64 = tmp59 + tmp63
    tmp65 = tmp39 + tmp43
    tmp66 = tmp65 - tmp47
    tmp67 = tmp47 / tmp66
    tmp68 = tmp51 - tmp67
    tmp69 = tmp64 + tmp68
    tmp70 = 0.25
    tmp71 = tmp69 * tmp70
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp71, 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)
        buf0 = empty_strided_cuda((), (), torch.float32)
        buf12 = buf0
        del buf0
        buf13 = buf12
        del buf12
        get_raw_stream(0)
        triton_per_fused_add_div_mul_rsub_sub_sum_0[grid(1)](buf13, arg1_1,
            arg0_1, 1, 64, XBLOCK=1, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
    return buf13,


def _iou(pred, target, size_average=True):
    b = pred.shape[0]
    IoU = 0.0
    for i in range(0, b):
        Iand1 = torch.sum(target[i, :, :, :] * pred[i, :, :, :])
        Ior1 = torch.sum(target[i, :, :, :]) + torch.sum(pred[i, :, :, :]
            ) - Iand1
        IoU1 = Iand1 / Ior1
        IoU = IoU + (1 - IoU1)
    return IoU / b


class IOUNew(torch.nn.Module):

    def __init__(self, size_average=True):
        super(IOUNew, self).__init__()
        self.size_average = size_average

    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.015669