# AOT ID: ['0_inference']
from ctypes import c_void_p, c_long, c_int
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align
from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_7/inductor_cache/n3/cn3xpf35zpoqzkocj4ldtzmkmz4mgun5y3arzp5fmziqmoi2sjkk.py
# Topologically Sorted Source Nodes: [mul, sub, y_pred, mul_2, y_pred_neg, sub_4, logit_n, logsumexp, sub_2, mul_3, y_pred_pos, logit_p, logsumexp_1, add_3, loss, mean], Original ATen: [aten.mul, aten.rsub, aten.sub, aten.logsumexp, aten.add, aten.softplus, aten.mean]
# Source node to ATen node mapping:
#   add_3 => add_5
#   logit_n => mul_5
#   logit_p => mul_4
#   logsumexp => abs_1, add_3, amax, eq, exp, full_default, log, sub_5, sum_1, where
#   logsumexp_1 => abs_2, add_4, amax_1, eq_1, exp_1, full_default_1, log_1, sub_6, sum_2, where_1
#   loss => div, exp_2, gt, log1p, mul_6, where_2
#   mean => mean
#   mul => mul
#   mul_2 => mul_2
#   mul_3 => mul_3
#   sub => sub
#   sub_2 => sub_2
#   sub_4 => sub_4
#   y_pred => mul_1
#   y_pred_neg => sub_1
#   y_pred_pos => sub_3
# Graph fragment:
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg0_1, 2), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %mul), kwargs = {})
#   %mul_1 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub, %arg1_1), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg0_1, 1000000000000.0), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mul_1, %mul_2), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_1, 4), kwargs = {})
#   %mul_5 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_4, 4), kwargs = {})
#   %amax : [num_users=2] = call_function[target=torch.ops.aten.amax.default](args = (%mul_5, [-1], True), kwargs = {})
#   %abs_1 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%amax,), kwargs = {})
#   %eq : [num_users=1] = call_function[target=torch.ops.aten.eq.Scalar](args = (%abs_1, inf), kwargs = {})
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%eq, %full_default, %amax), kwargs = {})
#   %sub_5 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mul_5, %where), kwargs = {})
#   %exp : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%sub_5,), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp, [-1]), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sum_1,), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%log, %squeeze), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %arg0_1), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_2, 1000000000000.0), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mul_1, %mul_3), kwargs = {})
#   %mul_4 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_3, 4), kwargs = {})
#   %amax_1 : [num_users=2] = call_function[target=torch.ops.aten.amax.default](args = (%mul_4, [-1], True), kwargs = {})
#   %abs_2 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%amax_1,), kwargs = {})
#   %eq_1 : [num_users=1] = call_function[target=torch.ops.aten.eq.Scalar](args = (%abs_2, inf), kwargs = {})
#   %full_default_1 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_1 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%eq_1, %full_default_1, %amax_1), kwargs = {})
#   %sub_6 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mul_4, %where_1), kwargs = {})
#   %exp_1 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%sub_6,), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp_1, [-1]), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sum_2,), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%log_1, %squeeze_1), kwargs = {})
#   %add_5 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_3, %add_4), kwargs = {})
#   %mul_6 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add_5, 1.0), kwargs = {})
#   %gt : [num_users=1] = call_function[target=torch.ops.aten.gt.Scalar](args = (%mul_6, 20.0), kwargs = {})
#   %exp_2 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%mul_6,), kwargs = {})
#   %log1p : [num_users=1] = call_function[target=torch.ops.aten.log1p.default](args = (%exp_2,), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%log1p, 1.0), kwargs = {})
#   %where_2 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%gt, %add_5, %div), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%where_2,), kwargs = {})
triton_per_fused_add_logsumexp_mean_mul_rsub_softplus_sub_0 = async_compile.triton('triton_per_fused_add_logsumexp_mean_mul_rsub_softplus_sub_0', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.persistent_reduction(
    size_hints=[1, 64],
    reduction_hint=ReductionHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 4), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_logsumexp_mean_mul_rsub_softplus_sub_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 8, 'num_reduction': 1, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_add_logsumexp_mean_mul_rsub_softplus_sub_0(in_out_ptr0, in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 64
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (4*r0), None, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr1 + (4*r0), None, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr0 + (1 + (4*r0)), None, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr1 + (1 + (4*r0)), None, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr0 + (2 + (4*r0)), None, eviction_policy='evict_last')
    tmp26 = tl.load(in_ptr1 + (2 + (4*r0)), None, eviction_policy='evict_last')
    tmp33 = tl.load(in_ptr0 + (3 + (4*r0)), None, eviction_policy='evict_last')
    tmp36 = tl.load(in_ptr1 + (3 + (4*r0)), None, eviction_policy='evict_last')
    tmp1 = 2.0
    tmp2 = tmp0 * tmp1
    tmp3 = 1.0
    tmp4 = tmp3 - tmp2
    tmp6 = tmp4 * tmp5
    tmp7 = 1000000000000.0
    tmp8 = tmp0 * tmp7
    tmp9 = tmp6 - tmp8
    tmp10 = 4.0
    tmp11 = tmp9 - tmp10
    tmp12 = tmp11 * tmp10
    tmp14 = tmp13 * tmp1
    tmp15 = tmp3 - tmp14
    tmp17 = tmp15 * tmp16
    tmp18 = tmp13 * tmp7
    tmp19 = tmp17 - tmp18
    tmp20 = tmp19 - tmp10
    tmp21 = tmp20 * tmp10
    tmp22 = triton_helpers.maximum(tmp12, tmp21)
    tmp24 = tmp23 * tmp1
    tmp25 = tmp3 - tmp24
    tmp27 = tmp25 * tmp26
    tmp28 = tmp23 * tmp7
    tmp29 = tmp27 - tmp28
    tmp30 = tmp29 - tmp10
    tmp31 = tmp30 * tmp10
    tmp32 = triton_helpers.maximum(tmp22, tmp31)
    tmp34 = tmp33 * tmp1
    tmp35 = tmp3 - tmp34
    tmp37 = tmp35 * tmp36
    tmp38 = tmp33 * tmp7
    tmp39 = tmp37 - tmp38
    tmp40 = tmp39 - tmp10
    tmp41 = tmp40 * tmp10
    tmp42 = triton_helpers.maximum(tmp32, tmp41)
    tmp43 = tl_math.abs(tmp42)
    tmp44 = float("inf")
    tmp45 = tmp43 == tmp44
    tmp46 = 0.0
    tmp47 = tl.where(tmp45, tmp46, tmp42)
    tmp48 = tmp12 - tmp47
    tmp49 = tl_math.exp(tmp48)
    tmp50 = tmp21 - tmp47
    tmp51 = tl_math.exp(tmp50)
    tmp52 = tmp49 + tmp51
    tmp53 = tmp31 - tmp47
    tmp54 = tl_math.exp(tmp53)
    tmp55 = tmp52 + tmp54
    tmp56 = tmp41 - tmp47
    tmp57 = tl_math.exp(tmp56)
    tmp58 = tmp55 + tmp57
    tmp59 = tmp3 - tmp0
    tmp60 = tmp59 * tmp7
    tmp61 = tmp6 - tmp60
    tmp62 = tmp61 * tmp10
    tmp63 = tmp3 - tmp13
    tmp64 = tmp63 * tmp7
    tmp65 = tmp17 - tmp64
    tmp66 = tmp65 * tmp10
    tmp67 = triton_helpers.maximum(tmp62, tmp66)
    tmp68 = tmp3 - tmp23
    tmp69 = tmp68 * tmp7
    tmp70 = tmp27 - tmp69
    tmp71 = tmp70 * tmp10
    tmp72 = triton_helpers.maximum(tmp67, tmp71)
    tmp73 = tmp3 - tmp33
    tmp74 = tmp73 * tmp7
    tmp75 = tmp37 - tmp74
    tmp76 = tmp75 * tmp10
    tmp77 = triton_helpers.maximum(tmp72, tmp76)
    tmp78 = tl_math.abs(tmp77)
    tmp79 = tmp78 == tmp44
    tmp80 = tl.where(tmp79, tmp46, tmp77)
    tmp81 = tmp62 - tmp80
    tmp82 = tl_math.exp(tmp81)
    tmp83 = tmp66 - tmp80
    tmp84 = tl_math.exp(tmp83)
    tmp85 = tmp82 + tmp84
    tmp86 = tmp71 - tmp80
    tmp87 = tl_math.exp(tmp86)
    tmp88 = tmp85 + tmp87
    tmp89 = tmp76 - tmp80
    tmp90 = tl_math.exp(tmp89)
    tmp91 = tmp88 + tmp90
    tmp92 = tl_math.log(tmp58)
    tmp93 = tmp92 + tmp47
    tmp94 = tl_math.log(tmp91)
    tmp95 = tmp94 + tmp80
    tmp96 = tmp93 + tmp95
    tmp97 = tmp96 * tmp3
    tmp98 = 20.0
    tmp99 = tmp97 > tmp98
    tmp100 = tl_math.exp(tmp97)
    tmp101 = libdevice.log1p(tmp100)
    tmp102 = tmp101 * tmp3
    tmp103 = tl.where(tmp99, tmp96, tmp102)
    tmp104 = tl.broadcast_to(tmp103, [XBLOCK, RBLOCK])
    tmp106 = tl.sum(tmp104, 1)[:, None]
    tmp107 = 64.0
    tmp108 = tmp106 / tmp107
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp108, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

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)
        buf4 = empty_strided_cuda((), (), torch.float32)
        buf5 = buf4; del buf4  # reuse
        # Topologically Sorted Source Nodes: [mul, sub, y_pred, mul_2, y_pred_neg, sub_4, logit_n, logsumexp, sub_2, mul_3, y_pred_pos, logit_p, logsumexp_1, add_3, loss, mean], Original ATen: [aten.mul, aten.rsub, aten.sub, aten.logsumexp, aten.add, aten.softplus, aten.mean]
        stream0 = get_raw_stream(0)
        triton_per_fused_add_logsumexp_mean_mul_rsub_softplus_sub_0.run(buf5, arg0_1, arg1_1, 1, 64, grid=grid(1), stream=stream0)
        del arg0_1
        del arg1_1
    return (buf5, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    arg0_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_1])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

