# 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_8/inductor_cache/ei/ceinvgcpzgbnvzzkf7c5i3c2enhdduwygzv3zzsjlmaj4v3fbqd2.py
# Topologically Sorted Source Nodes: [ones_like, neg_targets, add, sub_1, relu, ranking_loss_matrix_1, neg_targets_01_sum, truediv, sum_3, mean, mul_2, add_1, sub_2, relu_1, ranking_loss_matrix_10, neg_targets_10_sum, truediv_1, sum_4, mean_1, mul_3, loss], Original ATen: [aten.ones_like, aten.sub, aten.add, aten.relu, aten.mul, aten.sum, aten.div, aten.mean]
# Source node to ATen node mapping:
#   add => add
#   add_1 => add_1
#   loss => add_2
#   mean => mean
#   mean_1 => mean_1
#   mul_2 => mul_2
#   mul_3 => mul_3
#   neg_targets => sub
#   neg_targets_01_sum => sum_1
#   neg_targets_10_sum => sum_2
#   ones_like => full_default
#   ranking_loss_matrix_1 => mul
#   ranking_loss_matrix_10 => mul_1
#   relu => relu
#   relu_1 => relu_1
#   sub_1 => sub_1
#   sub_2 => sub_2
#   sum_3 => sum_3
#   sum_4 => sum_4
#   truediv => div
#   truediv_1 => div_1
# Graph fragment:
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([4, 4], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %sub : [num_users=4] = call_function[target=torch.ops.aten.sub.Tensor](args = (%full_default, %arg1_1), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, 0.1), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add, %view), kwargs = {})
#   %relu : [num_users=1] = call_function[target=torch.ops.aten.relu.default](args = (%sub_1,), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub, %relu), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%sub, [1]), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%mul, %sum_1), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%div, [1]), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%sum_3,), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%mean, 0.5), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%arg0_1, 0.1), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_1, %view_1), kwargs = {})
#   %relu_1 : [num_users=1] = call_function[target=torch.ops.aten.relu.default](args = (%sub_2,), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub, %relu_1), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%sub, [0]), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%mul_1, %sum_2), kwargs = {})
#   %sum_4 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%div_1, [0]), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%sum_4,), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%mean_1, 0.5), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_2, %mul_3), kwargs = {})
triton_per_fused_add_div_mean_mul_ones_like_relu_sub_sum_0 = async_compile.triton('triton_per_fused_add_div_mean_mul_ones_like_relu_sub_sum_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, 4],
    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), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_div_mean_mul_ones_like_relu_sub_sum_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 33, 'num_reduction': 2, '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_div_mean_mul_ones_like_relu_sub_sum_0(in_out_ptr0, in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 4
    RBLOCK: tl.constexpr = 4
    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')
    tmp3 = tl.load(in_ptr1 + (4*r0), None, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + (5*r0), None, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (0))
    tmp12 = tl.broadcast_to(tmp11, [XBLOCK, RBLOCK])
    tmp14 = tl.load(in_ptr0 + (1))
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK, RBLOCK])
    tmp18 = tl.load(in_ptr0 + (2))
    tmp19 = tl.broadcast_to(tmp18, [XBLOCK, RBLOCK])
    tmp22 = tl.load(in_ptr0 + (3))
    tmp23 = tl.broadcast_to(tmp22, [XBLOCK, RBLOCK])
    tmp27 = tl.load(in_ptr0 + (1 + (4*r0)), None, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr1 + (1 + (4*r0)), None, eviction_policy='evict_last')
    tmp34 = tl.load(in_ptr0 + (4))
    tmp35 = tl.broadcast_to(tmp34, [XBLOCK, RBLOCK])
    tmp37 = tl.load(in_ptr0 + (5))
    tmp38 = tl.broadcast_to(tmp37, [XBLOCK, RBLOCK])
    tmp41 = tl.load(in_ptr0 + (6))
    tmp42 = tl.broadcast_to(tmp41, [XBLOCK, RBLOCK])
    tmp45 = tl.load(in_ptr0 + (7))
    tmp46 = tl.broadcast_to(tmp45, [XBLOCK, RBLOCK])
    tmp51 = tl.load(in_ptr0 + (2 + (4*r0)), None, eviction_policy='evict_last')
    tmp53 = tl.load(in_ptr1 + (2 + (4*r0)), None, eviction_policy='evict_last')
    tmp58 = tl.load(in_ptr0 + (8))
    tmp59 = tl.broadcast_to(tmp58, [XBLOCK, RBLOCK])
    tmp61 = tl.load(in_ptr0 + (9))
    tmp62 = tl.broadcast_to(tmp61, [XBLOCK, RBLOCK])
    tmp65 = tl.load(in_ptr0 + (10))
    tmp66 = tl.broadcast_to(tmp65, [XBLOCK, RBLOCK])
    tmp69 = tl.load(in_ptr0 + (11))
    tmp70 = tl.broadcast_to(tmp69, [XBLOCK, RBLOCK])
    tmp75 = tl.load(in_ptr0 + (3 + (4*r0)), None, eviction_policy='evict_last')
    tmp77 = tl.load(in_ptr1 + (3 + (4*r0)), None, eviction_policy='evict_last')
    tmp82 = tl.load(in_ptr0 + (12))
    tmp83 = tl.broadcast_to(tmp82, [XBLOCK, RBLOCK])
    tmp85 = tl.load(in_ptr0 + (13))
    tmp86 = tl.broadcast_to(tmp85, [XBLOCK, RBLOCK])
    tmp89 = tl.load(in_ptr0 + (14))
    tmp90 = tl.broadcast_to(tmp89, [XBLOCK, RBLOCK])
    tmp93 = tl.load(in_ptr0 + (15))
    tmp94 = tl.broadcast_to(tmp93, [XBLOCK, RBLOCK])
    tmp99 = tl.load(in_ptr0 + (r0), None)
    tmp101 = tl.load(in_ptr1 + (r0), None)
    tmp106 = tl.load(in_ptr0 + (4 + r0), None)
    tmp109 = tl.load(in_ptr0 + (8 + r0), None)
    tmp112 = tl.load(in_ptr0 + (12 + r0), None)
    tmp116 = tl.load(in_ptr1 + (4 + r0), None)
    tmp123 = tl.load(in_ptr1 + (8 + r0), None)
    tmp130 = tl.load(in_ptr1 + (12 + r0), None)
    tmp1 = 1.0
    tmp2 = tmp1 - tmp0
    tmp4 = 0.1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 - tmp6
    tmp8 = tl.full([1, 1], 0, tl.int32)
    tmp9 = triton_helpers.maximum(tmp8, tmp7)
    tmp10 = tmp2 * tmp9
    tmp13 = tmp1 - tmp12
    tmp16 = tmp1 - tmp15
    tmp17 = tmp13 + tmp16
    tmp20 = tmp1 - tmp19
    tmp21 = tmp17 + tmp20
    tmp24 = tmp1 - tmp23
    tmp25 = tmp21 + tmp24
    tmp26 = tmp10 / tmp25
    tmp28 = tmp1 - tmp27
    tmp30 = tmp29 + tmp4
    tmp31 = tmp30 - tmp6
    tmp32 = triton_helpers.maximum(tmp8, tmp31)
    tmp33 = tmp28 * tmp32
    tmp36 = tmp1 - tmp35
    tmp39 = tmp1 - tmp38
    tmp40 = tmp36 + tmp39
    tmp43 = tmp1 - tmp42
    tmp44 = tmp40 + tmp43
    tmp47 = tmp1 - tmp46
    tmp48 = tmp44 + tmp47
    tmp49 = tmp33 / tmp48
    tmp50 = tmp26 + tmp49
    tmp52 = tmp1 - tmp51
    tmp54 = tmp53 + tmp4
    tmp55 = tmp54 - tmp6
    tmp56 = triton_helpers.maximum(tmp8, tmp55)
    tmp57 = tmp52 * tmp56
    tmp60 = tmp1 - tmp59
    tmp63 = tmp1 - tmp62
    tmp64 = tmp60 + tmp63
    tmp67 = tmp1 - tmp66
    tmp68 = tmp64 + tmp67
    tmp71 = tmp1 - tmp70
    tmp72 = tmp68 + tmp71
    tmp73 = tmp57 / tmp72
    tmp74 = tmp50 + tmp73
    tmp76 = tmp1 - tmp75
    tmp78 = tmp77 + tmp4
    tmp79 = tmp78 - tmp6
    tmp80 = triton_helpers.maximum(tmp8, tmp79)
    tmp81 = tmp76 * tmp80
    tmp84 = tmp1 - tmp83
    tmp87 = tmp1 - tmp86
    tmp88 = tmp84 + tmp87
    tmp91 = tmp1 - tmp90
    tmp92 = tmp88 + tmp91
    tmp95 = tmp1 - tmp94
    tmp96 = tmp92 + tmp95
    tmp97 = tmp81 / tmp96
    tmp98 = tmp74 + tmp97
    tmp100 = tmp1 - tmp99
    tmp102 = tmp101 + tmp4
    tmp103 = tmp102 - tmp6
    tmp104 = triton_helpers.maximum(tmp8, tmp103)
    tmp105 = tmp100 * tmp104
    tmp107 = tmp1 - tmp106
    tmp108 = tmp100 + tmp107
    tmp110 = tmp1 - tmp109
    tmp111 = tmp108 + tmp110
    tmp113 = tmp1 - tmp112
    tmp114 = tmp111 + tmp113
    tmp115 = tmp105 / tmp114
    tmp117 = tmp116 + tmp4
    tmp118 = tmp117 - tmp6
    tmp119 = triton_helpers.maximum(tmp8, tmp118)
    tmp120 = tmp107 * tmp119
    tmp121 = tmp120 / tmp114
    tmp122 = tmp115 + tmp121
    tmp124 = tmp123 + tmp4
    tmp125 = tmp124 - tmp6
    tmp126 = triton_helpers.maximum(tmp8, tmp125)
    tmp127 = tmp110 * tmp126
    tmp128 = tmp127 / tmp114
    tmp129 = tmp122 + tmp128
    tmp131 = tmp130 + tmp4
    tmp132 = tmp131 - tmp6
    tmp133 = triton_helpers.maximum(tmp8, tmp132)
    tmp134 = tmp113 * tmp133
    tmp135 = tmp134 / tmp114
    tmp136 = tmp129 + tmp135
    tmp137 = tl.broadcast_to(tmp98, [XBLOCK, RBLOCK])
    tmp139 = tl.sum(tmp137, 1)[:, None]
    tmp140 = tl.broadcast_to(tmp136, [XBLOCK, RBLOCK])
    tmp142 = tl.sum(tmp140, 1)[:, None]
    tmp143 = 4.0
    tmp144 = tmp139 / tmp143
    tmp145 = 0.5
    tmp146 = tmp144 * tmp145
    tmp147 = tmp142 / tmp143
    tmp148 = tmp147 * tmp145
    tmp149 = tmp146 + tmp148
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp149, 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, 1))
    assert_size_stride(arg1_1, (4, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf1 = empty_strided_cuda((), (), torch.float32)
        buf4 = buf1; del buf1  # reuse
        # Topologically Sorted Source Nodes: [ones_like, neg_targets, add, sub_1, relu, ranking_loss_matrix_1, neg_targets_01_sum, truediv, sum_3, mean, mul_2, add_1, sub_2, relu_1, ranking_loss_matrix_10, neg_targets_10_sum, truediv_1, sum_4, mean_1, mul_3, loss], Original ATen: [aten.ones_like, aten.sub, aten.add, aten.relu, aten.mul, aten.sum, aten.div, aten.mean]
        stream0 = get_raw_stream(0)
        triton_per_fused_add_div_mean_mul_ones_like_relu_sub_sum_0.run(buf4, arg1_1, arg0_1, 1, 4, grid=grid(1), stream=stream0)
        del arg0_1
        del arg1_1
    return (buf4, )


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, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((4, 4), (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
from abc import abstractmethod
import torch.utils.data.dataloader
import torch.nn.functional as F
from torch import nn
import torch.nn


class SimilarityLoss(nn.Module):

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

    @abstractmethod
    def forward(self, inputs, targets):
        pass


class RankingLoss(SimilarityLoss):
    """
    Triplet ranking loss between pair similarities and pair labels.
    """

    def __init__(self, margin=0.1, direction_weights=[0.5, 0.5]):
        super(RankingLoss, self).__init__()
        self.margin = margin
        self.direction_weights = direction_weights

    def forward(self, inputs, targets):
        n = inputs.shape[0]
        neg_targets = torch.ones_like(targets) - targets
        ranking_loss_matrix_01 = neg_targets * F.relu(self.margin + inputs -
            torch.diag(inputs).view(n, 1))
        ranking_loss_matrix_10 = neg_targets * F.relu(self.margin + inputs -
            torch.diag(inputs).view(1, n))
        neg_targets_01_sum = torch.sum(neg_targets, dim=1)
        neg_targets_10_sum = torch.sum(neg_targets, dim=0)
        loss = self.direction_weights[0] * torch.mean(torch.sum(
            ranking_loss_matrix_01 / neg_targets_01_sum, dim=1)
            ) + self.direction_weights[1] * torch.mean(torch.sum(
            ranking_loss_matrix_10 / neg_targets_10_sum, dim=0))
        return loss


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


def get_init_inputs():
    return [[], {}]

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 abc import abstractmethod
import torch.utils.data.dataloader
from torch import nn
import torch.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_ones_like_relu_sub_sum_0(in_out_ptr0,
    in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 4
    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')
    tmp3 = tl.load(in_ptr1 + 4 * r0, None, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + 5 * r0, None, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + 0)
    tmp12 = tl.broadcast_to(tmp11, [XBLOCK, RBLOCK])
    tmp14 = tl.load(in_ptr0 + 1)
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK, RBLOCK])
    tmp18 = tl.load(in_ptr0 + 2)
    tmp19 = tl.broadcast_to(tmp18, [XBLOCK, RBLOCK])
    tmp22 = tl.load(in_ptr0 + 3)
    tmp23 = tl.broadcast_to(tmp22, [XBLOCK, RBLOCK])
    tmp27 = tl.load(in_ptr0 + (1 + 4 * r0), None, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr1 + (1 + 4 * r0), None, eviction_policy='evict_last')
    tmp34 = tl.load(in_ptr0 + 4)
    tmp35 = tl.broadcast_to(tmp34, [XBLOCK, RBLOCK])
    tmp37 = tl.load(in_ptr0 + 5)
    tmp38 = tl.broadcast_to(tmp37, [XBLOCK, RBLOCK])
    tmp41 = tl.load(in_ptr0 + 6)
    tmp42 = tl.broadcast_to(tmp41, [XBLOCK, RBLOCK])
    tmp45 = tl.load(in_ptr0 + 7)
    tmp46 = tl.broadcast_to(tmp45, [XBLOCK, RBLOCK])
    tmp51 = tl.load(in_ptr0 + (2 + 4 * r0), None, eviction_policy='evict_last')
    tmp53 = tl.load(in_ptr1 + (2 + 4 * r0), None, eviction_policy='evict_last')
    tmp58 = tl.load(in_ptr0 + 8)
    tmp59 = tl.broadcast_to(tmp58, [XBLOCK, RBLOCK])
    tmp61 = tl.load(in_ptr0 + 9)
    tmp62 = tl.broadcast_to(tmp61, [XBLOCK, RBLOCK])
    tmp65 = tl.load(in_ptr0 + 10)
    tmp66 = tl.broadcast_to(tmp65, [XBLOCK, RBLOCK])
    tmp69 = tl.load(in_ptr0 + 11)
    tmp70 = tl.broadcast_to(tmp69, [XBLOCK, RBLOCK])
    tmp75 = tl.load(in_ptr0 + (3 + 4 * r0), None, eviction_policy='evict_last')
    tmp77 = tl.load(in_ptr1 + (3 + 4 * r0), None, eviction_policy='evict_last')
    tmp82 = tl.load(in_ptr0 + 12)
    tmp83 = tl.broadcast_to(tmp82, [XBLOCK, RBLOCK])
    tmp85 = tl.load(in_ptr0 + 13)
    tmp86 = tl.broadcast_to(tmp85, [XBLOCK, RBLOCK])
    tmp89 = tl.load(in_ptr0 + 14)
    tmp90 = tl.broadcast_to(tmp89, [XBLOCK, RBLOCK])
    tmp93 = tl.load(in_ptr0 + 15)
    tmp94 = tl.broadcast_to(tmp93, [XBLOCK, RBLOCK])
    tmp99 = tl.load(in_ptr0 + r0, None)
    tmp101 = tl.load(in_ptr1 + r0, None)
    tmp106 = tl.load(in_ptr0 + (4 + r0), None)
    tmp109 = tl.load(in_ptr0 + (8 + r0), None)
    tmp112 = tl.load(in_ptr0 + (12 + r0), None)
    tmp116 = tl.load(in_ptr1 + (4 + r0), None)
    tmp123 = tl.load(in_ptr1 + (8 + r0), None)
    tmp130 = tl.load(in_ptr1 + (12 + r0), None)
    tmp1 = 1.0
    tmp2 = tmp1 - tmp0
    tmp4 = 0.1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 - tmp6
    tmp8 = tl.full([1, 1], 0, tl.int32)
    tmp9 = triton_helpers.maximum(tmp8, tmp7)
    tmp10 = tmp2 * tmp9
    tmp13 = tmp1 - tmp12
    tmp16 = tmp1 - tmp15
    tmp17 = tmp13 + tmp16
    tmp20 = tmp1 - tmp19
    tmp21 = tmp17 + tmp20
    tmp24 = tmp1 - tmp23
    tmp25 = tmp21 + tmp24
    tmp26 = tmp10 / tmp25
    tmp28 = tmp1 - tmp27
    tmp30 = tmp29 + tmp4
    tmp31 = tmp30 - tmp6
    tmp32 = triton_helpers.maximum(tmp8, tmp31)
    tmp33 = tmp28 * tmp32
    tmp36 = tmp1 - tmp35
    tmp39 = tmp1 - tmp38
    tmp40 = tmp36 + tmp39
    tmp43 = tmp1 - tmp42
    tmp44 = tmp40 + tmp43
    tmp47 = tmp1 - tmp46
    tmp48 = tmp44 + tmp47
    tmp49 = tmp33 / tmp48
    tmp50 = tmp26 + tmp49
    tmp52 = tmp1 - tmp51
    tmp54 = tmp53 + tmp4
    tmp55 = tmp54 - tmp6
    tmp56 = triton_helpers.maximum(tmp8, tmp55)
    tmp57 = tmp52 * tmp56
    tmp60 = tmp1 - tmp59
    tmp63 = tmp1 - tmp62
    tmp64 = tmp60 + tmp63
    tmp67 = tmp1 - tmp66
    tmp68 = tmp64 + tmp67
    tmp71 = tmp1 - tmp70
    tmp72 = tmp68 + tmp71
    tmp73 = tmp57 / tmp72
    tmp74 = tmp50 + tmp73
    tmp76 = tmp1 - tmp75
    tmp78 = tmp77 + tmp4
    tmp79 = tmp78 - tmp6
    tmp80 = triton_helpers.maximum(tmp8, tmp79)
    tmp81 = tmp76 * tmp80
    tmp84 = tmp1 - tmp83
    tmp87 = tmp1 - tmp86
    tmp88 = tmp84 + tmp87
    tmp91 = tmp1 - tmp90
    tmp92 = tmp88 + tmp91
    tmp95 = tmp1 - tmp94
    tmp96 = tmp92 + tmp95
    tmp97 = tmp81 / tmp96
    tmp98 = tmp74 + tmp97
    tmp100 = tmp1 - tmp99
    tmp102 = tmp101 + tmp4
    tmp103 = tmp102 - tmp6
    tmp104 = triton_helpers.maximum(tmp8, tmp103)
    tmp105 = tmp100 * tmp104
    tmp107 = tmp1 - tmp106
    tmp108 = tmp100 + tmp107
    tmp110 = tmp1 - tmp109
    tmp111 = tmp108 + tmp110
    tmp113 = tmp1 - tmp112
    tmp114 = tmp111 + tmp113
    tmp115 = tmp105 / tmp114
    tmp117 = tmp116 + tmp4
    tmp118 = tmp117 - tmp6
    tmp119 = triton_helpers.maximum(tmp8, tmp118)
    tmp120 = tmp107 * tmp119
    tmp121 = tmp120 / tmp114
    tmp122 = tmp115 + tmp121
    tmp124 = tmp123 + tmp4
    tmp125 = tmp124 - tmp6
    tmp126 = triton_helpers.maximum(tmp8, tmp125)
    tmp127 = tmp110 * tmp126
    tmp128 = tmp127 / tmp114
    tmp129 = tmp122 + tmp128
    tmp131 = tmp130 + tmp4
    tmp132 = tmp131 - tmp6
    tmp133 = triton_helpers.maximum(tmp8, tmp132)
    tmp134 = tmp113 * tmp133
    tmp135 = tmp134 / tmp114
    tmp136 = tmp129 + tmp135
    tmp137 = tl.broadcast_to(tmp98, [XBLOCK, RBLOCK])
    tmp139 = tl.sum(tmp137, 1)[:, None]
    tmp140 = tl.broadcast_to(tmp136, [XBLOCK, RBLOCK])
    tmp142 = tl.sum(tmp140, 1)[:, None]
    tmp143 = 4.0
    tmp144 = tmp139 / tmp143
    tmp145 = 0.5
    tmp146 = tmp144 * tmp145
    tmp147 = tmp142 / tmp143
    tmp148 = tmp147 * tmp145
    tmp149 = tmp146 + tmp148
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp149, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4), (4, 1))
    assert_size_stride(arg1_1, (4, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf1 = empty_strided_cuda((), (), torch.float32)
        buf4 = buf1
        del buf1
        get_raw_stream(0)
        triton_per_fused_add_div_mean_mul_ones_like_relu_sub_sum_0[grid(1)](
            buf4, arg1_1, arg0_1, 1, 4, XBLOCK=1, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
    return buf4,


class SimilarityLoss(nn.Module):

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

    @abstractmethod
    def forward(self, inputs, targets):
        pass


class RankingLossNew(SimilarityLoss):
    """
    Triplet ranking loss between pair similarities and pair labels.
    """

    def __init__(self, margin=0.1, direction_weights=[0.5, 0.5]):
        super(RankingLossNew, self).__init__()
        self.margin = margin
        self.direction_weights = direction_weights

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