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_rsub_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')
    tmp1 = tl.load(in_ptr1 + 16 * r0, None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (4 + 16 * r0), None, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + (4 + 16 * r0), None, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (8 + 16 * r0), None, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr1 + (8 + 16 * r0), None, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (12 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp12 = tl.load(in_ptr1 + (12 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp15 = tl.load(in_ptr0 + (1 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp16 = tl.load(in_ptr1 + (1 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp18 = tl.load(in_ptr0 + (5 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp19 = tl.load(in_ptr1 + (5 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp22 = tl.load(in_ptr0 + (9 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp23 = tl.load(in_ptr1 + (9 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp26 = tl.load(in_ptr0 + (13 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp27 = tl.load(in_ptr1 + (13 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp31 = tl.load(in_ptr0 + (2 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp32 = tl.load(in_ptr1 + (2 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp34 = tl.load(in_ptr0 + (6 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp35 = tl.load(in_ptr1 + (6 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp38 = tl.load(in_ptr0 + (10 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp39 = tl.load(in_ptr1 + (10 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp42 = tl.load(in_ptr0 + (14 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp43 = tl.load(in_ptr1 + (14 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp47 = tl.load(in_ptr0 + (3 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp48 = tl.load(in_ptr1 + (3 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp50 = tl.load(in_ptr0 + (7 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp51 = tl.load(in_ptr1 + (7 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp54 = tl.load(in_ptr0 + (11 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp55 = tl.load(in_ptr1 + (11 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp58 = tl.load(in_ptr0 + (15 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp59 = tl.load(in_ptr1 + (15 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp2 = tmp0 * tmp1
    tmp5 = tmp3 * tmp4
    tmp6 = tmp2 + tmp5
    tmp9 = tmp7 * tmp8
    tmp10 = tmp6 + tmp9
    tmp13 = tmp11 * tmp12
    tmp14 = tmp10 + tmp13
    tmp17 = tmp15 * tmp16
    tmp20 = tmp18 * tmp19
    tmp21 = tmp17 + tmp20
    tmp24 = tmp22 * tmp23
    tmp25 = tmp21 + tmp24
    tmp28 = tmp26 * tmp27
    tmp29 = tmp25 + tmp28
    tmp30 = tmp14 + tmp29
    tmp33 = tmp31 * tmp32
    tmp36 = tmp34 * tmp35
    tmp37 = tmp33 + tmp36
    tmp40 = tmp38 * tmp39
    tmp41 = tmp37 + tmp40
    tmp44 = tmp42 * tmp43
    tmp45 = tmp41 + tmp44
    tmp46 = tmp30 + tmp45
    tmp49 = tmp47 * tmp48
    tmp52 = tmp50 * tmp51
    tmp53 = tmp49 + tmp52
    tmp56 = tmp54 * tmp55
    tmp57 = tmp53 + tmp56
    tmp60 = tmp58 * tmp59
    tmp61 = tmp57 + tmp60
    tmp62 = tmp46 + tmp61
    tmp63 = tmp0 + tmp3
    tmp64 = tmp63 + tmp7
    tmp65 = tmp64 + tmp11
    tmp66 = tmp15 + tmp18
    tmp67 = tmp66 + tmp22
    tmp68 = tmp67 + tmp26
    tmp69 = tmp65 + tmp68
    tmp70 = tmp31 + tmp34
    tmp71 = tmp70 + tmp38
    tmp72 = tmp71 + tmp42
    tmp73 = tmp69 + tmp72
    tmp74 = tmp47 + tmp50
    tmp75 = tmp74 + tmp54
    tmp76 = tmp75 + tmp58
    tmp77 = tmp73 + tmp76
    tmp78 = tmp1 + tmp4
    tmp79 = tmp78 + tmp8
    tmp80 = tmp79 + tmp12
    tmp81 = tmp16 + tmp19
    tmp82 = tmp81 + tmp23
    tmp83 = tmp82 + tmp27
    tmp84 = tmp80 + tmp83
    tmp85 = tmp32 + tmp35
    tmp86 = tmp85 + tmp39
    tmp87 = tmp86 + tmp43
    tmp88 = tmp84 + tmp87
    tmp89 = tmp48 + tmp51
    tmp90 = tmp89 + tmp55
    tmp91 = tmp90 + tmp59
    tmp92 = tmp88 + tmp91
    tmp93 = 2.0
    tmp94 = tmp62 * tmp93
    tmp95 = 1.0
    tmp96 = tmp94 + tmp95
    tmp97 = tmp77 + tmp92
    tmp98 = tmp97 + tmp95
    tmp99 = tmp96 / tmp98
    tmp100 = tmp95 - tmp99
    tmp101 = tl.broadcast_to(tmp100, [XBLOCK, RBLOCK])
    tmp103 = tl.sum(tmp101, 1)[:, None]
    tmp104 = 16.0
    tmp105 = tmp103 / tmp104
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp105, 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)
        buf3 = empty_strided_cuda((), (), torch.float32)
        buf4 = buf3
        del buf3
        get_raw_stream(0)
        triton_per_fused_add_div_mean_mul_rsub_sum_0[grid(1)](buf4, arg0_1,
            arg1_1, 1, 16, XBLOCK=1, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
    return buf4,


class DiceLossNew(nn.Module):

    def __init__(self, weight=None, size_average=True):
        super(DiceLossNew, self).__init__()

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