import torch
import torch.nn as nn


class RankingLoss(nn.Module):
    """
    ref: https://arxiv.org/abs/2002.10857
    """

    def __init__(self, m: 'float', gamma: 'float') ->None:
        super(RankingLoss, self).__init__()
        self.m = m
        self.gamma = gamma
        self.soft_plus = nn.Softplus()

    def forward(self, y_pred, y_true):
        y_pred = (1 - 2 * y_true) * y_pred
        y_pred_neg = y_pred - y_true * 1000000000000.0
        y_pred_pos = y_pred - (1 - y_true) * 1000000000000.0
        torch.clamp_min(y_pred_pos.detach() + 1 + self.m, min=0.0)
        torch.clamp_min(y_pred_neg.detach() + self.m, min=0.0)
        logit_p = y_pred_pos * self.gamma
        logit_n = (y_pred_neg - self.m) * self.gamma
        loss = self.soft_plus(torch.logsumexp(logit_n, dim=-1) + torch.
            logsumexp(logit_p, dim=-1))
        return loss.mean()


def get_inputs():
    return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])]


def get_init_inputs():
    return [[], {'m': 4, 'gamma': 4}]

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


class RankingLossNew(nn.Module):
    """
    ref: https://arxiv.org/abs/2002.10857
    """

    def __init__(self, m: 'float', gamma: 'float') ->None:
        super(RankingLossNew, self).__init__()
        self.m = m
        self.gamma = gamma
        self.soft_plus = nn.Softplus()

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