# 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_6/inductor_cache/mw/cmwulpxxw2jt763yw6dihufmcwawkztohwf6my2rtf33kl2nbgds.py
# Topologically Sorted Source Nodes: [eye, ne, lap, sum_1], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.sum]
# Source node to ATen node mapping:
#   eye => eq, full_default, full_default_1, iota_1, where
#   lap => full_default_2, where_1
#   ne => ne
#   sum_1 => sum_1
# Graph fragment:
#   %iota_1 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%unsqueeze, %iota_1), kwargs = {})
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([1], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %full_default_1 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq, %full_default, %full_default_1), kwargs = {})
#   %ne : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%where, 0), kwargs = {})
#   %full_default_2 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_1 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%ne, %full_default_2, %select), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%where_1, [0]), kwargs = {})
triton_poi_fused_eye_masked_fill_ne_sum_0 = async_compile.triton('triton_poi_fused_eye_masked_fill_ne_sum_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=[4], 
    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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_eye_masked_fill_ne_sum_0', '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_eye_masked_fill_ne_sum_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp7 = tl.load(in_ptr0 + (x0), xmask)
    tmp16 = tl.load(in_ptr0 + (4 + x0), xmask)
    tmp25 = tl.load(in_ptr0 + (8 + x0), xmask)
    tmp34 = tl.load(in_ptr0 + (12 + x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = x0
    tmp2 = tmp0 == tmp1
    tmp3 = 1.0
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp5 != tmp4
    tmp8 = tl_math.exp(tmp7)
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = tl.where(tmp6, tmp4, tmp10)
    tmp12 = tl.full([1], 1, tl.int64)
    tmp13 = tmp12 == tmp1
    tmp14 = tl.where(tmp13, tmp3, tmp4)
    tmp15 = tmp14 != tmp4
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp17 + tmp9
    tmp19 = tl.where(tmp15, tmp4, tmp18)
    tmp20 = tmp11 + tmp19
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp21 == tmp1
    tmp23 = tl.where(tmp22, tmp3, tmp4)
    tmp24 = tmp23 != tmp4
    tmp26 = tl_math.exp(tmp25)
    tmp27 = tmp26 + tmp9
    tmp28 = tl.where(tmp24, tmp4, tmp27)
    tmp29 = tmp20 + tmp28
    tmp30 = tl.full([1], 3, tl.int64)
    tmp31 = tmp30 == tmp1
    tmp32 = tl.where(tmp31, tmp3, tmp4)
    tmp33 = tmp32 != tmp4
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 + tmp9
    tmp37 = tl.where(tmp33, tmp4, tmp36)
    tmp38 = tmp29 + tmp37
    tl.store(out_ptr0 + (x0), tmp38, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/5f/c5fvishccr56l7e7obdlxzywjkbh3davnf5cdvnuqxihtgywozfd.py
# Topologically Sorted Source Nodes: [eye, ne, lap, neg, diag, lap_1, diag_1, exp_1], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp]
# Source node to ATen node mapping:
#   diag => eq_1, full_default_3, iota_2, where_2
#   diag_1 => diagonal_copy
#   exp_1 => exp_1
#   eye => eq, full_default, full_default_1, iota_1, where
#   lap => full_default_2, where_1
#   lap_1 => add_1
#   ne => ne
#   neg => neg
# Graph fragment:
#   %iota_1 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%unsqueeze, %iota_1), kwargs = {})
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([1], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %full_default_1 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq, %full_default, %full_default_1), kwargs = {})
#   %ne : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%where, 0), kwargs = {})
#   %full_default_2 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_1 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%ne, %full_default_2, %select), kwargs = {})
#   %neg : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%where_1,), kwargs = {})
#   %iota_2 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_1 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_2, %unsqueeze_2), kwargs = {})
#   %full_default_3 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_2 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_1, %permute, %full_default_3), kwargs = {})
#   %add_1 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%neg, %where_2), kwargs = {})
#   %diagonal_copy : [num_users=1] = call_function[target=torch.ops.aten.diagonal_copy.default](args = (%select_1,), kwargs = {})
#   %exp_1 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%diagonal_copy,), kwargs = {})
#   %select_scatter_default : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%add_1, %exp_1, 0, 0), kwargs = {})
triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_1 = async_compile.triton('triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[16], 
    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_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_1(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 4)
    x0 = xindex % 4
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (5*x0), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (x2), xmask)
    tmp18 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tl_math.exp(tmp3)
    tmp5 = x0
    tmp6 = tmp0 == tmp5
    tmp7 = 1.0
    tmp8 = 0.0
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tmp9 != tmp8
    tmp12 = tl_math.exp(tmp11)
    tmp13 = 1e-05
    tmp14 = tmp12 + tmp13
    tmp15 = tl.where(tmp10, tmp8, tmp14)
    tmp16 = -tmp15
    tmp17 = tmp5 == tmp0
    tmp19 = tl.where(tmp17, tmp18, tmp8)
    tmp20 = tmp16 + tmp19
    tmp21 = tl.where(tmp2, tmp4, tmp20)
    tl.store(out_ptr0 + (x2), tmp21, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/5k/c5kir7ouxg6vi6ka3fqtxb3atjlynhq3dcipimsepx55zvv5ls6k.py
# Topologically Sorted Source Nodes: [eye_1, ne_1, lap_2, sum_2], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.sum]
# Source node to ATen node mapping:
#   eye_1 => eq_3, full_default_7, full_default_8, iota_7, where_4
#   lap_2 => full_default_9, where_5
#   ne_1 => ne_1
#   sum_2 => sum_2
# Graph fragment:
#   %iota_7 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_3 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%unsqueeze_6, %iota_7), kwargs = {})
#   %full_default_7 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([1], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %full_default_8 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_4 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_3, %full_default_7, %full_default_8), kwargs = {})
#   %ne_1 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%where_4, 0), kwargs = {})
#   %full_default_9 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_5 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%ne_1, %full_default_9, %select_20), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%where_5, [0]), kwargs = {})
triton_poi_fused_eye_masked_fill_ne_sum_2 = async_compile.triton('triton_poi_fused_eye_masked_fill_ne_sum_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=[4], 
    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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_eye_masked_fill_ne_sum_2', '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_eye_masked_fill_ne_sum_2(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp7 = tl.load(in_ptr0 + (16 + x0), xmask)
    tmp16 = tl.load(in_ptr0 + (20 + x0), xmask)
    tmp25 = tl.load(in_ptr0 + (24 + x0), xmask)
    tmp34 = tl.load(in_ptr0 + (28 + x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = x0
    tmp2 = tmp0 == tmp1
    tmp3 = 1.0
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp5 != tmp4
    tmp8 = tl_math.exp(tmp7)
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = tl.where(tmp6, tmp4, tmp10)
    tmp12 = tl.full([1], 1, tl.int64)
    tmp13 = tmp12 == tmp1
    tmp14 = tl.where(tmp13, tmp3, tmp4)
    tmp15 = tmp14 != tmp4
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp17 + tmp9
    tmp19 = tl.where(tmp15, tmp4, tmp18)
    tmp20 = tmp11 + tmp19
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp21 == tmp1
    tmp23 = tl.where(tmp22, tmp3, tmp4)
    tmp24 = tmp23 != tmp4
    tmp26 = tl_math.exp(tmp25)
    tmp27 = tmp26 + tmp9
    tmp28 = tl.where(tmp24, tmp4, tmp27)
    tmp29 = tmp20 + tmp28
    tmp30 = tl.full([1], 3, tl.int64)
    tmp31 = tmp30 == tmp1
    tmp32 = tl.where(tmp31, tmp3, tmp4)
    tmp33 = tmp32 != tmp4
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 + tmp9
    tmp37 = tl.where(tmp33, tmp4, tmp36)
    tmp38 = tmp29 + tmp37
    tl.store(out_ptr0 + (x0), tmp38, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/ny/cnyxgqp3tmqmvliho4wkdr5wi6tnqd2oycsfgq3cjapc2phvva3v.py
# Topologically Sorted Source Nodes: [eye_1, ne_1, lap_2, neg_1, diag_5, lap_3, diag_6, exp_5], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp]
# Source node to ATen node mapping:
#   diag_5 => eq_4, full_default_10, iota_8, where_6
#   diag_6 => diagonal_copy_3
#   exp_5 => exp_5
#   eye_1 => eq_3, full_default_7, full_default_8, iota_7, where_4
#   lap_2 => full_default_9, where_5
#   lap_3 => add_3
#   ne_1 => ne_1
#   neg_1 => neg_1
# Graph fragment:
#   %iota_7 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_3 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%unsqueeze_6, %iota_7), kwargs = {})
#   %full_default_7 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([1], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %full_default_8 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_4 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_3, %full_default_7, %full_default_8), kwargs = {})
#   %ne_1 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%where_4, 0), kwargs = {})
#   %full_default_9 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_5 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%ne_1, %full_default_9, %select_20), kwargs = {})
#   %neg_1 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%where_5,), kwargs = {})
#   %iota_8 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_4 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_8, %unsqueeze_8), kwargs = {})
#   %full_default_10 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_6 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_4, %permute_5, %full_default_10), kwargs = {})
#   %add_3 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%neg_1, %where_6), kwargs = {})
#   %diagonal_copy_3 : [num_users=1] = call_function[target=torch.ops.aten.diagonal_copy.default](args = (%select_21,), kwargs = {})
#   %exp_5 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%diagonal_copy_3,), kwargs = {})
#   %select_scatter_default_4 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%add_3, %exp_5, 0, 0), kwargs = {})
triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_3 = async_compile.triton('triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_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=[16], 
    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_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_3(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 4)
    x0 = xindex % 4
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (16 + (5*x0)), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (16 + x2), xmask)
    tmp18 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tl_math.exp(tmp3)
    tmp5 = x0
    tmp6 = tmp0 == tmp5
    tmp7 = 1.0
    tmp8 = 0.0
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tmp9 != tmp8
    tmp12 = tl_math.exp(tmp11)
    tmp13 = 1e-05
    tmp14 = tmp12 + tmp13
    tmp15 = tl.where(tmp10, tmp8, tmp14)
    tmp16 = -tmp15
    tmp17 = tmp5 == tmp0
    tmp19 = tl.where(tmp17, tmp18, tmp8)
    tmp20 = tmp16 + tmp19
    tmp21 = tl.where(tmp2, tmp4, tmp20)
    tl.store(out_ptr0 + (x2), tmp21, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/76/c764os7jr65oallcf3eupkgmn4rajwnkb7qa2a4qrpedfegb2xji.py
# Topologically Sorted Source Nodes: [diag_4, add_2], Original ATen: [aten.diag_embed, aten.add]
# Source node to ATen node mapping:
#   add_2 => add_2
#   diag_4 => eq_2, full_default_6, iota_4, where_3
# Graph fragment:
#   %iota_4 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_2 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_4, %unsqueeze_5), kwargs = {})
#   %full_default_6 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_3 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_2, %permute_4, %full_default_6), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_16, %where_3), kwargs = {})
triton_poi_fused_add_diag_embed_4 = async_compile.triton('triton_poi_fused_add_diag_embed_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=[16], 
    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_diag_embed_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_add_diag_embed_4(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x2 = xindex
    x1 = (xindex // 4)
    tmp4 = tl.load(in_ptr0 + (x2), xmask)
    tmp6 = tl.load(in_ptr1 + (5*x0), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr1 + (x2), xmask)
    tmp18 = tl.load(in_ptr0 + (5*x0), xmask, eviction_policy='evict_last')
    tmp20 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp0 = tl.full([1], 0, tl.int32)
    tmp1 = tmp0 == tmp0
    tmp2 = x0
    tmp3 = tmp2 == tmp0
    tmp5 = tl_math.exp(tmp4)
    tmp7 = tmp5 * tmp6
    tmp8 = 0.0
    tmp9 = tl.where(tmp3, tmp8, tmp7)
    tmp10 = x1
    tmp11 = tmp10 == tmp0
    tmp13 = tmp5 * tmp12
    tmp14 = tl.where(tmp11, tmp8, tmp13)
    tmp15 = tmp9 - tmp14
    tmp16 = tl.where(tmp1, tmp15, tmp4)
    tmp17 = tmp2 == tmp10
    tmp19 = tl_math.exp(tmp18)
    tmp21 = tmp19 * tmp20
    tmp22 = tl.where(tmp17, tmp21, tmp8)
    tmp23 = tmp16 + tmp22
    tl.store(out_ptr0 + (x2), tmp23, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/ry/crysshrrigakeht5r6neboffuaxbkjaegs3cqmvdij2ytziz5vck.py
# Topologically Sorted Source Nodes: [exp_2, mul, setitem_1, exp_3, mul_1, setitem_2, sub, diag_4, add_2], Original ATen: [aten.exp, aten.mul, aten.lift_fresh, aten.fill, aten.sub, aten.diag_embed, aten.add]
# Source node to ATen node mapping:
#   add_2 => add_2
#   diag_4 => eq_2, full_default_6, iota_4, where_3
#   exp_2 => exp_2
#   exp_3 => exp_3
#   mul => mul
#   mul_1 => mul_1
#   setitem_1 => copy_1, full_default_4
#   setitem_2 => copy_2, full_default_5
#   sub => sub
# Graph fragment:
#   %exp_2 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%select_5,), kwargs = {})
#   %mul : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_2, %permute_1), kwargs = {})
#   %full_default_4 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %copy_1 : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_7, %full_default_4), kwargs = {})
#   %select_scatter_default_1 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%mul, %copy_1, 1, 0), kwargs = {})
#   %exp_3 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%select_6,), kwargs = {})
#   %mul_1 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_3, %permute_2), kwargs = {})
#   %full_default_5 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %copy_2 : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_9, %full_default_5), kwargs = {})
#   %select_scatter_default_2 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%mul_1, %copy_2, 0, 0), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_scatter_default_1, %select_scatter_default_2), kwargs = {})
#   %select_scatter_default_3 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%arg0_1, %sub, 0, 0), kwargs = {})
#   %iota_4 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_2 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_4, %unsqueeze_5), kwargs = {})
#   %full_default_6 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_3 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_2, %permute_4, %full_default_6), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_16, %where_3), kwargs = {})
#   %select_scatter_default_5 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_3, %add_2, 0, 0), kwargs = {})
triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_5 = async_compile.triton('triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_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: '*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_diag_embed_exp_fill_lift_fresh_mul_sub_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_add_diag_embed_exp_fill_lift_fresh_mul_sub_5(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = (xindex // 16)
    x3 = xindex % 16
    x0 = xindex % 4
    x1 = (xindex // 4) % 4
    x5 = xindex
    tmp3 = tl.load(in_ptr0 + (x3), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + (x3), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr2 + (5*x0), xmask, eviction_policy='evict_last')
    tmp14 = tl.load(in_ptr2 + (x3), xmask, eviction_policy='evict_last')
    tmp18 = tl.load(in_ptr1 + (x5), xmask)
    tmp0 = x2
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = x0
    tmp5 = tmp4 == tmp1
    tmp7 = tl_math.exp(tmp6)
    tmp9 = tmp7 * tmp8
    tmp10 = 0.0
    tmp11 = tl.where(tmp5, tmp10, tmp9)
    tmp12 = x1
    tmp13 = tmp12 == tmp1
    tmp15 = tmp7 * tmp14
    tmp16 = tl.where(tmp13, tmp10, tmp15)
    tmp17 = tmp11 - tmp16
    tmp19 = tl.where(tmp2, tmp17, tmp18)
    tmp20 = tl.where(tmp2, tmp3, tmp19)
    tl.store(out_ptr0 + (x5), tmp20, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/ds/cdsgimfrigpgjvo5w5eo5m4acelh6kweus6l5g6oa5euxfo5zryv.py
# Topologically Sorted Source Nodes: [eye_2, ne_2, lap_4, sum_3], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.sum]
# Source node to ATen node mapping:
#   eye_2 => eq_6, full_default_14, full_default_15, iota_13, where_8
#   lap_4 => full_default_16, where_9
#   ne_2 => ne_2
#   sum_3 => sum_3
# Graph fragment:
#   %iota_13 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_6 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%unsqueeze_12, %iota_13), kwargs = {})
#   %full_default_14 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([1], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %full_default_15 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_8 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_6, %full_default_14, %full_default_15), kwargs = {})
#   %ne_2 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%where_8, 0), kwargs = {})
#   %full_default_16 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_9 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%ne_2, %full_default_16, %select_41), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%where_9, [0]), kwargs = {})
triton_poi_fused_eye_masked_fill_ne_sum_6 = async_compile.triton('triton_poi_fused_eye_masked_fill_ne_sum_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=[4], 
    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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_eye_masked_fill_ne_sum_6', '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_eye_masked_fill_ne_sum_6(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp7 = tl.load(in_ptr0 + (32 + x0), xmask)
    tmp16 = tl.load(in_ptr0 + (36 + x0), xmask)
    tmp25 = tl.load(in_ptr0 + (40 + x0), xmask)
    tmp34 = tl.load(in_ptr0 + (44 + x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = x0
    tmp2 = tmp0 == tmp1
    tmp3 = 1.0
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp5 != tmp4
    tmp8 = tl_math.exp(tmp7)
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = tl.where(tmp6, tmp4, tmp10)
    tmp12 = tl.full([1], 1, tl.int64)
    tmp13 = tmp12 == tmp1
    tmp14 = tl.where(tmp13, tmp3, tmp4)
    tmp15 = tmp14 != tmp4
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp17 + tmp9
    tmp19 = tl.where(tmp15, tmp4, tmp18)
    tmp20 = tmp11 + tmp19
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp21 == tmp1
    tmp23 = tl.where(tmp22, tmp3, tmp4)
    tmp24 = tmp23 != tmp4
    tmp26 = tl_math.exp(tmp25)
    tmp27 = tmp26 + tmp9
    tmp28 = tl.where(tmp24, tmp4, tmp27)
    tmp29 = tmp20 + tmp28
    tmp30 = tl.full([1], 3, tl.int64)
    tmp31 = tmp30 == tmp1
    tmp32 = tl.where(tmp31, tmp3, tmp4)
    tmp33 = tmp32 != tmp4
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 + tmp9
    tmp37 = tl.where(tmp33, tmp4, tmp36)
    tmp38 = tmp29 + tmp37
    tl.store(out_ptr0 + (x0), tmp38, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/bx/cbx52hvmunlgryyn5hbdsqyfni653yiknzgubzvil2q6yaseomvy.py
# Topologically Sorted Source Nodes: [eye_2, ne_2, lap_4, neg_2, diag_10, lap_5, diag_11, exp_9], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp]
# Source node to ATen node mapping:
#   diag_10 => eq_7, full_default_17, iota_14, where_10
#   diag_11 => diagonal_copy_6
#   exp_9 => exp_9
#   eye_2 => eq_6, full_default_14, full_default_15, iota_13, where_8
#   lap_4 => full_default_16, where_9
#   lap_5 => add_5
#   ne_2 => ne_2
#   neg_2 => neg_2
# Graph fragment:
#   %iota_13 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_6 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%unsqueeze_12, %iota_13), kwargs = {})
#   %full_default_14 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([1], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %full_default_15 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_8 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_6, %full_default_14, %full_default_15), kwargs = {})
#   %ne_2 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%where_8, 0), kwargs = {})
#   %full_default_16 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_9 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%ne_2, %full_default_16, %select_41), kwargs = {})
#   %neg_2 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%where_9,), kwargs = {})
#   %iota_14 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_7 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_14, %unsqueeze_14), kwargs = {})
#   %full_default_17 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_10 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_7, %permute_10, %full_default_17), kwargs = {})
#   %add_5 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%neg_2, %where_10), kwargs = {})
#   %diagonal_copy_6 : [num_users=1] = call_function[target=torch.ops.aten.diagonal_copy.default](args = (%select_42,), kwargs = {})
#   %exp_9 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%diagonal_copy_6,), kwargs = {})
#   %select_scatter_default_9 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%add_5, %exp_9, 0, 0), kwargs = {})
triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_7 = async_compile.triton('triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_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=[16], 
    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_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_7(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 4)
    x0 = xindex % 4
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (32 + (5*x0)), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (32 + x2), xmask)
    tmp18 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tl_math.exp(tmp3)
    tmp5 = x0
    tmp6 = tmp0 == tmp5
    tmp7 = 1.0
    tmp8 = 0.0
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tmp9 != tmp8
    tmp12 = tl_math.exp(tmp11)
    tmp13 = 1e-05
    tmp14 = tmp12 + tmp13
    tmp15 = tl.where(tmp10, tmp8, tmp14)
    tmp16 = -tmp15
    tmp17 = tmp5 == tmp0
    tmp19 = tl.where(tmp17, tmp18, tmp8)
    tmp20 = tmp16 + tmp19
    tmp21 = tl.where(tmp2, tmp4, tmp20)
    tl.store(out_ptr0 + (x2), tmp21, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/mz/cmzl5zoke7j2kqgzcvjpkpdzkg2kwyb47nzibimhi2hklzb5s6ut.py
# Topologically Sorted Source Nodes: [diag_9, add_4], Original ATen: [aten.diag_embed, aten.add]
# Source node to ATen node mapping:
#   add_4 => add_4
#   diag_9 => eq_5, full_default_13, iota_10, where_7
# Graph fragment:
#   %iota_10 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_5 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_10, %unsqueeze_11), kwargs = {})
#   %full_default_13 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_7 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_5, %permute_9, %full_default_13), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_37, %where_7), kwargs = {})
triton_poi_fused_add_diag_embed_8 = async_compile.triton('triton_poi_fused_add_diag_embed_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.pointwise(
    size_hints=[16], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_diag_embed_8', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 6, '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_diag_embed_8(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x2 = xindex
    x1 = (xindex // 4)
    tmp5 = tl.load(in_ptr0 + (16 + x2), xmask)
    tmp7 = tl.load(in_ptr1 + (5*x0), xmask, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr1 + (x2), xmask)
    tmp17 = tl.load(in_ptr2 + (16 + x2), xmask)
    tmp20 = tl.load(in_ptr0 + (16 + (5*x0)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp0 = tl.full([1], 1, tl.int32)
    tmp1 = tmp0 == tmp0
    tmp2 = x0
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = tmp2 == tmp3
    tmp6 = tl_math.exp(tmp5)
    tmp8 = tmp6 * tmp7
    tmp9 = 0.0
    tmp10 = tl.where(tmp4, tmp9, tmp8)
    tmp11 = x1
    tmp12 = tmp11 == tmp3
    tmp14 = tmp6 * tmp13
    tmp15 = tl.where(tmp12, tmp9, tmp14)
    tmp16 = tmp10 - tmp15
    tmp18 = tl.where(tmp1, tmp16, tmp17)
    tmp19 = tmp2 == tmp11
    tmp21 = tl_math.exp(tmp20)
    tmp23 = tmp21 * tmp22
    tmp24 = tl.where(tmp19, tmp23, tmp9)
    tmp25 = tmp18 + tmp24
    tl.store(out_ptr0 + (x2), tmp25, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/4m/c4mfewqtg74k4hoz5gcjnz5z3hfa6tzmoe5hz6cil2jwbmx7cosw.py
# Topologically Sorted Source Nodes: [exp_6, mul_3, setitem_6, exp_7, mul_4, setitem_7, sub_1, diag_9, add_4], Original ATen: [aten.exp, aten.mul, aten.lift_fresh, aten.fill, aten.sub, aten.diag_embed, aten.add]
# Source node to ATen node mapping:
#   add_4 => add_4
#   diag_9 => eq_5, full_default_13, iota_10, where_7
#   exp_6 => exp_6
#   exp_7 => exp_7
#   mul_3 => mul_3
#   mul_4 => mul_4
#   setitem_6 => copy_6, full_default_11
#   setitem_7 => copy_7, full_default_12
#   sub_1 => sub_1
# Graph fragment:
#   %exp_6 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%select_25,), kwargs = {})
#   %mul_3 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_6, %permute_6), kwargs = {})
#   %full_default_11 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %copy_6 : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_27, %full_default_11), kwargs = {})
#   %select_scatter_default_6 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%mul_3, %copy_6, 1, 0), kwargs = {})
#   %exp_7 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%select_26,), kwargs = {})
#   %mul_4 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_7, %permute_7), kwargs = {})
#   %full_default_12 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %copy_7 : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_29, %full_default_12), kwargs = {})
#   %select_scatter_default_7 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%mul_4, %copy_7, 0, 0), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_scatter_default_6, %select_scatter_default_7), kwargs = {})
#   %select_scatter_default_8 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_5, %sub_1, 0, 1), kwargs = {})
#   %iota_10 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_5 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_10, %unsqueeze_11), kwargs = {})
#   %full_default_13 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_7 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_5, %permute_9, %full_default_13), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_37, %where_7), kwargs = {})
#   %select_scatter_default_10 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_8, %add_4, 0, 1), kwargs = {})
triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_9 = async_compile.triton('triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_9', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_9', 'mutated_arg_names': ['in_out_ptr0'], '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_diag_embed_exp_fill_lift_fresh_mul_sub_9(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = (xindex // 16)
    x3 = xindex % 16
    x0 = xindex % 4
    x1 = (xindex // 4) % 4
    x5 = xindex
    tmp3 = tl.load(in_ptr0 + (x3), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr1 + (16 + x3), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr2 + (5*x0), xmask, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr2 + (x3), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_out_ptr0 + (x5), xmask)
    tmp0 = x2
    tmp1 = tl.full([1], 1, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = x0
    tmp5 = tl.full([1], 0, tl.int32)
    tmp6 = tmp4 == tmp5
    tmp8 = tl_math.exp(tmp7)
    tmp10 = tmp8 * tmp9
    tmp11 = 0.0
    tmp12 = tl.where(tmp6, tmp11, tmp10)
    tmp13 = x1
    tmp14 = tmp13 == tmp5
    tmp16 = tmp8 * tmp15
    tmp17 = tl.where(tmp14, tmp11, tmp16)
    tmp18 = tmp12 - tmp17
    tmp20 = tl.where(tmp2, tmp18, tmp19)
    tmp21 = tl.where(tmp2, tmp3, tmp20)
    tl.store(in_out_ptr0 + (x5), tmp21, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/f4/cf43dymhxq3xler6ijzfxsjgm3oemfpzsjaoarspoimxqod3bkiv.py
# Topologically Sorted Source Nodes: [eye_3, ne_3, lap_6, sum_4], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.sum]
# Source node to ATen node mapping:
#   eye_3 => eq_9, full_default_21, full_default_22, iota_19, where_12
#   lap_6 => full_default_23, where_13
#   ne_3 => ne_3
#   sum_4 => sum_4
# Graph fragment:
#   %iota_19 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_9 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%unsqueeze_18, %iota_19), kwargs = {})
#   %full_default_21 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([1], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %full_default_22 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_12 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_9, %full_default_21, %full_default_22), kwargs = {})
#   %ne_3 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%where_12, 0), kwargs = {})
#   %full_default_23 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_13 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%ne_3, %full_default_23, %select_62), kwargs = {})
#   %sum_4 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%where_13, [0]), kwargs = {})
triton_poi_fused_eye_masked_fill_ne_sum_10 = async_compile.triton('triton_poi_fused_eye_masked_fill_ne_sum_10', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[4], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_eye_masked_fill_ne_sum_10', '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_eye_masked_fill_ne_sum_10(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp7 = tl.load(in_ptr0 + (48 + x0), xmask)
    tmp16 = tl.load(in_ptr0 + (52 + x0), xmask)
    tmp25 = tl.load(in_ptr0 + (56 + x0), xmask)
    tmp34 = tl.load(in_ptr0 + (60 + x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = x0
    tmp2 = tmp0 == tmp1
    tmp3 = 1.0
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp5 != tmp4
    tmp8 = tl_math.exp(tmp7)
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = tl.where(tmp6, tmp4, tmp10)
    tmp12 = tl.full([1], 1, tl.int64)
    tmp13 = tmp12 == tmp1
    tmp14 = tl.where(tmp13, tmp3, tmp4)
    tmp15 = tmp14 != tmp4
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp17 + tmp9
    tmp19 = tl.where(tmp15, tmp4, tmp18)
    tmp20 = tmp11 + tmp19
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp21 == tmp1
    tmp23 = tl.where(tmp22, tmp3, tmp4)
    tmp24 = tmp23 != tmp4
    tmp26 = tl_math.exp(tmp25)
    tmp27 = tmp26 + tmp9
    tmp28 = tl.where(tmp24, tmp4, tmp27)
    tmp29 = tmp20 + tmp28
    tmp30 = tl.full([1], 3, tl.int64)
    tmp31 = tmp30 == tmp1
    tmp32 = tl.where(tmp31, tmp3, tmp4)
    tmp33 = tmp32 != tmp4
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 + tmp9
    tmp37 = tl.where(tmp33, tmp4, tmp36)
    tmp38 = tmp29 + tmp37
    tl.store(out_ptr0 + (x0), tmp38, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/sg/csgmzo5h24yeta5phehu6lzwmojkxl6w5o6pxa7fu4tywve6h72o.py
# Topologically Sorted Source Nodes: [eye_3, ne_3, lap_6, neg_3, diag_15, lap_7, diag_16, exp_13], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp]
# Source node to ATen node mapping:
#   diag_15 => eq_10, full_default_24, iota_20, where_14
#   diag_16 => diagonal_copy_9
#   exp_13 => exp_13
#   eye_3 => eq_9, full_default_21, full_default_22, iota_19, where_12
#   lap_6 => full_default_23, where_13
#   lap_7 => add_7
#   ne_3 => ne_3
#   neg_3 => neg_3
# Graph fragment:
#   %iota_19 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_9 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%unsqueeze_18, %iota_19), kwargs = {})
#   %full_default_21 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([1], 1), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %full_default_22 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_12 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_9, %full_default_21, %full_default_22), kwargs = {})
#   %ne_3 : [num_users=1] = call_function[target=torch.ops.aten.ne.Scalar](args = (%where_12, 0), kwargs = {})
#   %full_default_23 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_13 : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%ne_3, %full_default_23, %select_62), kwargs = {})
#   %neg_3 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%where_13,), kwargs = {})
#   %iota_20 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_10 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_20, %unsqueeze_20), kwargs = {})
#   %full_default_24 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_14 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_10, %permute_15, %full_default_24), kwargs = {})
#   %add_7 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%neg_3, %where_14), kwargs = {})
#   %diagonal_copy_9 : [num_users=1] = call_function[target=torch.ops.aten.diagonal_copy.default](args = (%select_63,), kwargs = {})
#   %exp_13 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%diagonal_copy_9,), kwargs = {})
#   %select_scatter_default_14 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%add_7, %exp_13, 0, 0), kwargs = {})
triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_11 = async_compile.triton('triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_11', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[16], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '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_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_11', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_11(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 4)
    x0 = xindex % 4
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (48 + (5*x0)), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (48 + x2), xmask)
    tmp18 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tl_math.exp(tmp3)
    tmp5 = x0
    tmp6 = tmp0 == tmp5
    tmp7 = 1.0
    tmp8 = 0.0
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tmp9 != tmp8
    tmp12 = tl_math.exp(tmp11)
    tmp13 = 1e-05
    tmp14 = tmp12 + tmp13
    tmp15 = tl.where(tmp10, tmp8, tmp14)
    tmp16 = -tmp15
    tmp17 = tmp5 == tmp0
    tmp19 = tl.where(tmp17, tmp18, tmp8)
    tmp20 = tmp16 + tmp19
    tmp21 = tl.where(tmp2, tmp4, tmp20)
    tl.store(out_ptr0 + (x2), tmp21, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/s3/cs3gvd4vxrcwwln23ccoasr7omajc7scigkbutbxw7gq332qtsp2.py
# Topologically Sorted Source Nodes: [diag_14, add_6], Original ATen: [aten.diag_embed, aten.add]
# Source node to ATen node mapping:
#   add_6 => add_6
#   diag_14 => eq_8, full_default_20, iota_16, where_11
# Graph fragment:
#   %iota_16 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_8 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_16, %unsqueeze_17), kwargs = {})
#   %full_default_20 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_11 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_8, %permute_14, %full_default_20), kwargs = {})
#   %add_6 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_58, %where_11), kwargs = {})
triton_poi_fused_add_diag_embed_12 = async_compile.triton('triton_poi_fused_add_diag_embed_12', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[16], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_diag_embed_12', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 6, '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_diag_embed_12(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x2 = xindex
    x1 = (xindex // 4)
    tmp5 = tl.load(in_ptr0 + (32 + x2), xmask)
    tmp7 = tl.load(in_ptr1 + (5*x0), xmask, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr1 + (x2), xmask)
    tmp17 = tl.load(in_ptr2 + (32 + x2), xmask)
    tmp20 = tl.load(in_ptr0 + (32 + (5*x0)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp0 = tl.full([1], 2, tl.int32)
    tmp1 = tmp0 == tmp0
    tmp2 = x0
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = tmp2 == tmp3
    tmp6 = tl_math.exp(tmp5)
    tmp8 = tmp6 * tmp7
    tmp9 = 0.0
    tmp10 = tl.where(tmp4, tmp9, tmp8)
    tmp11 = x1
    tmp12 = tmp11 == tmp3
    tmp14 = tmp6 * tmp13
    tmp15 = tl.where(tmp12, tmp9, tmp14)
    tmp16 = tmp10 - tmp15
    tmp18 = tl.where(tmp1, tmp16, tmp17)
    tmp19 = tmp2 == tmp11
    tmp21 = tl_math.exp(tmp20)
    tmp23 = tmp21 * tmp22
    tmp24 = tl.where(tmp19, tmp23, tmp9)
    tmp25 = tmp18 + tmp24
    tl.store(out_ptr0 + (x2), tmp25, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/me/cmej2qnos2ywrczshe25nqkszxvcm53ics5lgh4v3txzow4adwk6.py
# Topologically Sorted Source Nodes: [exp_10, mul_6, setitem_11, exp_11, mul_7, setitem_12, sub_2, diag_14, add_6], Original ATen: [aten.exp, aten.mul, aten.lift_fresh, aten.fill, aten.sub, aten.diag_embed, aten.add]
# Source node to ATen node mapping:
#   add_6 => add_6
#   diag_14 => eq_8, full_default_20, iota_16, where_11
#   exp_10 => exp_10
#   exp_11 => exp_11
#   mul_6 => mul_6
#   mul_7 => mul_7
#   setitem_11 => copy_11, full_default_18
#   setitem_12 => copy_12, full_default_19
#   sub_2 => sub_2
# Graph fragment:
#   %exp_10 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%select_46,), kwargs = {})
#   %mul_6 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_10, %permute_11), kwargs = {})
#   %full_default_18 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %copy_11 : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_48, %full_default_18), kwargs = {})
#   %select_scatter_default_11 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%mul_6, %copy_11, 1, 0), kwargs = {})
#   %exp_11 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%select_47,), kwargs = {})
#   %mul_7 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_11, %permute_12), kwargs = {})
#   %full_default_19 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %copy_12 : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_50, %full_default_19), kwargs = {})
#   %select_scatter_default_12 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%mul_7, %copy_12, 0, 0), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_scatter_default_11, %select_scatter_default_12), kwargs = {})
#   %select_scatter_default_13 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_10, %sub_2, 0, 2), kwargs = {})
#   %iota_16 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_8 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_16, %unsqueeze_17), kwargs = {})
#   %full_default_20 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_11 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_8, %permute_14, %full_default_20), kwargs = {})
#   %add_6 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_58, %where_11), kwargs = {})
#   %select_scatter_default_15 : [num_users=2] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_13, %add_6, 0, 2), kwargs = {})
triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_13 = async_compile.triton('triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_13', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_13', 'mutated_arg_names': ['in_out_ptr0'], '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_diag_embed_exp_fill_lift_fresh_mul_sub_13(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = (xindex // 16)
    x3 = xindex % 16
    x0 = xindex % 4
    x1 = (xindex // 4) % 4
    x5 = xindex
    tmp3 = tl.load(in_ptr0 + (x3), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr1 + (32 + x3), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr2 + (5*x0), xmask, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr2 + (x3), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_out_ptr0 + (x5), xmask)
    tmp0 = x2
    tmp1 = tl.full([1], 2, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = x0
    tmp5 = tl.full([1], 0, tl.int32)
    tmp6 = tmp4 == tmp5
    tmp8 = tl_math.exp(tmp7)
    tmp10 = tmp8 * tmp9
    tmp11 = 0.0
    tmp12 = tl.where(tmp6, tmp11, tmp10)
    tmp13 = x1
    tmp14 = tmp13 == tmp5
    tmp16 = tmp8 * tmp15
    tmp17 = tl.where(tmp14, tmp11, tmp16)
    tmp18 = tmp12 - tmp17
    tmp20 = tl.where(tmp2, tmp18, tmp19)
    tmp21 = tl.where(tmp2, tmp3, tmp20)
    tl.store(in_out_ptr0 + (x5), tmp21, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/7m/c7mcscnhipdy5wvhd42yefmq35fu4oqgmcy7p53evfyoamhb6fsp.py
# Topologically Sorted Source Nodes: [diag_19, add_8], Original ATen: [aten.diag_embed, aten.add]
# Source node to ATen node mapping:
#   add_8 => add_8
#   diag_19 => eq_11, full_default_27, iota_22, where_15
# Graph fragment:
#   %iota_22 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_11 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_22, %unsqueeze_23), kwargs = {})
#   %full_default_27 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_15 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_11, %permute_19, %full_default_27), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_79, %where_15), kwargs = {})
triton_poi_fused_add_diag_embed_14 = async_compile.triton('triton_poi_fused_add_diag_embed_14', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[16], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_diag_embed_14', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 6, '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_diag_embed_14(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x2 = xindex
    x1 = (xindex // 4)
    tmp5 = tl.load(in_ptr0 + (48 + x2), xmask)
    tmp7 = tl.load(in_ptr1 + (5*x0), xmask, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr1 + (x2), xmask)
    tmp17 = tl.load(in_ptr2 + (48 + x2), xmask)
    tmp20 = tl.load(in_ptr0 + (48 + (5*x0)), xmask, eviction_policy='evict_last')
    tmp22 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp0 = tl.full([1], 3, tl.int32)
    tmp1 = tmp0 == tmp0
    tmp2 = x0
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = tmp2 == tmp3
    tmp6 = tl_math.exp(tmp5)
    tmp8 = tmp6 * tmp7
    tmp9 = 0.0
    tmp10 = tl.where(tmp4, tmp9, tmp8)
    tmp11 = x1
    tmp12 = tmp11 == tmp3
    tmp14 = tmp6 * tmp13
    tmp15 = tl.where(tmp12, tmp9, tmp14)
    tmp16 = tmp10 - tmp15
    tmp18 = tl.where(tmp1, tmp16, tmp17)
    tmp19 = tmp2 == tmp11
    tmp21 = tl_math.exp(tmp20)
    tmp23 = tmp21 * tmp22
    tmp24 = tl.where(tmp19, tmp23, tmp9)
    tmp25 = tmp18 + tmp24
    tl.store(out_ptr0 + (x2), tmp25, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/xd/cxdxskm7n54mdwp6h2mbtokxdjclp2po3usor7fw3tqm473pzik6.py
# Topologically Sorted Source Nodes: [exp_14, mul_9, setitem_16, exp_15, mul_10, setitem_17, sub_3, diag_19, add_8], Original ATen: [aten.exp, aten.mul, aten.lift_fresh, aten.fill, aten.sub, aten.diag_embed, aten.add]
# Source node to ATen node mapping:
#   add_8 => add_8
#   diag_19 => eq_11, full_default_27, iota_22, where_15
#   exp_14 => exp_14
#   exp_15 => exp_15
#   mul_10 => mul_10
#   mul_9 => mul_9
#   setitem_16 => copy_16, full_default_25
#   setitem_17 => copy_17, full_default_26
#   sub_3 => sub_3
# Graph fragment:
#   %exp_14 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%select_67,), kwargs = {})
#   %mul_9 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_14, %permute_16), kwargs = {})
#   %full_default_25 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %copy_16 : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_69, %full_default_25), kwargs = {})
#   %select_scatter_default_16 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%mul_9, %copy_16, 1, 0), kwargs = {})
#   %exp_15 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%select_68,), kwargs = {})
#   %mul_10 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_15, %permute_17), kwargs = {})
#   %full_default_26 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %copy_17 : [num_users=1] = call_function[target=torch.ops.aten.copy.default](args = (%select_71, %full_default_26), kwargs = {})
#   %select_scatter_default_17 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%mul_10, %copy_17, 0, 0), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%select_scatter_default_16, %select_scatter_default_17), kwargs = {})
#   %select_scatter_default_18 : [num_users=3] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_15, %sub_3, 0, 3), kwargs = {})
#   %iota_22 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (4,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %eq_11 : [num_users=1] = call_function[target=torch.ops.aten.eq.Tensor](args = (%iota_22, %unsqueeze_23), kwargs = {})
#   %full_default_27 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where_15 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq_11, %permute_19, %full_default_27), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%select_79, %where_15), kwargs = {})
#   %select_scatter_default_19 : [num_users=1] = call_function[target=torch.ops.aten.select_scatter.default](args = (%select_scatter_default_18, %add_8, 0, 3), kwargs = {})
triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_15 = async_compile.triton('triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_15', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_15', 'mutated_arg_names': ['in_out_ptr0'], '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_diag_embed_exp_fill_lift_fresh_mul_sub_15(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = (xindex // 16)
    x3 = xindex % 16
    x0 = xindex % 4
    x1 = (xindex // 4) % 4
    x5 = xindex
    tmp3 = tl.load(in_ptr0 + (x3), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr1 + (48 + x3), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr2 + (5*x0), xmask, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr2 + (x3), xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_out_ptr0 + (x5), xmask)
    tmp0 = x2
    tmp1 = tl.full([1], 3, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = x0
    tmp5 = tl.full([1], 0, tl.int32)
    tmp6 = tmp4 == tmp5
    tmp8 = tl_math.exp(tmp7)
    tmp10 = tmp8 * tmp9
    tmp11 = 0.0
    tmp12 = tl.where(tmp6, tmp11, tmp10)
    tmp13 = x1
    tmp14 = tmp13 == tmp5
    tmp16 = tmp8 * tmp15
    tmp17 = tl.where(tmp14, tmp11, tmp16)
    tmp18 = tmp12 - tmp17
    tmp20 = tl.where(tmp2, tmp18, tmp19)
    tmp21 = tl.where(tmp2, tmp3, tmp20)
    tl.store(in_out_ptr0 + (x5), tmp21, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4), (16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [eye, ne, lap, sum_1], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.sum]
        stream0 = get_raw_stream(0)
        triton_poi_fused_eye_masked_fill_ne_sum_0.run(arg0_1, buf0, 4, grid=grid(4), stream=stream0)
        buf1 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [eye, ne, lap, neg, diag, lap_1, diag_1, exp_1], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp]
        triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_1.run(arg0_1, buf0, buf1, 16, grid=grid(16), stream=stream0)
        # Topologically Sorted Source Nodes: [eye, ne, lap, neg, diag, lap_1, diag_1, exp_1, inv_laplacian], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp, aten.linalg_inv_ex]
        buf2 = torch.ops.aten.linalg_inv_ex.default(buf1)
        buf3 = buf2[0]
        del buf2
        buf5 = buf0; del buf0  # reuse
        # Topologically Sorted Source Nodes: [eye_1, ne_1, lap_2, sum_2], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.sum]
        triton_poi_fused_eye_masked_fill_ne_sum_2.run(arg0_1, buf5, 4, grid=grid(4), stream=stream0)
        buf6 = buf1; del buf1  # reuse
        # Topologically Sorted Source Nodes: [eye_1, ne_1, lap_2, neg_1, diag_5, lap_3, diag_6, exp_5], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp]
        triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_3.run(arg0_1, buf5, buf6, 16, grid=grid(16), stream=stream0)
        # Topologically Sorted Source Nodes: [eye_1, ne_1, lap_2, neg_1, diag_5, lap_3, diag_6, exp_5, inv_laplacian_1], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp, aten.linalg_inv_ex]
        buf7 = torch.ops.aten.linalg_inv_ex.default(buf6)
        buf8 = buf7[0]
        del buf7
        buf10 = buf6; del buf6  # reuse
        # Topologically Sorted Source Nodes: [diag_4, add_2], Original ATen: [aten.diag_embed, aten.add]
        triton_poi_fused_add_diag_embed_4.run(arg0_1, buf3, buf10, 16, grid=grid(16), stream=stream0)
        buf11 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [exp_2, mul, setitem_1, exp_3, mul_1, setitem_2, sub, diag_4, add_2], Original ATen: [aten.exp, aten.mul, aten.lift_fresh, aten.fill, aten.sub, aten.diag_embed, aten.add]
        triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_5.run(buf10, arg0_1, buf3, buf11, 64, grid=grid(64), stream=stream0)
        del buf10
        buf12 = buf5; del buf5  # reuse
        # Topologically Sorted Source Nodes: [eye_2, ne_2, lap_4, sum_3], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.sum]
        triton_poi_fused_eye_masked_fill_ne_sum_6.run(arg0_1, buf12, 4, grid=grid(4), stream=stream0)
        buf13 = reinterpret_tensor(buf3, (4, 4), (4, 1), 0); del buf3  # reuse
        # Topologically Sorted Source Nodes: [eye_2, ne_2, lap_4, neg_2, diag_10, lap_5, diag_11, exp_9], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp]
        triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_7.run(arg0_1, buf12, buf13, 16, grid=grid(16), stream=stream0)
        # Topologically Sorted Source Nodes: [eye_2, ne_2, lap_4, neg_2, diag_10, lap_5, diag_11, exp_9, inv_laplacian_2], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp, aten.linalg_inv_ex]
        buf14 = torch.ops.aten.linalg_inv_ex.default(buf13)
        buf15 = buf14[0]
        del buf14
        buf17 = buf13; del buf13  # reuse
        # Topologically Sorted Source Nodes: [diag_9, add_4], Original ATen: [aten.diag_embed, aten.add]
        triton_poi_fused_add_diag_embed_8.run(arg0_1, buf8, buf11, buf17, 16, grid=grid(16), stream=stream0)
        buf18 = buf11; del buf11  # reuse
        # Topologically Sorted Source Nodes: [exp_6, mul_3, setitem_6, exp_7, mul_4, setitem_7, sub_1, diag_9, add_4], Original ATen: [aten.exp, aten.mul, aten.lift_fresh, aten.fill, aten.sub, aten.diag_embed, aten.add]
        triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_9.run(buf18, buf17, arg0_1, buf8, 64, grid=grid(64), stream=stream0)
        del buf17
        buf19 = buf12; del buf12  # reuse
        # Topologically Sorted Source Nodes: [eye_3, ne_3, lap_6, sum_4], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.sum]
        triton_poi_fused_eye_masked_fill_ne_sum_10.run(arg0_1, buf19, 4, grid=grid(4), stream=stream0)
        buf20 = reinterpret_tensor(buf8, (4, 4), (4, 1), 0); del buf8  # reuse
        # Topologically Sorted Source Nodes: [eye_3, ne_3, lap_6, neg_3, diag_15, lap_7, diag_16, exp_13], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp]
        triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_11.run(arg0_1, buf19, buf20, 16, grid=grid(16), stream=stream0)
        del buf19
        # Topologically Sorted Source Nodes: [eye_3, ne_3, lap_6, neg_3, diag_15, lap_7, diag_16, exp_13, inv_laplacian_3], Original ATen: [aten.eye, aten.ne, aten.masked_fill, aten.neg, aten.diag_embed, aten.add, aten.diagonal_copy, aten.exp, aten.linalg_inv_ex]
        buf21 = torch.ops.aten.linalg_inv_ex.default(buf20)
        buf22 = buf21[0]
        del buf21
        buf24 = buf20; del buf20  # reuse
        # Topologically Sorted Source Nodes: [diag_14, add_6], Original ATen: [aten.diag_embed, aten.add]
        triton_poi_fused_add_diag_embed_12.run(arg0_1, buf15, buf18, buf24, 16, grid=grid(16), stream=stream0)
        buf25 = buf18; del buf18  # reuse
        # Topologically Sorted Source Nodes: [exp_10, mul_6, setitem_11, exp_11, mul_7, setitem_12, sub_2, diag_14, add_6], Original ATen: [aten.exp, aten.mul, aten.lift_fresh, aten.fill, aten.sub, aten.diag_embed, aten.add]
        triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_13.run(buf25, buf24, arg0_1, buf15, 64, grid=grid(64), stream=stream0)
        del buf15
        buf26 = buf24; del buf24  # reuse
        # Topologically Sorted Source Nodes: [diag_19, add_8], Original ATen: [aten.diag_embed, aten.add]
        triton_poi_fused_add_diag_embed_14.run(arg0_1, buf22, buf25, buf26, 16, grid=grid(16), stream=stream0)
        buf27 = buf25; del buf25  # reuse
        # Topologically Sorted Source Nodes: [exp_14, mul_9, setitem_16, exp_15, mul_10, setitem_17, sub_3, diag_19, add_8], Original ATen: [aten.exp, aten.mul, aten.lift_fresh, aten.fill, aten.sub, aten.diag_embed, aten.add]
        triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_15.run(buf27, buf26, arg0_1, buf22, 64, grid=grid(64), stream=stream0)
        del arg0_1
        del buf22
        del buf26
    return (buf27, )


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), (16, 4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_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
import torch.cuda
import torch.distributed


class MatrixTree(nn.Module):
    """Implementation of the matrix-tree theorem for computing marginals
    of non-projective dependency parsing. This attention layer is used
    in the paper "Learning Structured Text Representations"
    :cite:`DBLP:journals/corr/LiuL17d`.
    """

    def __init__(self, eps=1e-05):
        self.eps = eps
        super(MatrixTree, self).__init__()

    def forward(self, input):
        laplacian = input.exp() + self.eps
        output = input.clone()
        for b in range(input.size(0)):
            lap = laplacian[b].masked_fill(torch.eye(input.size(1), device=
                input.device).ne(0), 0)
            lap = -lap + torch.diag(lap.sum(0))
            lap[0] = input[b].diag().exp()
            inv_laplacian = lap.inverse()
            factor = inv_laplacian.diag().unsqueeze(1).expand_as(input[b]
                ).transpose(0, 1)
            term1 = input[b].exp().mul(factor).clone()
            term2 = input[b].exp().mul(inv_laplacian.transpose(0, 1)).clone()
            term1[:, 0] = 0
            term2[0] = 0
            output[b] = term1 - term2
            roots_output = input[b].diag().exp().mul(inv_laplacian.
                transpose(0, 1)[0])
            output[b] = output[b] + torch.diag(roots_output)
        return output


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


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

import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
import torch.cuda
import torch.distributed
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_eye_masked_fill_ne_sum_0(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp7 = tl.load(in_ptr0 + x0, xmask)
    tmp16 = tl.load(in_ptr0 + (4 + x0), xmask)
    tmp25 = tl.load(in_ptr0 + (8 + x0), xmask)
    tmp34 = tl.load(in_ptr0 + (12 + x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = x0
    tmp2 = tmp0 == tmp1
    tmp3 = 1.0
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp5 != tmp4
    tmp8 = tl_math.exp(tmp7)
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = tl.where(tmp6, tmp4, tmp10)
    tmp12 = tl.full([1], 1, tl.int64)
    tmp13 = tmp12 == tmp1
    tmp14 = tl.where(tmp13, tmp3, tmp4)
    tmp15 = tmp14 != tmp4
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp17 + tmp9
    tmp19 = tl.where(tmp15, tmp4, tmp18)
    tmp20 = tmp11 + tmp19
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp21 == tmp1
    tmp23 = tl.where(tmp22, tmp3, tmp4)
    tmp24 = tmp23 != tmp4
    tmp26 = tl_math.exp(tmp25)
    tmp27 = tmp26 + tmp9
    tmp28 = tl.where(tmp24, tmp4, tmp27)
    tmp29 = tmp20 + tmp28
    tmp30 = tl.full([1], 3, tl.int64)
    tmp31 = tmp30 == tmp1
    tmp32 = tl.where(tmp31, tmp3, tmp4)
    tmp33 = tmp32 != tmp4
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 + tmp9
    tmp37 = tl.where(tmp33, tmp4, tmp36)
    tmp38 = tmp29 + tmp37
    tl.store(out_ptr0 + x0, tmp38, xmask)


@triton.jit
def triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_1(
    in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4
    x0 = xindex % 4
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + 5 * x0, xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + x2, xmask)
    tmp18 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tl_math.exp(tmp3)
    tmp5 = x0
    tmp6 = tmp0 == tmp5
    tmp7 = 1.0
    tmp8 = 0.0
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tmp9 != tmp8
    tmp12 = tl_math.exp(tmp11)
    tmp13 = 1e-05
    tmp14 = tmp12 + tmp13
    tmp15 = tl.where(tmp10, tmp8, tmp14)
    tmp16 = -tmp15
    tmp17 = tmp5 == tmp0
    tmp19 = tl.where(tmp17, tmp18, tmp8)
    tmp20 = tmp16 + tmp19
    tmp21 = tl.where(tmp2, tmp4, tmp20)
    tl.store(out_ptr0 + x2, tmp21, xmask)


@triton.jit
def triton_poi_fused_eye_masked_fill_ne_sum_2(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp7 = tl.load(in_ptr0 + (16 + x0), xmask)
    tmp16 = tl.load(in_ptr0 + (20 + x0), xmask)
    tmp25 = tl.load(in_ptr0 + (24 + x0), xmask)
    tmp34 = tl.load(in_ptr0 + (28 + x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = x0
    tmp2 = tmp0 == tmp1
    tmp3 = 1.0
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp5 != tmp4
    tmp8 = tl_math.exp(tmp7)
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = tl.where(tmp6, tmp4, tmp10)
    tmp12 = tl.full([1], 1, tl.int64)
    tmp13 = tmp12 == tmp1
    tmp14 = tl.where(tmp13, tmp3, tmp4)
    tmp15 = tmp14 != tmp4
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp17 + tmp9
    tmp19 = tl.where(tmp15, tmp4, tmp18)
    tmp20 = tmp11 + tmp19
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp21 == tmp1
    tmp23 = tl.where(tmp22, tmp3, tmp4)
    tmp24 = tmp23 != tmp4
    tmp26 = tl_math.exp(tmp25)
    tmp27 = tmp26 + tmp9
    tmp28 = tl.where(tmp24, tmp4, tmp27)
    tmp29 = tmp20 + tmp28
    tmp30 = tl.full([1], 3, tl.int64)
    tmp31 = tmp30 == tmp1
    tmp32 = tl.where(tmp31, tmp3, tmp4)
    tmp33 = tmp32 != tmp4
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 + tmp9
    tmp37 = tl.where(tmp33, tmp4, tmp36)
    tmp38 = tmp29 + tmp37
    tl.store(out_ptr0 + x0, tmp38, xmask)


@triton.jit
def triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_3(
    in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4
    x0 = xindex % 4
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (16 + 5 * x0), xmask, eviction_policy='evict_last'
        )
    tmp11 = tl.load(in_ptr0 + (16 + x2), xmask)
    tmp18 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tl_math.exp(tmp3)
    tmp5 = x0
    tmp6 = tmp0 == tmp5
    tmp7 = 1.0
    tmp8 = 0.0
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tmp9 != tmp8
    tmp12 = tl_math.exp(tmp11)
    tmp13 = 1e-05
    tmp14 = tmp12 + tmp13
    tmp15 = tl.where(tmp10, tmp8, tmp14)
    tmp16 = -tmp15
    tmp17 = tmp5 == tmp0
    tmp19 = tl.where(tmp17, tmp18, tmp8)
    tmp20 = tmp16 + tmp19
    tmp21 = tl.where(tmp2, tmp4, tmp20)
    tl.store(out_ptr0 + x2, tmp21, xmask)


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


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


@triton.jit
def triton_poi_fused_eye_masked_fill_ne_sum_6(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp7 = tl.load(in_ptr0 + (32 + x0), xmask)
    tmp16 = tl.load(in_ptr0 + (36 + x0), xmask)
    tmp25 = tl.load(in_ptr0 + (40 + x0), xmask)
    tmp34 = tl.load(in_ptr0 + (44 + x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = x0
    tmp2 = tmp0 == tmp1
    tmp3 = 1.0
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp5 != tmp4
    tmp8 = tl_math.exp(tmp7)
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = tl.where(tmp6, tmp4, tmp10)
    tmp12 = tl.full([1], 1, tl.int64)
    tmp13 = tmp12 == tmp1
    tmp14 = tl.where(tmp13, tmp3, tmp4)
    tmp15 = tmp14 != tmp4
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp17 + tmp9
    tmp19 = tl.where(tmp15, tmp4, tmp18)
    tmp20 = tmp11 + tmp19
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp21 == tmp1
    tmp23 = tl.where(tmp22, tmp3, tmp4)
    tmp24 = tmp23 != tmp4
    tmp26 = tl_math.exp(tmp25)
    tmp27 = tmp26 + tmp9
    tmp28 = tl.where(tmp24, tmp4, tmp27)
    tmp29 = tmp20 + tmp28
    tmp30 = tl.full([1], 3, tl.int64)
    tmp31 = tmp30 == tmp1
    tmp32 = tl.where(tmp31, tmp3, tmp4)
    tmp33 = tmp32 != tmp4
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 + tmp9
    tmp37 = tl.where(tmp33, tmp4, tmp36)
    tmp38 = tmp29 + tmp37
    tl.store(out_ptr0 + x0, tmp38, xmask)


@triton.jit
def triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_7(
    in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4
    x0 = xindex % 4
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (32 + 5 * x0), xmask, eviction_policy='evict_last'
        )
    tmp11 = tl.load(in_ptr0 + (32 + x2), xmask)
    tmp18 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tl_math.exp(tmp3)
    tmp5 = x0
    tmp6 = tmp0 == tmp5
    tmp7 = 1.0
    tmp8 = 0.0
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tmp9 != tmp8
    tmp12 = tl_math.exp(tmp11)
    tmp13 = 1e-05
    tmp14 = tmp12 + tmp13
    tmp15 = tl.where(tmp10, tmp8, tmp14)
    tmp16 = -tmp15
    tmp17 = tmp5 == tmp0
    tmp19 = tl.where(tmp17, tmp18, tmp8)
    tmp20 = tmp16 + tmp19
    tmp21 = tl.where(tmp2, tmp4, tmp20)
    tl.store(out_ptr0 + x2, tmp21, xmask)


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


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


@triton.jit
def triton_poi_fused_eye_masked_fill_ne_sum_10(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp7 = tl.load(in_ptr0 + (48 + x0), xmask)
    tmp16 = tl.load(in_ptr0 + (52 + x0), xmask)
    tmp25 = tl.load(in_ptr0 + (56 + x0), xmask)
    tmp34 = tl.load(in_ptr0 + (60 + x0), xmask)
    tmp0 = tl.full([1], 0, tl.int64)
    tmp1 = x0
    tmp2 = tmp0 == tmp1
    tmp3 = 1.0
    tmp4 = 0.0
    tmp5 = tl.where(tmp2, tmp3, tmp4)
    tmp6 = tmp5 != tmp4
    tmp8 = tl_math.exp(tmp7)
    tmp9 = 1e-05
    tmp10 = tmp8 + tmp9
    tmp11 = tl.where(tmp6, tmp4, tmp10)
    tmp12 = tl.full([1], 1, tl.int64)
    tmp13 = tmp12 == tmp1
    tmp14 = tl.where(tmp13, tmp3, tmp4)
    tmp15 = tmp14 != tmp4
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp17 + tmp9
    tmp19 = tl.where(tmp15, tmp4, tmp18)
    tmp20 = tmp11 + tmp19
    tmp21 = tl.full([1], 2, tl.int64)
    tmp22 = tmp21 == tmp1
    tmp23 = tl.where(tmp22, tmp3, tmp4)
    tmp24 = tmp23 != tmp4
    tmp26 = tl_math.exp(tmp25)
    tmp27 = tmp26 + tmp9
    tmp28 = tl.where(tmp24, tmp4, tmp27)
    tmp29 = tmp20 + tmp28
    tmp30 = tl.full([1], 3, tl.int64)
    tmp31 = tmp30 == tmp1
    tmp32 = tl.where(tmp31, tmp3, tmp4)
    tmp33 = tmp32 != tmp4
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 + tmp9
    tmp37 = tl.where(tmp33, tmp4, tmp36)
    tmp38 = tmp29 + tmp37
    tl.store(out_ptr0 + x0, tmp38, xmask)


@triton.jit
def triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_11(
    in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4
    x0 = xindex % 4
    x2 = xindex
    tmp3 = tl.load(in_ptr0 + (48 + 5 * x0), xmask, eviction_policy='evict_last'
        )
    tmp11 = tl.load(in_ptr0 + (48 + x2), xmask)
    tmp18 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = tl_math.exp(tmp3)
    tmp5 = x0
    tmp6 = tmp0 == tmp5
    tmp7 = 1.0
    tmp8 = 0.0
    tmp9 = tl.where(tmp6, tmp7, tmp8)
    tmp10 = tmp9 != tmp8
    tmp12 = tl_math.exp(tmp11)
    tmp13 = 1e-05
    tmp14 = tmp12 + tmp13
    tmp15 = tl.where(tmp10, tmp8, tmp14)
    tmp16 = -tmp15
    tmp17 = tmp5 == tmp0
    tmp19 = tl.where(tmp17, tmp18, tmp8)
    tmp20 = tmp16 + tmp19
    tmp21 = tl.where(tmp2, tmp4, tmp20)
    tl.store(out_ptr0 + x2, tmp21, xmask)


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


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


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


@triton.jit
def triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_15(in_out_ptr0,
    in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex // 16
    x3 = xindex % 16
    x0 = xindex % 4
    x1 = xindex // 4 % 4
    x5 = xindex
    tmp3 = tl.load(in_ptr0 + x3, xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr1 + (48 + x3), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr2 + 5 * x0, xmask, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr2 + x3, xmask, eviction_policy='evict_last')
    tmp19 = tl.load(in_out_ptr0 + x5, xmask)
    tmp0 = x2
    tmp1 = tl.full([1], 3, tl.int32)
    tmp2 = tmp0 == tmp1
    tmp4 = x0
    tmp5 = tl.full([1], 0, tl.int32)
    tmp6 = tmp4 == tmp5
    tmp8 = tl_math.exp(tmp7)
    tmp10 = tmp8 * tmp9
    tmp11 = 0.0
    tmp12 = tl.where(tmp6, tmp11, tmp10)
    tmp13 = x1
    tmp14 = tmp13 == tmp5
    tmp16 = tmp8 * tmp15
    tmp17 = tl.where(tmp14, tmp11, tmp16)
    tmp18 = tmp12 - tmp17
    tmp20 = tl.where(tmp2, tmp18, tmp19)
    tmp21 = tl.where(tmp2, tmp3, tmp20)
    tl.store(in_out_ptr0 + x5, tmp21, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4), (16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4,), (1,), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_eye_masked_fill_ne_sum_0[grid(4)](arg0_1, buf0, 4,
            XBLOCK=4, num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_1[
            grid(16)](arg0_1, buf0, buf1, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        buf2 = torch.ops.aten.linalg_inv_ex.default(buf1)
        buf3 = buf2[0]
        del buf2
        buf5 = buf0
        del buf0
        triton_poi_fused_eye_masked_fill_ne_sum_2[grid(4)](arg0_1, buf5, 4,
            XBLOCK=4, num_warps=1, num_stages=1)
        buf6 = buf1
        del buf1
        triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_3[
            grid(16)](arg0_1, buf5, buf6, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        buf7 = torch.ops.aten.linalg_inv_ex.default(buf6)
        buf8 = buf7[0]
        del buf7
        buf10 = buf6
        del buf6
        triton_poi_fused_add_diag_embed_4[grid(16)](arg0_1, buf3, buf10, 16,
            XBLOCK=16, num_warps=1, num_stages=1)
        buf11 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_5[grid(64)
            ](buf10, arg0_1, buf3, buf11, 64, XBLOCK=64, num_warps=1,
            num_stages=1)
        del buf10
        buf12 = buf5
        del buf5
        triton_poi_fused_eye_masked_fill_ne_sum_6[grid(4)](arg0_1, buf12, 4,
            XBLOCK=4, num_warps=1, num_stages=1)
        buf13 = reinterpret_tensor(buf3, (4, 4), (4, 1), 0)
        del buf3
        triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_7[
            grid(16)](arg0_1, buf12, buf13, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        buf14 = torch.ops.aten.linalg_inv_ex.default(buf13)
        buf15 = buf14[0]
        del buf14
        buf17 = buf13
        del buf13
        triton_poi_fused_add_diag_embed_8[grid(16)](arg0_1, buf8, buf11,
            buf17, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf18 = buf11
        del buf11
        triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_9[grid(64)
            ](buf18, buf17, arg0_1, buf8, 64, XBLOCK=64, num_warps=1,
            num_stages=1)
        del buf17
        buf19 = buf12
        del buf12
        triton_poi_fused_eye_masked_fill_ne_sum_10[grid(4)](arg0_1, buf19, 
            4, XBLOCK=4, num_warps=1, num_stages=1)
        buf20 = reinterpret_tensor(buf8, (4, 4), (4, 1), 0)
        del buf8
        triton_poi_fused_add_diag_embed_diagonal_copy_exp_eye_masked_fill_ne_neg_11[
            grid(16)](arg0_1, buf19, buf20, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        del buf19
        buf21 = torch.ops.aten.linalg_inv_ex.default(buf20)
        buf22 = buf21[0]
        del buf21
        buf24 = buf20
        del buf20
        triton_poi_fused_add_diag_embed_12[grid(16)](arg0_1, buf15, buf18,
            buf24, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf25 = buf18
        del buf18
        triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_13[grid(64)
            ](buf25, buf24, arg0_1, buf15, 64, XBLOCK=64, num_warps=1,
            num_stages=1)
        del buf15
        buf26 = buf24
        del buf24
        triton_poi_fused_add_diag_embed_14[grid(16)](arg0_1, buf22, buf25,
            buf26, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf27 = buf25
        del buf25
        triton_poi_fused_add_diag_embed_exp_fill_lift_fresh_mul_sub_15[grid(64)
            ](buf27, buf26, arg0_1, buf22, 64, XBLOCK=64, num_warps=1,
            num_stages=1)
        del arg0_1
        del buf22
        del buf26
    return buf27,


class MatrixTreeNew(nn.Module):
    """Implementation of the matrix-tree theorem for computing marginals
    of non-projective dependency parsing. This attention layer is used
    in the paper "Learning Structured Text Representations"
    :cite:`DBLP:journals/corr/LiuL17d`.
    """

    def __init__(self, eps=1e-05):
        self.eps = eps
        super(MatrixTreeNew, self).__init__()

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