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.utils.data
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_poi_fused_binary_cross_entropy_mean_0(in_ptr0, in_ptr1, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x1 = xindex // 16
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 64 * x1), xmask)
    tmp3 = tl.load(in_ptr1 + (x0 + 64 * x1), xmask)
    tmp13 = tl.load(in_ptr0 + (16 + x0 + 64 * x1), xmask)
    tmp15 = tl.load(in_ptr1 + (16 + x0 + 64 * x1), xmask)
    tmp25 = tl.load(in_ptr0 + (32 + x0 + 64 * x1), xmask)
    tmp27 = tl.load(in_ptr1 + (32 + x0 + 64 * x1), xmask)
    tmp37 = tl.load(in_ptr0 + (48 + x0 + 64 * x1), xmask)
    tmp39 = tl.load(in_ptr1 + (48 + x0 + 64 * x1), xmask)
    tmp1 = 1.0
    tmp2 = tmp0 - tmp1
    tmp4 = -tmp3
    tmp5 = libdevice.log1p(tmp4)
    tmp6 = -100.0
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp2 * tmp7
    tmp9 = tl_math.log(tmp3)
    tmp10 = triton_helpers.maximum(tmp9, tmp6)
    tmp11 = tmp0 * tmp10
    tmp12 = tmp8 - tmp11
    tmp14 = tmp13 - tmp1
    tmp16 = -tmp15
    tmp17 = libdevice.log1p(tmp16)
    tmp18 = triton_helpers.maximum(tmp17, tmp6)
    tmp19 = tmp14 * tmp18
    tmp20 = tl_math.log(tmp15)
    tmp21 = triton_helpers.maximum(tmp20, tmp6)
    tmp22 = tmp13 * tmp21
    tmp23 = tmp19 - tmp22
    tmp24 = tmp12 + tmp23
    tmp26 = tmp25 - tmp1
    tmp28 = -tmp27
    tmp29 = libdevice.log1p(tmp28)
    tmp30 = triton_helpers.maximum(tmp29, tmp6)
    tmp31 = tmp26 * tmp30
    tmp32 = tl_math.log(tmp27)
    tmp33 = triton_helpers.maximum(tmp32, tmp6)
    tmp34 = tmp25 * tmp33
    tmp35 = tmp31 - tmp34
    tmp36 = tmp24 + tmp35
    tmp38 = tmp37 - tmp1
    tmp40 = -tmp39
    tmp41 = libdevice.log1p(tmp40)
    tmp42 = triton_helpers.maximum(tmp41, tmp6)
    tmp43 = tmp38 * tmp42
    tmp44 = tl_math.log(tmp39)
    tmp45 = triton_helpers.maximum(tmp44, tmp6)
    tmp46 = tmp37 * tmp45
    tmp47 = tmp43 - tmp46
    tmp48 = tmp36 + tmp47
    tmp49 = 4.0
    tmp50 = tmp48 / tmp49
    tl.store(out_ptr0 + x2, tmp50, xmask)


@triton.jit
def triton_poi_fused_mul_1(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 64
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x2, xmask)
    tmp2 = tmp0 * tmp1
    tl.store(out_ptr0 + x2, tmp2, xmask)


def call(args):
    arg0_1, arg1_1, arg2_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))
    assert_size_stride(arg2_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_binary_cross_entropy_mean_0[grid(64)](arg0_1,
            arg1_1, buf0, 64, XBLOCK=64, num_warps=1, num_stages=1)
        del arg0_1
        del arg1_1
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_mul_1[grid(256)](buf0, arg2_1, buf1, 256, XBLOCK=
            256, num_warps=4, num_stages=1)
        del arg2_1
        del buf0
    return buf1,


class HandTypeLossNew(nn.Module):

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

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


Measured latency_ms: 0.02872