# 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_8/inductor_cache/fh/cfhnguw4v6uy4ysjg54ojclakwi3bj2lte6oqizl4rpf4lcxpiyp.py
# Topologically Sorted Source Nodes: [f_s_1], Original ATen: [aten.div]
# Source node to ATen node mapping:
#   f_s_1 => div
# Graph fragment:
#   %div : [num_users=8] = call_function[target=torch.ops.aten.div.Tensor](args = (%select, %expand), kwargs = {})
triton_poi_fused_div_0 = async_compile.triton('triton_poi_fused_div_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: '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_div_0', '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_div_0(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
    x3 = xindex
    x0 = xindex % 16
    x2 = (xindex // 64)
    tmp0 = tl.load(in_ptr0 + (x3), xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (16 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (32 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (48 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + (x3), tmp15, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/vb/cvbckpx36pmi43pm4nuhmb6mk2i2izcpcwp6w2mt4dtyxosapprc.py
# Topologically Sorted Source Nodes: [f_s_3], Original ATen: [aten.div]
# Source node to ATen node mapping:
#   f_s_3 => div_6
# Graph fragment:
#   %div_6 : [num_users=8] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_1, %expand_4), kwargs = {})
triton_poi_fused_div_1 = async_compile.triton('triton_poi_fused_div_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: '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_div_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_div_1(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
    x3 = xindex
    x0 = xindex % 16
    x2 = (xindex // 64)
    tmp0 = tl.load(in_ptr0 + (256 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (256 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (272 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (288 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (304 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + (x3), tmp15, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/gx/cgxjobnzpzl5xuw5yvex6rq6zcbzjr3ccnjs2perkcswcbvp6qmi.py
# Topologically Sorted Source Nodes: [f_s_5], Original ATen: [aten.div]
# Source node to ATen node mapping:
#   f_s_5 => div_12
# Graph fragment:
#   %div_12 : [num_users=8] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_2, %expand_8), kwargs = {})
triton_poi_fused_div_2 = async_compile.triton('triton_poi_fused_div_2', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_div_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_div_2(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = (xindex // 64)
    tmp0 = tl.load(in_ptr0 + (512 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (512 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (528 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (544 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (560 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + (x3), tmp15, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/n2/cn2spcpuvudmkpvrlw2achoyo7v7k2vktctfincso3dyfom5oz4x.py
# Topologically Sorted Source Nodes: [f_s_7], Original ATen: [aten.div]
# Source node to ATen node mapping:
#   f_s_7 => div_18
# Graph fragment:
#   %div_18 : [num_users=8] = call_function[target=torch.ops.aten.div.Tensor](args = (%select_3, %expand_12), kwargs = {})
triton_poi_fused_div_3 = async_compile.triton('triton_poi_fused_div_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: '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_div_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_div_3(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
    x3 = xindex
    x0 = xindex % 16
    x2 = (xindex // 64)
    tmp0 = tl.load(in_ptr0 + (768 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (768 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (784 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (800 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (816 + x0 + (64*x2)), xmask, eviction_policy='evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + (x3), tmp15, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/4m/c4m2wk5rzhradyfdzzmfqu2fhq5ceu6npmbjot6ovfl5pvukl5cw.py
# Topologically Sorted Source Nodes: [energy_new], Original ATen: [aten.sub]
# Source node to ATen node mapping:
#   energy_new => sub_3
# Graph fragment:
#   %sub_3 : [num_users=2] = call_function[target=torch.ops.aten.sub.Tensor](args = (%expand_2, %bmm_4), kwargs = {})
triton_poi_fused_sub_4 = async_compile.triton('triton_poi_fused_sub_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: '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_sub_4', '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_sub_4(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
    x1 = (xindex // 4)
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (4*x1), xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (2 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (3 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + (x2), xmask)
    tmp2 = triton_helpers.maximum(tmp0, tmp1)
    tmp4 = triton_helpers.maximum(tmp2, tmp3)
    tmp6 = triton_helpers.maximum(tmp4, tmp5)
    tmp8 = tmp6 - tmp7
    tl.store(out_ptr0 + (x2), tmp8, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/j7/cj7mv2k5l2kigfluq2rwwpouckm4oow7jia7wwvjogp3qlr23xwv.py
# Topologically Sorted Source Nodes: [attention_2], Original ATen: [aten._softmax]
# Source node to ATen node mapping:
#   attention_2 => amax_2, exp_2, sub_4
# Graph fragment:
#   %amax_2 : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%sub_3, [-1], True), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_3, %amax_2), kwargs = {})
#   %exp_2 : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%sub_4,), kwargs = {})
triton_poi_fused__softmax_5 = async_compile.triton('triton_poi_fused__softmax_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=[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__softmax_5', '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__softmax_5(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
    x2 = xindex
    x1 = (xindex // 4)
    tmp0 = tl.load(in_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr0 + (4*x1), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (2 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (3 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp3 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tmp9 = tl_math.exp(tmp8)
    tl.store(out_ptr0 + (x2), tmp9, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/b4/cb4vdtviarmy2ckmxjdkc3dnwp4gssl3dh4u4col3s2illvdpvql.py
# Topologically Sorted Source Nodes: [attention_2], Original ATen: [aten._softmax]
# Source node to ATen node mapping:
#   attention_2 => div_4, sum_5
# Graph fragment:
#   %sum_5 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp_2, [-1], True), kwargs = {})
#   %div_4 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%exp_2, %sum_5), kwargs = {})
triton_poi_fused__softmax_6 = async_compile.triton('triton_poi_fused__softmax_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=[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__softmax_6', '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__softmax_6(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
    x2 = xindex
    x1 = (xindex // 4)
    tmp0 = tl.load(in_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr0 + (4*x1), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (2 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (3 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + (x2), tmp8, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/ps/cpsrn3vzizx4kiw2ao7vdniku66p6jnqllxcgsuag4wnndz4qytq.py
# Topologically Sorted Source Nodes: [attention], Original ATen: [aten._softmax]
# Source node to ATen node mapping:
#   attention => amax, div_2, exp, sub, sum_3
# Graph fragment:
#   %amax : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%bmm, [-1], True), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%bmm, %amax), kwargs = {})
#   %exp : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%sub,), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp, [-1], True), kwargs = {})
#   %div_2 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%exp, %sum_3), kwargs = {})
triton_per_fused__softmax_7 = async_compile.triton('triton_per_fused__softmax_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.persistent_reduction(
    size_hints=[64, 16],
    reduction_hint=ReductionHint.INNER,
    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, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__softmax_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 2, '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}
)
@triton.jit
def triton_per_fused__softmax_7(in_ptr0, out_ptr2, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    rnumel = 16
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + (16*x0)), xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, float("-inf"))
    tmp4 = triton_helpers.max2(tmp3, 1)[:, None]
    tmp5 = tmp0 - tmp4
    tmp6 = tl_math.exp(tmp5)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK, RBLOCK])
    tmp9 = tl.where(xmask, tmp7, 0)
    tmp10 = tl.sum(tmp9, 1)[:, None]
    tmp11 = tmp6 / tmp10
    tl.store(out_ptr2 + (r1 + (16*x0)), tmp11, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_8/inductor_cache/2r/c2rthu53scnzgesjbiparrgvjr27o2yifa3oqcdcu5hbzqwmf3wx.py
# Topologically Sorted Source Nodes: [mul_2, out_8, mul_3, out_11, ca_loss, mul, out_2, mul_1, out_5, sa_loss, add_4, add_20, mul_6, out_20, mul_7, out_23, ca_loss_1, mul_4, out_14, mul_5, out_17, sa_loss_1, add_9, add_21, mul_10, out_32, mul_11, out_35, ca_loss_2, mul_8, out_26, mul_9, out_29, sa_loss_2, add_14, add_22, mul_14, out_44, mul_15, out_47, ca_loss_3, mul_12, out_38, mul_13, out_41, sa_loss_3, add_19, add_23], Original ATen: [aten.mul, aten.add, aten.sub, aten.abs, aten.mean]
# Source node to ATen node mapping:
#   add_14 => add_14
#   add_19 => add_19
#   add_20 => add_20
#   add_21 => add_21
#   add_22 => add_22
#   add_23 => add_23
#   add_4 => add_4
#   add_9 => add_9
#   ca_loss => abs_2, mean_1, sub_7
#   ca_loss_1 => abs_4, mean_3, sub_15
#   ca_loss_2 => abs_6, mean_5, sub_23
#   ca_loss_3 => abs_8, mean_7, sub_31
#   mul => mul
#   mul_1 => mul_1
#   mul_10 => mul_10
#   mul_11 => mul_11
#   mul_12 => mul_12
#   mul_13 => mul_13
#   mul_14 => mul_14
#   mul_15 => mul_15
#   mul_2 => mul_2
#   mul_3 => mul_3
#   mul_4 => mul_4
#   mul_5 => mul_5
#   mul_6 => mul_6
#   mul_7 => mul_7
#   mul_8 => mul_8
#   mul_9 => mul_9
#   out_11 => add_3
#   out_14 => add_5
#   out_17 => add_6
#   out_2 => add
#   out_20 => add_7
#   out_23 => add_8
#   out_26 => add_10
#   out_29 => add_11
#   out_32 => add_12
#   out_35 => add_13
#   out_38 => add_15
#   out_41 => add_16
#   out_44 => add_17
#   out_47 => add_18
#   out_5 => add_1
#   out_8 => add_2
#   sa_loss => abs_1, mean, sub_2
#   sa_loss_1 => abs_3, mean_2, sub_10
#   sa_loss_2 => abs_5, mean_4, sub_18
#   sa_loss_3 => abs_7, mean_6, sub_26
# Graph fragment:
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_11, 0.1), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_2, %div), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_15, 0.1), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_3, %div_1), kwargs = {})
#   %sub_7 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_2, %add_3), kwargs = {})
#   %abs_2 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_7,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_2,), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_3, 0.1), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul, %div), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_7, 0.1), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_1, %div_1), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add, %add_1), kwargs = {})
#   %abs_1 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_2,), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_1,), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mean_1, %mean), kwargs = {})
#   %add_20 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_4, 0), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_27, 0.1), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_6, %div_6), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_31, 0.1), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_7, %div_7), kwargs = {})
#   %sub_15 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_7, %add_8), kwargs = {})
#   %abs_4 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_15,), kwargs = {})
#   %mean_3 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_4,), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_19, 0.1), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_4, %div_6), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_23, 0.1), kwargs = {})
#   %add_6 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_5, %div_7), kwargs = {})
#   %sub_10 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_5, %add_6), kwargs = {})
#   %abs_3 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_10,), kwargs = {})
#   %mean_2 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_3,), kwargs = {})
#   %add_9 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mean_3, %mean_2), kwargs = {})
#   %add_21 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_20, %add_9), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_43, 0.1), kwargs = {})
#   %add_12 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_10, %div_12), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_47, 0.1), kwargs = {})
#   %add_13 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_11, %div_13), kwargs = {})
#   %sub_23 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_12, %add_13), kwargs = {})
#   %abs_6 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_23,), kwargs = {})
#   %mean_5 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_6,), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_35, 0.1), kwargs = {})
#   %add_10 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_8, %div_12), kwargs = {})
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_39, 0.1), kwargs = {})
#   %add_11 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_9, %div_13), kwargs = {})
#   %sub_18 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_10, %add_11), kwargs = {})
#   %abs_5 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_18,), kwargs = {})
#   %mean_4 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_5,), kwargs = {})
#   %add_14 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mean_5, %mean_4), kwargs = {})
#   %add_22 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_21, %add_14), kwargs = {})
#   %mul_14 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_59, 0.1), kwargs = {})
#   %add_17 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_14, %div_18), kwargs = {})
#   %mul_15 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_63, 0.1), kwargs = {})
#   %add_18 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_15, %div_19), kwargs = {})
#   %sub_31 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_17, %add_18), kwargs = {})
#   %abs_8 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_31,), kwargs = {})
#   %mean_7 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_8,), kwargs = {})
#   %mul_12 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_51, 0.1), kwargs = {})
#   %add_15 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_12, %div_18), kwargs = {})
#   %mul_13 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_55, 0.1), kwargs = {})
#   %add_16 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_13, %div_19), kwargs = {})
#   %sub_26 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_15, %add_16), kwargs = {})
#   %abs_7 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_26,), kwargs = {})
#   %mean_6 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_7,), kwargs = {})
#   %add_19 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mean_7, %mean_6), kwargs = {})
#   %add_23 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_22, %add_19), kwargs = {})
triton_per_fused_abs_add_mean_mul_sub_8 = async_compile.triton('triton_per_fused_abs_add_mean_mul_sub_8', '''
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.persistent_reduction(
    size_hints=[1, 256],
    reduction_hint=ReductionHint.INNER,
    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: '*fp32', 11: '*fp32', 12: '*fp32', 13: '*fp32', 14: '*fp32', 15: '*fp32', 16: '*fp32', 17: '*fp32', 18: '*fp32', 19: '*fp32', 20: '*fp32', 21: '*fp32', 22: '*fp32', 23: '*fp32', 24: '*fp32', 25: 'i32', 26: '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': {25: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26), equal_to_1=(25,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_abs_add_mean_mul_sub_8', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': True, 'num_load': 24, 'num_reduction': 8, '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}
)
@triton.jit
def triton_per_fused_abs_add_mean_mul_sub_8(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, in_ptr8, in_ptr9, in_ptr10, in_ptr11, in_ptr12, in_ptr13, in_ptr14, in_ptr15, in_ptr16, in_ptr17, in_ptr18, in_ptr19, in_ptr20, in_ptr21, in_ptr22, in_ptr23, xnumel, rnumel):
    xnumel = 1
    XBLOCK: tl.constexpr = 1
    rnumel = 256
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    xmask = tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    roffset = 0
    rmask = tl.full([RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (r0), None)
    tmp3 = tl.load(in_ptr1 + (r0), None)
    tmp5 = tl.load(in_ptr2 + (r0), None)
    tmp7 = tl.load(in_ptr3 + (r0), None)
    tmp14 = tl.load(in_ptr4 + (r0), None)
    tmp17 = tl.load(in_ptr5 + (r0), None)
    tmp25 = tl.load(in_ptr6 + (r0), None)
    tmp27 = tl.load(in_ptr7 + (r0), None)
    tmp29 = tl.load(in_ptr8 + (r0), None)
    tmp31 = tl.load(in_ptr9 + (r0), None)
    tmp38 = tl.load(in_ptr10 + (r0), None)
    tmp41 = tl.load(in_ptr11 + (r0), None)
    tmp49 = tl.load(in_ptr12 + (r0), None)
    tmp51 = tl.load(in_ptr13 + (r0), None)
    tmp53 = tl.load(in_ptr14 + (r0), None)
    tmp55 = tl.load(in_ptr15 + (r0), None)
    tmp62 = tl.load(in_ptr16 + (r0), None)
    tmp65 = tl.load(in_ptr17 + (r0), None)
    tmp73 = tl.load(in_ptr18 + (r0), None)
    tmp75 = tl.load(in_ptr19 + (r0), None)
    tmp77 = tl.load(in_ptr20 + (r0), None)
    tmp79 = tl.load(in_ptr21 + (r0), None)
    tmp86 = tl.load(in_ptr22 + (r0), None)
    tmp89 = tl.load(in_ptr23 + (r0), None)
    tmp1 = 0.1
    tmp2 = tmp0 * tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp5 * tmp1
    tmp8 = tmp6 + tmp7
    tmp9 = tmp4 - tmp8
    tmp10 = tl_math.abs(tmp9)
    tmp11 = tl.broadcast_to(tmp10, [RBLOCK])
    tmp13 = triton_helpers.promote_to_tensor(tl.sum(tmp11, 0))
    tmp15 = tmp14 * tmp1
    tmp16 = tmp15 + tmp3
    tmp18 = tmp17 * tmp1
    tmp19 = tmp18 + tmp7
    tmp20 = tmp16 - tmp19
    tmp21 = tl_math.abs(tmp20)
    tmp22 = tl.broadcast_to(tmp21, [RBLOCK])
    tmp24 = triton_helpers.promote_to_tensor(tl.sum(tmp22, 0))
    tmp26 = tmp25 * tmp1
    tmp28 = tmp26 + tmp27
    tmp30 = tmp29 * tmp1
    tmp32 = tmp30 + tmp31
    tmp33 = tmp28 - tmp32
    tmp34 = tl_math.abs(tmp33)
    tmp35 = tl.broadcast_to(tmp34, [RBLOCK])
    tmp37 = triton_helpers.promote_to_tensor(tl.sum(tmp35, 0))
    tmp39 = tmp38 * tmp1
    tmp40 = tmp39 + tmp27
    tmp42 = tmp41 * tmp1
    tmp43 = tmp42 + tmp31
    tmp44 = tmp40 - tmp43
    tmp45 = tl_math.abs(tmp44)
    tmp46 = tl.broadcast_to(tmp45, [RBLOCK])
    tmp48 = triton_helpers.promote_to_tensor(tl.sum(tmp46, 0))
    tmp50 = tmp49 * tmp1
    tmp52 = tmp50 + tmp51
    tmp54 = tmp53 * tmp1
    tmp56 = tmp54 + tmp55
    tmp57 = tmp52 - tmp56
    tmp58 = tl_math.abs(tmp57)
    tmp59 = tl.broadcast_to(tmp58, [RBLOCK])
    tmp61 = triton_helpers.promote_to_tensor(tl.sum(tmp59, 0))
    tmp63 = tmp62 * tmp1
    tmp64 = tmp63 + tmp51
    tmp66 = tmp65 * tmp1
    tmp67 = tmp66 + tmp55
    tmp68 = tmp64 - tmp67
    tmp69 = tl_math.abs(tmp68)
    tmp70 = tl.broadcast_to(tmp69, [RBLOCK])
    tmp72 = triton_helpers.promote_to_tensor(tl.sum(tmp70, 0))
    tmp74 = tmp73 * tmp1
    tmp76 = tmp74 + tmp75
    tmp78 = tmp77 * tmp1
    tmp80 = tmp78 + tmp79
    tmp81 = tmp76 - tmp80
    tmp82 = tl_math.abs(tmp81)
    tmp83 = tl.broadcast_to(tmp82, [RBLOCK])
    tmp85 = triton_helpers.promote_to_tensor(tl.sum(tmp83, 0))
    tmp87 = tmp86 * tmp1
    tmp88 = tmp87 + tmp75
    tmp90 = tmp89 * tmp1
    tmp91 = tmp90 + tmp79
    tmp92 = tmp88 - tmp91
    tmp93 = tl_math.abs(tmp92)
    tmp94 = tl.broadcast_to(tmp93, [RBLOCK])
    tmp96 = triton_helpers.promote_to_tensor(tl.sum(tmp94, 0))
    tmp97 = 256.0
    tmp98 = tmp13 / tmp97
    tmp99 = tmp24 / tmp97
    tmp100 = tmp98 + tmp99
    tmp101 = 0.0
    tmp102 = tmp100 + tmp101
    tmp103 = tmp37 / tmp97
    tmp104 = tmp48 / tmp97
    tmp105 = tmp103 + tmp104
    tmp106 = tmp102 + tmp105
    tmp107 = tmp61 / tmp97
    tmp108 = tmp72 / tmp97
    tmp109 = tmp107 + tmp108
    tmp110 = tmp106 + tmp109
    tmp111 = tmp85 / tmp97
    tmp112 = tmp96 / tmp97
    tmp113 = tmp111 + tmp112
    tmp114 = tmp110 + tmp113
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([1], 0, tl.int32)), tmp114, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [f_s_1], Original ATen: [aten.div]
        stream0 = get_raw_stream(0)
        triton_poi_fused_div_0.run(arg0_1, buf0, 256, grid=grid(256), stream=stream0)
        buf1 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_2], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf0, (4, 16, 4), (64, 1, 16), 0), out=buf1)
        buf2 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [f_t_1], Original ATen: [aten.div]
        triton_poi_fused_div_0.run(arg1_1, buf2, 256, grid=grid(256), stream=stream0)
        buf3 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_3], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf2, (4, 16, 4), (64, 1, 16), 0), out=buf3)
        buf4 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [f_s_3], Original ATen: [aten.div]
        triton_poi_fused_div_1.run(arg0_1, buf4, 256, grid=grid(256), stream=stream0)
        buf5 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_6], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf4, (4, 16, 4), (64, 1, 16), 0), out=buf5)
        buf6 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [f_t_3], Original ATen: [aten.div]
        triton_poi_fused_div_1.run(arg1_1, buf6, 256, grid=grid(256), stream=stream0)
        buf7 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_7], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf6, (4, 16, 4), (64, 1, 16), 0), out=buf7)
        buf8 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [f_s_5], Original ATen: [aten.div]
        triton_poi_fused_div_2.run(arg0_1, buf8, 256, grid=grid(256), stream=stream0)
        buf9 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_10], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf8, (4, 16, 4), (64, 1, 16), 0), out=buf9)
        buf10 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [f_t_5], Original ATen: [aten.div]
        triton_poi_fused_div_2.run(arg1_1, buf10, 256, grid=grid(256), stream=stream0)
        buf11 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_11], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf10, (4, 16, 4), (64, 1, 16), 0), out=buf11)
        buf12 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [f_s_7], Original ATen: [aten.div]
        triton_poi_fused_div_3.run(arg0_1, buf12, 256, grid=grid(256), stream=stream0)
        del arg0_1
        buf13 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_14], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf12, (4, 16, 4), (64, 1, 16), 0), out=buf13)
        buf14 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [f_t_7], Original ATen: [aten.div]
        triton_poi_fused_div_3.run(arg1_1, buf14, 256, grid=grid(256), stream=stream0)
        del arg1_1
        buf15 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_15], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf14, (4, 16, 4), (64, 1, 16), 0), out=buf15)
        buf16 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy_new], Original ATen: [aten.sub]
        triton_poi_fused_sub_4.run(buf1, buf16, 64, grid=grid(64), stream=stream0)
        buf17 = buf1; del buf1  # reuse
        # Topologically Sorted Source Nodes: [attention_2], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_5.run(buf16, buf17, 64, grid=grid(64), stream=stream0)
        buf18 = buf16; del buf16  # reuse
        # Topologically Sorted Source Nodes: [attention_2], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_6.run(buf17, buf18, 64, grid=grid(64), stream=stream0)
        del buf17
        buf19 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention_2, out_6], Original ATen: [aten._softmax, aten.bmm]
        extern_kernels.bmm(buf18, reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1), 0), out=buf19)
        buf20 = buf18; del buf18  # reuse
        # Topologically Sorted Source Nodes: [energy_new_1], Original ATen: [aten.sub]
        triton_poi_fused_sub_4.run(buf3, buf20, 64, grid=grid(64), stream=stream0)
        buf21 = buf3; del buf3  # reuse
        # Topologically Sorted Source Nodes: [attention_3], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_5.run(buf20, buf21, 64, grid=grid(64), stream=stream0)
        buf22 = buf20; del buf20  # reuse
        # Topologically Sorted Source Nodes: [attention_3], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_6.run(buf21, buf22, 64, grid=grid(64), stream=stream0)
        del buf21
        buf23 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention_3, out_9], Original ATen: [aten._softmax, aten.bmm]
        extern_kernels.bmm(buf22, reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1), 0), out=buf23)
        buf25 = empty_strided_cuda((4, 16, 16), (256, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [energy], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 16, 4), (64, 1, 16), 0), reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1), 0), out=buf25)
        buf28 = empty_strided_cuda((4, 16, 16), (256, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention], Original ATen: [aten._softmax]
        triton_per_fused__softmax_7.run(buf25, buf28, 64, 16, grid=grid(64), stream=stream0)
        buf29 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf28, (4, 16, 16), (256, 1, 16), 0), out=buf29)
        buf30 = buf28; del buf28  # reuse
        # Topologically Sorted Source Nodes: [energy_1], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 16, 4), (64, 1, 16), 0), reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1), 0), out=buf30)
        buf33 = buf25; del buf25  # reuse
        # Topologically Sorted Source Nodes: [attention_1], Original ATen: [aten._softmax]
        triton_per_fused__softmax_7.run(buf30, buf33, 64, 16, grid=grid(64), stream=stream0)
        buf34 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out_3], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf33, (4, 16, 16), (256, 1, 16), 0), out=buf34)
        buf36 = buf22; del buf22  # reuse
        # Topologically Sorted Source Nodes: [energy_new_2], Original ATen: [aten.sub]
        triton_poi_fused_sub_4.run(buf5, buf36, 64, grid=grid(64), stream=stream0)
        buf37 = buf5; del buf5  # reuse
        # Topologically Sorted Source Nodes: [attention_6], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_5.run(buf36, buf37, 64, grid=grid(64), stream=stream0)
        buf38 = buf36; del buf36  # reuse
        # Topologically Sorted Source Nodes: [attention_6], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_6.run(buf37, buf38, 64, grid=grid(64), stream=stream0)
        del buf37
        buf39 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention_6, out_18], Original ATen: [aten._softmax, aten.bmm]
        extern_kernels.bmm(buf38, reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1), 0), out=buf39)
        buf40 = buf38; del buf38  # reuse
        # Topologically Sorted Source Nodes: [energy_new_3], Original ATen: [aten.sub]
        triton_poi_fused_sub_4.run(buf7, buf40, 64, grid=grid(64), stream=stream0)
        buf41 = buf7; del buf7  # reuse
        # Topologically Sorted Source Nodes: [attention_7], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_5.run(buf40, buf41, 64, grid=grid(64), stream=stream0)
        buf42 = buf40; del buf40  # reuse
        # Topologically Sorted Source Nodes: [attention_7], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_6.run(buf41, buf42, 64, grid=grid(64), stream=stream0)
        del buf41
        buf43 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention_7, out_21], Original ATen: [aten._softmax, aten.bmm]
        extern_kernels.bmm(buf42, reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1), 0), out=buf43)
        buf45 = buf33; del buf33  # reuse
        # Topologically Sorted Source Nodes: [energy_4], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 16, 4), (64, 1, 16), 0), reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1), 0), out=buf45)
        buf48 = buf30; del buf30  # reuse
        # Topologically Sorted Source Nodes: [attention_4], Original ATen: [aten._softmax]
        triton_per_fused__softmax_7.run(buf45, buf48, 64, 16, grid=grid(64), stream=stream0)
        buf49 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out_12], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf48, (4, 16, 16), (256, 1, 16), 0), out=buf49)
        buf50 = buf48; del buf48  # reuse
        # Topologically Sorted Source Nodes: [energy_5], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 16, 4), (64, 1, 16), 0), reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1), 0), out=buf50)
        buf53 = buf45; del buf45  # reuse
        # Topologically Sorted Source Nodes: [attention_5], Original ATen: [aten._softmax]
        triton_per_fused__softmax_7.run(buf50, buf53, 64, 16, grid=grid(64), stream=stream0)
        buf54 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out_15], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf53, (4, 16, 16), (256, 1, 16), 0), out=buf54)
        buf56 = buf42; del buf42  # reuse
        # Topologically Sorted Source Nodes: [energy_new_4], Original ATen: [aten.sub]
        triton_poi_fused_sub_4.run(buf9, buf56, 64, grid=grid(64), stream=stream0)
        buf57 = buf9; del buf9  # reuse
        # Topologically Sorted Source Nodes: [attention_10], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_5.run(buf56, buf57, 64, grid=grid(64), stream=stream0)
        buf58 = buf56; del buf56  # reuse
        # Topologically Sorted Source Nodes: [attention_10], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_6.run(buf57, buf58, 64, grid=grid(64), stream=stream0)
        del buf57
        buf59 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention_10, out_30], Original ATen: [aten._softmax, aten.bmm]
        extern_kernels.bmm(buf58, reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1), 0), out=buf59)
        buf60 = buf58; del buf58  # reuse
        # Topologically Sorted Source Nodes: [energy_new_5], Original ATen: [aten.sub]
        triton_poi_fused_sub_4.run(buf11, buf60, 64, grid=grid(64), stream=stream0)
        buf61 = buf11; del buf11  # reuse
        # Topologically Sorted Source Nodes: [attention_11], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_5.run(buf60, buf61, 64, grid=grid(64), stream=stream0)
        buf62 = buf60; del buf60  # reuse
        # Topologically Sorted Source Nodes: [attention_11], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_6.run(buf61, buf62, 64, grid=grid(64), stream=stream0)
        del buf61
        buf63 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention_11, out_33], Original ATen: [aten._softmax, aten.bmm]
        extern_kernels.bmm(buf62, reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1), 0), out=buf63)
        buf65 = buf53; del buf53  # reuse
        # Topologically Sorted Source Nodes: [energy_8], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 16, 4), (64, 1, 16), 0), reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1), 0), out=buf65)
        buf68 = buf50; del buf50  # reuse
        # Topologically Sorted Source Nodes: [attention_8], Original ATen: [aten._softmax]
        triton_per_fused__softmax_7.run(buf65, buf68, 64, 16, grid=grid(64), stream=stream0)
        buf69 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out_24], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf68, (4, 16, 16), (256, 1, 16), 0), out=buf69)
        buf70 = buf68; del buf68  # reuse
        # Topologically Sorted Source Nodes: [energy_9], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 16, 4), (64, 1, 16), 0), reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1), 0), out=buf70)
        buf73 = buf65; del buf65  # reuse
        # Topologically Sorted Source Nodes: [attention_9], Original ATen: [aten._softmax]
        triton_per_fused__softmax_7.run(buf70, buf73, 64, 16, grid=grid(64), stream=stream0)
        buf74 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out_27], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf73, (4, 16, 16), (256, 1, 16), 0), out=buf74)
        buf76 = buf62; del buf62  # reuse
        # Topologically Sorted Source Nodes: [energy_new_6], Original ATen: [aten.sub]
        triton_poi_fused_sub_4.run(buf13, buf76, 64, grid=grid(64), stream=stream0)
        buf77 = buf13; del buf13  # reuse
        # Topologically Sorted Source Nodes: [attention_14], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_5.run(buf76, buf77, 64, grid=grid(64), stream=stream0)
        buf78 = buf76; del buf76  # reuse
        # Topologically Sorted Source Nodes: [attention_14], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_6.run(buf77, buf78, 64, grid=grid(64), stream=stream0)
        del buf77
        buf79 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention_14, out_42], Original ATen: [aten._softmax, aten.bmm]
        extern_kernels.bmm(buf78, reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1), 0), out=buf79)
        buf80 = buf78; del buf78  # reuse
        # Topologically Sorted Source Nodes: [energy_new_7], Original ATen: [aten.sub]
        triton_poi_fused_sub_4.run(buf15, buf80, 64, grid=grid(64), stream=stream0)
        buf81 = buf15; del buf15  # reuse
        # Topologically Sorted Source Nodes: [attention_15], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_5.run(buf80, buf81, 64, grid=grid(64), stream=stream0)
        buf82 = buf80; del buf80  # reuse
        # Topologically Sorted Source Nodes: [attention_15], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_6.run(buf81, buf82, 64, grid=grid(64), stream=stream0)
        del buf81
        buf83 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention_15, out_45], Original ATen: [aten._softmax, aten.bmm]
        extern_kernels.bmm(buf82, reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1), 0), out=buf83)
        del buf82
        buf85 = buf73; del buf73  # reuse
        # Topologically Sorted Source Nodes: [energy_12], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 16, 4), (64, 1, 16), 0), reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1), 0), out=buf85)
        buf88 = buf70; del buf70  # reuse
        # Topologically Sorted Source Nodes: [attention_12], Original ATen: [aten._softmax]
        triton_per_fused__softmax_7.run(buf85, buf88, 64, 16, grid=grid(64), stream=stream0)
        buf89 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out_36], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf88, (4, 16, 16), (256, 1, 16), 0), out=buf89)
        buf90 = buf88; del buf88  # reuse
        # Topologically Sorted Source Nodes: [energy_13], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 16, 4), (64, 1, 16), 0), reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1), 0), out=buf90)
        buf93 = buf85; del buf85  # reuse
        # Topologically Sorted Source Nodes: [attention_13], Original ATen: [aten._softmax]
        triton_per_fused__softmax_7.run(buf90, buf93, 64, 16, grid=grid(64), stream=stream0)
        del buf90
        buf94 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out_39], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1), 0), reinterpret_tensor(buf93, (4, 16, 16), (256, 1, 16), 0), out=buf94)
        del buf93
        buf24 = empty_strided_cuda((), (), torch.float32)
        buf96 = buf24; del buf24  # reuse
        # Topologically Sorted Source Nodes: [mul_2, out_8, mul_3, out_11, ca_loss, mul, out_2, mul_1, out_5, sa_loss, add_4, add_20, mul_6, out_20, mul_7, out_23, ca_loss_1, mul_4, out_14, mul_5, out_17, sa_loss_1, add_9, add_21, mul_10, out_32, mul_11, out_35, ca_loss_2, mul_8, out_26, mul_9, out_29, sa_loss_2, add_14, add_22, mul_14, out_44, mul_15, out_47, ca_loss_3, mul_12, out_38, mul_13, out_41, sa_loss_3, add_19, add_23], Original ATen: [aten.mul, aten.add, aten.sub, aten.abs, aten.mean]
        triton_per_fused_abs_add_mean_mul_sub_8.run(buf96, buf19, buf0, buf23, buf2, buf29, buf34, buf39, buf4, buf43, buf6, buf49, buf54, buf59, buf8, buf63, buf10, buf69, buf74, buf79, buf12, buf83, buf14, buf89, buf94, 1, 256, grid=grid(1), stream=stream0)
        del buf0
        del buf10
        del buf12
        del buf14
        del buf19
        del buf2
        del buf23
        del buf29
        del buf34
        del buf39
        del buf4
        del buf43
        del buf49
        del buf54
        del buf59
        del buf6
        del buf63
        del buf69
        del buf74
        del buf79
        del buf8
        del buf83
        del buf89
        del buf94
    return (buf96, )


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, 4), (256, 64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((4, 4, 4, 4, 4), (256, 64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_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.functional as F
import torch.nn as nn


class SCRM(nn.Module):
    """
    spatial & channel wise relation loss
    """

    def __init__(self, gamma=0.1):
        super(SCRM, self).__init__()
        self.softmax = nn.Softmax(dim=-1)
        self.gamma = gamma

    def spatial_wise(self, x):
        m_batchsize, C, height, width = x.size()
        proj_query = x.view(m_batchsize, -1, width * height).permute(0, 2, 1)
        proj_key = x.view(m_batchsize, -1, width * height)
        energy = torch.bmm(proj_query, proj_key)
        attention = self.softmax(energy)
        proj_value = x.view(m_batchsize, -1, width * height)
        out = torch.bmm(proj_value, attention.permute(0, 2, 1))
        out = out.view(m_batchsize, C, height, width)
        out = self.gamma * out + x
        return out

    def channel_wise(self, x):
        m_batchsize, C, height, width = x.size()
        proj_query = x.view(m_batchsize, C, -1)
        proj_key = x.view(m_batchsize, C, -1).permute(0, 2, 1)
        energy = torch.bmm(proj_query, proj_key)
        energy_new = torch.max(energy, -1, keepdim=True)[0].expand_as(energy
            ) - energy
        attention = self.softmax(energy_new)
        proj_value = x.view(m_batchsize, C, -1)
        out = torch.bmm(attention, proj_value)
        out = out.view(m_batchsize, C, height, width)
        out = self.gamma * out + x
        return out

    def cal_loss(self, f_s, f_t):
        f_s = F.normalize(f_s, dim=1)
        f_t = F.normalize(f_t, dim=1)
        sa_loss = F.l1_loss(self.spatial_wise(f_s), self.spatial_wise(f_t))
        ca_loss = F.l1_loss(self.channel_wise(f_s), self.channel_wise(f_t))
        return ca_loss + sa_loss

    def forward(self, g_s, g_t):
        return sum(self.cal_loss(f_s, f_t) for f_s, f_t in zip(g_s, g_t))


def get_inputs():
    return [torch.rand([4, 4, 4, 4, 4]), torch.rand([4, 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
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import torch.nn.functional as F
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_div_0(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
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_div_1(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
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + (256 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (256 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (272 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (288 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (304 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_div_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + (512 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (512 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (528 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (544 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (560 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_div_3(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
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + (768 + x3), xmask)
    tmp1 = tl.load(in_ptr0 + (768 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (784 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (800 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (816 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp1 * tmp1
    tmp4 = tmp3 * tmp3
    tmp5 = tmp2 + tmp4
    tmp7 = tmp6 * tmp6
    tmp8 = tmp5 + tmp7
    tmp10 = tmp9 * tmp9
    tmp11 = tmp8 + tmp10
    tmp12 = libdevice.sqrt(tmp11)
    tmp13 = 1e-12
    tmp14 = triton_helpers.maximum(tmp12, tmp13)
    tmp15 = tmp0 / tmp14
    tl.store(out_ptr0 + x3, tmp15, xmask)


@triton.jit
def triton_poi_fused_sub_4(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
    x1 = xindex // 4
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr0 + x2, xmask)
    tmp2 = triton_helpers.maximum(tmp0, tmp1)
    tmp4 = triton_helpers.maximum(tmp2, tmp3)
    tmp6 = triton_helpers.maximum(tmp4, tmp5)
    tmp8 = tmp6 - tmp7
    tl.store(out_ptr0 + x2, tmp8, xmask)


@triton.jit
def triton_poi_fused__softmax_5(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
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp3 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tmp9 = tl_math.exp(tmp8)
    tl.store(out_ptr0 + x2, tmp9, xmask)


@triton.jit
def triton_poi_fused__softmax_6(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
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + x2, tmp8, xmask)


@triton.jit
def triton_per_fused__softmax_7(in_ptr0, out_ptr2, xnumel, rnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 16 * x0), xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, float('-inf'))
    tmp4 = triton_helpers.max2(tmp3, 1)[:, None]
    tmp5 = tmp0 - tmp4
    tmp6 = tl_math.exp(tmp5)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK, RBLOCK])
    tmp9 = tl.where(xmask, tmp7, 0)
    tmp10 = tl.sum(tmp9, 1)[:, None]
    tmp11 = tmp6 / tmp10
    tl.store(out_ptr2 + (r1 + 16 * x0), tmp11, xmask)


@triton.jit
def triton_per_fused_abs_add_mean_mul_sub_8(in_out_ptr0, in_ptr0, in_ptr1,
    in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, in_ptr8, in_ptr9,
    in_ptr10, in_ptr11, in_ptr12, in_ptr13, in_ptr14, in_ptr15, in_ptr16,
    in_ptr17, in_ptr18, in_ptr19, in_ptr20, in_ptr21, in_ptr22, in_ptr23,
    xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp3 = tl.load(in_ptr1 + r0, None)
    tmp5 = tl.load(in_ptr2 + r0, None)
    tmp7 = tl.load(in_ptr3 + r0, None)
    tmp14 = tl.load(in_ptr4 + r0, None)
    tmp17 = tl.load(in_ptr5 + r0, None)
    tmp25 = tl.load(in_ptr6 + r0, None)
    tmp27 = tl.load(in_ptr7 + r0, None)
    tmp29 = tl.load(in_ptr8 + r0, None)
    tmp31 = tl.load(in_ptr9 + r0, None)
    tmp38 = tl.load(in_ptr10 + r0, None)
    tmp41 = tl.load(in_ptr11 + r0, None)
    tmp49 = tl.load(in_ptr12 + r0, None)
    tmp51 = tl.load(in_ptr13 + r0, None)
    tmp53 = tl.load(in_ptr14 + r0, None)
    tmp55 = tl.load(in_ptr15 + r0, None)
    tmp62 = tl.load(in_ptr16 + r0, None)
    tmp65 = tl.load(in_ptr17 + r0, None)
    tmp73 = tl.load(in_ptr18 + r0, None)
    tmp75 = tl.load(in_ptr19 + r0, None)
    tmp77 = tl.load(in_ptr20 + r0, None)
    tmp79 = tl.load(in_ptr21 + r0, None)
    tmp86 = tl.load(in_ptr22 + r0, None)
    tmp89 = tl.load(in_ptr23 + r0, None)
    tmp1 = 0.1
    tmp2 = tmp0 * tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp5 * tmp1
    tmp8 = tmp6 + tmp7
    tmp9 = tmp4 - tmp8
    tmp10 = tl_math.abs(tmp9)
    tmp11 = tl.broadcast_to(tmp10, [RBLOCK])
    tmp13 = triton_helpers.promote_to_tensor(tl.sum(tmp11, 0))
    tmp15 = tmp14 * tmp1
    tmp16 = tmp15 + tmp3
    tmp18 = tmp17 * tmp1
    tmp19 = tmp18 + tmp7
    tmp20 = tmp16 - tmp19
    tmp21 = tl_math.abs(tmp20)
    tmp22 = tl.broadcast_to(tmp21, [RBLOCK])
    tmp24 = triton_helpers.promote_to_tensor(tl.sum(tmp22, 0))
    tmp26 = tmp25 * tmp1
    tmp28 = tmp26 + tmp27
    tmp30 = tmp29 * tmp1
    tmp32 = tmp30 + tmp31
    tmp33 = tmp28 - tmp32
    tmp34 = tl_math.abs(tmp33)
    tmp35 = tl.broadcast_to(tmp34, [RBLOCK])
    tmp37 = triton_helpers.promote_to_tensor(tl.sum(tmp35, 0))
    tmp39 = tmp38 * tmp1
    tmp40 = tmp39 + tmp27
    tmp42 = tmp41 * tmp1
    tmp43 = tmp42 + tmp31
    tmp44 = tmp40 - tmp43
    tmp45 = tl_math.abs(tmp44)
    tmp46 = tl.broadcast_to(tmp45, [RBLOCK])
    tmp48 = triton_helpers.promote_to_tensor(tl.sum(tmp46, 0))
    tmp50 = tmp49 * tmp1
    tmp52 = tmp50 + tmp51
    tmp54 = tmp53 * tmp1
    tmp56 = tmp54 + tmp55
    tmp57 = tmp52 - tmp56
    tmp58 = tl_math.abs(tmp57)
    tmp59 = tl.broadcast_to(tmp58, [RBLOCK])
    tmp61 = triton_helpers.promote_to_tensor(tl.sum(tmp59, 0))
    tmp63 = tmp62 * tmp1
    tmp64 = tmp63 + tmp51
    tmp66 = tmp65 * tmp1
    tmp67 = tmp66 + tmp55
    tmp68 = tmp64 - tmp67
    tmp69 = tl_math.abs(tmp68)
    tmp70 = tl.broadcast_to(tmp69, [RBLOCK])
    tmp72 = triton_helpers.promote_to_tensor(tl.sum(tmp70, 0))
    tmp74 = tmp73 * tmp1
    tmp76 = tmp74 + tmp75
    tmp78 = tmp77 * tmp1
    tmp80 = tmp78 + tmp79
    tmp81 = tmp76 - tmp80
    tmp82 = tl_math.abs(tmp81)
    tmp83 = tl.broadcast_to(tmp82, [RBLOCK])
    tmp85 = triton_helpers.promote_to_tensor(tl.sum(tmp83, 0))
    tmp87 = tmp86 * tmp1
    tmp88 = tmp87 + tmp75
    tmp90 = tmp89 * tmp1
    tmp91 = tmp90 + tmp79
    tmp92 = tmp88 - tmp91
    tmp93 = tl_math.abs(tmp92)
    tmp94 = tl.broadcast_to(tmp93, [RBLOCK])
    tmp96 = triton_helpers.promote_to_tensor(tl.sum(tmp94, 0))
    tmp97 = 256.0
    tmp98 = tmp13 / tmp97
    tmp99 = tmp24 / tmp97
    tmp100 = tmp98 + tmp99
    tmp101 = 0.0
    tmp102 = tmp100 + tmp101
    tmp103 = tmp37 / tmp97
    tmp104 = tmp48 / tmp97
    tmp105 = tmp103 + tmp104
    tmp106 = tmp102 + tmp105
    tmp107 = tmp61 / tmp97
    tmp108 = tmp72 / tmp97
    tmp109 = tmp107 + tmp108
    tmp110 = tmp106 + tmp109
    tmp111 = tmp85 / tmp97
    tmp112 = tmp96 / tmp97
    tmp113 = tmp111 + tmp112
    tmp114 = tmp110 + tmp113
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([1], 0, tl.int32), tmp114, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4, 4), (256, 64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_div_0[grid(256)](arg0_1, buf0, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf1 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf0, (4, 16, 4), (64, 1, 16), 0), out=buf1)
        buf2 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_0[grid(256)](arg1_1, buf2, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf3 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf2, (4, 16, 4), (64, 1, 16), 0), out=buf3)
        buf4 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_1[grid(256)](arg0_1, buf4, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf5 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf4, (4, 16, 4), (64, 1, 16), 0), out=buf5)
        buf6 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_1[grid(256)](arg1_1, buf6, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf7 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf6, (4, 16, 4), (64, 1, 16), 0), out=buf7)
        buf8 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_2[grid(256)](arg0_1, buf8, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf9 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf8, (4, 16, 4), (64, 1, 16), 0), out=buf9)
        buf10 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_2[grid(256)](arg1_1, buf10, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf11 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf10, (4, 16, 4), (64, 1, 16), 0),
            out=buf11)
        buf12 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_3[grid(256)](arg0_1, buf12, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg0_1
        buf13 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf12, (4, 16, 4), (64, 1, 16), 0),
            out=buf13)
        buf14 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_div_3[grid(256)](arg1_1, buf14, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg1_1
        buf15 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf14, (4, 16, 4), (64, 1, 16), 0),
            out=buf15)
        buf16 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_sub_4[grid(64)](buf1, buf16, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf17 = buf1
        del buf1
        triton_poi_fused__softmax_5[grid(64)](buf16, buf17, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf18 = buf16
        del buf16
        triton_poi_fused__softmax_6[grid(64)](buf17, buf18, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf17
        buf19 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf18, reinterpret_tensor(buf0, (4, 4, 16), (64,
            16, 1), 0), out=buf19)
        buf20 = buf18
        del buf18
        triton_poi_fused_sub_4[grid(64)](buf3, buf20, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf21 = buf3
        del buf3
        triton_poi_fused__softmax_5[grid(64)](buf20, buf21, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf22 = buf20
        del buf20
        triton_poi_fused__softmax_6[grid(64)](buf21, buf22, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf21
        buf23 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf22, reinterpret_tensor(buf2, (4, 4, 16), (64,
            16, 1), 0), out=buf23)
        buf25 = empty_strided_cuda((4, 16, 16), (256, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1), 0), out=buf25
            )
        buf28 = empty_strided_cuda((4, 16, 16), (256, 16, 1), torch.float32)
        triton_per_fused__softmax_7[grid(64)](buf25, buf28, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf29 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf0, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf28, (4, 16, 16), (256, 1, 16), 0),
            out=buf29)
        buf30 = buf28
        del buf28
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1), 0), out=buf30
            )
        buf33 = buf25
        del buf25
        triton_per_fused__softmax_7[grid(64)](buf30, buf33, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf34 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf2, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf33, (4, 16, 16), (256, 1, 16), 0),
            out=buf34)
        buf36 = buf22
        del buf22
        triton_poi_fused_sub_4[grid(64)](buf5, buf36, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf37 = buf5
        del buf5
        triton_poi_fused__softmax_5[grid(64)](buf36, buf37, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf38 = buf36
        del buf36
        triton_poi_fused__softmax_6[grid(64)](buf37, buf38, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf37
        buf39 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf38, reinterpret_tensor(buf4, (4, 4, 16), (64,
            16, 1), 0), out=buf39)
        buf40 = buf38
        del buf38
        triton_poi_fused_sub_4[grid(64)](buf7, buf40, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf41 = buf7
        del buf7
        triton_poi_fused__softmax_5[grid(64)](buf40, buf41, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf42 = buf40
        del buf40
        triton_poi_fused__softmax_6[grid(64)](buf41, buf42, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf41
        buf43 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf42, reinterpret_tensor(buf6, (4, 4, 16), (64,
            16, 1), 0), out=buf43)
        buf45 = buf33
        del buf33
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1), 0), out=buf45
            )
        buf48 = buf30
        del buf30
        triton_per_fused__softmax_7[grid(64)](buf45, buf48, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf49 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf4, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf48, (4, 16, 16), (256, 1, 16), 0),
            out=buf49)
        buf50 = buf48
        del buf48
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1), 0), out=buf50
            )
        buf53 = buf45
        del buf45
        triton_per_fused__softmax_7[grid(64)](buf50, buf53, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf54 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf6, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf53, (4, 16, 16), (256, 1, 16), 0),
            out=buf54)
        buf56 = buf42
        del buf42
        triton_poi_fused_sub_4[grid(64)](buf9, buf56, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf57 = buf9
        del buf9
        triton_poi_fused__softmax_5[grid(64)](buf56, buf57, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf58 = buf56
        del buf56
        triton_poi_fused__softmax_6[grid(64)](buf57, buf58, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf57
        buf59 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf58, reinterpret_tensor(buf8, (4, 4, 16), (64,
            16, 1), 0), out=buf59)
        buf60 = buf58
        del buf58
        triton_poi_fused_sub_4[grid(64)](buf11, buf60, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf61 = buf11
        del buf11
        triton_poi_fused__softmax_5[grid(64)](buf60, buf61, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf62 = buf60
        del buf60
        triton_poi_fused__softmax_6[grid(64)](buf61, buf62, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf61
        buf63 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf62, reinterpret_tensor(buf10, (4, 4, 16), (64,
            16, 1), 0), out=buf63)
        buf65 = buf53
        del buf53
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 16, 4), (64, 1, 16),
            0), reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1), 0), out=buf65
            )
        buf68 = buf50
        del buf50
        triton_per_fused__softmax_7[grid(64)](buf65, buf68, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf69 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf8, (4, 4, 16), (64, 16, 1),
            0), reinterpret_tensor(buf68, (4, 16, 16), (256, 1, 16), 0),
            out=buf69)
        buf70 = buf68
        del buf68
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 16, 4), (64, 1, 16
            ), 0), reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1), 0),
            out=buf70)
        buf73 = buf65
        del buf65
        triton_per_fused__softmax_7[grid(64)](buf70, buf73, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf74 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf10, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf73, (4, 16, 16), (256, 1, 16), 0),
            out=buf74)
        buf76 = buf62
        del buf62
        triton_poi_fused_sub_4[grid(64)](buf13, buf76, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf77 = buf13
        del buf13
        triton_poi_fused__softmax_5[grid(64)](buf76, buf77, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf78 = buf76
        del buf76
        triton_poi_fused__softmax_6[grid(64)](buf77, buf78, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf77
        buf79 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf78, reinterpret_tensor(buf12, (4, 4, 16), (64,
            16, 1), 0), out=buf79)
        buf80 = buf78
        del buf78
        triton_poi_fused_sub_4[grid(64)](buf15, buf80, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf81 = buf15
        del buf15
        triton_poi_fused__softmax_5[grid(64)](buf80, buf81, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf82 = buf80
        del buf80
        triton_poi_fused__softmax_6[grid(64)](buf81, buf82, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf81
        buf83 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(buf82, reinterpret_tensor(buf14, (4, 4, 16), (64,
            16, 1), 0), out=buf83)
        del buf82
        buf85 = buf73
        del buf73
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 16, 4), (64, 1, 16
            ), 0), reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1), 0),
            out=buf85)
        buf88 = buf70
        del buf70
        triton_per_fused__softmax_7[grid(64)](buf85, buf88, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        buf89 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf12, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf88, (4, 16, 16), (256, 1, 16), 0),
            out=buf89)
        buf90 = buf88
        del buf88
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 16, 4), (64, 1, 16
            ), 0), reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1), 0),
            out=buf90)
        buf93 = buf85
        del buf85
        triton_per_fused__softmax_7[grid(64)](buf90, buf93, 64, 16, XBLOCK=
            8, num_warps=2, num_stages=1)
        del buf90
        buf94 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf14, (4, 4, 16), (64, 16, 1
            ), 0), reinterpret_tensor(buf93, (4, 16, 16), (256, 1, 16), 0),
            out=buf94)
        del buf93
        buf24 = empty_strided_cuda((), (), torch.float32)
        buf96 = buf24
        del buf24
        triton_per_fused_abs_add_mean_mul_sub_8[grid(1)](buf96, buf19, buf0,
            buf23, buf2, buf29, buf34, buf39, buf4, buf43, buf6, buf49,
            buf54, buf59, buf8, buf63, buf10, buf69, buf74, buf79, buf12,
            buf83, buf14, buf89, buf94, 1, 256, num_warps=2, num_stages=1)
        del buf0
        del buf10
        del buf12
        del buf14
        del buf19
        del buf2
        del buf23
        del buf29
        del buf34
        del buf39
        del buf4
        del buf43
        del buf49
        del buf54
        del buf59
        del buf6
        del buf63
        del buf69
        del buf74
        del buf79
        del buf8
        del buf83
        del buf89
        del buf94
    return buf96,


class SCRMNew(nn.Module):
    """
    spatial & channel wise relation loss
    """

    def __init__(self, gamma=0.1):
        super(SCRMNew, self).__init__()
        self.softmax = nn.Softmax(dim=-1)
        self.gamma = gamma

    def spatial_wise(self, x):
        m_batchsize, C, height, width = x.size()
        proj_query = x.view(m_batchsize, -1, width * height).permute(0, 2, 1)
        proj_key = x.view(m_batchsize, -1, width * height)
        energy = torch.bmm(proj_query, proj_key)
        attention = self.softmax(energy)
        proj_value = x.view(m_batchsize, -1, width * height)
        out = torch.bmm(proj_value, attention.permute(0, 2, 1))
        out = out.view(m_batchsize, C, height, width)
        out = self.gamma * out + x
        return out

    def channel_wise(self, x):
        m_batchsize, C, height, width = x.size()
        proj_query = x.view(m_batchsize, C, -1)
        proj_key = x.view(m_batchsize, C, -1).permute(0, 2, 1)
        energy = torch.bmm(proj_query, proj_key)
        energy_new = torch.max(energy, -1, keepdim=True)[0].expand_as(energy
            ) - energy
        attention = self.softmax(energy_new)
        proj_value = x.view(m_batchsize, C, -1)
        out = torch.bmm(attention, proj_value)
        out = out.view(m_batchsize, C, height, width)
        out = self.gamma * out + x
        return out

    def cal_loss(self, f_s, f_t):
        f_s = F.normalize(f_s, dim=1)
        f_t = F.normalize(f_t, dim=1)
        sa_loss = F.l1_loss(self.spatial_wise(f_s), self.spatial_wise(f_t))
        ca_loss = F.l1_loss(self.channel_wise(f_s), self.channel_wise(f_t))
        return ca_loss + sa_loss

    def forward(self, input_0, input_1):
        arg0_1 = input_0
        arg1_1 = input_1
        output = call([arg0_1, arg1_1])
        return output[0]
