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 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_abs_index_put_lift_fresh_mean_mul_sub_zeros_like_0(
    in_out_ptr1, in_ptr0, in_ptr1, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp33 = tl.load(in_ptr1 + r0, None)
    tmp1 = 5.0
    tmp2 = tmp0 < tmp1
    tmp3 = 0.5
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp0 >= tmp1
    tmp7 = 15.0
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = 1.2000000476837158
    tmp11 = tl.where(tmp9, tmp10, tmp5)
    tmp12 = tmp0 >= tmp7
    tmp13 = 30.0
    tmp14 = tmp0 < tmp13
    tmp15 = tmp12 & tmp14
    tmp16 = 1.399999976158142
    tmp17 = tl.where(tmp15, tmp16, tmp11)
    tmp18 = tmp0 >= tmp13
    tmp19 = 40.0
    tmp20 = tmp0 < tmp19
    tmp21 = tmp18 & tmp20
    tmp22 = 1.600000023841858
    tmp23 = tl.where(tmp21, tmp22, tmp17)
    tmp24 = tmp0 >= tmp19
    tmp25 = 45.0
    tmp26 = tmp0 < tmp25
    tmp27 = tmp24 & tmp26
    tmp28 = 1.7999999523162842
    tmp29 = tl.where(tmp27, tmp28, tmp23)
    tmp30 = tmp0 >= tmp25
    tmp31 = 2.0
    tmp32 = tl.where(tmp30, tmp31, tmp29)
    tmp34 = tmp33 - tmp0
    tmp35 = tl_math.abs(tmp34)
    tmp36 = tmp32 * tmp35
    tmp37 = tl.broadcast_to(tmp36, [RBLOCK])
    tmp39 = triton_helpers.promote_to_tensor(tl.sum(tmp37, 0))
    tmp40 = 256.0
    tmp41 = tmp39 / tmp40
    tl.debug_barrier()
    tl.store(in_out_ptr1 + tl.full([1], 0, tl.int32), tmp41, 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)
        buf6 = empty_strided_cuda((), (), torch.float32)
        buf7 = buf6
        del buf6
        get_raw_stream(0)
        triton_per_fused_abs_index_put_lift_fresh_mean_mul_sub_zeros_like_0[
            grid(1)](buf7, arg0_1, arg1_1, 1, 256, num_warps=2, num_stages=1)
        del arg0_1
        del arg1_1
    return buf7,


class weighted_mae_windowsNew(nn.Module):

    def __init__(self, weights=(0.5, 1.2, 1.4, 1.6, 1.8, 2.0), thresholds=(
        5.0, 15.0, 30.0, 40.0, 45.0)):
        super(weighted_mae_windowsNew, self).__init__()
        assert len(thresholds) + 1 == len(weights)
        self.weights = weights
        self.threholds = thresholds

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