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
import torch.nn as nn
import torch.utils
from typing import Tuple
from abc import ABC
from abc import abstractmethod
import torch.utils.data
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_linalg_vector_norm_mul_pow_sum_0(in_out_ptr0,
    in_ptr0, 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 % 4
    r1 = rindex // 4
    tmp0 = tl.load(in_ptr0 + (r0 + 16 * r1), None)
    tmp2 = tl.load(in_ptr0 + (4 + r0 + 16 * r1), None)
    tmp5 = tl.load(in_ptr0 + (8 + r0 + 16 * r1), None)
    tmp8 = tl.load(in_ptr0 + (12 + r0 + 16 * r1), None)
    tmp17 = tl.load(in_ptr0 + (64 + r0 + 16 * r1), None)
    tmp19 = tl.load(in_ptr0 + (68 + r0 + 16 * r1), None)
    tmp22 = tl.load(in_ptr0 + (72 + r0 + 16 * r1), None)
    tmp25 = tl.load(in_ptr0 + (76 + r0 + 16 * r1), None)
    tmp34 = tl.load(in_ptr0 + (128 + r0 + 16 * r1), None)
    tmp36 = tl.load(in_ptr0 + (132 + r0 + 16 * r1), None)
    tmp39 = tl.load(in_ptr0 + (136 + r0 + 16 * r1), None)
    tmp42 = tl.load(in_ptr0 + (140 + r0 + 16 * r1), None)
    tmp51 = tl.load(in_ptr0 + (192 + r0 + 16 * r1), None)
    tmp53 = tl.load(in_ptr0 + (196 + r0 + 16 * r1), None)
    tmp56 = tl.load(in_ptr0 + (200 + r0 + 16 * r1), None)
    tmp59 = tl.load(in_ptr0 + (204 + r0 + 16 * r1), None)
    tmp1 = tmp0 * tmp0
    tmp3 = tmp2 * tmp2
    tmp4 = tmp1 + tmp3
    tmp6 = tmp5 * tmp5
    tmp7 = tmp4 + tmp6
    tmp9 = tmp8 * tmp8
    tmp10 = tmp7 + tmp9
    tmp11 = libdevice.sqrt(tmp10)
    tmp12 = tmp11 * tmp11
    tmp13 = tmp12 * tmp11
    tmp14 = tl.broadcast_to(tmp13, [XBLOCK, RBLOCK])
    tmp16 = tl.sum(tmp14, 1)[:, None]
    tmp18 = tmp17 * tmp17
    tmp20 = tmp19 * tmp19
    tmp21 = tmp18 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = tmp21 + tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp24 + tmp26
    tmp28 = libdevice.sqrt(tmp27)
    tmp29 = tmp28 * tmp28
    tmp30 = tmp29 * tmp28
    tmp31 = tl.broadcast_to(tmp30, [XBLOCK, RBLOCK])
    tmp33 = tl.sum(tmp31, 1)[:, None]
    tmp35 = tmp34 * tmp34
    tmp37 = tmp36 * tmp36
    tmp38 = tmp35 + tmp37
    tmp40 = tmp39 * tmp39
    tmp41 = tmp38 + tmp40
    tmp43 = tmp42 * tmp42
    tmp44 = tmp41 + tmp43
    tmp45 = libdevice.sqrt(tmp44)
    tmp46 = tmp45 * tmp45
    tmp47 = tmp46 * tmp45
    tmp48 = tl.broadcast_to(tmp47, [XBLOCK, RBLOCK])
    tmp50 = tl.sum(tmp48, 1)[:, None]
    tmp52 = tmp51 * tmp51
    tmp54 = tmp53 * tmp53
    tmp55 = tmp52 + tmp54
    tmp57 = tmp56 * tmp56
    tmp58 = tmp55 + tmp57
    tmp60 = tmp59 * tmp59
    tmp61 = tmp58 + tmp60
    tmp62 = libdevice.sqrt(tmp61)
    tmp63 = tmp62 * tmp62
    tmp64 = tmp63 * tmp62
    tmp65 = tl.broadcast_to(tmp64, [XBLOCK, RBLOCK])
    tmp67 = tl.sum(tmp65, 1)[:, None]
    tmp68 = 4.0
    tmp69 = tmp16 * tmp68
    tmp70 = 0.0
    tmp71 = tmp69 + tmp70
    tmp72 = tmp33 * tmp68
    tmp73 = tmp71 + tmp72
    tmp74 = tmp50 * tmp68
    tmp75 = tmp73 + tmp74
    tmp76 = tmp67 * tmp68
    tmp77 = tmp75 + tmp76
    tmp78 = 0.25
    tmp79 = tmp77 * tmp78
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp79, 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)
        buf0 = empty_strided_cuda((), (), torch.float32)
        buf4 = buf0
        del buf0
        get_raw_stream(0)
        triton_per_fused_add_div_linalg_vector_norm_mul_pow_sum_0[grid(1)](buf4
            , arg0_1, 1, 16, XBLOCK=1, num_warps=2, num_stages=1)
        del arg0_1
    return buf4,


class Regularizer(nn.Module, ABC):

    @abstractmethod
    def forward(self, factors: 'Tuple[torch.Tensor]'):
        pass


class N2New(Regularizer):

    def __init__(self, weight: 'float'):
        super(N2New, self).__init__()
        self.weight = weight

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


Measured latency_ms: 0.014086