# 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_7/inductor_cache/ol/coleukbd4gfp6mi3s5pfvlzujqgup2l44vcgqarbw3lhhkduc6dj.py
# Topologically Sorted Source Nodes: [mul_, batch_mean, mul, add_, mul__1, pow_1, batch_sq_mean, mul_1, add__1], Original ATen: [aten.mul, aten.mean, aten.add, aten.pow]
# Source node to ATen node mapping:
#   add_ => add
#   add__1 => add_1
#   batch_mean => mean
#   batch_sq_mean => mean_1
#   mul => mul_1
#   mul_ => mul
#   mul_1 => mul_3
#   mul__1 => mul_2
#   pow_1 => pow_1
# Graph fragment:
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg1_1, 0.99999), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%arg0_1, [0]), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%mean, 9.99999999995449e-06), kwargs = {})
#   %add : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul, %mul_1), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg2_1, 0.99999), kwargs = {})
#   %pow_1 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%arg0_1, 2), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.dim](args = (%pow_1, [0]), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%mean_1, 9.99999999995449e-06), kwargs = {})
#   %add_1 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_2, %mul_3), kwargs = {})
#   %copy_ : [num_users=0] = call_function[target=torch.ops.aten.copy_.default](args = (%arg1_1, %add), kwargs = {})
#   %copy__1 : [num_users=0] = call_function[target=torch.ops.aten.copy_.default](args = (%arg2_1, %add_1), kwargs = {})
triton_poi_fused_add_mean_mul_pow_0 = async_compile.triton('triton_poi_fused_add_mean_mul_pow_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.pointwise(
    size_hints=[4], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_mean_mul_pow_0', 'mutated_arg_names': ['in_ptr0', 'in_ptr2', 'out_ptr2', 'out_ptr3'], 'no_x_dim': False, 'num_load': 6, 'num_reduction': 0, '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},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_mean_mul_pow_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, out_ptr3, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (x0), xmask)
    tmp3 = tl.load(in_ptr1 + (x0), xmask)
    tmp4 = tl.load(in_ptr1 + (4 + x0), xmask)
    tmp6 = tl.load(in_ptr1 + (8 + x0), xmask)
    tmp8 = tl.load(in_ptr1 + (12 + x0), xmask)
    tmp15 = tl.load(in_ptr2 + (x0), xmask)
    tmp1 = 0.99999
    tmp2 = tmp0 * tmp1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp9 = tmp7 + tmp8
    tmp10 = 4.0
    tmp11 = tmp9 / tmp10
    tmp12 = 9.99999999995449e-06
    tmp13 = tmp11 * tmp12
    tmp14 = tmp2 + tmp13
    tmp16 = tmp15 * tmp1
    tmp17 = tmp3 * tmp3
    tmp18 = tmp4 * tmp4
    tmp19 = tmp17 + tmp18
    tmp20 = tmp6 * tmp6
    tmp21 = tmp19 + tmp20
    tmp22 = tmp8 * tmp8
    tmp23 = tmp21 + tmp22
    tmp24 = tmp23 / tmp10
    tmp25 = tmp24 * tmp12
    tmp26 = tmp16 + tmp25
    tl.store(out_ptr0 + (x0), tmp14, xmask)
    tl.store(out_ptr1 + (x0), tmp26, xmask)
    tl.store(out_ptr2 + (x0), tmp14, xmask)
    tl.store(out_ptr3 + (x0), tmp26, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/34/c34k5n6zlh6ctbtv6yhf3gt4istbg575siewxu3qdttnxbv6azmv.py
# Topologically Sorted Source Nodes: [sub_1, out], Original ATen: [aten.sub, aten.div]
# Source node to ATen node mapping:
#   out => div_2
#   sub_1 => sub_1
# Graph fragment:
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%arg0_1, %unsqueeze), kwargs = {})
#   %div_2 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_1, %unsqueeze_1), kwargs = {})
triton_poi_fused_div_sub_1 = async_compile.triton('triton_poi_fused_div_sub_1', '''
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.pointwise(
    size_hints=[16], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_div_sub_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, '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},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_div_sub_1(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 4
    tmp0 = tl.load(in_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr2 + (0))
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK])
    tmp12 = tl.load(in_ptr3 + (x0), xmask, eviction_policy='evict_last')
    tmp4 = 0.99999
    tmp5 = tmp3 * tmp4
    tmp6 = 9.99999999995449e-06
    tmp7 = tmp5 + tmp6
    tmp8 = 1e-05
    tmp9 = triton_helpers.maximum(tmp7, tmp8)
    tmp10 = tmp1 / tmp9
    tmp11 = tmp0 - tmp10
    tmp13 = tmp12 / tmp9
    tmp14 = tmp10 * tmp10
    tmp15 = tmp13 - tmp14
    tmp16 = 0.01
    tmp17 = triton_helpers.maximum(tmp15, tmp16)
    tmp18 = libdevice.sqrt(tmp17)
    tmp19 = tmp11 / tmp18
    tl.store(out_ptr0 + (x2), tmp19, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/de/cdel5yvcigdc3wxhc2izhof3tnqyjmddrnkds6neshcrqkaoursj.py
# Topologically Sorted Source Nodes: [mul__2, add__2], Original ATen: [aten.mul, aten.add]
# Source node to ATen node mapping:
#   add__2 => add_2
#   mul__2 => mul_4
# Graph fragment:
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg3_1, 0.99999), kwargs = {})
#   %add_2 : [num_users=3] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_4, 9.99999999995449e-06), kwargs = {})
#   %copy__2 : [num_users=0] = call_function[target=torch.ops.aten.copy_.default](args = (%arg3_1, %add_2), kwargs = {})
triton_poi_fused_add_mul_2 = async_compile.triton('triton_poi_fused_add_mul_2', '''
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.pointwise(
    size_hints=[1], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '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': {2: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=(2,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_mul_2', 'mutated_arg_names': ['in_ptr0', 'out_ptr1'], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, '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},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_mul_2(in_ptr0, out_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    tmp0 = tl.load(in_ptr0 + (0))
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK])
    tmp2 = 0.99999
    tmp3 = tmp1 * tmp2
    tmp4 = 9.99999999995449e-06
    tmp5 = tmp3 + tmp4
    tl.store(out_ptr1 + (tl.full([XBLOCK], 0, tl.int32)), tmp5, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4), (4, 1))
    assert_size_stride(arg1_1, (4, ), (1, ))
    assert_size_stride(arg2_1, (4, ), (1, ))
    assert_size_stride(arg3_1, (), ())
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf1 = empty_strided_cuda((4, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [mul_, batch_mean, mul, add_, mul__1, pow_1, batch_sq_mean, mul_1, add__1], Original ATen: [aten.mul, aten.mean, aten.add, aten.pow]
        stream0 = get_raw_stream(0)
        triton_poi_fused_add_mean_mul_pow_0.run(arg1_1, arg0_1, arg2_1, buf0, buf1, arg1_1, arg2_1, 4, grid=grid(4), stream=stream0)
        del arg1_1
        del arg2_1
        buf2 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [sub_1, out], Original ATen: [aten.sub, aten.div]
        triton_poi_fused_div_sub_1.run(arg0_1, buf0, arg3_1, buf1, buf2, 16, grid=grid(16), stream=stream0)
        del arg0_1
        del buf0
        del buf1
        # Topologically Sorted Source Nodes: [mul__2, add__2], Original ATen: [aten.mul, aten.add]
        triton_poi_fused_add_mul_2.run(arg3_1, arg3_1, 1, grid=grid(1), stream=stream0)
        del arg3_1
    return (buf2, )


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, ), (1, ), device='cuda:0', dtype=torch.float32)
    arg2_1 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    arg3_1 = rand_strided((), (), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_1, arg2_1, arg3_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
import numpy as np
import torch.nn as nn


class PopArt(nn.Module):
    """Normalize a vector of observations - across the first norm_axes dimensions"""

    def __init__(self, input_shape, norm_axes=1, beta=0.99999,
        per_element_update=False, epsilon=1e-05, device=torch.device('cpu')):
        super(PopArt, self).__init__()
        self.input_shape = input_shape
        self.norm_axes = norm_axes
        self.epsilon = epsilon
        self.beta = beta
        self.per_element_update = per_element_update
        self.tpdv = dict(dtype=torch.float32, device=device)
        self.running_mean = nn.Parameter(torch.zeros(input_shape),
            requires_grad=False)
        self.running_mean_sq = nn.Parameter(torch.zeros(input_shape),
            requires_grad=False)
        self.debiasing_term = nn.Parameter(torch.tensor(0.0), requires_grad
            =False)

    def reset_parameters(self):
        self.running_mean.zero_()
        self.running_mean_sq.zero_()
        self.debiasing_term.zero_()

    def running_mean_var(self):
        debiased_mean = self.running_mean / self.debiasing_term.clamp(min=
            self.epsilon)
        debiased_mean_sq = self.running_mean_sq / self.debiasing_term.clamp(min
            =self.epsilon)
        debiased_var = (debiased_mean_sq - debiased_mean ** 2).clamp(min=0.01)
        return debiased_mean, debiased_var

    def forward(self, input_vector, train=True):
        if type(input_vector) == np.ndarray:
            input_vector = torch.from_numpy(input_vector)
        input_vector = input_vector
        if train:
            detached_input = input_vector.detach()
            batch_mean = detached_input.mean(dim=tuple(range(self.norm_axes)))
            batch_sq_mean = (detached_input ** 2).mean(dim=tuple(range(self
                .norm_axes)))
            if self.per_element_update:
                batch_size = np.prod(detached_input.size()[:self.norm_axes])
                weight = self.beta ** batch_size
            else:
                weight = self.beta
            self.running_mean.mul_(weight).add_(batch_mean * (1.0 - weight))
            self.running_mean_sq.mul_(weight).add_(batch_sq_mean * (1.0 -
                weight))
            self.debiasing_term.mul_(weight).add_(1.0 * (1.0 - weight))
        mean, var = self.running_mean_var()
        out = (input_vector - mean[(None,) * self.norm_axes]) / torch.sqrt(var
            )[(None,) * self.norm_axes]
        return out

    def denormalize(self, input_vector):
        """Transform normalized data back into original distribution"""
        if type(input_vector) == np.ndarray:
            input_vector = torch.from_numpy(input_vector)
        input_vector = input_vector
        mean, var = self.running_mean_var()
        out = input_vector * torch.sqrt(var)[(None,) * self.norm_axes] + mean[
            (None,) * self.norm_axes]
        out = out.cpu().numpy()
        return out


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


def get_init_inputs():
    return [[], {'input_shape': 4}]

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 libdevice
import numpy as np
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_poi_fused_add_mean_mul_pow_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0,
    out_ptr1, out_ptr2, out_ptr3, xnumel, XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp3 = tl.load(in_ptr1 + x0, xmask)
    tmp4 = tl.load(in_ptr1 + (4 + x0), xmask)
    tmp6 = tl.load(in_ptr1 + (8 + x0), xmask)
    tmp8 = tl.load(in_ptr1 + (12 + x0), xmask)
    tmp15 = tl.load(in_ptr2 + x0, xmask)
    tmp1 = 0.99999
    tmp2 = tmp0 * tmp1
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp9 = tmp7 + tmp8
    tmp10 = 4.0
    tmp11 = tmp9 / tmp10
    tmp12 = 9.99999999995449e-06
    tmp13 = tmp11 * tmp12
    tmp14 = tmp2 + tmp13
    tmp16 = tmp15 * tmp1
    tmp17 = tmp3 * tmp3
    tmp18 = tmp4 * tmp4
    tmp19 = tmp17 + tmp18
    tmp20 = tmp6 * tmp6
    tmp21 = tmp19 + tmp20
    tmp22 = tmp8 * tmp8
    tmp23 = tmp21 + tmp22
    tmp24 = tmp23 / tmp10
    tmp25 = tmp24 * tmp12
    tmp26 = tmp16 + tmp25
    tl.store(out_ptr0 + x0, tmp14, xmask)
    tl.store(out_ptr1 + x0, tmp26, xmask)
    tl.store(out_ptr2 + x0, tmp14, xmask)
    tl.store(out_ptr3 + x0, tmp26, xmask)


@triton.jit
def triton_poi_fused_div_sub_1(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr2 + 0)
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK])
    tmp12 = tl.load(in_ptr3 + x0, xmask, eviction_policy='evict_last')
    tmp4 = 0.99999
    tmp5 = tmp3 * tmp4
    tmp6 = 9.99999999995449e-06
    tmp7 = tmp5 + tmp6
    tmp8 = 1e-05
    tmp9 = triton_helpers.maximum(tmp7, tmp8)
    tmp10 = tmp1 / tmp9
    tmp11 = tmp0 - tmp10
    tmp13 = tmp12 / tmp9
    tmp14 = tmp10 * tmp10
    tmp15 = tmp13 - tmp14
    tmp16 = 0.01
    tmp17 = triton_helpers.maximum(tmp15, tmp16)
    tmp18 = libdevice.sqrt(tmp17)
    tmp19 = tmp11 / tmp18
    tl.store(out_ptr0 + x2, tmp19, xmask)


