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.triton_helpers import libdevice
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_mean_pow_sqrt_sub_0(in_out_ptr0, in_ptr0, 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 % 4
    r1 = rindex // 4 % 4
    r2 = rindex // 16
    tmp0 = tl.load(in_ptr0 + (4 * (3 * (3 <= r1) + r1 * (r1 < 3)) + 64 * r2 +
        (3 * (3 <= 1 + r0) + (1 + r0) * (1 + r0 < 3))), None)
    tmp1 = tl.load(in_ptr0 + (4 * (3 * (3 <= r1) + r1 * (r1 < 3)) + 64 * r2 +
        (3 * (3 <= r0) + r0 * (r0 < 3))), None)
    tmp4 = tl.load(in_ptr0 + (4 * (3 * (3 <= 1 + r1) + (1 + r1) * (1 + r1 <
        3)) + 64 * r2 + (3 * (3 <= r0) + r0 * (r0 < 3))), None)
    tmp10 = tl.load(in_ptr0 + (16 + 4 * (3 * (3 <= r1) + r1 * (r1 < 3)) + 
        64 * r2 + (3 * (3 <= 1 + r0) + (1 + r0) * (1 + r0 < 3))), None)
    tmp11 = tl.load(in_ptr0 + (16 + 4 * (3 * (3 <= r1) + r1 * (r1 < 3)) + 
        64 * r2 + (3 * (3 <= r0) + r0 * (r0 < 3))), None)
    tmp14 = tl.load(in_ptr0 + (16 + 4 * (3 * (3 <= 1 + r1) + (1 + r1) * (1 +
        r1 < 3)) + 64 * r2 + (3 * (3 <= r0) + r0 * (r0 < 3))), None)
    tmp20 = tl.load(in_ptr0 + (32 + 4 * (3 * (3 <= r1) + r1 * (r1 < 3)) + 
        64 * r2 + (3 * (3 <= 1 + r0) + (1 + r0) * (1 + r0 < 3))), None)
    tmp21 = tl.load(in_ptr0 + (32 + 4 * (3 * (3 <= r1) + r1 * (r1 < 3)) + 
        64 * r2 + (3 * (3 <= r0) + r0 * (r0 < 3))), None)
    tmp24 = tl.load(in_ptr0 + (32 + 4 * (3 * (3 <= 1 + r1) + (1 + r1) * (1 +
        r1 < 3)) + 64 * r2 + (3 * (3 <= r0) + r0 * (r0 < 3))), None)
    tmp30 = tl.load(in_ptr0 + (48 + 4 * (3 * (3 <= r1) + r1 * (r1 < 3)) + 
        64 * r2 + (3 * (3 <= 1 + r0) + (1 + r0) * (1 + r0 < 3))), None)
    tmp31 = tl.load(in_ptr0 + (48 + 4 * (3 * (3 <= r1) + r1 * (r1 < 3)) + 
        64 * r2 + (3 * (3 <= r0) + r0 * (r0 < 3))), None)
    tmp34 = tl.load(in_ptr0 + (48 + 4 * (3 * (3 <= 1 + r1) + (1 + r1) * (1 +
        r1 < 3)) + 64 * r2 + (3 * (3 <= r0) + r0 * (r0 < 3))), None)
    tmp2 = tmp0 - tmp1
    tmp3 = tmp2 * tmp2
    tmp5 = tmp4 - tmp1
    tmp6 = tmp5 * tmp5
    tmp7 = tmp3 + tmp6
    tmp8 = 1e-08
    tmp9 = tmp7 + tmp8
    tmp12 = tmp10 - tmp11
    tmp13 = tmp12 * tmp12
    tmp15 = tmp14 - tmp11
    tmp16 = tmp15 * tmp15
    tmp17 = tmp13 + tmp16
    tmp18 = tmp17 + tmp8
    tmp19 = tmp9 + tmp18
    tmp22 = tmp20 - tmp21
    tmp23 = tmp22 * tmp22
    tmp25 = tmp24 - tmp21
    tmp26 = tmp25 * tmp25
    tmp27 = tmp23 + tmp26
    tmp28 = tmp27 + tmp8
    tmp29 = tmp19 + tmp28
    tmp32 = tmp30 - tmp31
    tmp33 = tmp32 * tmp32
    tmp35 = tmp34 - tmp31
    tmp36 = tmp35 * tmp35
    tmp37 = tmp33 + tmp36
    tmp38 = tmp37 + tmp8
    tmp39 = tmp29 + tmp38
    tmp40 = 4.0
    tmp41 = tmp39 / tmp40
    tmp42 = libdevice.sqrt(tmp41)
    tmp43 = tl.broadcast_to(tmp42, [XBLOCK, RBLOCK])
    tmp45 = tl.sum(tmp43, 1)[:, None]
    tmp46 = 64.0
    tmp47 = tmp45 / tmp46
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp47, None)


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


class TVLossNew(nn.Module):

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


Measured latency_ms: 0.014389