# 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_4/inductor_cache/fy/cfyns74s37xab276pc6dbqyls6hbctvmvaztno7qbvcax2iqsmkp.py
# Topologically Sorted Source Nodes: [tp, tp_1, tp_2, tp_3, mul_3, mul_4, sub, fn, fn_1, fn_2, mul_5, add, sub_1, fp, fp_1, fp_2, add_1, add_2, truediv, result, result_1], Original ATen: [aten.mul, aten.sum, aten.add, aten.rsub, aten.div, aten.mean]
# Source node to ATen node mapping:
#   add => add_1
#   add_1 => add_2
#   add_2 => add_3
#   fn => mul_1
#   fn_1 => sum_2
#   fn_2 => sum_5
#   fp => mul_2
#   fp_1 => sum_3
#   fp_2 => sum_6
#   mul_3 => mul_3
#   mul_4 => mul_4
#   mul_5 => mul_5
#   result => sub_2
#   result_1 => mean
#   sub => sub
#   sub_1 => sub_1
#   tp => mul
#   tp_1 => sum_1
#   tp_2 => sum_4
#   tp_3 => add
#   truediv => div
# Graph fragment:
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg1_1, %arg0_1), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul, [-1]), kwargs = {})
#   %sum_4 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%sum_1, [-1]), kwargs = {})
#   %add : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%sum_4, 0), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add, 2.0), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%add, 2.0), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %arg1_1), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub, %arg0_1), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul_1, [-1]), kwargs = {})
#   %sum_5 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%sum_2, [-1]), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sum_5, 1.0), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_4, %mul_5), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %arg0_1), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg1_1, %sub_1), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul_2, [-1]), kwargs = {})
#   %sum_6 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%sum_3, [-1]), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_1, %sum_6), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_2, 1e-06), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%mul_3, %add_3), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %div), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%sub_2,), kwargs = {})
triton_per_fused_add_div_mean_mul_rsub_sum_0 = async_compile.triton('triton_per_fused_add_div_mean_mul_rsub_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, 16],
    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_div_mean_mul_rsub_sum_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 32, '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_div_mean_mul_rsub_sum_0(in_out_ptr0, in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 16
    RBLOCK: tl.constexpr = 16
    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 + (16*r0), None, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (16*r0), None, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (1 + (16*r0)), None, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + (1 + (16*r0)), None, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (2 + (16*r0)), None, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr1 + (2 + (16*r0)), None, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (3 + (16*r0)), None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr1 + (3 + (16*r0)), None, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr0 + (4 + (16*r0)), None, eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr1 + (4 + (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 + (6 + (16*r0)), None, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr1 + (6 + (16*r0)), None, eviction_policy='evict_last')
    tmp26 = tl.load(in_ptr0 + (7 + (16*r0)), None, eviction_policy='evict_last')
    tmp27 = tl.load(in_ptr1 + (7 + (16*r0)), None, eviction_policy='evict_last')
    tmp31 = tl.load(in_ptr0 + (8 + (16*r0)), None, eviction_policy='evict_last')
    tmp32 = tl.load(in_ptr1 + (8 + (16*r0)), None, eviction_policy='evict_last')
    tmp34 = tl.load(in_ptr0 + (9 + (16*r0)), None, eviction_policy='evict_last')
    tmp35 = tl.load(in_ptr1 + (9 + (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 + (11 + (16*r0)), None, eviction_policy='evict_last')
    tmp43 = tl.load(in_ptr1 + (11 + (16*r0)), None, eviction_policy='evict_last')
    tmp47 = tl.load(in_ptr0 + (12 + (16*r0)), None, eviction_policy='evict_last')
    tmp48 = tl.load(in_ptr1 + (12 + (16*r0)), None, eviction_policy='evict_last')
    tmp50 = tl.load(in_ptr0 + (13 + (16*r0)), None, eviction_policy='evict_last')
    tmp51 = tl.load(in_ptr1 + (13 + (16*r0)), None, eviction_policy='evict_last')
    tmp54 = tl.load(in_ptr0 + (14 + (16*r0)), None, eviction_policy='evict_last')
    tmp55 = tl.load(in_ptr1 + (14 + (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 = 1.0
    tmp64 = tmp63 - tmp0
    tmp65 = tmp64 * tmp1
    tmp66 = tmp63 - tmp3
    tmp67 = tmp66 * tmp4
    tmp68 = tmp65 + tmp67
    tmp69 = tmp63 - tmp7
    tmp70 = tmp69 * tmp8
    tmp71 = tmp68 + tmp70
    tmp72 = tmp63 - tmp11
    tmp73 = tmp72 * tmp12
    tmp74 = tmp71 + tmp73
    tmp75 = tmp63 - tmp15
    tmp76 = tmp75 * tmp16
    tmp77 = tmp63 - tmp18
    tmp78 = tmp77 * tmp19
    tmp79 = tmp76 + tmp78
    tmp80 = tmp63 - tmp22
    tmp81 = tmp80 * tmp23
    tmp82 = tmp79 + tmp81
    tmp83 = tmp63 - tmp26
    tmp84 = tmp83 * tmp27
    tmp85 = tmp82 + tmp84
    tmp86 = tmp74 + tmp85
    tmp87 = tmp63 - tmp31
    tmp88 = tmp87 * tmp32
    tmp89 = tmp63 - tmp34
    tmp90 = tmp89 * tmp35
    tmp91 = tmp88 + tmp90
    tmp92 = tmp63 - tmp38
    tmp93 = tmp92 * tmp39
    tmp94 = tmp91 + tmp93
    tmp95 = tmp63 - tmp42
    tmp96 = tmp95 * tmp43
    tmp97 = tmp94 + tmp96
    tmp98 = tmp86 + tmp97
    tmp99 = tmp63 - tmp47
    tmp100 = tmp99 * tmp48
    tmp101 = tmp63 - tmp50
    tmp102 = tmp101 * tmp51
    tmp103 = tmp100 + tmp102
    tmp104 = tmp63 - tmp54
    tmp105 = tmp104 * tmp55
    tmp106 = tmp103 + tmp105
    tmp107 = tmp63 - tmp58
    tmp108 = tmp107 * tmp59
    tmp109 = tmp106 + tmp108
    tmp110 = tmp98 + tmp109
    tmp111 = tmp63 - tmp1
    tmp112 = tmp0 * tmp111
    tmp113 = tmp63 - tmp4
    tmp114 = tmp3 * tmp113
    tmp115 = tmp112 + tmp114
    tmp116 = tmp63 - tmp8
    tmp117 = tmp7 * tmp116
    tmp118 = tmp115 + tmp117
    tmp119 = tmp63 - tmp12
    tmp120 = tmp11 * tmp119
    tmp121 = tmp118 + tmp120
    tmp122 = tmp63 - tmp16
    tmp123 = tmp15 * tmp122
    tmp124 = tmp63 - tmp19
    tmp125 = tmp18 * tmp124
    tmp126 = tmp123 + tmp125
    tmp127 = tmp63 - tmp23
    tmp128 = tmp22 * tmp127
    tmp129 = tmp126 + tmp128
    tmp130 = tmp63 - tmp27
    tmp131 = tmp26 * tmp130
    tmp132 = tmp129 + tmp131
    tmp133 = tmp121 + tmp132
    tmp134 = tmp63 - tmp32
    tmp135 = tmp31 * tmp134
    tmp136 = tmp63 - tmp35
    tmp137 = tmp34 * tmp136
    tmp138 = tmp135 + tmp137
    tmp139 = tmp63 - tmp39
    tmp140 = tmp38 * tmp139
    tmp141 = tmp138 + tmp140
    tmp142 = tmp63 - tmp43
    tmp143 = tmp42 * tmp142
    tmp144 = tmp141 + tmp143
    tmp145 = tmp133 + tmp144
    tmp146 = tmp63 - tmp48
    tmp147 = tmp47 * tmp146
    tmp148 = tmp63 - tmp51
    tmp149 = tmp50 * tmp148
    tmp150 = tmp147 + tmp149
    tmp151 = tmp63 - tmp55
    tmp152 = tmp54 * tmp151
    tmp153 = tmp150 + tmp152
    tmp154 = tmp63 - tmp59
    tmp155 = tmp58 * tmp154
    tmp156 = tmp153 + tmp155
    tmp157 = tmp145 + tmp156
    tmp158 = 0.0
    tmp159 = tmp62 + tmp158
    tmp160 = 2.0
    tmp161 = tmp159 * tmp160
    tmp162 = tmp110 * tmp63
    tmp163 = tmp161 + tmp162
    tmp164 = tmp163 + tmp157
    tmp165 = 1e-06
    tmp166 = tmp164 + tmp165
    tmp167 = tmp161 / tmp166
    tmp168 = tmp63 - tmp167
    tmp169 = tl.broadcast_to(tmp168, [XBLOCK, RBLOCK])
    tmp171 = tl.sum(tmp169, 1)[:, None]
    tmp172 = 16.0
    tmp173 = tmp171 / tmp172
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp173, 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)
        buf3 = empty_strided_cuda((), (), torch.float32)
        buf4 = buf3; del buf3  # reuse
        # Topologically Sorted Source Nodes: [tp, tp_1, tp_2, tp_3, mul_3, mul_4, sub, fn, fn_1, fn_2, mul_5, add, sub_1, fp, fp_1, fp_2, add_1, add_2, truediv, result, result_1], Original ATen: [aten.mul, aten.sum, aten.add, aten.rsub, aten.div, aten.mean]
        stream0 = get_raw_stream(0)
        triton_per_fused_add_div_mean_mul_rsub_sum_0.run(buf4, arg1_1, arg0_1, 1, 16, 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, 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
from typing import Union
from typing import Optional
from typing import Iterable
from torch import nn


class FScoreLoss(nn.modules.loss._WeightedLoss):
    """Uses the 1 - F-score as a loss.

    .. math::
        F = rac{ (1 + eta^2) TP }{ (1 + eta^2) TP + eta^2 FN + FP }

    Args:
        beta: The beta in the above formula.
        eps: Epsilon for numerical stability.
        tp_bias: This is added to the TP count. Should add a little stability for
            very small structures.
        make_onehot: Convert the target segmentation to onehot internally. Turn this
            off if the target is already onehot.
        make_onehot_newaxis: 'newaxis' argument for the onehot conversion.
        ignore_index: These classes will not contribute to the loss. Has no effect if
            reduction is "none".
        weight: Weights for the different classes. Has no effect if reduction is "none".
        reduction: "mean", "sum", or "none".

    """

    def __init__(self, beta: 'float'=1.0, eps: 'float'=1e-06, tp_bias:
        'Union[int, float]'=0, make_onehot: 'bool'=False,
        make_onehot_newaxis: 'bool'=False, ignore_index:
        'Optional[Union[int, Iterable[int]]]'=None, weight:
        'Optional[torch.Tensor]'=None, reduction='mean', **kwargs):
        super(FScoreLoss, self).__init__(weight=weight, reduction=reduction)
        self.beta = beta
        self.eps = eps
        self.tp_bias = tp_bias
        self.make_onehot = make_onehot
        self.make_onehot_newaxis = make_onehot_newaxis
        self.ignore_index = ignore_index
        if isinstance(ignore_index, int):
            self.ignore_index = [ignore_index]

    def forward(self, input_: 'torch.Tensor', target: 'torch.Tensor'
        ) ->torch.Tensor:
        """Forward pass through the loss.

        Args:
            input_: Input with expected shape (B, C, ...) with C the number of classes.
            target: Target, either onehot with shape (B, C, ...), or not with shape
                either (B, ...) or (B, 1, ...). Make sure to set the make_onehot and
                make_onehot_newaxis arguments appropriately.

        Returns:
            The loss.

        """
        assert not target.requires_grad
        if self.make_onehot:
            target = make_onehot_segmentation(target, range(input_.shape[1]
                ), newaxis=self.make_onehot_newaxis)
        target = target.float()
        tp = input_ * target
        fn = (1 - input_) * target
        fp = input_ * (1 - target)
        while tp.dim() > 2:
            tp = tp.sum(-1, keepdim=False)
            fn = fn.sum(-1, keepdim=False)
            fp = fp.sum(-1, keepdim=False)
        tp += self.tp_bias
        result = 1 - (1 + self.beta * self.beta) * tp / ((1 + self.beta *
            self.beta) * tp + self.beta * self.beta * fn + fp + self.eps)
        if self.reduction != 'none':
            if self.weight is not None:
                self.weight = self.weight.float()
                self.weight = self.weight
                weight = self.weight.expand_as(result)
                result = result * weight
            if self.ignore_index is not None:
                for cls in sorted(self.ignore_index, reverse=True):
                    if cls == result.shape[1] - 1:
                        result = result[:, :-1]
                    elif cls == 0:
                        result = result[:, 1:]
                    else:
                        result = torch.cat([result[:, :cls], result[:, cls +
                            1:]], 1)
            if self.reduction == 'mean':
                result = torch.mean(result)
            elif self.reduction == 'sum':
                result = torch.sum(result)
            else:
                raise ValueError(
                    "reduction must be 'none', 'mean' or 'sum', but is {}".
                    format(self.reduction))
        return result


def get_inputs():
    return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 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 typing import Union
from typing import Optional
from typing import Iterable
from torch import 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 + (1 + 16 * r0), None, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + (1 + 16 * r0), None, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (2 + 16 * r0), None, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr1 + (2 + 16 * r0), None, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (3 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr1 + (3 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp15 = tl.load(in_ptr0 + (4 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp16 = tl.load(in_ptr1 + (4 + 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 + (6 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp23 = tl.load(in_ptr1 + (6 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp26 = tl.load(in_ptr0 + (7 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp27 = tl.load(in_ptr1 + (7 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp31 = tl.load(in_ptr0 + (8 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp32 = tl.load(in_ptr1 + (8 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp34 = tl.load(in_ptr0 + (9 + 16 * r0), None, eviction_policy='evict_last'
        )
    tmp35 = tl.load(in_ptr1 + (9 + 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 + (11 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp43 = tl.load(in_ptr1 + (11 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp47 = tl.load(in_ptr0 + (12 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp48 = tl.load(in_ptr1 + (12 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp50 = tl.load(in_ptr0 + (13 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp51 = tl.load(in_ptr1 + (13 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp54 = tl.load(in_ptr0 + (14 + 16 * r0), None, eviction_policy=
        'evict_last')
    tmp55 = tl.load(in_ptr1 + (14 + 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 = 1.0
    tmp64 = tmp63 - tmp0
    tmp65 = tmp64 * tmp1
    tmp66 = tmp63 - tmp3
    tmp67 = tmp66 * tmp4
    tmp68 = tmp65 + tmp67
    tmp69 = tmp63 - tmp7
    tmp70 = tmp69 * tmp8
    tmp71 = tmp68 + tmp70
    tmp72 = tmp63 - tmp11
    tmp73 = tmp72 * tmp12
    tmp74 = tmp71 + tmp73
    tmp75 = tmp63 - tmp15
    tmp76 = tmp75 * tmp16
    tmp77 = tmp63 - tmp18
    tmp78 = tmp77 * tmp19
    tmp79 = tmp76 + tmp78
    tmp80 = tmp63 - tmp22
    tmp81 = tmp80 * tmp23
    tmp82 = tmp79 + tmp81
    tmp83 = tmp63 - tmp26
    tmp84 = tmp83 * tmp27
    tmp85 = tmp82 + tmp84
    tmp86 = tmp74 + tmp85
    tmp87 = tmp63 - tmp31
    tmp88 = tmp87 * tmp32
    tmp89 = tmp63 - tmp34
    tmp90 = tmp89 * tmp35
    tmp91 = tmp88 + tmp90
    tmp92 = tmp63 - tmp38
    tmp93 = tmp92 * tmp39
    tmp94 = tmp91 + tmp93
    tmp95 = tmp63 - tmp42
    tmp96 = tmp95 * tmp43
    tmp97 = tmp94 + tmp96
    tmp98 = tmp86 + tmp97
    tmp99 = tmp63 - tmp47
    tmp100 = tmp99 * tmp48
    tmp101 = tmp63 - tmp50
    tmp102 = tmp101 * tmp51
    tmp103 = tmp100 + tmp102
    tmp104 = tmp63 - tmp54
    tmp105 = tmp104 * tmp55
    tmp106 = tmp103 + tmp105
    tmp107 = tmp63 - tmp58
    tmp108 = tmp107 * tmp59
    tmp109 = tmp106 + tmp108
    tmp110 = tmp98 + tmp109
    tmp111 = tmp63 - tmp1
    tmp112 = tmp0 * tmp111
    tmp113 = tmp63 - tmp4
    tmp114 = tmp3 * tmp113
    tmp115 = tmp112 + tmp114
    tmp116 = tmp63 - tmp8
    tmp117 = tmp7 * tmp116
    tmp118 = tmp115 + tmp117
    tmp119 = tmp63 - tmp12
    tmp120 = tmp11 * tmp119
    tmp121 = tmp118 + tmp120
    tmp122 = tmp63 - tmp16
    tmp123 = tmp15 * tmp122
    tmp124 = tmp63 - tmp19
    tmp125 = tmp18 * tmp124
    tmp126 = tmp123 + tmp125
    tmp127 = tmp63 - tmp23
    tmp128 = tmp22 * tmp127
    tmp129 = tmp126 + tmp128
    tmp130 = tmp63 - tmp27
    tmp131 = tmp26 * tmp130
    tmp132 = tmp129 + tmp131
    tmp133 = tmp121 + tmp132
    tmp134 = tmp63 - tmp32
    tmp135 = tmp31 * tmp134
    tmp136 = tmp63 - tmp35
    tmp137 = tmp34 * tmp136
    tmp138 = tmp135 + tmp137
    tmp139 = tmp63 - tmp39
    tmp140 = tmp38 * tmp139
    tmp141 = tmp138 + tmp140
    tmp142 = tmp63 - tmp43
    tmp143 = tmp42 * tmp142
    tmp144 = tmp141 + tmp143
    tmp145 = tmp133 + tmp144
    tmp146 = tmp63 - tmp48
    tmp147 = tmp47 * tmp146
    tmp148 = tmp63 - tmp51
    tmp149 = tmp50 * tmp148
    tmp150 = tmp147 + tmp149
    tmp151 = tmp63 - tmp55
    tmp152 = tmp54 * tmp151
    tmp153 = tmp150 + tmp152
    tmp154 = tmp63 - tmp59
    tmp155 = tmp58 * tmp154
    tmp156 = tmp153 + tmp155
    tmp157 = tmp145 + tmp156
    tmp158 = 0.0
    tmp159 = tmp62 + tmp158
    tmp160 = 2.0
    tmp161 = tmp159 * tmp160
    tmp162 = tmp110 * tmp63
    tmp163 = tmp161 + tmp162
    tmp164 = tmp163 + tmp157
    tmp165 = 1e-06
    tmp166 = tmp164 + tmp165
    tmp167 = tmp161 / tmp166
    tmp168 = tmp63 - tmp167
    tmp169 = tl.broadcast_to(tmp168, [XBLOCK, RBLOCK])
    tmp171 = tl.sum(tmp169, 1)[:, None]
    tmp172 = 16.0
    tmp173 = tmp171 / tmp172
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp173, 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, arg1_1,
            arg0_1, 1, 16, XBLOCK=1, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
    return buf4,


class FScoreLossNew(nn.modules.loss._WeightedLoss):
    """Uses the 1 - F-score as a loss.

    .. math::
        F = rac{ (1 + eta^2) TP }{ (1 + eta^2) TP + eta^2 FN + FP }

    Args:
        beta: The beta in the above formula.
        eps: Epsilon for numerical stability.
        tp_bias: This is added to the TP count. Should add a little stability for
            very small structures.
        make_onehot: Convert the target segmentation to onehot internally. Turn this
            off if the target is already onehot.
        make_onehot_newaxis: 'newaxis' argument for the onehot conversion.
        ignore_index: These classes will not contribute to the loss. Has no effect if
            reduction is "none".
        weight: Weights for the different classes. Has no effect if reduction is "none".
        reduction: "mean", "sum", or "none".

    """

    def __init__(self, beta: 'float'=1.0, eps: 'float'=1e-06, tp_bias:
        'Union[int, float]'=0, make_onehot: 'bool'=False,
        make_onehot_newaxis: 'bool'=False, ignore_index:
        'Optional[Union[int, Iterable[int]]]'=None, weight:
        'Optional[torch.Tensor]'=None, reduction='mean', **kwargs):
        super(FScoreLossNew, self).__init__(weight=weight, reduction=reduction)
        self.beta = beta
        self.eps = eps
        self.tp_bias = tp_bias
        self.make_onehot = make_onehot
        self.make_onehot_newaxis = make_onehot_newaxis
        self.ignore_index = ignore_index
        if isinstance(ignore_index, int):
            self.ignore_index = [ignore_index]

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