# 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_9/inductor_cache/r3/cr3febcwm3t44fuoitsx3ou2p6xg4sk4f7unagmmrvffasxf47te.py
# Topologically Sorted Source Nodes: [relu], Original ATen: [aten.relu, aten.threshold_backward]
# Source node to ATen node mapping:
#   relu => relu
# Graph fragment:
#   %relu : [num_users=2] = call_function[target=torch.ops.aten.relu.default](args = (%view_3,), kwargs = {})
#   %le : [num_users=1] = call_function[target=torch.ops.aten.le.Scalar](args = (%relu, 0), kwargs = {})
triton_poi_fused_relu_threshold_backward_0 = async_compile.triton('triton_poi_fused_relu_threshold_backward_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=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*i1', 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_relu_threshold_backward_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_relu_threshold_backward_0(in_out_ptr0, 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
    x2 = xindex
    x0 = xindex % 4
    tmp0 = tl.load(in_out_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr0 + (x0), xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(in_out_ptr0 + (x2), tmp4, xmask)
    tl.store(out_ptr0 + (x2), tmp6, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_9/inductor_cache/3v/c3vbbnaoh2ala54xhjzwr7f44xb5tmg7hvdni6ytelrhdlekfg4j.py
# Topologically Sorted Source Nodes: [att_logits_1, softmax], Original ATen: [aten.add, aten._softmax]
# Source node to ATen node mapping:
#   att_logits_1 => add
#   softmax => amax, exp, sub, sum_1
# Graph fragment:
#   %add : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%primals_8, %squeeze), kwargs = {})
#   %amax : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%add, [-1], True), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add, %amax), kwargs = {})
#   %exp : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%sub,), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp, [-1], True), kwargs = {})
triton_poi_fused__softmax_add_1 = async_compile.triton('triton_poi_fused__softmax_add_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=[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__softmax_add_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 8, '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__softmax_add_1(in_ptr0, in_ptr1, out_ptr0, out_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    tmp0 = tl.load(in_ptr0 + (4*x2), xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (4*x0), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (1 + (4*x2)), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + (1 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (2 + (4*x2)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr1 + (2 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (3 + (4*x2)), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr1 + (3 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp6 = triton_helpers.maximum(tmp2, tmp5)
    tmp9 = tmp7 + tmp8
    tmp10 = triton_helpers.maximum(tmp6, tmp9)
    tmp13 = tmp11 + tmp12
    tmp14 = triton_helpers.maximum(tmp10, tmp13)
    tmp15 = tmp2 - tmp14
    tmp16 = tl_math.exp(tmp15)
    tmp17 = tmp5 - tmp14
    tmp18 = tl_math.exp(tmp17)
    tmp19 = tmp16 + tmp18
    tmp20 = tmp9 - tmp14
    tmp21 = tl_math.exp(tmp20)
    tmp22 = tmp19 + tmp21
    tmp23 = tmp13 - tmp14
    tmp24 = tl_math.exp(tmp23)
    tmp25 = tmp22 + tmp24
    tl.store(out_ptr0 + (x2), tmp14, xmask)
    tl.store(out_ptr1 + (x2), tmp25, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_9/inductor_cache/ec/cecsiupxfmmb3m5bbivf5bciiq2k5ishu3qab2b2u6oieray7t5b.py
# Topologically Sorted Source Nodes: [mul_1], Original ATen: [aten.mul]
# Source node to ATen node mapping:
#   mul_1 => mul_1
# Graph fragment:
#   %mul_1 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%unsqueeze, %view_1), kwargs = {})
triton_poi_fused_mul_2 = async_compile.triton('triton_poi_fused_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=[1024], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '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_mul_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, '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_mul_2(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x4 = (xindex // 4)
    x5 = (xindex // 4) % 64
    x7 = (xindex // 16)
    x8 = xindex % 256
    x9 = xindex
    tmp0 = tl.load(in_ptr0 + (x4), xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (x5), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + (x7), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr3 + (x7), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr4 + (x8), xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 - tmp3
    tmp5 = tl_math.exp(tmp4)
    tmp7 = tmp5 / tmp6
    tmp9 = tmp7 * tmp8
    tl.store(out_ptr0 + (x9), tmp9, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_9/inductor_cache/pk/cpky4ikacz2hgolxoehy6foq57gecnbejjobg6du4jubou3tbafn.py
# Topologically Sorted Source Nodes: [mul, utter_rep, mul_2, sum_2, pow_1, sub, add_1, variance], Original ATen: [aten.mul, aten.sum, aten.pow, aten.sub, aten.add, aten.sqrt]
# Source node to ATen node mapping:
#   add_1 => add_1
#   mul => mul
#   mul_2 => mul_2
#   pow_1 => pow_1
#   sub => sub_1
#   sum_2 => sum_3
#   utter_rep => sum_2
#   variance => sqrt
# Graph fragment:
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_1, %unsqueeze), kwargs = {})
#   %sum_2 : [num_users=3] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul, [1]), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%mul_1, %view_1), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul_2, [1]), kwargs = {})
#   %pow_1 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_2, 2), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sum_3, %pow_1), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%sub_1, 1e-08), kwargs = {})
#   %sqrt : [num_users=2] = call_function[target=torch.ops.aten.sqrt.default](args = (%add_1,), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Scalar](args = (%sqrt, 2), kwargs = {})
#   %pow_2 : [num_users=1] = call_function[target=torch.ops.aten.pow.Tensor_Scalar](args = (%sum_2, 1.0), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Scalar](args = (%pow_2, 2.0), kwargs = {})
triton_poi_fused_add_mul_pow_sqrt_sub_sum_3 = async_compile.triton('triton_poi_fused_add_mul_pow_sqrt_sub_sum_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: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '*fp32', 8: '*fp32', 9: '*fp32', 10: '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, 8, 9, 10), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_mul_pow_sqrt_sub_sum_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 24, '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_pow_sqrt_sub_sum_3(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, out_ptr0, out_ptr2, out_ptr3, out_ptr4, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x6 = xindex % 64
    x3 = (xindex // 64)
    x4 = (xindex // 4) % 16
    x2 = (xindex // 16) % 4
    x0 = xindex % 4
    x5 = (xindex // 4)
    x8 = xindex
    tmp0 = tl.load(in_ptr0 + (x6), xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (x4 + (64*x3)), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr2 + (x4), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr3 + (x2 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr4 + (x2 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr0 + (64 + x6), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr1 + (16 + x4 + (64*x3)), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr2 + (16 + x4), xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr3 + (4 + x2 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp17 = tl.load(in_ptr4 + (4 + x2 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp21 = tl.load(in_ptr0 + (128 + x6), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (32 + x4 + (64*x3)), xmask, eviction_policy='evict_last')
    tmp23 = tl.load(in_ptr2 + (32 + x4), xmask, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr3 + (8 + x2 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp28 = tl.load(in_ptr4 + (8 + x2 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp32 = tl.load(in_ptr0 + (192 + x6), xmask, eviction_policy='evict_last')
    tmp33 = tl.load(in_ptr1 + (48 + x4 + (64*x3)), xmask, eviction_policy='evict_last')
    tmp34 = tl.load(in_ptr2 + (48 + x4), xmask, eviction_policy='evict_last')
    tmp36 = tl.load(in_ptr3 + (12 + x2 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp39 = tl.load(in_ptr4 + (12 + x2 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp43 = tl.load(in_ptr5 + (x6 + (256*x3)), xmask)
    tmp45 = tl.load(in_ptr5 + (64 + x6 + (256*x3)), xmask)
    tmp48 = tl.load(in_ptr5 + (128 + x6 + (256*x3)), xmask)
    tmp51 = tl.load(in_ptr5 + (192 + x6 + (256*x3)), xmask)
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 - tmp4
    tmp6 = tl_math.exp(tmp5)
    tmp8 = tmp6 / tmp7
    tmp9 = tmp0 * tmp8
    tmp13 = tmp11 + tmp12
    tmp15 = tmp13 - tmp14
    tmp16 = tl_math.exp(tmp15)
    tmp18 = tmp16 / tmp17
    tmp19 = tmp10 * tmp18
    tmp20 = tmp9 + tmp19
    tmp24 = tmp22 + tmp23
    tmp26 = tmp24 - tmp25
    tmp27 = tl_math.exp(tmp26)
    tmp29 = tmp27 / tmp28
    tmp30 = tmp21 * tmp29
    tmp31 = tmp20 + tmp30
    tmp35 = tmp33 + tmp34
    tmp37 = tmp35 - tmp36
    tmp38 = tl_math.exp(tmp37)
    tmp40 = tmp38 / tmp39
    tmp41 = tmp32 * tmp40
    tmp42 = tmp31 + tmp41
    tmp44 = tmp43 * tmp0
    tmp46 = tmp45 * tmp10
    tmp47 = tmp44 + tmp46
    tmp49 = tmp48 * tmp21
    tmp50 = tmp47 + tmp49
    tmp52 = tmp51 * tmp32
    tmp53 = tmp50 + tmp52
    tmp54 = tmp42 * tmp42
    tmp55 = tmp53 - tmp54
    tmp56 = 1e-08
    tmp57 = tmp55 + tmp56
    tmp58 = libdevice.sqrt(tmp57)
    tmp59 = 2.0
    tmp60 = tmp58 * tmp59
    tmp61 = tmp42 * tmp59
    tl.store(out_ptr0 + (x0 + (8*x5)), tmp42, xmask)
    tl.store(out_ptr2 + (x0 + (8*x5)), tmp58, xmask)
    tl.store(out_ptr3 + (x8), tmp60, xmask)
    tl.store(out_ptr4 + (x8), tmp61, 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 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4, ), (1, ))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (4, 4), (4, 1))
    assert_size_stride(primals_5, (4, ), (1, ))
    assert_size_stride(primals_6, (1, 4), (4, 1))
    assert_size_stride(primals_7, (1, ), (1, ))
    assert_size_stride(primals_8, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [feature_BxTxH], Original ATen: [aten.addmm]
        extern_kernels.addmm(primals_2, reinterpret_tensor(primals_3, (64, 4), (4, 1), 0), reinterpret_tensor(primals_1, (4, 4), (1, 4), 0), alpha=1, beta=1, out=buf0)
        del primals_1
        del primals_2
        buf1 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(buf0, reinterpret_tensor(primals_4, (4, 4), (1, 4), 0), out=buf1)
        buf2 = reinterpret_tensor(buf1, (4, 4, 4, 4), (64, 16, 4, 1), 0); del buf1  # reuse
        buf14 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        # Topologically Sorted Source Nodes: [relu], Original ATen: [aten.relu, aten.threshold_backward]
        stream0 = get_raw_stream(0)
        triton_poi_fused_relu_threshold_backward_0.run(buf2, primals_5, buf14, 256, grid=grid(256), stream=stream0)
        del primals_5
        buf4 = empty_strided_cuda((64, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [linear_2], Original ATen: [aten.addmm]
        extern_kernels.addmm(primals_7, reinterpret_tensor(buf2, (64, 4), (4, 1), 0), reinterpret_tensor(primals_6, (4, 1), (1, 4), 0), alpha=1, beta=1, out=buf4)
        del primals_7
        buf5 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf6 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        # Topologically Sorted Source Nodes: [att_logits_1, softmax], Original ATen: [aten.add, aten._softmax]
        triton_poi_fused__softmax_add_1.run(primals_8, buf4, buf5, buf6, 64, grid=grid(64), stream=stream0)
        buf8 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [mul_1], Original ATen: [aten.mul]
        triton_poi_fused_mul_2.run(primals_8, buf4, buf5, buf6, buf0, buf8, 1024, grid=grid(1024), stream=stream0)
        buf11 = empty_strided_cuda((4, 4, 4, 8), (128, 32, 8, 1), torch.float32)
        buf7 = reinterpret_tensor(buf11, (4, 4, 4, 4), (128, 32, 8, 1), 0)  # alias
        buf10 = reinterpret_tensor(buf11, (4, 4, 4, 4), (128, 32, 8, 1), 4)  # alias
        buf12 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        buf13 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [mul, utter_rep, mul_2, sum_2, pow_1, sub, add_1, variance], Original ATen: [aten.mul, aten.sum, aten.pow, aten.sub, aten.add, aten.sqrt]
        triton_poi_fused_add_mul_pow_sqrt_sub_sum_3.run(buf0, primals_8, buf4, buf5, buf6, buf8, buf7, buf10, buf12, buf13, 256, grid=grid(256), stream=stream0)
        del buf5
        del buf6
    return (buf11, primals_8, reinterpret_tensor(primals_3, (64, 4), (4, 1), 0), buf0, reinterpret_tensor(buf2, (64, 4), (4, 1), 0), buf4, buf8, buf12, buf13, primals_6, buf14, 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((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, ), (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((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((1, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_7 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_8 = 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])
    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 import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
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_relu_threshold_backward_0(in_out_ptr0, 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
    x2 = xindex
    x0 = xindex % 4
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(in_out_ptr0 + x2, tmp4, xmask)
    tl.store(out_ptr0 + x2, tmp6, xmask)


@triton.jit
def triton_poi_fused__softmax_add_1(in_ptr0, in_ptr1, out_ptr0, out_ptr1,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 16
    tmp0 = tl.load(in_ptr0 + 4 * x2, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (1 + 4 * x2), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (2 + 4 * x2), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr1 + (2 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (3 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr1 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp6 = triton_helpers.maximum(tmp2, tmp5)
    tmp9 = tmp7 + tmp8
    tmp10 = triton_helpers.maximum(tmp6, tmp9)
    tmp13 = tmp11 + tmp12
    tmp14 = triton_helpers.maximum(tmp10, tmp13)
    tmp15 = tmp2 - tmp14
    tmp16 = tl_math.exp(tmp15)
    tmp17 = tmp5 - tmp14
    tmp18 = tl_math.exp(tmp17)
    tmp19 = tmp16 + tmp18
    tmp20 = tmp9 - tmp14
    tmp21 = tl_math.exp(tmp20)
    tmp22 = tmp19 + tmp21
    tmp23 = tmp13 - tmp14
    tmp24 = tl_math.exp(tmp23)
    tmp25 = tmp22 + tmp24
    tl.store(out_ptr0 + x2, tmp14, xmask)
    tl.store(out_ptr1 + x2, tmp25, xmask)


@triton.jit
def triton_poi_fused_mul_2(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x4 = xindex // 4
    x5 = xindex // 4 % 64
    x7 = xindex // 16
    x8 = xindex % 256
    x9 = xindex
    tmp0 = tl.load(in_ptr0 + x4, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + x5, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x7, xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr3 + x7, xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr4 + x8, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 - tmp3
    tmp5 = tl_math.exp(tmp4)
    tmp7 = tmp5 / tmp6
    tmp9 = tmp7 * tmp8
    tl.store(out_ptr0 + x9, tmp9, xmask)


@triton.jit
def triton_poi_fused_add_mul_pow_sqrt_sub_sum_3(in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, in_ptr5, out_ptr0, out_ptr2, out_ptr3, out_ptr4,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x6 = xindex % 64
    x3 = xindex // 64
    x4 = xindex // 4 % 16
    x2 = xindex // 16 % 4
    x0 = xindex % 4
    x5 = xindex // 4
    x8 = xindex
    tmp0 = tl.load(in_ptr0 + x6, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (x4 + 64 * x3), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr2 + x4, xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr3 + (x2 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp7 = tl.load(in_ptr4 + (x2 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp10 = tl.load(in_ptr0 + (64 + x6), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr1 + (16 + x4 + 64 * x3), xmask, eviction_policy=
        'evict_last')
    tmp12 = tl.load(in_ptr2 + (16 + x4), xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr3 + (4 + x2 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp17 = tl.load(in_ptr4 + (4 + x2 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp21 = tl.load(in_ptr0 + (128 + x6), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (32 + x4 + 64 * x3), xmask, eviction_policy=
        'evict_last')
    tmp23 = tl.load(in_ptr2 + (32 + x4), xmask, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr3 + (8 + x2 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp28 = tl.load(in_ptr4 + (8 + x2 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp32 = tl.load(in_ptr0 + (192 + x6), xmask, eviction_policy='evict_last')
    tmp33 = tl.load(in_ptr1 + (48 + x4 + 64 * x3), xmask, eviction_policy=
        'evict_last')
    tmp34 = tl.load(in_ptr2 + (48 + x4), xmask, eviction_policy='evict_last')
    tmp36 = tl.load(in_ptr3 + (12 + x2 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp39 = tl.load(in_ptr4 + (12 + x2 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp43 = tl.load(in_ptr5 + (x6 + 256 * x3), xmask)
    tmp45 = tl.load(in_ptr5 + (64 + x6 + 256 * x3), xmask)
    tmp48 = tl.load(in_ptr5 + (128 + x6 + 256 * x3), xmask)
    tmp51 = tl.load(in_ptr5 + (192 + x6 + 256 * x3), xmask)
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 - tmp4
    tmp6 = tl_math.exp(tmp5)
    tmp8 = tmp6 / tmp7
    tmp9 = tmp0 * tmp8
    tmp13 = tmp11 + tmp12
    tmp15 = tmp13 - tmp14
    tmp16 = tl_math.exp(tmp15)
    tmp18 = tmp16 / tmp17
    tmp19 = tmp10 * tmp18
    tmp20 = tmp9 + tmp19
    tmp24 = tmp22 + tmp23
    tmp26 = tmp24 - tmp25
    tmp27 = tl_math.exp(tmp26)
    tmp29 = tmp27 / tmp28
    tmp30 = tmp21 * tmp29
    tmp31 = tmp20 + tmp30
    tmp35 = tmp33 + tmp34
    tmp37 = tmp35 - tmp36
    tmp38 = tl_math.exp(tmp37)
    tmp40 = tmp38 / tmp39
    tmp41 = tmp32 * tmp40
    tmp42 = tmp31 + tmp41
    tmp44 = tmp43 * tmp0
    tmp46 = tmp45 * tmp10
    tmp47 = tmp44 + tmp46
    tmp49 = tmp48 * tmp21
    tmp50 = tmp47 + tmp49
    tmp52 = tmp51 * tmp32
    tmp53 = tmp50 + tmp52
    tmp54 = tmp42 * tmp42
    tmp55 = tmp53 - tmp54
    tmp56 = 1e-08
    tmp57 = tmp55 + tmp56
    tmp58 = libdevice.sqrt(tmp57)
    tmp59 = 2.0
    tmp60 = tmp58 * tmp59
    tmp61 = tmp42 * tmp59
    tl.store(out_ptr0 + (x0 + 8 * x5), tmp42, xmask)
    tl.store(out_ptr2 + (x0 + 8 * x5), tmp58, xmask)
    tl.store(out_ptr3 + x8, tmp60, xmask)
    tl.store(out_ptr4 + x8, tmp61, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4,), (1,))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (4, 4), (4, 1))
    assert_size_stride(primals_5, (4,), (1,))
    assert_size_stride(primals_6, (1, 4), (4, 1))
    assert_size_stride(primals_7, (1,), (1,))
    assert_size_stride(primals_8, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_2, reinterpret_tensor(primals_3, (64, 
            4), (4, 1), 0), reinterpret_tensor(primals_1, (4, 4), (1, 4), 0
            ), alpha=1, beta=1, out=buf0)
        del primals_1
        del primals_2
        buf1 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.mm(buf0, reinterpret_tensor(primals_4, (4, 4), (1, 4
            ), 0), out=buf1)
        buf2 = reinterpret_tensor(buf1, (4, 4, 4, 4), (64, 16, 4, 1), 0)
        del buf1
        buf14 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        get_raw_stream(0)
        triton_poi_fused_relu_threshold_backward_0[grid(256)](buf2,
            primals_5, buf14, 256, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_5
        buf4 = empty_strided_cuda((64, 1), (1, 1), torch.float32)
        extern_kernels.addmm(primals_7, reinterpret_tensor(buf2, (64, 4), (
            4, 1), 0), reinterpret_tensor(primals_6, (4, 1), (1, 4), 0),
            alpha=1, beta=1, out=buf4)
        del primals_7
        buf5 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf6 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        triton_poi_fused__softmax_add_1[grid(64)](primals_8, buf4, buf5,
            buf6, 64, XBLOCK=64, num_warps=1, num_stages=1)
        buf8 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1),
            torch.float32)
        triton_poi_fused_mul_2[grid(1024)](primals_8, buf4, buf5, buf6,
            buf0, buf8, 1024, XBLOCK=256, num_warps=4, num_stages=1)
        buf11 = empty_strided_cuda((4, 4, 4, 8), (128, 32, 8, 1), torch.float32
            )
        buf7 = reinterpret_tensor(buf11, (4, 4, 4, 4), (128, 32, 8, 1), 0)
        buf10 = reinterpret_tensor(buf11, (4, 4, 4, 4), (128, 32, 8, 1), 4)
        buf12 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        buf13 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_add_mul_pow_sqrt_sub_sum_3[grid(256)](buf0,
            primals_8, buf4, buf5, buf6, buf8, buf7, buf10, buf12, buf13, 
            256, XBLOCK=128, num_warps=4, num_stages=1)
        del buf5
        del buf6
    return buf11, primals_8, reinterpret_tensor(primals_3, (64, 4), (4, 1), 0
        ), buf0, reinterpret_tensor(buf2, (64, 4), (4, 1), 0
        ), buf4, buf8, buf12, buf13, primals_6, buf14, primals_4


class AttentivePooling(nn.Module):
    """
    Implementation of Attentive Pooling 
    """

    def __init__(self, input_dim, **kwargs):
        super(AttentivePooling, self).__init__()
        self.W_a = nn.Linear(input_dim, input_dim)
        self.W = nn.Linear(input_dim, 1)
        self.act_fn = nn.ReLU()
        self.softmax = nn.functional.softmax

    def forward(self, batch_rep, att_mask):
        """
        input:
        batch_rep : size (B, T, H), B: batch size, T: sequence length, H: Hidden dimension
        
        attention_weight:
        att_w : size (B, T, 1)
        
        return:
        utter_rep: size (B, H)
        """
        att_logits = self.W(self.act_fn(self.W_a(batch_rep))).squeeze(-1)
        att_logits = att_mask + att_logits
        att_w = self.softmax(att_logits, dim=-1).unsqueeze(-1)
        utter_rep = torch.sum(batch_rep * att_w, dim=1)
        return utter_rep, att_w


class ASPNew(nn.Module):
    """ Attentive Statistic Pooling module incoporate attention mask"""

    def __init__(self, out_dim, input_dim):
        super(ASPNew, self).__init__()
        self.linear = nn.Linear(input_dim, out_dim)
        self.ap_layer = AttentivePooling(out_dim)

    def forward(self, input_0, input_1):
        primals_1 = self.linear.weight
        primals_2 = self.linear.bias
        primals_4 = self.ap_layer.W_a.weight
        primals_5 = self.ap_layer.W_a.bias
        primals_6 = self.ap_layer.W.weight
        primals_7 = self.ap_layer.W.bias
        primals_3 = input_0
        primals_8 = input_1
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8])
        return output[0]
