# AOT ID: ['0_forward']
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_8/inductor_cache/a2/ca2wr2cvkya5clovpxidv7ia56pdcyp7uq4omtpg5m2nr7ya3ryn.py
# Topologically Sorted Source Nodes: [act_1], Original ATen: [aten.tanh]
# Source node to ATen node mapping:
#   act_1 => tanh
# Graph fragment:
#   %tanh : [num_users=2] = call_function[target=torch.ops.aten.tanh.default](args = (%view_1,), kwargs = {})
triton_poi_fused_tanh_0 = async_compile.triton('triton_poi_fused_tanh_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=[4096], 
    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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_tanh_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, '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_tanh_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 64
    tmp0 = tl.load(in_out_ptr0 + (x2), None)
    tmp1 = tl.load(in_ptr0 + (x0), None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + (x2), tmp3, None)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/rm/crml6cl7ra2xdnppzfbgrwvxe5s26loldvzf6sy46tpauphxhkm4.py
# Topologically Sorted Source Nodes: [act_3], Original ATen: [aten.tanh]
# Source node to ATen node mapping:
#   act_3 => tanh_1
# Graph fragment:
#   %tanh_1 : [num_users=2] = call_function[target=torch.ops.aten.tanh.default](args = (%view_3,), kwargs = {})
triton_poi_fused_tanh_1 = async_compile.triton('triton_poi_fused_tanh_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=[8192], 
    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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_tanh_1', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, '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_tanh_1(in_out_ptr0, in_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 8192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + (x2), None)
    tmp1 = tl.load(in_ptr0 + (x0), None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + (x2), tmp3, None)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/6i/c6iefo5vb2yvl5gn4srwtkd6udev6frlw7gwcd6kvbskdmribvuv.py
# Topologically Sorted Source Nodes: [std], Original ATen: [aten.exp]
# Source node to ATen node mapping:
#   std => exp
# Graph fragment:
#   %exp : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%expand,), kwargs = {})
triton_poi_fused_exp_2 = async_compile.triton('triton_poi_fused_exp_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=[256], 
    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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_exp_2', 'mutated_arg_names': [], '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_exp_2(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0), xmask, eviction_policy='evict_last')
    tmp1 = tl_math.exp(tmp0)
    tl.store(out_ptr0 + (x2), tmp1, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/ep/cepsknhymfiex5chhfnggot5dwk2c7wwi6scobx54473se4rhvah.py
# Topologically Sorted Source Nodes: [sub], Original ATen: [aten.sub]
# Source node to ATen node mapping:
#   sub => sub
# Graph fragment:
#   %sub : [num_users=2] = call_function[target=torch.ops.aten.sub.Tensor](args = (%normal, %view_5), kwargs = {})
triton_poi_fused_sub_3 = async_compile.triton('triton_poi_fused_sub_3', '''
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=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_sub_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, '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_sub_3(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (x0), xmask)
    tmp1 = tl.load(in_ptr1 + (x0), xmask)
    tmp2 = tmp0 - tmp1
    tl.store(out_ptr0 + (x0), tmp2, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/mu/cmui65nc45s7hcf7ohlwkcmzhodypc45qbtaxhbfkqk6y4ggq526.py
# Topologically Sorted Source Nodes: [variance, pow_2, neg, mul, truediv, wrapped_mul, sub_1, log_density, log_density_1], Original ATen: [aten.pow, aten.neg, aten.mul, aten.div, aten.sub, aten.sum]
# Source node to ATen node mapping:
#   log_density => sub_2
#   log_density_1 => sum_1
#   mul => mul
#   neg => neg
#   pow_2 => pow_2
#   sub_1 => sub_1
#   truediv => div
#   variance => pow_1
#   wrapped_mul => full_default
# Graph fragment:
#   %pow_1 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%exp, 2), kwargs = {})
#   %pow_2 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sub, 2), kwargs = {})
#   %neg : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%pow_2,), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%pow_1, 2), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%neg, %mul), kwargs = {})
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.9189385332046727), kwargs = {dtype: torch.float64, layout: torch.strided, device: cpu, pin_memory: False})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div, %full_default), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_1, %expand), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%sub_2, [1], True), kwargs = {})
triton_poi_fused_div_mul_neg_pow_sub_sum_4 = async_compile.triton('triton_poi_fused_div_mul_neg_pow_sub_sum_4', '''
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=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_div_mul_neg_pow_sub_sum_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 9, '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_mul_neg_pow_sub_sum_4(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = (xindex // 16)
    x3 = xindex % 16
    x0 = xindex % 4
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x3 + (64*x2)), xmask)
    tmp3 = tl.load(in_ptr1 + (x3 + (64*x2)), xmask)
    tmp10 = tl.load(in_ptr2 + (x0), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr0 + (16 + x3 + (64*x2)), xmask)
    tmp15 = tl.load(in_ptr1 + (16 + x3 + (64*x2)), xmask)
    tmp22 = tl.load(in_ptr0 + (32 + x3 + (64*x2)), xmask)
    tmp25 = tl.load(in_ptr1 + (32 + x3 + (64*x2)), xmask)
    tmp32 = tl.load(in_ptr0 + (48 + x3 + (64*x2)), xmask)
    tmp35 = tl.load(in_ptr1 + (48 + x3 + (64*x2)), xmask)
    tmp1 = tmp0 * tmp0
    tmp2 = -tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = 2.0
    tmp6 = tmp4 * tmp5
    tmp7 = tmp2 / tmp6
    tmp8 = 0.9189385332046727
    tmp9 = tmp7 - tmp8
    tmp11 = tmp9 - tmp10
    tmp13 = tmp12 * tmp12
    tmp14 = -tmp13
    tmp16 = tmp15 * tmp15
    tmp17 = tmp16 * tmp5
    tmp18 = tmp14 / tmp17
    tmp19 = tmp18 - tmp8
    tmp20 = tmp19 - tmp10
    tmp21 = tmp11 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = -tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp26 * tmp5
    tmp28 = tmp24 / tmp27
    tmp29 = tmp28 - tmp8
    tmp30 = tmp29 - tmp10
    tmp31 = tmp21 + tmp30
    tmp33 = tmp32 * tmp32
    tmp34 = -tmp33
    tmp36 = tmp35 * tmp35
    tmp37 = tmp36 * tmp5
    tmp38 = tmp34 / tmp37
    tmp39 = tmp38 - tmp8
    tmp40 = tmp39 - tmp10
    tmp41 = tmp31 + tmp40
    tl.store(out_ptr0 + (x4), tmp41, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5, primals_6, primals_7, primals_8, primals_9, primals_10, primals_11, primals_12, primals_13, primals_14 = args
    args.clear()
    assert_size_stride(primals_1, (64, 4), (4, 1))
    assert_size_stride(primals_2, (64, ), (1, ))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (128, 64), (64, 1))
    assert_size_stride(primals_5, (128, ), (1, ))
    assert_size_stride(primals_6, (4, 128), (128, 1))
    assert_size_stride(primals_7, (4, ), (1, ))
    assert_size_stride(primals_8, (4, ), (1, ))
    assert_size_stride(primals_9, (64, 4), (4, 1))
    assert_size_stride(primals_10, (64, ), (1, ))
    assert_size_stride(primals_11, (128, 64), (64, 1))
    assert_size_stride(primals_12, (128, ), (1, ))
    assert_size_stride(primals_13, (1, 128), (128, 1))
    assert_size_stride(primals_14, (1, ), (1, ))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((64, 64), (64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(reinterpret_tensor(primals_3, (64, 4), (4, 1), 0), reinterpret_tensor(primals_1, (4, 64), (1, 4), 0), out=buf0)
        del primals_1
        buf1 = reinterpret_tensor(buf0, (4, 4, 4, 64), (1024, 256, 64, 1), 0); del buf0  # reuse
        # Topologically Sorted Source Nodes: [act_1], Original ATen: [aten.tanh]
        stream0 = get_raw_stream(0)
        triton_poi_fused_tanh_0.run(buf1, primals_2, 4096, grid=grid(4096), stream=stream0)
        del primals_2
        buf2 = empty_strided_cuda((64, 128), (128, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(reinterpret_tensor(buf1, (64, 64), (64, 1), 0), reinterpret_tensor(primals_4, (64, 128), (1, 64), 0), out=buf2)
        buf3 = reinterpret_tensor(buf2, (4, 4, 4, 128), (2048, 512, 128, 1), 0); del buf2  # reuse
        # Topologically Sorted Source Nodes: [act_3], Original ATen: [aten.tanh]
        triton_poi_fused_tanh_1.run(buf3, primals_5, 8192, grid=grid(8192), stream=stream0)
        del primals_5
        buf4 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [mean], Original ATen: [aten.addmm]
        extern_kernels.addmm(primals_7, reinterpret_tensor(buf3, (64, 128), (128, 1), 0), reinterpret_tensor(primals_6, (128, 4), (1, 128), 0), alpha=1, beta=1, out=buf4)
        del primals_7
        buf5 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [std], Original ATen: [aten.exp]
        triton_poi_fused_exp_2.run(primals_8, buf5, 256, grid=grid(256), stream=stream0)
        # Topologically Sorted Source Nodes: [std, action], Original ATen: [aten.exp, aten.normal]
        buf6 = torch.ops.aten.normal.Tensor_Tensor(reinterpret_tensor(buf4, (4, 4, 4, 4), (64, 16, 4, 1), 0), buf5)
        buf7 = buf6
        del buf6
        buf8 = empty_strided_cuda((64, 64), (64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(reinterpret_tensor(primals_3, (64, 4), (4, 1), 0), reinterpret_tensor(primals_9, (4, 64), (1, 4), 0), out=buf8)
        del primals_9
        buf9 = reinterpret_tensor(buf8, (4, 4, 4, 64), (1024, 256, 64, 1), 0); del buf8  # reuse
        # Topologically Sorted Source Nodes: [v_1], Original ATen: [aten.tanh]
        triton_poi_fused_tanh_0.run(buf9, primals_10, 4096, grid=grid(4096), stream=stream0)
        del primals_10
        buf10 = empty_strided_cuda((64, 128), (128, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(reinterpret_tensor(buf9, (64, 64), (64, 1), 0), reinterpret_tensor(primals_11, (64, 128), (1, 64), 0), out=buf10)
        buf11 = reinterpret_tensor(buf10, (4, 4, 4, 128), (2048, 512, 128, 1), 0); del buf10  # reuse
        # Topologically Sorted Source Nodes: [v_3], Original ATen: [aten.tanh]
        triton_poi_fused_tanh_1.run(buf11, primals_12, 8192, grid=grid(8192), stream=stream0)
        del primals_12
        buf13 = empty_strided_cuda((64, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [v_4], Original ATen: [aten.addmm]
        extern_kernels.addmm(primals_14, reinterpret_tensor(buf11, (64, 128), (128, 1), 0), reinterpret_tensor(primals_13, (128, 1), (1, 128), 0), alpha=1, beta=1, out=buf13)
        del primals_14
        buf14 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [sub], Original ATen: [aten.sub]
        triton_poi_fused_sub_3.run(buf7, buf4, buf14, 256, grid=grid(256), stream=stream0)
        buf15 = empty_strided_cuda((4, 1, 4, 4), (16, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [variance, pow_2, neg, mul, truediv, wrapped_mul, sub_1, log_density, log_density_1], Original ATen: [aten.pow, aten.neg, aten.mul, aten.div, aten.sub, aten.sum]
        triton_poi_fused_div_mul_neg_pow_sub_sum_4.run(buf14, buf5, primals_8, buf15, 64, grid=grid(64), stream=stream0)
        del buf5
    return (reinterpret_tensor(buf13, (4, 4, 4, 1), (16, 4, 1, 1), 0), buf7, buf15, reinterpret_tensor(buf4, (4, 4, 4, 4), (64, 16, 4, 1), 0), primals_8, reinterpret_tensor(primals_3, (64, 4), (4, 1), 0), buf1, buf3, buf9, buf11, buf14, primals_13, primals_11, primals_6, primals_4, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    primals_1 = rand_strided((64, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((128, 64), (64, 1), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((128, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((4, 128), (128, 1), device='cuda:0', dtype=torch.float32)
    primals_7 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_8 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_9 = rand_strided((64, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_10 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_11 = rand_strided((128, 64), (64, 1), device='cuda:0', dtype=torch.float32)
    primals_12 = rand_strided((128, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_13 = rand_strided((1, 128), (128, 1), device='cuda:0', dtype=torch.float32)
    primals_14 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([primals_1, primals_2, primals_3, primals_4, primals_5, primals_6, primals_7, primals_8, primals_9, primals_10, primals_11, primals_12, primals_13, primals_14])
    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 torch._inductor.select_algorithm import extern_kernels
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, math as tl_math
import math
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
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_tanh_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 64
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x2, tmp3, None)


@triton.jit
def triton_poi_fused_tanh_1(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 128
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x2, tmp3, None)


@triton.jit
def triton_poi_fused_exp_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp1 = tl_math.exp(tmp0)
    tl.store(out_ptr0 + x2, tmp1, xmask)


@triton.jit
def triton_poi_fused_sub_3(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask)
    tmp2 = tmp0 - tmp1
    tl.store(out_ptr0 + x0, tmp2, xmask)


@triton.jit
def triton_poi_fused_div_mul_neg_pow_sub_sum_4(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex // 16
    x3 = xindex % 16
    x0 = xindex % 4
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x3 + 64 * x2), xmask)
    tmp3 = tl.load(in_ptr1 + (x3 + 64 * x2), xmask)
    tmp10 = tl.load(in_ptr2 + x0, xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr0 + (16 + x3 + 64 * x2), xmask)
    tmp15 = tl.load(in_ptr1 + (16 + x3 + 64 * x2), xmask)
    tmp22 = tl.load(in_ptr0 + (32 + x3 + 64 * x2), xmask)
    tmp25 = tl.load(in_ptr1 + (32 + x3 + 64 * x2), xmask)
    tmp32 = tl.load(in_ptr0 + (48 + x3 + 64 * x2), xmask)
    tmp35 = tl.load(in_ptr1 + (48 + x3 + 64 * x2), xmask)
    tmp1 = tmp0 * tmp0
    tmp2 = -tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = 2.0
    tmp6 = tmp4 * tmp5
    tmp7 = tmp2 / tmp6
    tmp8 = 0.9189385332046727
    tmp9 = tmp7 - tmp8
    tmp11 = tmp9 - tmp10
    tmp13 = tmp12 * tmp12
    tmp14 = -tmp13
    tmp16 = tmp15 * tmp15
    tmp17 = tmp16 * tmp5
    tmp18 = tmp14 / tmp17
    tmp19 = tmp18 - tmp8
    tmp20 = tmp19 - tmp10
    tmp21 = tmp11 + tmp20
    tmp23 = tmp22 * tmp22
    tmp24 = -tmp23
    tmp26 = tmp25 * tmp25
    tmp27 = tmp26 * tmp5
    tmp28 = tmp24 / tmp27
    tmp29 = tmp28 - tmp8
    tmp30 = tmp29 - tmp10
    tmp31 = tmp21 + tmp30
    tmp33 = tmp32 * tmp32
    tmp34 = -tmp33
    tmp36 = tmp35 * tmp35
    tmp37 = tmp36 * tmp5
    tmp38 = tmp34 / tmp37
    tmp39 = tmp38 - tmp8
    tmp40 = tmp39 - tmp10
    tmp41 = tmp31 + tmp40
    tl.store(out_ptr0 + x4, tmp41, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14) = args
    args.clear()
    assert_size_stride(primals_1, (64, 4), (4, 1))
    assert_size_stride(primals_2, (64,), (1,))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (128, 64), (64, 1))
    assert_size_stride(primals_5, (128,), (1,))
    assert_size_stride(primals_6, (4, 128), (128, 1))
    assert_size_stride(primals_7, (4,), (1,))
    assert_size_stride(primals_8, (4,), (1,))
    assert_size_stride(primals_9, (64, 4), (4, 1))
    assert_size_stride(primals_10, (64,), (1,))
    assert_size_stride(primals_11, (128, 64), (64, 1))
    assert_size_stride(primals_12, (128,), (1,))
    assert_size_stride(primals_13, (1, 128), (128, 1))
    assert_size_stride(primals_14, (1,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((64, 64), (64, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_3, (64, 4), (4, 1), 0),
            reinterpret_tensor(primals_1, (4, 64), (1, 4), 0), out=buf0)
        del primals_1
        buf1 = reinterpret_tensor(buf0, (4, 4, 4, 64), (1024, 256, 64, 1), 0)
        del buf0
        get_raw_stream(0)
        triton_poi_fused_tanh_0[grid(4096)](buf1, primals_2, 4096, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_2
        buf2 = empty_strided_cuda((64, 128), (128, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf1, (64, 64), (64, 1), 0),
            reinterpret_tensor(primals_4, (64, 128), (1, 64), 0), out=buf2)
        buf3 = reinterpret_tensor(buf2, (4, 4, 4, 128), (2048, 512, 128, 1), 0)
        del buf2
        triton_poi_fused_tanh_1[grid(8192)](buf3, primals_5, 8192, XBLOCK=
            256, num_warps=4, num_stages=1)
        del primals_5
        buf4 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_7, reinterpret_tensor(buf3, (64, 128),
            (128, 1), 0), reinterpret_tensor(primals_6, (128, 4), (1, 128),
            0), alpha=1, beta=1, out=buf4)
        del primals_7
        buf5 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_exp_2[grid(256)](primals_8, buf5, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf6 = torch.ops.aten.normal.Tensor_Tensor(reinterpret_tensor(buf4,
            (4, 4, 4, 4), (64, 16, 4, 1), 0), buf5)
        buf7 = buf6
        del buf6
        buf8 = empty_strided_cuda((64, 64), (64, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_3, (64, 4), (4, 1), 0),
            reinterpret_tensor(primals_9, (4, 64), (1, 4), 0), out=buf8)
        del primals_9
        buf9 = reinterpret_tensor(buf8, (4, 4, 4, 64), (1024, 256, 64, 1), 0)
        del buf8
        triton_poi_fused_tanh_0[grid(4096)](buf9, primals_10, 4096, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_10
        buf10 = empty_strided_cuda((64, 128), (128, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf9, (64, 64), (64, 1), 0),
            reinterpret_tensor(primals_11, (64, 128), (1, 64), 0), out=buf10)
        buf11 = reinterpret_tensor(buf10, (4, 4, 4, 128), (2048, 512, 128, 
            1), 0)
        del buf10
        triton_poi_fused_tanh_1[grid(8192)](buf11, primals_12, 8192, XBLOCK
            =256, num_warps=4, num_stages=1)
        del primals_12
        buf13 = empty_strided_cuda((64, 1), (1, 1), torch.float32)
        extern_kernels.addmm(primals_14, reinterpret_tensor(buf11, (64, 128
            ), (128, 1), 0), reinterpret_tensor(primals_13, (128, 1), (1, 
            128), 0), alpha=1, beta=1, out=buf13)
        del primals_14
        buf14 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_sub_3[grid(256)](buf7, buf4, buf14, 256, XBLOCK=
            128, num_warps=4, num_stages=1)
        buf15 = empty_strided_cuda((4, 1, 4, 4), (16, 16, 4, 1), torch.float32)
        triton_poi_fused_div_mul_neg_pow_sub_sum_4[grid(64)](buf14, buf5,
            primals_8, buf15, 64, XBLOCK=64, num_warps=1, num_stages=1)
        del buf5
    return (reinterpret_tensor(buf13, (4, 4, 4, 1), (16, 4, 1, 1), 0), buf7,
        buf15, reinterpret_tensor(buf4, (4, 4, 4, 4), (64, 16, 4, 1), 0),
        primals_8, reinterpret_tensor(primals_3, (64, 4), (4, 1), 0), buf1,
        buf3, buf9, buf11, buf14, primals_13, primals_11, primals_6, primals_4)


def log_normal_density(x, mean, log_std, std):
    """returns guassian density given x on log scale"""
    variance = std.pow(2)
    log_density = -(x - mean).pow(2) / (2 * variance) - 0.5 * np.log(2 * np.pi
        ) - log_std
    log_density = log_density.sum(dim=1, keepdim=True)
    return log_density


class MLPPolicyNew(nn.Module):

    def __init__(self, obs_space, action_space):
        super(MLPPolicyNew, self).__init__()
        self.act_fc1 = nn.Linear(obs_space, 64)
        self.act_fc2 = nn.Linear(64, 128)
        self.mu = nn.Linear(128, action_space)
        self.mu.weight.data.mul_(0.1)
        self.logstd = nn.Parameter(torch.zeros(action_space))
        self.value_fc1 = nn.Linear(obs_space, 64)
        self.value_fc2 = nn.Linear(64, 128)
        self.value_fc3 = nn.Linear(128, 1)
        self.value_fc3.weight.data.mul(0.1)

    def evaluate_actions(self, x, action):
        v, _, _, mean = self.forward(x)
        logstd = self.logstd.expand_as(mean)
        std = torch.exp(logstd)
        logprob = log_normal_density(action, mean, log_std=logstd, std=std)
        dist_entropy = 0.5 + 0.5 * math.log(2 * math.pi) + logstd
        dist_entropy = dist_entropy.sum(-1).mean()
        return v, logprob, dist_entropy

    def forward(self, input_0):
        primals_7 = self.logstd
        primals_1 = self.act_fc1.weight
        primals_2 = self.act_fc1.bias
        primals_4 = self.act_fc2.weight
        primals_5 = self.act_fc2.bias
        primals_6 = self.mu.weight
        primals_8 = self.mu.bias
        primals_9 = self.value_fc1.weight
        primals_10 = self.value_fc1.bias
        primals_11 = self.value_fc2.weight
        primals_12 = self.value_fc2.bias
        primals_13 = self.value_fc3.weight
        primals_14 = self.value_fc3.bias
        primals_3 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14])
        return output[0], output[1], output[2], output[3]
