# 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_4/inductor_cache/oo/coo46bs5zpai6ydehcambdwmxekrecdbbhcbxivotaebjhzp7llm.py
# Topologically Sorted Source Nodes: [weight_wd_1], Original ATen: [aten.clone, aten._unsafe_view]
# Source node to ATen node mapping:
#   weight_wd_1 => clone, view
# Graph fragment:
#   %clone : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%permute,), kwargs = {memory_format: torch.contiguous_format})
#   %view : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%clone, [16, 4]), kwargs = {})
triton_poi_fused__unsafe_view_clone_0 = async_compile.triton('triton_poi_fused__unsafe_view_clone_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=[64], 
    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__unsafe_view_clone_0', '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__unsafe_view_clone_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x1 = (xindex // 4)
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + ((4*(x1 % 4)) + (16*x0) + (x1 // 4)), xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2), tmp0, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/kk/ckkn7vlnz5gfvzigo3gxfhxwb6i7tj47p7plxoih22qwcvc7em26.py
# Topologically Sorted Source Nodes: [weight_wd_5], Original ATen: [aten.clone, aten._unsafe_view]
# Source node to ATen node mapping:
#   weight_wd_5 => clone_2, view_4
# Graph fragment:
#   %clone_2 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%permute_2,), kwargs = {memory_format: torch.contiguous_format})
#   %view_4 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%clone_2, [16, 4]), kwargs = {})
triton_poi_fused__unsafe_view_clone_1 = async_compile.triton('triton_poi_fused__unsafe_view_clone_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, 4], tile_hint=TileHint.SQUARE,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32', 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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__unsafe_view_clone_1', '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__unsafe_view_clone_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + ((4*x1) + (16*(y0 // 4)) + (y0 % 4)), xmask & ymask, eviction_policy='evict_last')
    tl.store(out_ptr0 + (x1 + (4*y0)), tmp0, xmask & ymask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/4p/c4p5vybvk5kczshqzudonrympy7hqc7dyeur4eomof353wgjgkm6.py
# Topologically Sorted Source Nodes: [tanh, mul, weight_wd_9], Original ATen: [aten.tanh, aten.mul, aten.add]
# Source node to ATen node mapping:
#   mul => mul
#   tanh => tanh
#   weight_wd_9 => add
# Graph fragment:
#   %tanh : [num_users=1] = call_function[target=torch.ops.aten.tanh.default](args = (%squeeze,), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%primals_6, %tanh), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul, %primals_7), kwargs = {})
triton_poi_fused_add_mul_tanh_2 = async_compile.triton('triton_poi_fused_add_mul_tanh_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=[16], 
    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_add_mul_tanh_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, '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_tanh_2(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    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)
    tmp4 = tl.load(in_ptr2 + (x0), xmask)
    tmp2 = libdevice.tanh(tmp1)
    tmp3 = tmp0 * tmp2
    tmp5 = tmp3 + tmp4
    tl.store(out_ptr0 + (x0), tmp5, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/er/certponyoudrebqs7ovkmzybyrkb26c4kqh3oaysaxf4ryytitj2.py
# Topologically Sorted Source Nodes: [tanh_1, mul_1, bias_wd_6], Original ATen: [aten.tanh, aten.mul, aten.add]
# Source node to ATen node mapping:
#   bias_wd_6 => add_1
#   mul_1 => mul_1
#   tanh_1 => tanh_1
# Graph fragment:
#   %tanh_1 : [num_users=1] = call_function[target=torch.ops.aten.tanh.default](args = (%squeeze_1,), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%primals_12, %tanh_1), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_1, %primals_13), kwargs = {})
triton_poi_fused_add_mul_tanh_3 = async_compile.triton('triton_poi_fused_add_mul_tanh_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=[4], 
    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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_mul_tanh_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, '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_tanh_3(in_ptr0, in_ptr1, in_ptr2, out_ptr0, 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)
    tmp1 = tl.load(in_ptr1 + (x0), xmask)
    tmp4 = tl.load(in_ptr2 + (x0), xmask)
    tmp2 = libdevice.tanh(tmp1)
    tmp3 = tmp0 * tmp2
    tmp5 = tmp3 + tmp4
    tl.store(out_ptr0 + (x0), tmp5, 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, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (4, 4), (4, 1))
    assert_size_stride(primals_4, (4, 4), (4, 1))
    assert_size_stride(primals_5, (4, 1), (1, 1))
    assert_size_stride(primals_6, (4, 4), (4, 1))
    assert_size_stride(primals_7, (4, 4), (4, 1))
    assert_size_stride(primals_8, (4, 4), (4, 1))
    assert_size_stride(primals_9, (4, 4), (4, 1))
    assert_size_stride(primals_10, (4, 4), (4, 1))
    assert_size_stride(primals_11, (4, 1), (1, 1))
    assert_size_stride(primals_12, (4, ), (1, ))
    assert_size_stride(primals_13, (4, ), (1, ))
    assert_size_stride(primals_14, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [weight_wd_1], Original ATen: [aten.clone, aten._unsafe_view]
        stream0 = get_raw_stream(0)
        triton_poi_fused__unsafe_view_clone_0.run(primals_1, buf0, 64, grid=grid(64), stream=stream0)
        del primals_1
        buf1 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [weight_wd_1], Original ATen: [aten.mm]
        extern_kernels.mm(buf0, primals_2, out=buf1)
        del primals_2
        buf2 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [weight_wd_3], Original ATen: [aten.clone, aten._unsafe_view]
        triton_poi_fused__unsafe_view_clone_0.run(buf1, buf2, 64, grid=grid(64), stream=stream0)
        buf3 = buf1; del buf1  # reuse
        # Topologically Sorted Source Nodes: [weight_wd_3], Original ATen: [aten.mm]
        extern_kernels.mm(buf2, primals_3, out=buf3)
        buf4 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [weight_wd_5], Original ATen: [aten.clone, aten._unsafe_view]
        triton_poi_fused__unsafe_view_clone_1.run(buf3, buf4, 16, 4, grid=grid(16, 4), stream=stream0)
        buf5 = buf3; del buf3  # reuse
        # Topologically Sorted Source Nodes: [weight_wd_5], Original ATen: [aten.mm]
        extern_kernels.mm(buf4, primals_4, out=buf5)
        buf6 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [weight_wd_7], Original ATen: [aten.clone, aten._unsafe_view]
        triton_poi_fused__unsafe_view_clone_1.run(buf5, buf6, 16, 4, grid=grid(16, 4), stream=stream0)
        del buf5
        buf7 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [weight_wd_7], Original ATen: [aten.mm]
        extern_kernels.mm(buf6, primals_5, out=buf7)
        buf8 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [bias_wd_1], Original ATen: [aten.mm]
        extern_kernels.mm(reinterpret_tensor(primals_8, (4, 4), (1, 4), 0), primals_9, out=buf8)
        del primals_9
        buf9 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [bias_wd_3], Original ATen: [aten.mm]
        extern_kernels.mm(reinterpret_tensor(buf8, (4, 4), (1, 4), 0), primals_10, out=buf9)
        buf10 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [bias_wd_4], Original ATen: [aten.mm]
        extern_kernels.mm(buf9, primals_11, out=buf10)
        buf11 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [tanh, mul, weight_wd_9], Original ATen: [aten.tanh, aten.mul, aten.add]
        triton_poi_fused_add_mul_tanh_2.run(primals_6, buf7, primals_7, buf11, 16, grid=grid(16), stream=stream0)
        del primals_7
        buf12 = empty_strided_cuda((4, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [tanh_1, mul_1, bias_wd_6], Original ATen: [aten.tanh, aten.mul, aten.add]
        triton_poi_fused_add_mul_tanh_3.run(primals_12, buf10, primals_13, buf12, 4, grid=grid(4), stream=stream0)
        del primals_13
        buf13 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [tanh_1, mul_1, bias_wd_6, linear], Original ATen: [aten.tanh, aten.mul, aten.add, aten.addmm]
        extern_kernels.addmm(buf12, reinterpret_tensor(primals_14, (64, 4), (4, 1), 0), reinterpret_tensor(buf11, (4, 4), (1, 4), 0), alpha=1, beta=1, out=buf13)
        del buf11
        del buf12
    return (reinterpret_tensor(buf13, (4, 4, 4, 4), (64, 16, 4, 1), 0), primals_6, primals_10, primals_12, buf7, buf10, reinterpret_tensor(primals_14, (64, 4), (4, 1), 0), reinterpret_tensor(buf9, (4, 4), (1, 4), 0), reinterpret_tensor(primals_11, (1, 4), (1, 1), 0), buf8, primals_8, reinterpret_tensor(buf6, (4, 16), (1, 4), 0), reinterpret_tensor(primals_5, (1, 4), (1, 1), 0), reinterpret_tensor(buf4, (4, 16), (1, 4), 0), reinterpret_tensor(primals_4, (4, 4), (1, 4), 0), reinterpret_tensor(buf2, (4, 16), (1, 4), 0), reinterpret_tensor(primals_3, (4, 4), (1, 4), 0), reinterpret_tensor(buf0, (4, 16), (1, 4), 0), )


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((4, 4, 4), (16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((4, 1), (1, 1), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_7 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_8 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_9 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_10 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_11 = rand_strided((4, 1), (1, 1), device='cuda:0', dtype=torch.float32)
    primals_12 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_13 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_14 = rand_strided((4, 4, 4, 4), (64, 16, 4, 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 math
import torch
import torch.nn.functional as F
import torch.utils.data
from torch.nn import Parameter
import torch.onnx.operators
from torch.nn.parameter import Parameter
from torch.nn import init
import torch.optim
import torch.optim.lr_scheduler


class WDV52Linear(torch.nn.Module):
    """Applies a linear transformation to the incoming data: :math:`y = xA^T + b`

    Args:
        in_features: size of each input sample
        out_features: size of each output sample
        bias: If set to ``False``, the layer will not learn an additive bias.
            Default: ``True``

    Shape:
        - Input: :math:`(N, *, H_{in})` where :math:`*` means any number of
          additional dimensions and :math:`H_{in} = \\text{in\\_features}`
        - Output: :math:`(N, *, H_{out})` where all but the last dimension
          are the same shape as the input and :math:`H_{out} = \\text{out\\_features}`.

    Attributes:
        weight: the learnable weights of the module of shape
            :math:`(\\text{out\\_features}, \\text{in\\_features})`. The values are
            initialized from :math:`\\mathcal{U}(-\\sqrt{k}, \\sqrt{k})`, where
            :math:`k = \\frac{1}{\\text{in\\_features}}`
        bias:   the learnable bias of the module of shape :math:`(\\text{out\\_features})`.
                If :attr:`bias` is ``True``, the values are initialized from
                :math:`\\mathcal{U}(-\\sqrt{k}, \\sqrt{k})` where
                :math:`k = \\frac{1}{\\text{in\\_features}}`

    Examples::

        >>> m = nn.Linear(20, 30)
        >>> input = torch.randn(128, 20)
        >>> output = m(input)
        >>> print(output.size())
        torch.Size([128, 30])
    """
    __constants__ = ['bias', 'in_features', 'out_features']

    def __init__(self, ts, in_features, out_features, wd_in_features,
        wd_out_features, wd_decoder_layers, wd_require_gradient=False, bias
        =True):
        super(WDV52Linear, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.ts = ts
        self.wd_decoder_layers = wd_decoder_layers
        self.out_wd_weight = Parameter(torch.Tensor(wd_out_features,
            out_features))
        self.in_wd_weight = Parameter(torch.Tensor(wd_in_features, in_features)
            )
        self.ly_wd_weight = Parameter(torch.Tensor(ts, ts))
        self.wd_weight = Parameter(torch.Tensor(ts, 1))
        self.weight = Parameter(torch.Tensor(wd_out_features,
            wd_in_features, ts), requires_grad=wd_require_gradient)
        self.tanh_weight_weight = Parameter(torch.Tensor(out_features,
            in_features))
        self.tanh_bias_weight = Parameter(torch.Tensor(out_features,
            in_features))
        if bias:
            self.out_wd_bias = Parameter(torch.Tensor(wd_out_features,
                out_features))
            self.ly_wd_bias = Parameter(torch.Tensor(ts, ts))
            self.wd_bias = Parameter(torch.Tensor(ts, 1))
            self.bias = Parameter(torch.Tensor(wd_out_features, ts),
                requires_grad=wd_require_gradient)
            self.tanh_weight_bias = Parameter(torch.Tensor(out_features))
            self.tanh_bias_bias = Parameter(torch.Tensor(out_features))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()

    def reset_parameters(self):
        torch.nn.init.xavier_normal_(self.out_wd_weight)
        torch.nn.init.xavier_normal_(self.in_wd_weight)
        torch.nn.init.xavier_normal_(self.ly_wd_weight)
        torch.nn.init.constant_(self.wd_weight, 1 / self.ts)
        torch.nn.init.constant_(self.tanh_weight_weight, 1.0)
        torch.nn.init.constant_(self.tanh_weight_bias, 1.0)
        init.kaiming_uniform_(self.weight, a=math.sqrt(5))
        if self.bias is not None:
            torch.nn.init.xavier_normal_(self.out_wd_bias)
            torch.nn.init.xavier_normal_(self.ly_wd_bias)
            torch.nn.init.constant_(self.wd_bias, 1 / self.ts)
            torch.nn.init.constant_(self.tanh_bias_weight, 0.0)
            torch.nn.init.constant_(self.tanh_bias_bias, 0.0)
            fan_in, _ = init._calculate_fan_in_and_fan_out(self.weight)
            bound = 1 / math.sqrt(fan_in)
            init.uniform_(self.bias, -bound, bound)

    def forward(self, input):
        weight = self.weight
        weight_wd = torch.transpose(weight, 0, 2)
        weight_wd = torch.matmul(weight_wd, self.out_wd_weight)
        weight_wd = torch.transpose(weight_wd, 0, 2)
        weight_wd = torch.matmul(weight_wd, self.ly_wd_weight)
        weight_wd = torch.transpose(weight_wd, 1, 2)
        weight_wd = torch.matmul(weight_wd, self.in_wd_weight)
        weight_wd = torch.transpose(weight_wd, 1, 2)
        weight_wd = torch.matmul(weight_wd, self.wd_weight)
        weight_wd = weight_wd.squeeze(-1)
        weight_wd = self.tanh_weight_weight * torch.tanh(weight_wd
            ) + self.tanh_bias_weight
        bias = self.bias
        bias_wd = torch.transpose(bias, 0, 1)
        bias_wd = torch.matmul(bias_wd, self.out_wd_bias)
        bias_wd = torch.transpose(bias_wd, 0, 1)
        bias_wd = torch.matmul(bias_wd, self.ly_wd_bias)
        bias_wd = torch.matmul(bias_wd, self.wd_bias)
        bias_wd = bias_wd.squeeze(-1)
        bias_wd = self.tanh_weight_bias * torch.tanh(bias_wd
            ) + self.tanh_bias_bias
        return F.linear(input, weight_wd, bias_wd)

    def extra_repr(self):
        return 'in_features={}, out_features={}, bias={}'.format(self.
            in_features, self.out_features, self.bias is not None)


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


def get_init_inputs():
    return [[], {'ts': 4, 'in_features': 4, 'out_features': 4,
        'wd_in_features': 4, 'wd_out_features': 4, 'wd_decoder_layers': 1}]

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
import math
import torch.utils.data
from torch.nn import Parameter
import torch.onnx.operators
from torch.nn.parameter import Parameter
from torch.nn import init
import torch.optim
import torch.optim.lr_scheduler
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__unsafe_view_clone_0(in_ptr0, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x1 = xindex // 4
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (4 * (x1 % 4) + 16 * x0 + x1 // 4), xmask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + x2, tmp0, xmask)


@triton.jit
def triton_poi_fused__unsafe_view_clone_1(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (4 * x1 + 16 * (y0 // 4) + y0 % 4), xmask &
        ymask, eviction_policy='evict_last')
    tl.store(out_ptr0 + (x1 + 4 * y0), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_add_mul_tanh_2(in_ptr0, in_ptr1, in_ptr2, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    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)
    tmp4 = tl.load(in_ptr2 + x0, xmask)
    tmp2 = libdevice.tanh(tmp1)
    tmp3 = tmp0 * tmp2
    tmp5 = tmp3 + tmp4
    tl.store(out_ptr0 + x0, tmp5, xmask)


@triton.jit
def triton_poi_fused_add_mul_tanh_3(in_ptr0, in_ptr1, in_ptr2, out_ptr0,
    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)
    tmp1 = tl.load(in_ptr1 + x0, xmask)
    tmp4 = tl.load(in_ptr2 + x0, xmask)
    tmp2 = libdevice.tanh(tmp1)
    tmp3 = tmp0 * tmp2
    tmp5 = tmp3 + tmp4
    tl.store(out_ptr0 + x0, tmp5, 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, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (4, 4), (4, 1))
    assert_size_stride(primals_4, (4, 4), (4, 1))
    assert_size_stride(primals_5, (4, 1), (1, 1))
    assert_size_stride(primals_6, (4, 4), (4, 1))
    assert_size_stride(primals_7, (4, 4), (4, 1))
    assert_size_stride(primals_8, (4, 4), (4, 1))
    assert_size_stride(primals_9, (4, 4), (4, 1))
    assert_size_stride(primals_10, (4, 4), (4, 1))
    assert_size_stride(primals_11, (4, 1), (1, 1))
    assert_size_stride(primals_12, (4,), (1,))
    assert_size_stride(primals_13, (4,), (1,))
    assert_size_stride(primals_14, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused__unsafe_view_clone_0[grid(64)](primals_1, buf0, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        del primals_1
        buf1 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.mm(buf0, primals_2, out=buf1)
        del primals_2
        buf2 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        triton_poi_fused__unsafe_view_clone_0[grid(64)](buf1, buf2, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf3 = buf1
        del buf1
        extern_kernels.mm(buf2, primals_3, out=buf3)
        buf4 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        triton_poi_fused__unsafe_view_clone_1[grid(16, 4)](buf3, buf4, 16, 
            4, XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf5 = buf3
        del buf3
        extern_kernels.mm(buf4, primals_4, out=buf5)
        buf6 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        triton_poi_fused__unsafe_view_clone_1[grid(16, 4)](buf5, buf6, 16, 
            4, XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        del buf5
        buf7 = empty_strided_cuda((16, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf6, primals_5, out=buf7)
        buf8 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_8, (4, 4), (1, 4), 0),
            primals_9, out=buf8)
        del primals_9
        buf9 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf8, (4, 4), (1, 4), 0),
            primals_10, out=buf9)
        buf10 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf9, primals_11, out=buf10)
        buf11 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_mul_tanh_2[grid(16)](primals_6, buf7,
            primals_7, buf11, 16, XBLOCK=16, num_warps=1, num_stages=1)
        del primals_7
        buf12 = empty_strided_cuda((4,), (1,), torch.float32)
        triton_poi_fused_add_mul_tanh_3[grid(4)](primals_12, buf10,
            primals_13, buf12, 4, XBLOCK=4, num_warps=1, num_stages=1)
        del primals_13
        buf13 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.addmm(buf12, reinterpret_tensor(primals_14, (64, 4),
            (4, 1), 0), reinterpret_tensor(buf11, (4, 4), (1, 4), 0), alpha
            =1, beta=1, out=buf13)
        del buf11
        del buf12
    return reinterpret_tensor(buf13, (4, 4, 4, 4), (64, 16, 4, 1), 0
        ), primals_6, primals_10, primals_12, buf7, buf10, reinterpret_tensor(
        primals_14, (64, 4), (4, 1), 0), reinterpret_tensor(buf9, (4, 4), (
        1, 4), 0), reinterpret_tensor(primals_11, (1, 4), (1, 1), 0
        ), buf8, primals_8, reinterpret_tensor(buf6, (4, 16), (1, 4), 0
        ), reinterpret_tensor(primals_5, (1, 4), (1, 1), 0
        ), reinterpret_tensor(buf4, (4, 16), (1, 4), 0), reinterpret_tensor(
        primals_4, (4, 4), (1, 4), 0), reinterpret_tensor(buf2, (4, 16), (1,
        4), 0), reinterpret_tensor(primals_3, (4, 4), (1, 4), 0
        ), reinterpret_tensor(buf0, (4, 16), (1, 4), 0)


class WDV52LinearNew(torch.nn.Module):
    """Applies a linear transformation to the incoming data: :math:`y = xA^T + b`

    Args:
        in_features: size of each input sample
        out_features: size of each output sample
        bias: If set to ``False``, the layer will not learn an additive bias.
            Default: ``True``

    Shape:
        - Input: :math:`(N, *, H_{in})` where :math:`*` means any number of
          additional dimensions and :math:`H_{in} = \\text{in\\_features}`
        - Output: :math:`(N, *, H_{out})` where all but the last dimension
          are the same shape as the input and :math:`H_{out} = \\text{out\\_features}`.

    Attributes:
        weight: the learnable weights of the module of shape
            :math:`(\\text{out\\_features}, \\text{in\\_features})`. The values are
            initialized from :math:`\\mathcal{U}(-\\sqrt{k}, \\sqrt{k})`, where
            :math:`k = \\frac{1}{\\text{in\\_features}}`
        bias:   the learnable bias of the module of shape :math:`(\\text{out\\_features})`.
                If :attr:`bias` is ``True``, the values are initialized from
                :math:`\\mathcal{U}(-\\sqrt{k}, \\sqrt{k})` where
                :math:`k = \\frac{1}{\\text{in\\_features}}`

    Examples::

        >>> m = nn.Linear(20, 30)
        >>> input = torch.randn(128, 20)
        >>> output = m(input)
        >>> print(output.size())
        torch.Size([128, 30])
    """
    __constants__ = ['bias', 'in_features', 'out_features']

    def __init__(self, ts, in_features, out_features, wd_in_features,
        wd_out_features, wd_decoder_layers, wd_require_gradient=False, bias
        =True):
        super(WDV52LinearNew, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.ts = ts
        self.wd_decoder_layers = wd_decoder_layers
        self.out_wd_weight = Parameter(torch.Tensor(wd_out_features,
            out_features))
        self.in_wd_weight = Parameter(torch.Tensor(wd_in_features, in_features)
            )
        self.ly_wd_weight = Parameter(torch.Tensor(ts, ts))
        self.wd_weight = Parameter(torch.Tensor(ts, 1))
        self.weight = Parameter(torch.Tensor(wd_out_features,
            wd_in_features, ts), requires_grad=wd_require_gradient)
        self.tanh_weight_weight = Parameter(torch.Tensor(out_features,
            in_features))
        self.tanh_bias_weight = Parameter(torch.Tensor(out_features,
            in_features))
        if bias:
            self.out_wd_bias = Parameter(torch.Tensor(wd_out_features,
                out_features))
            self.ly_wd_bias = Parameter(torch.Tensor(ts, ts))
            self.wd_bias = Parameter(torch.Tensor(ts, 1))
            self.bias = Parameter(torch.Tensor(wd_out_features, ts),
                requires_grad=wd_require_gradient)
            self.tanh_weight_bias = Parameter(torch.Tensor(out_features))
            self.tanh_bias_bias = Parameter(torch.Tensor(out_features))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()

    def reset_parameters(self):
        torch.nn.init.xavier_normal_(self.out_wd_weight)
        torch.nn.init.xavier_normal_(self.in_wd_weight)
        torch.nn.init.xavier_normal_(self.ly_wd_weight)
        torch.nn.init.constant_(self.wd_weight, 1 / self.ts)
        torch.nn.init.constant_(self.tanh_weight_weight, 1.0)
        torch.nn.init.constant_(self.tanh_weight_bias, 1.0)
        init.kaiming_uniform_(self.weight, a=math.sqrt(5))
        if self.bias is not None:
            torch.nn.init.xavier_normal_(self.out_wd_bias)
            torch.nn.init.xavier_normal_(self.ly_wd_bias)
            torch.nn.init.constant_(self.wd_bias, 1 / self.ts)
            torch.nn.init.constant_(self.tanh_bias_weight, 0.0)
            torch.nn.init.constant_(self.tanh_bias_bias, 0.0)
            fan_in, _ = init._calculate_fan_in_and_fan_out(self.weight)
            bound = 1 / math.sqrt(fan_in)
            init.uniform_(self.bias, -bound, bound)

    def extra_repr(self):
        return 'in_features={}, out_features={}, bias={}'.format(self.
            in_features, self.out_features, self.bias is not None)

    def forward(self, input_0):
        primals_2 = self.out_wd_weight
        primals_3 = self.in_wd_weight
        primals_4 = self.ly_wd_weight
        primals_5 = self.wd_weight
        primals_1 = self.weight
        primals_6 = self.tanh_weight_weight
        primals_7 = self.tanh_bias_weight
        primals_8 = self.out_wd_bias
        primals_9 = self.ly_wd_bias
        primals_11 = self.wd_bias
        primals_10 = self.bias
        primals_12 = self.tanh_weight_bias
        primals_13 = self.tanh_bias_bias
        primals_14 = 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]