@triton.jit
def triton_poi_fused_add_mul_2(in_ptr0, out_ptr1, xnumel, XBLOCK: tl.constexpr
    ):
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    tmp0 = tl.load(in_ptr0 + 0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK])
    tmp2 = 0.99999
    tmp3 = tmp1 * tmp2
    tmp4 = 9.99999999995449e-06
    tmp5 = tmp3 + tmp4
    tl.store(out_ptr1 + tl.full([XBLOCK], 0, tl.int32), tmp5, None)


def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4), (4, 1))
    assert_size_stride(arg1_1, (4,), (1,))
    assert_size_stride(arg2_1, (4,), (1,))
    assert_size_stride(arg3_1, (), ())
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4,), (1,), torch.float32)
        buf1 = empty_strided_cuda((4,), (1,), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_add_mean_mul_pow_0[grid(4)](arg1_1, arg0_1, arg2_1,
            buf0, buf1, arg1_1, arg2_1, 4, XBLOCK=4, num_warps=1, num_stages=1)
        del arg1_1
        del arg2_1
        buf2 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_div_sub_1[grid(16)](arg0_1, buf0, arg3_1, buf1,
            buf2, 16, XBLOCK=16, num_warps=1, num_stages=1)
        del arg0_1
        del buf0
        del buf1
        triton_poi_fused_add_mul_2[grid(1)](arg3_1, arg3_1, 1, XBLOCK=1,
            num_warps=1, num_stages=1)
        del arg3_1
    return buf2,


class PopArtNew(nn.Module):
    """Normalize a vector of observations - across the first norm_axes dimensions"""

    def __init__(self, input_shape, norm_axes=1, beta=0.99999,
        per_element_update=False, epsilon=1e-05, device=torch.device('cpu')):
        super(PopArtNew, self).__init__()
        self.input_shape = input_shape
        self.norm_axes = norm_axes
        self.epsilon = epsilon
        self.beta = beta
        self.per_element_update = per_element_update
        self.tpdv = dict(dtype=torch.float32, device=device)
        self.running_mean = nn.Parameter(torch.zeros(input_shape),
            requires_grad=False)
        self.running_mean_sq = nn.Parameter(torch.zeros(input_shape),
            requires_grad=False)
        self.debiasing_term = nn.Parameter(torch.tensor(0.0), requires_grad
            =False)

    def reset_parameters(self):
        self.running_mean.zero_()
        self.running_mean_sq.zero_()
        self.debiasing_term.zero_()

    def running_mean_var(self):
        debiased_mean = self.running_mean / self.debiasing_term.clamp(min=
            self.epsilon)
        debiased_mean_sq = self.running_mean_sq / self.debiasing_term.clamp(min
            =self.epsilon)
        debiased_var = (debiased_mean_sq - debiased_mean ** 2).clamp(min=0.01)
        return debiased_mean, debiased_var

    def denormalize(self, input_vector):
        """Transform normalized data back into original distribution"""
        if type(input_vector) == np.ndarray:
            input_vector = torch.from_numpy(input_vector)
        input_vector = input_vector
        mean, var = self.running_mean_var()
        out = input_vector * torch.sqrt(var)[(None,) * self.norm_axes] + mean[
            (None,) * self.norm_axes]
        out = out.cpu().numpy()
        return out

    def forward(self, input_0):
        arg1_1 = self.running_mean
        arg2_1 = self.running_mean_sq
        arg3_1 = self.debiasing_term
        arg0_1 = input_0
        output = call([arg0_1, arg1_1, arg2_1, arg3_1])
        return output[0]
