# AOT ID: ['0_inference']
from ctypes import c_void_p, c_long, c_int
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align
from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_7/inductor_cache/dy/cdywar5f2qbebbyurn5rszzhljo5u65dfph3ymyaygqb5uojqv63.py
# Topologically Sorted Source Nodes: [sub, mul_1, mul_2, window_sum, mul_3, iadd, mul_4, iadd_1, sub_1, mul_5, mul_6, window_sum_1, mul_7, iadd_2], Original ATen: [aten.rsub, aten.mul, aten.add]
# Source node to ATen node mapping:
#   iadd => add_1
#   iadd_1 => add_2
#   iadd_2 => add_4
#   mul_1 => mul_1
#   mul_2 => mul_2
#   mul_3 => mul_3
#   mul_4 => mul_4
#   mul_5 => mul_5
#   mul_6 => mul_6
#   mul_7 => mul_7
#   sub => sub
#   sub_1 => sub_1
#   window_sum => add
#   window_sum_1 => add_3
# Graph fragment:
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %select_9), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_4, %select_5), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_6, %select_7), kwargs = {})
#   %add : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_1, %mul_2), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub, %add), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_10, %mul_3), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_16, %add), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_17, %mul_4), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %select_27), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_22, %select_23), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_24, %select_25), kwargs = {})
#   %add_3 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_5, %mul_6), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_1, %add_3), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_28, %mul_7), kwargs = {})
triton_poi_fused_add_mul_rsub_0 = async_compile.triton('triton_poi_fused_add_mul_rsub_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: '*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_add_mul_rsub_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 7, '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_rsub_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, out_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x1 = (xindex // 16)
    x2 = xindex
    tmp2 = tl.load(in_ptr0 + (x0 + (64*x1)), xmask)
    tmp3 = tl.load(in_ptr1 + (x0 + (64*x1)), xmask)
    tmp7 = tl.load(in_ptr2 + (16 + x0 + (64*x1)), xmask)
    tmp10 = tl.load(in_ptr1 + (16 + x0 + (64*x1)), xmask)
    tmp12 = tl.load(in_ptr0 + (16 + x0 + (64*x1)), xmask)
    tmp28 = tl.load(in_ptr2 + (32 + x0 + (64*x1)), xmask)
    tmp31 = tl.load(in_ptr0 + (32 + x0 + (64*x1)), xmask)
    tmp0 = tl.full([1], 0, tl.int32)
    tmp1 = tmp0 == tmp0
    tmp4 = tmp2 * tmp3
    tmp5 = 0.0
    tmp6 = tl.where(tmp1, tmp4, tmp5)
    tmp8 = 1.0
    tmp9 = tmp8 - tmp7
    tmp11 = tmp2 * tmp10
    tmp13 = tmp12 * tmp3
    tmp14 = tmp11 + tmp13
    tmp15 = tmp9 * tmp14
    tmp16 = tmp6 + tmp15
    tmp17 = tl.full([1], 1, tl.int32)
    tmp18 = tmp17 == tmp0
    tmp19 = tl.where(tmp1, tmp16, tmp6)
    tmp20 = tl.where(tmp18, tmp4, tmp5)
    tmp21 = tl.where(tmp18, tmp16, tmp20)
    tmp22 = tl.where(tmp18, tmp19, tmp21)
    tmp23 = tmp7 * tmp14
    tmp24 = tmp22 + tmp23
    tmp25 = tmp17 == tmp17
    tmp26 = tl.where(tmp25, tmp24, tmp22)
    tmp27 = tl.where(tmp25, tmp26, tmp26)
    tmp29 = tmp8 - tmp28
    tmp30 = tmp12 * tmp10
    tmp32 = tmp31 * tmp3
    tmp33 = tmp30 + tmp32
    tmp34 = tmp29 * tmp33
    tmp35 = tmp27 + tmp34
    tl.store(out_ptr0 + (x2), tmp16, xmask)
    tl.store(out_ptr1 + (x2), tmp24, xmask)
    tl.store(out_ptr2 + (x2), tmp35, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/dv/cdvw7g4pu7def2jdmmzxz4e4yjzerbtzs7oje4vnx3ldumq52twz.py
# Topologically Sorted Source Nodes: [new_a_t, mul, setitem, sub, mul_1, mul_2, window_sum, mul_3, iadd, mul_4, iadd_1, sub_1, mul_5, mul_6, window_sum_1, mul_7, iadd_2], Original ATen: [aten.zeros_like, aten.mul, aten.copy, aten.rsub, aten.add]
# Source node to ATen node mapping:
#   iadd => add_1
#   iadd_1 => add_2
#   iadd_2 => add_4
#   mul => mul
#   mul_1 => mul_1
#   mul_2 => mul_2
#   mul_3 => mul_3
#   mul_4 => mul_4
#   mul_5 => mul_5
#   mul_6 => mul_6
#   mul_7 => mul_7
#   new_a_t => full_default
#   setitem => copy
#   sub => sub
#   sub_1 => sub_1
#   window_sum => add
#   window_sum_1 => add_3
# Graph fragment:
#   %full_default : [num_users=2] = call_function[target=torch.ops.aten.full.default](args = ([4, 4, 4, 4], 0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select, %select_1), kwargs = {})
#   %copy : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_2, %mul), kwargs = {})
#   %select_scatter_default : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%full_default, %copy, 1, 0), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %select_9), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_4, %select_5), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_6, %select_7), kwargs = {})
#   %add : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_1, %mul_2), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub, %add), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_10, %mul_3), kwargs = {})
#   %select_scatter_default_1 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default, %add_1, 1, 0), kwargs = {})
#   %select_scatter_default_2 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_1, %select_11, 1, 0), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_16, %add), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_17, %mul_4), kwargs = {})
#   %select_scatter_default_3 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_2, %add_2, 1, 1), kwargs = {})
#   %select_scatter_default_4 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_3, %select_18, 1, 1), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %select_27), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_22, %select_23), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_24, %select_25), kwargs = {})
#   %add_3 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_5, %mul_6), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_1, %add_3), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_28, %mul_7), kwargs = {})
#   %select_scatter_default_5 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_4, %add_4, 1, 1), kwargs = {})
triton_poi_fused_add_copy_mul_rsub_zeros_like_1 = async_compile.triton('triton_poi_fused_add_copy_mul_rsub_zeros_like_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=[256], 
    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_add_copy_mul_rsub_zeros_like_1', '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_add_copy_mul_rsub_zeros_like_1(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 16) % 4
    x0 = xindex % 16
    x2 = (xindex // 64)
    x3 = xindex
    tmp3 = tl.load(in_ptr0 + (x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr1 + (x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr2 + (x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr3 + (x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr4 + (x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 1, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tmp1 == tmp1
    tmp6 = tl.full([1], 0, tl.int32)
    tmp7 = tmp1 == tmp6
    tmp8 = tmp6 == tmp6
    tmp12 = tmp10 * tmp11
    tmp13 = 0.0
    tmp14 = tl.where(tmp8, tmp12, tmp13)
    tmp15 = tl.where(tmp8, tmp9, tmp14)
    tmp16 = tl.where(tmp7, tmp12, tmp13)
    tmp17 = tl.where(tmp7, tmp9, tmp16)
    tmp18 = tl.where(tmp7, tmp15, tmp17)
    tmp19 = tl.where(tmp4, tmp5, tmp18)
    tmp20 = tmp0 == tmp6
    tmp21 = tl.where(tmp20, tmp12, tmp13)
    tmp22 = tl.where(tmp20, tmp9, tmp21)
    tmp23 = tl.where(tmp20, tmp15, tmp22)
    tmp24 = tl.where(tmp2, tmp5, tmp23)
    tmp25 = tl.where(tmp2, tmp19, tmp24)
    tmp26 = tl.where(tmp2, tmp3, tmp25)
    tl.store(out_ptr0 + (x3), tmp26, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/ia/ciaqv7khfe2u6g2y2vumclczfppaivga7hm2o63swy6qvfkcgh7o.py
# Topologically Sorted Source Nodes: [mul_5, mul_6, window_sum_1, mul_8, iadd_3, sub_2, mul_9, mul_10, window_sum_2, mul_11, iadd_4], Original ATen: [aten.mul, aten.add, aten.rsub]
# Source node to ATen node mapping:
#   iadd_3 => add_5
#   iadd_4 => add_7
#   mul_10 => mul_10
#   mul_11 => mul_11
#   mul_5 => mul_5
#   mul_6 => mul_6
#   mul_8 => mul_8
#   mul_9 => mul_9
#   sub_2 => sub_2
#   window_sum_1 => add_3
#   window_sum_2 => add_6
# Graph fragment:
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_22, %select_23), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_24, %select_25), kwargs = {})
#   %add_3 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_5, %mul_6), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_34, %add_3), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_35, %mul_8), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %select_45), kwargs = {})
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_40, %select_41), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_42, %select_43), kwargs = {})
#   %add_6 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_9, %mul_10), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_2, %add_6), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_46, %mul_11), kwargs = {})
triton_poi_fused_add_mul_rsub_2 = async_compile.triton('triton_poi_fused_add_mul_rsub_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=[64], 
    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_add_mul_rsub_2', '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_add_mul_rsub_2(in_ptr0, in_ptr1, in_ptr2, in_ptr3, 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
    x0 = xindex % 16
    x1 = (xindex // 16)
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (16 + x0 + (64*x1)), xmask)
    tmp4 = tl.load(in_ptr0 + (32 + x0 + (64*x1)), xmask)
    tmp6 = tl.load(in_ptr1 + (32 + x0 + (64*x1)), xmask)
    tmp7 = tl.load(in_ptr2 + (16 + x0 + (64*x1)), xmask)
    tmp8 = tl.load(in_ptr3 + (16 + x0 + (64*x1)), xmask)
    tmp10 = tl.load(in_ptr2 + (32 + x0 + (64*x1)), xmask)
    tmp11 = tl.load(in_ptr3 + (x0 + (64*x1)), xmask)
    tmp19 = tl.load(in_ptr1 + (48 + x0 + (64*x1)), xmask)
    tmp23 = tl.load(in_ptr2 + (48 + x0 + (64*x1)), xmask)
    tmp0 = tl.full([1], 2, tl.int32)
    tmp1 = tl.full([1], 1, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp9 = tmp7 * tmp8
    tmp12 = tmp10 * tmp11
    tmp13 = tmp9 + tmp12
    tmp14 = tmp6 * tmp13
    tmp15 = tmp5 + tmp14
    tmp16 = tmp0 == tmp0
    tmp17 = tl.where(tmp16, tmp15, tmp5)
    tmp18 = tl.where(tmp16, tmp17, tmp17)
    tmp20 = 1.0
    tmp21 = tmp20 - tmp19
    tmp22 = tmp10 * tmp8
    tmp24 = tmp23 * tmp11
    tmp25 = tmp22 + tmp24
    tmp26 = tmp21 * tmp25
    tmp27 = tmp18 + tmp26
    tl.store(out_ptr0 + (x2), tmp15, xmask)
    tl.store(out_ptr1 + (x2), tmp27, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/er/ceriofu2zhtxm7aqm3yj4d6qycbg7x75pnsxq35gsdvylurnfpyh.py
# Topologically Sorted Source Nodes: [mul_5, mul_6, window_sum_1, mul_8, iadd_3, sub_2, mul_9, mul_10, window_sum_2, mul_11, iadd_4], Original ATen: [aten.mul, aten.add, aten.rsub]
# Source node to ATen node mapping:
#   iadd_3 => add_5
#   iadd_4 => add_7
#   mul_10 => mul_10
#   mul_11 => mul_11
#   mul_5 => mul_5
#   mul_6 => mul_6
#   mul_8 => mul_8
#   mul_9 => mul_9
#   sub_2 => sub_2
#   window_sum_1 => add_3
#   window_sum_2 => add_6
# Graph fragment:
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_22, %select_23), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_24, %select_25), kwargs = {})
#   %add_3 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_5, %mul_6), kwargs = {})
#   %select_scatter_default_6 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_5, %select_29, 1, 1), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_34, %add_3), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_35, %mul_8), kwargs = {})
#   %select_scatter_default_7 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_6, %add_5, 1, 2), kwargs = {})
#   %select_scatter_default_8 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_7, %select_36, 1, 2), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %select_45), kwargs = {})
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_40, %select_41), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_42, %select_43), kwargs = {})
#   %add_6 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_9, %mul_10), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_2, %add_6), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_46, %mul_11), kwargs = {})
#   %select_scatter_default_9 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_8, %add_7, 1, 2), kwargs = {})
triton_poi_fused_add_mul_rsub_3 = async_compile.triton('triton_poi_fused_add_mul_rsub_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: '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_rsub_3', '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_add_mul_rsub_3(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 16) % 4
    x0 = xindex % 16
    x2 = (xindex // 64)
    x3 = xindex
    tmp3 = tl.load(in_ptr0 + (x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr1 + (x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr2 + (16 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr2 + (32 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr2 + (x3), xmask)
    tmp0 = x1
    tmp1 = tl.full([1], 2, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tmp1 == tmp1
    tmp6 = tl.full([1], 1, tl.int32)
    tmp7 = tmp1 == tmp6
    tmp10 = tl.where(tmp7, tmp8, tmp9)
    tmp11 = tl.where(tmp4, tmp5, tmp10)
    tmp12 = tmp0 == tmp6
    tmp14 = tl.where(tmp12, tmp8, tmp13)
    tmp15 = tl.where(tmp2, tmp5, tmp14)
    tmp16 = tl.where(tmp2, tmp11, tmp15)
    tmp17 = tl.where(tmp2, tmp3, tmp16)
    tl.store(out_ptr0 + (x3), tmp17, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/mk/cmk7mrommckkrg5z25aq3zipqmjbxe2bchw4m64rr5ku6dzmcueg.py
# Topologically Sorted Source Nodes: [mul_9, mul_10, window_sum_2, mul_12, iadd_5], Original ATen: [aten.mul, aten.add]
# Source node to ATen node mapping:
#   iadd_5 => add_8
#   mul_10 => mul_10
#   mul_12 => mul_12
#   mul_9 => mul_9
#   window_sum_2 => add_6
# Graph fragment:
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_40, %select_41), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_42, %select_43), kwargs = {})
#   %add_6 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_9, %mul_10), kwargs = {})
#   %mul_12 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_52, %add_6), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_53, %mul_12), kwargs = {})
triton_poi_fused_add_mul_4 = async_compile.triton('triton_poi_fused_add_mul_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: '*fp32', 5: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_mul_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 7, '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_4(in_ptr0, in_ptr1, in_ptr2, in_ptr3, 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 % 16
    x1 = (xindex // 16)
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (32 + x0 + (64*x1)), xmask)
    tmp4 = tl.load(in_ptr0 + (48 + x0 + (64*x1)), xmask)
    tmp6 = tl.load(in_ptr1 + (48 + x0 + (64*x1)), xmask)
    tmp7 = tl.load(in_ptr2 + (32 + x0 + (64*x1)), xmask)
    tmp8 = tl.load(in_ptr3 + (16 + x0 + (64*x1)), xmask)
    tmp10 = tl.load(in_ptr2 + (48 + x0 + (64*x1)), xmask)
    tmp11 = tl.load(in_ptr3 + (x0 + (64*x1)), xmask)
    tmp0 = tl.full([1], 3, tl.int32)
    tmp1 = tl.full([1], 2, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp9 = tmp7 * tmp8
    tmp12 = tmp10 * tmp11
    tmp13 = tmp9 + tmp12
    tmp14 = tmp6 * tmp13
    tmp15 = tmp5 + tmp14
    tl.store(out_ptr0 + (x2), tmp15, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/h5/ch5tiq6ditp5yqht3zxkasv6xqovjhvu4pmv5ors3tz3ritkr76x.py
# Topologically Sorted Source Nodes: [matmul], Original ATen: [aten.clone]
# Source node to ATen node mapping:
#   matmul => clone
# Graph fragment:
#   %clone : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%expand_1,), kwargs = {memory_format: torch.contiguous_format})
triton_poi_fused_clone_5 = async_compile.triton('triton_poi_fused_clone_5', '''
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: '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_clone_5', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_clone_5(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 16) % 4
    x0 = xindex % 16
    x3 = (xindex // 256)
    x5 = xindex % 64
    x6 = xindex
    tmp4 = tl.load(in_ptr0 + (x0 + (16*x3)), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr1 + (32 + x0 + (64*x3)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr1 + (48 + x0 + (64*x3)), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr1 + (x5 + (64*x3)), xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 3, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp3 = tmp1 == tmp1
    tmp5 = tl.full([1], 2, tl.int32)
    tmp6 = tmp1 == tmp5
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tl.where(tmp3, tmp4, tmp9)
    tmp11 = tmp0 == tmp5
    tmp13 = tl.where(tmp11, tmp7, tmp12)
    tmp14 = tl.where(tmp2, tmp4, tmp13)
    tmp15 = tl.where(tmp2, tmp10, tmp14)
    tl.store(out_ptr0 + (x6), tmp15, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/pj/cpjqksgptaxzhklsg2nw3g6rpbi6fdthhy77vrczeivw5ngyma4h.py
# Topologically Sorted Source Nodes: [matmul], Original ATen: [aten.clone]
# Source node to ATen node mapping:
#   matmul => clone_1
# Graph fragment:
#   %clone_1 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%expand_2,), kwargs = {memory_format: torch.contiguous_format})
triton_poi_fused_clone_6 = async_compile.triton('triton_poi_fused_clone_6', '''
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: '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_clone_6', '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_clone_6(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 256
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0), xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2), tmp0, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/kf/ckfqusnxtqjza2ghpvyoopa42p6nercy7ddhs2apo322ea5jnvak.py
# Topologically Sorted Source Nodes: [mul_9, mul_10, window_sum_2, mul_12, iadd_5], Original ATen: [aten.mul, aten.add]
# Source node to ATen node mapping:
#   iadd_5 => add_8
#   mul_10 => mul_10
#   mul_12 => mul_12
#   mul_9 => mul_9
#   window_sum_2 => add_6
# Graph fragment:
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_40, %select_41), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_42, %select_43), kwargs = {})
#   %add_6 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_9, %mul_10), kwargs = {})
#   %select_scatter_default_10 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_9, %select_47, 1, 2), kwargs = {})
#   %mul_12 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%select_52, %add_6), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_53, %mul_12), kwargs = {})
#   %select_scatter_default_11 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_10, %add_8, 1, 3), kwargs = {})
#   %select_scatter_default_12 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_11, %select_54, 1, 3), kwargs = {})
triton_poi_fused_add_mul_7 = async_compile.triton('triton_poi_fused_add_mul_7', '''
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_add_mul_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_mul_7(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
    x1 = (xindex // 16) % 4
    x0 = xindex % 16
    x2 = (xindex // 64)
    x3 = xindex
    tmp4 = tl.load(in_ptr0 + (x0 + (16*x2)), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr1 + (32 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr1 + (48 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr1 + (x3), xmask)
    tmp0 = x1
    tmp1 = tl.full([1], 3, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp3 = tmp1 == tmp1
    tmp5 = tl.full([1], 2, tl.int32)
    tmp6 = tmp1 == tmp5
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tl.where(tmp3, tmp4, tmp9)
    tmp11 = tmp0 == tmp5
    tmp13 = tl.where(tmp11, tmp7, tmp12)
    tmp14 = tl.where(tmp2, tmp4, tmp13)
    tmp15 = tl.where(tmp2, tmp10, tmp14)
    tl.store(out_ptr0 + (x3), tmp15, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg2_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg3_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        buf1 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        buf2 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [sub, mul_1, mul_2, window_sum, mul_3, iadd, mul_4, iadd_1, sub_1, mul_5, mul_6, window_sum_1, mul_7, iadd_2], Original ATen: [aten.rsub, aten.mul, aten.add]
        stream0 = get_raw_stream(0)
        triton_poi_fused_add_mul_rsub_0.run(arg0_1, arg1_1, arg2_1, buf0, buf1, buf2, 64, grid=grid(64), stream=stream0)
        buf3 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [new_a_t, mul, setitem, sub, mul_1, mul_2, window_sum, mul_3, iadd, mul_4, iadd_1, sub_1, mul_5, mul_6, window_sum_1, mul_7, iadd_2], Original ATen: [aten.zeros_like, aten.mul, aten.copy, aten.rsub, aten.add]
        triton_poi_fused_add_copy_mul_rsub_zeros_like_1.run(buf2, buf1, buf0, arg0_1, arg1_1, buf3, 256, grid=grid(256), stream=stream0)
        del buf0
        buf4 = buf2; del buf2  # reuse
        buf5 = buf1; del buf1  # reuse
        # Topologically Sorted Source Nodes: [mul_5, mul_6, window_sum_1, mul_8, iadd_3, sub_2, mul_9, mul_10, window_sum_2, mul_11, iadd_4], Original ATen: [aten.mul, aten.add, aten.rsub]
        triton_poi_fused_add_mul_rsub_2.run(buf3, arg2_1, arg0_1, arg1_1, buf4, buf5, 64, grid=grid(64), stream=stream0)
        buf6 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [mul_5, mul_6, window_sum_1, mul_8, iadd_3, sub_2, mul_9, mul_10, window_sum_2, mul_11, iadd_4], Original ATen: [aten.mul, aten.add, aten.rsub]
        triton_poi_fused_add_mul_rsub_3.run(buf5, buf4, buf3, buf6, 256, grid=grid(256), stream=stream0)
        del buf4
        buf7 = buf5; del buf5  # reuse
        # Topologically Sorted Source Nodes: [mul_9, mul_10, window_sum_2, mul_12, iadd_5], Original ATen: [aten.mul, aten.add]
        triton_poi_fused_add_mul_4.run(buf6, arg2_1, arg0_1, arg1_1, buf7, 64, grid=grid(64), stream=stream0)
        del arg0_1
        del arg1_1
        del arg2_1
        buf8 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [matmul], Original ATen: [aten.clone]
        triton_poi_fused_clone_5.run(buf7, buf6, buf8, 1024, grid=grid(1024), stream=stream0)
        buf9 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [matmul], Original ATen: [aten.clone]
        triton_poi_fused_clone_6.run(arg3_1, buf9, 1024, grid=grid(1024), stream=stream0)
        del arg3_1
        buf10 = empty_strided_cuda((64, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [matmul], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf8, (64, 4, 4), (16, 4, 1), 0), reinterpret_tensor(buf9, (64, 4, 4), (16, 4, 1), 0), out=buf10)
        del buf8
        del buf9
        buf11 = buf3; del buf3  # reuse
        # Topologically Sorted Source Nodes: [mul_9, mul_10, window_sum_2, mul_12, iadd_5], Original ATen: [aten.mul, aten.add]
        triton_poi_fused_add_mul_7.run(buf7, buf6, buf11, 256, grid=grid(256), stream=stream0)
        del buf6
        del buf7
    return (reinterpret_tensor(buf10, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1), 0), buf11, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    arg0_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg2_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg3_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_1, arg2_1, arg3_1])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

import torch
import torch.nn as nn


class StateAttention(nn.Module):

    def __init__(self):
        super(StateAttention, self).__init__()
        self.sm = nn.Softmax(dim=1)

    def forward(self, a_t, r_t, input_embedding, padded_mask):
        new_a_t = torch.zeros_like(a_t)
        for i in range(a_t.shape[1]):
            if i == 0:
                new_a_t[:, i] = a_t[:, 0] * r_t[:, 0]
            else:
                window = a_t[:, i - 1:i + 1]
                window_sum = window[:, 0] * r_t[:, 1] + window[:, 1] * r_t[:, 0
                    ]
                new_a_t[:, i - 1] += (1 - padded_mask[:, i]) * window_sum
                new_a_t[:, i] += padded_mask[:, i] * window_sum
        new_a_t = new_a_t.unsqueeze(dim=1)
        output = torch.matmul(new_a_t, input_embedding).squeeze(dim=1)
        return output, new_a_t.squeeze(dim=1)


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


def get_init_inputs():
    return [[], {}]

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
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_add_mul_rsub_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0,
    out_ptr1, out_ptr2, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x1 = xindex // 16
    x2 = xindex
    tmp2 = tl.load(in_ptr0 + (x0 + 64 * x1), xmask)
    tmp3 = tl.load(in_ptr1 + (x0 + 64 * x1), xmask)
    tmp7 = tl.load(in_ptr2 + (16 + x0 + 64 * x1), xmask)
    tmp10 = tl.load(in_ptr1 + (16 + x0 + 64 * x1), xmask)
    tmp12 = tl.load(in_ptr0 + (16 + x0 + 64 * x1), xmask)
    tmp28 = tl.load(in_ptr2 + (32 + x0 + 64 * x1), xmask)
    tmp31 = tl.load(in_ptr0 + (32 + x0 + 64 * x1), xmask)
    tmp0 = tl.full([1], 0, tl.int32)
    tmp1 = tmp0 == tmp0
    tmp4 = tmp2 * tmp3
    tmp5 = 0.0
    tmp6 = tl.where(tmp1, tmp4, tmp5)
    tmp8 = 1.0
    tmp9 = tmp8 - tmp7
    tmp11 = tmp2 * tmp10
    tmp13 = tmp12 * tmp3
    tmp14 = tmp11 + tmp13
    tmp15 = tmp9 * tmp14
    tmp16 = tmp6 + tmp15
    tmp17 = tl.full([1], 1, tl.int32)
    tmp18 = tmp17 == tmp0
    tmp19 = tl.where(tmp1, tmp16, tmp6)
    tmp20 = tl.where(tmp18, tmp4, tmp5)
    tmp21 = tl.where(tmp18, tmp16, tmp20)
    tmp22 = tl.where(tmp18, tmp19, tmp21)
    tmp23 = tmp7 * tmp14
    tmp24 = tmp22 + tmp23
    tmp25 = tmp17 == tmp17
    tmp26 = tl.where(tmp25, tmp24, tmp22)
    tmp27 = tl.where(tmp25, tmp26, tmp26)
    tmp29 = tmp8 - tmp28
    tmp30 = tmp12 * tmp10
    tmp32 = tmp31 * tmp3
    tmp33 = tmp30 + tmp32
    tmp34 = tmp29 * tmp33
    tmp35 = tmp27 + tmp34
    tl.store(out_ptr0 + x2, tmp16, xmask)
    tl.store(out_ptr1 + x2, tmp24, xmask)
    tl.store(out_ptr2 + x2, tmp35, xmask)


@triton.jit
def triton_poi_fused_add_copy_mul_rsub_zeros_like_1(in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16 % 4
    x0 = xindex % 16
    x2 = xindex // 64
    x3 = xindex
    tmp3 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp5 = tl.load(in_ptr1 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr2 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp10 = tl.load(in_ptr3 + (x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp11 = tl.load(in_ptr4 + (x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 1, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tmp1 == tmp1
    tmp6 = tl.full([1], 0, tl.int32)
    tmp7 = tmp1 == tmp6
    tmp8 = tmp6 == tmp6
    tmp12 = tmp10 * tmp11
    tmp13 = 0.0
    tmp14 = tl.where(tmp8, tmp12, tmp13)
    tmp15 = tl.where(tmp8, tmp9, tmp14)
    tmp16 = tl.where(tmp7, tmp12, tmp13)
    tmp17 = tl.where(tmp7, tmp9, tmp16)
    tmp18 = tl.where(tmp7, tmp15, tmp17)
    tmp19 = tl.where(tmp4, tmp5, tmp18)
    tmp20 = tmp0 == tmp6
    tmp21 = tl.where(tmp20, tmp12, tmp13)
    tmp22 = tl.where(tmp20, tmp9, tmp21)
    tmp23 = tl.where(tmp20, tmp15, tmp22)
    tmp24 = tl.where(tmp2, tmp5, tmp23)
    tmp25 = tl.where(tmp2, tmp19, tmp24)
    tmp26 = tl.where(tmp2, tmp3, tmp25)
    tl.store(out_ptr0 + x3, tmp26, xmask)


@triton.jit
def triton_poi_fused_add_mul_rsub_2(in_ptr0, in_ptr1, in_ptr2, in_ptr3,
    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
    x0 = xindex % 16
    x1 = xindex // 16
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (16 + x0 + 64 * x1), xmask)
    tmp4 = tl.load(in_ptr0 + (32 + x0 + 64 * x1), xmask)
    tmp6 = tl.load(in_ptr1 + (32 + x0 + 64 * x1), xmask)
    tmp7 = tl.load(in_ptr2 + (16 + x0 + 64 * x1), xmask)
    tmp8 = tl.load(in_ptr3 + (16 + x0 + 64 * x1), xmask)
    tmp10 = tl.load(in_ptr2 + (32 + x0 + 64 * x1), xmask)
    tmp11 = tl.load(in_ptr3 + (x0 + 64 * x1), xmask)
    tmp19 = tl.load(in_ptr1 + (48 + x0 + 64 * x1), xmask)
    tmp23 = tl.load(in_ptr2 + (48 + x0 + 64 * x1), xmask)
    tmp0 = tl.full([1], 2, tl.int32)
    tmp1 = tl.full([1], 1, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp9 = tmp7 * tmp8
    tmp12 = tmp10 * tmp11
    tmp13 = tmp9 + tmp12
    tmp14 = tmp6 * tmp13
    tmp15 = tmp5 + tmp14
    tmp16 = tmp0 == tmp0
    tmp17 = tl.where(tmp16, tmp15, tmp5)
    tmp18 = tl.where(tmp16, tmp17, tmp17)
    tmp20 = 1.0
    tmp21 = tmp20 - tmp19
    tmp22 = tmp10 * tmp8
    tmp24 = tmp23 * tmp11
    tmp25 = tmp22 + tmp24
    tmp26 = tmp21 * tmp25
    tmp27 = tmp18 + tmp26
    tl.store(out_ptr0 + x2, tmp15, xmask)
    tl.store(out_ptr1 + x2, tmp27, xmask)


@triton.jit
def triton_poi_fused_add_mul_rsub_3(in_ptr0, in_ptr1, in_ptr2, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16 % 4
    x0 = xindex % 16
    x2 = xindex // 64
    x3 = xindex
    tmp3 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp5 = tl.load(in_ptr1 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp8 = tl.load(in_ptr2 + (16 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr2 + (32 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp13 = tl.load(in_ptr2 + x3, xmask)
    tmp0 = x1
    tmp1 = tl.full([1], 2, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tmp1 == tmp1
    tmp6 = tl.full([1], 1, tl.int32)
    tmp7 = tmp1 == tmp6
    tmp10 = tl.where(tmp7, tmp8, tmp9)
    tmp11 = tl.where(tmp4, tmp5, tmp10)
    tmp12 = tmp0 == tmp6
    tmp14 = tl.where(tmp12, tmp8, tmp13)
    tmp15 = tl.where(tmp2, tmp5, tmp14)
    tmp16 = tl.where(tmp2, tmp11, tmp15)
    tmp17 = tl.where(tmp2, tmp3, tmp16)
    tl.store(out_ptr0 + x3, tmp17, xmask)


@triton.jit
def triton_poi_fused_add_mul_4(in_ptr0, in_ptr1, in_ptr2, in_ptr3, 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 % 16
    x1 = xindex // 16
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (32 + x0 + 64 * x1), xmask)
    tmp4 = tl.load(in_ptr0 + (48 + x0 + 64 * x1), xmask)
    tmp6 = tl.load(in_ptr1 + (48 + x0 + 64 * x1), xmask)
    tmp7 = tl.load(in_ptr2 + (32 + x0 + 64 * x1), xmask)
    tmp8 = tl.load(in_ptr3 + (16 + x0 + 64 * x1), xmask)
    tmp10 = tl.load(in_ptr2 + (48 + x0 + 64 * x1), xmask)
    tmp11 = tl.load(in_ptr3 + (x0 + 64 * x1), xmask)
    tmp0 = tl.full([1], 3, tl.int32)
    tmp1 = tl.full([1], 2, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp9 = tmp7 * tmp8
    tmp12 = tmp10 * tmp11
    tmp13 = tmp9 + tmp12
    tmp14 = tmp6 * tmp13
    tmp15 = tmp5 + tmp14
    tl.store(out_ptr0 + x2, tmp15, xmask)


@triton.jit
def triton_poi_fused_clone_5(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16 % 4
    x0 = xindex % 16
    x3 = xindex // 256
    x5 = xindex % 64
    x6 = xindex
    tmp4 = tl.load(in_ptr0 + (x0 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp7 = tl.load(in_ptr1 + (32 + x0 + 64 * x3), xmask, eviction_policy=
        'evict_last')
    tmp8 = tl.load(in_ptr1 + (48 + x0 + 64 * x3), xmask, eviction_policy=
        'evict_last')
    tmp12 = tl.load(in_ptr1 + (x5 + 64 * x3), xmask, eviction_policy=
        'evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 3, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp3 = tmp1 == tmp1
    tmp5 = tl.full([1], 2, tl.int32)
    tmp6 = tmp1 == tmp5
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tl.where(tmp3, tmp4, tmp9)
    tmp11 = tmp0 == tmp5
    tmp13 = tl.where(tmp11, tmp7, tmp12)
    tmp14 = tl.where(tmp2, tmp4, tmp13)
    tmp15 = tl.where(tmp2, tmp10, tmp14)
    tl.store(out_ptr0 + x6, tmp15, xmask)


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


@triton.jit
def triton_poi_fused_add_mul_7(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
    x1 = xindex // 16 % 4
    x0 = xindex % 16
    x2 = xindex // 64
    x3 = xindex
    tmp4 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp7 = tl.load(in_ptr1 + (32 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp8 = tl.load(in_ptr1 + (48 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp12 = tl.load(in_ptr1 + x3, xmask)
    tmp0 = x1
    tmp1 = tl.full([1], 3, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp3 = tmp1 == tmp1
    tmp5 = tl.full([1], 2, tl.int32)
    tmp6 = tmp1 == tmp5
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tl.where(tmp3, tmp4, tmp9)
    tmp11 = tmp0 == tmp5
    tmp13 = tl.where(tmp11, tmp7, tmp12)
    tmp14 = tl.where(tmp2, tmp4, tmp13)
    tmp15 = tl.where(tmp2, tmp10, tmp14)
    tl.store(out_ptr0 + x3, tmp15, xmask)


def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg2_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg3_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        buf1 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        buf2 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_add_mul_rsub_0[grid(64)](arg0_1, arg1_1, arg2_1,
            buf0, buf1, buf2, 64, XBLOCK=64, num_warps=1, num_stages=1)
        buf3 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_add_copy_mul_rsub_zeros_like_1[grid(256)](buf2,
            buf1, buf0, arg0_1, arg1_1, buf3, 256, XBLOCK=256, num_warps=4,
            num_stages=1)
        del buf0
        buf4 = buf2
        del buf2
        buf5 = buf1
        del buf1
        triton_poi_fused_add_mul_rsub_2[grid(64)](buf3, arg2_1, arg0_1,
            arg1_1, buf4, buf5, 64, XBLOCK=64, num_warps=1, num_stages=1)
        buf6 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_add_mul_rsub_3[grid(256)](buf5, buf4, buf3, buf6, 
            256, XBLOCK=256, num_warps=4, num_stages=1)
        del buf4
        buf7 = buf5
        del buf5
        triton_poi_fused_add_mul_4[grid(64)](buf6, arg2_1, arg0_1, arg1_1,
            buf7, 64, XBLOCK=64, num_warps=1, num_stages=1)
        del arg0_1
        del arg1_1
        del arg2_1
        buf8 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1),
            torch.float32)
        triton_poi_fused_clone_5[grid(1024)](buf7, buf6, buf8, 1024, XBLOCK
            =256, num_warps=4, num_stages=1)
        buf9 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1),
            torch.float32)
        triton_poi_fused_clone_6[grid(1024)](arg3_1, buf9, 1024, XBLOCK=256,
            num_warps=4, num_stages=1)
        del arg3_1
        buf10 = empty_strided_cuda((64, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf8, (64, 4, 4), (16, 4, 1),
            0), reinterpret_tensor(buf9, (64, 4, 4), (16, 4, 1), 0), out=buf10)
        del buf8
        del buf9
        buf11 = buf3
        del buf3
        triton_poi_fused_add_mul_7[grid(256)](buf7, buf6, buf11, 256,
            XBLOCK=256, num_warps=4, num_stages=1)
        del buf6
        del buf7
    return reinterpret_tensor(buf10, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1), 0
        ), buf11


class StateAttentionNew(nn.Module):

    def __init__(self):
        super(StateAttentionNew, self).__init__()
        self.sm = nn.Softmax(dim=1)

    def forward(self, input_0, input_1, input_2, input_3):
        arg0_1 = input_0
        arg1_1 = input_1
        arg2_1 = input_2
        arg3_1 = input_3
        output = call([arg0_1, arg1_1, arg2_1, arg3_1])
        return output[0], output[1]
