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.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_add_binary_cross_entropy_mean_mul_rsub_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
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp7 = tl.load(in_ptr1 + x0, xmask)
    tmp17 = tl.load(in_ptr0 + (64 + x0), xmask)
    tmp22 = tl.load(in_ptr1 + (64 + x0), xmask)
    tmp32 = tl.load(in_ptr0 + (128 + x0), xmask)
    tmp37 = tl.load(in_ptr1 + (128 + x0), xmask)
    tmp47 = tl.load(in_ptr0 + (192 + x0), xmask)
    tmp52 = tl.load(in_ptr1 + (192 + x0), xmask)
    tmp1 = 1.0
    tmp2 = tmp1 - tmp0
    tmp3 = 0.2
    tmp4 = tmp2 * tmp3
    tmp5 = tmp0 + tmp4
    tmp6 = tmp5 - tmp1
    tmp8 = -tmp7
    tmp9 = libdevice.log1p(tmp8)
    tmp10 = -100.0
    tmp11 = triton_helpers.maximum(tmp9, tmp10)
    tmp12 = tmp6 * tmp11
    tmp13 = tl_math.log(tmp7)
    tmp14 = triton_helpers.maximum(tmp13, tmp10)
    tmp15 = tmp5 * tmp14
    tmp16 = tmp12 - tmp15
    tmp18 = tmp1 - tmp17
    tmp19 = tmp18 * tmp3
    tmp20 = tmp17 + tmp19
    tmp21 = tmp20 - tmp1
    tmp23 = -tmp22
    tmp24 = libdevice.log1p(tmp23)
    tmp25 = triton_helpers.maximum(tmp24, tmp10)
    tmp26 = tmp21 * tmp25
    tmp27 = tl_math.log(tmp22)
    tmp28 = triton_helpers.maximum(tmp27, tmp10)
    tmp29 = tmp20 * tmp28
    tmp30 = tmp26 - tmp29
    tmp31 = tmp16 + tmp30
    tmp33 = tmp1 - tmp32
    tmp34 = tmp33 * tmp3
    tmp35 = tmp32 + tmp34
    tmp36 = tmp35 - tmp1
    tmp38 = -tmp37
    tmp39 = libdevice.log1p(tmp38)
    tmp40 = triton_helpers.maximum(tmp39, tmp10)
    tmp41 = tmp36 * tmp40
    tmp42 = tl_math.log(tmp37)
    tmp43 = triton_helpers.maximum(tmp42, tmp10)
    tmp44 = tmp35 * tmp43
    tmp45 = tmp41 - tmp44
    tmp46 = tmp31 + tmp45
    tmp48 = tmp1 - tmp47
    tmp49 = tmp48 * tmp3
    tmp50 = tmp47 + tmp49
    tmp51 = tmp50 - tmp1
    tmp53 = -tmp52
    tmp54 = libdevice.log1p(tmp53)
    tmp55 = triton_helpers.maximum(tmp54, tmp10)
    tmp56 = tmp51 * tmp55
    tmp57 = tl_math.log(tmp52)
    tmp58 = triton_helpers.maximum(tmp57, tmp10)
    tmp59 = tmp50 * tmp58
    tmp60 = tmp56 - tmp59
    tmp61 = tmp46 + tmp60
    tmp62 = 4.0
    tmp63 = tmp61 / tmp62
    tl.store(out_ptr0 + x0, tmp63, xmask)


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((4, 4, 4), (16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_add_binary_cross_entropy_mean_mul_rsub_0[grid(64)](
            arg0_1, arg1_1, buf0, 64, XBLOCK=64, num_warps=1, num_stages=1)
        del arg0_1
        del arg1_1
    return buf0,


class BCE_disc_sm_v4New(nn.Module):

    def __init__(self, weight_list=None, lb_sm=0.2):
        super(BCE_disc_sm_v4New, self).__init__()
        self.weight_list = weight_list
        self.lb_sm = lb_sm

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