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

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


# kernel path: runs/run_shard_7/inductor_cache/bf/cbfn6biyhpdcfaij4vjig5nh5xt4je4rg3x3bagvsu2fdhsnlwqu.py
# Topologically Sorted Source Nodes: [l1_loss], Original ATen: [aten.sub, aten.abs, aten.mean]
# Source node to ATen node mapping:
#   l1_loss => abs_1, mean, sub
# Graph fragment:
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%slice_2, %slice_4), kwargs = {})
#   %abs_1 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub,), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_1,), kwargs = {})
triton_per_fused_abs_mean_sub_0 = async_compile.triton('triton_per_fused_abs_mean_sub_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.persistent_reduction(
    size_hints=[1, 256],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 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': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 4), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_abs_mean_sub_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 1, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_abs_mean_sub_0(in_ptr0, in_ptr1, out_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 192
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = rindex < rnumel
    r0 = rindex % 12
    r1 = (rindex // 12)
    tmp0 = tl.load(in_ptr0 + (r0 + (16*r1)), rmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r0 + (16*r1)), rmask, other=0.0)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.where(rmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tl.store(out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp7, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/3a/c3apnbbwvnbpmlssyryfnegjcoiiojqwffulk3quq3feirf2cj2h.py
# Topologically Sorted Source Nodes: [l1_loss_1], Original ATen: [aten.sub, aten.abs, aten.mean]
# Source node to ATen node mapping:
#   l1_loss_1 => abs_2, mean_1, sub_1
# Graph fragment:
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%slice_6, %slice_8), kwargs = {})
#   %abs_2 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_1,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_2,), kwargs = {})
triton_per_fused_abs_mean_sub_1 = async_compile.triton('triton_per_fused_abs_mean_sub_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.persistent_reduction(
    size_hints=[1, 64],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 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': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 4), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_abs_mean_sub_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 1, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_abs_mean_sub_1(in_ptr0, in_ptr1, out_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 64
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex % 4
    r1 = (rindex // 4)
    tmp0 = tl.load(in_ptr0 + (12 + r0 + (16*r1)), None)
    tmp1 = tl.load(in_ptr1 + (12 + r0 + (16*r1)), None)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.sum(tmp4, 1)[:, None]
    tl.store(out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp6, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/fd/cfd72hdpas6e44h5d6kd57hdmg3f2q3o6vrmxjzsggmpjucnsz27.py
# Topologically Sorted Source Nodes: [vos], Original ATen: [aten.stack]
# Source node to ATen node mapping:
#   vos => cat_4
# Graph fragment:
#   %cat_4 : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%cat, %cat_1, %cat_2, %cat_3],), kwargs = {})
triton_poi_fused_stack_2 = async_compile.triton('triton_poi_fused_stack_2', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_stack_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 24, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_stack_2(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 16)
    x0 = xindex % 16
    x2 = xindex
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 3, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.full([1], 1, tl.int64)
    tmp6 = tmp0 < tmp5
    tmp7 = tmp6 & tmp4
    tmp8 = tl.load(in_ptr0 + (16 + x0), tmp7 & xmask, eviction_policy='evict_last', other=0.0)
    tmp9 = tl.load(in_ptr0 + (x0), tmp7 & xmask, eviction_policy='evict_last', other=0.0)
    tmp10 = tmp8 - tmp9
    tmp11 = tl.full(tmp10.shape, 0.0, tmp10.dtype)
    tmp12 = tl.where(tmp7, tmp10, tmp11)
    tmp13 = tmp0 >= tmp5
    tmp14 = tl.full([1], 2, tl.int64)
    tmp15 = tmp0 < tmp14
    tmp16 = tmp13 & tmp15
    tmp17 = tmp16 & tmp4
    tmp18 = tl.load(in_ptr0 + (32 + x0), tmp17 & xmask, eviction_policy='evict_last', other=0.0)
    tmp19 = tl.load(in_ptr0 + (16 + x0), tmp17 & xmask, eviction_policy='evict_last', other=0.0)
    tmp20 = tmp18 - tmp19
    tmp21 = tl.full(tmp20.shape, 0.0, tmp20.dtype)
    tmp22 = tl.where(tmp17, tmp20, tmp21)
    tmp23 = tmp0 >= tmp14
    tmp24 = tmp23 & tmp4
    tmp25 = tl.load(in_ptr0 + (48 + x0), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp26 = tl.load(in_ptr0 + (32 + x0), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp27 = tmp25 - tmp26
    tmp28 = tl.full(tmp27.shape, 0.0, tmp27.dtype)
    tmp29 = tl.where(tmp24, tmp27, tmp28)
    tmp30 = tl.where(tmp16, tmp22, tmp29)
    tmp31 = tl.where(tmp6, tmp12, tmp30)
    tmp32 = tl.full(tmp31.shape, 0.0, tmp31.dtype)
    tmp33 = tl.where(tmp4, tmp31, tmp32)
    tmp34 = tmp0 >= tmp3
    tmp35 = tl.full([1], 6, tl.int64)
    tmp36 = tmp0 < tmp35
    tmp37 = tmp34 & tmp36
    tmp38 = (-3) + x1
    tmp39 = tmp38 >= tmp1
    tmp40 = tmp38 < tmp5
    tmp41 = tmp40 & tmp37
    tmp42 = tl.load(in_ptr0 + (80 + x0), tmp41 & xmask, eviction_policy='evict_last', other=0.0)
    tmp43 = tl.load(in_ptr0 + (64 + x0), tmp41 & xmask, eviction_policy='evict_last', other=0.0)
    tmp44 = tmp42 - tmp43
    tmp45 = tl.full(tmp44.shape, 0.0, tmp44.dtype)
    tmp46 = tl.where(tmp41, tmp44, tmp45)
    tmp47 = tmp38 >= tmp5
    tmp48 = tmp38 < tmp14
    tmp49 = tmp47 & tmp48
    tmp50 = tmp49 & tmp37
    tmp51 = tl.load(in_ptr0 + (96 + x0), tmp50 & xmask, eviction_policy='evict_last', other=0.0)
    tmp52 = tl.load(in_ptr0 + (80 + x0), tmp50 & xmask, eviction_policy='evict_last', other=0.0)
    tmp53 = tmp51 - tmp52
    tmp54 = tl.full(tmp53.shape, 0.0, tmp53.dtype)
    tmp55 = tl.where(tmp50, tmp53, tmp54)
    tmp56 = tmp38 >= tmp14
    tmp57 = tmp38 < tmp3
    tmp58 = tmp56 & tmp37
    tmp59 = tl.load(in_ptr0 + (112 + x0), tmp58 & xmask, eviction_policy='evict_last', other=0.0)
    tmp60 = tl.load(in_ptr0 + (96 + x0), tmp58 & xmask, eviction_policy='evict_last', other=0.0)
    tmp61 = tmp59 - tmp60
    tmp62 = tl.full(tmp61.shape, 0.0, tmp61.dtype)
    tmp63 = tl.where(tmp58, tmp61, tmp62)
    tmp64 = tl.where(tmp49, tmp55, tmp63)
    tmp65 = tl.where(tmp40, tmp46, tmp64)
    tmp66 = tl.full(tmp65.shape, 0.0, tmp65.dtype)
    tmp67 = tl.where(tmp37, tmp65, tmp66)
    tmp68 = tmp0 >= tmp35
    tmp69 = tl.full([1], 9, tl.int64)
    tmp70 = tmp0 < tmp69
    tmp71 = tmp68 & tmp70
    tmp72 = (-6) + x1
    tmp73 = tmp72 >= tmp1
    tmp74 = tmp72 < tmp5
    tmp75 = tmp74 & tmp71
    tmp76 = tl.load(in_ptr0 + (144 + x0), tmp75 & xmask, eviction_policy='evict_last', other=0.0)
    tmp77 = tl.load(in_ptr0 + (128 + x0), tmp75 & xmask, eviction_policy='evict_last', other=0.0)
    tmp78 = tmp76 - tmp77
    tmp79 = tl.full(tmp78.shape, 0.0, tmp78.dtype)
    tmp80 = tl.where(tmp75, tmp78, tmp79)
    tmp81 = tmp72 >= tmp5
    tmp82 = tmp72 < tmp14
    tmp83 = tmp81 & tmp82
    tmp84 = tmp83 & tmp71
    tmp85 = tl.load(in_ptr0 + (160 + x0), tmp84 & xmask, eviction_policy='evict_last', other=0.0)
    tmp86 = tl.load(in_ptr0 + (144 + x0), tmp84 & xmask, eviction_policy='evict_last', other=0.0)
    tmp87 = tmp85 - tmp86
    tmp88 = tl.full(tmp87.shape, 0.0, tmp87.dtype)
    tmp89 = tl.where(tmp84, tmp87, tmp88)
    tmp90 = tmp72 >= tmp14
    tmp91 = tmp72 < tmp3
    tmp92 = tmp90 & tmp71
    tmp93 = tl.load(in_ptr0 + (176 + x0), tmp92 & xmask, eviction_policy='evict_last', other=0.0)
    tmp94 = tl.load(in_ptr0 + (160 + x0), tmp92 & xmask, eviction_policy='evict_last', other=0.0)
    tmp95 = tmp93 - tmp94
    tmp96 = tl.full(tmp95.shape, 0.0, tmp95.dtype)
    tmp97 = tl.where(tmp92, tmp95, tmp96)
    tmp98 = tl.where(tmp83, tmp89, tmp97)
    tmp99 = tl.where(tmp74, tmp80, tmp98)
    tmp100 = tl.full(tmp99.shape, 0.0, tmp99.dtype)
    tmp101 = tl.where(tmp71, tmp99, tmp100)
    tmp102 = tmp0 >= tmp69
    tmp103 = tl.full([1], 12, tl.int64)
    tmp104 = tmp0 < tmp103
    tmp105 = (-9) + x1
    tmp106 = tmp105 >= tmp1
    tmp107 = tmp105 < tmp5
    tmp108 = tmp107 & tmp102
    tmp109 = tl.load(in_ptr0 + (208 + x0), tmp108 & xmask, eviction_policy='evict_last', other=0.0)
    tmp110 = tl.load(in_ptr0 + (192 + x0), tmp108 & xmask, eviction_policy='evict_last', other=0.0)
    tmp111 = tmp109 - tmp110
    tmp112 = tl.full(tmp111.shape, 0.0, tmp111.dtype)
    tmp113 = tl.where(tmp108, tmp111, tmp112)
    tmp114 = tmp105 >= tmp5
    tmp115 = tmp105 < tmp14
    tmp116 = tmp114 & tmp115
    tmp117 = tmp116 & tmp102
    tmp118 = tl.load(in_ptr0 + (224 + x0), tmp117 & xmask, eviction_policy='evict_last', other=0.0)
    tmp119 = tl.load(in_ptr0 + (208 + x0), tmp117 & xmask, eviction_policy='evict_last', other=0.0)
    tmp120 = tmp118 - tmp119
    tmp121 = tl.full(tmp120.shape, 0.0, tmp120.dtype)
    tmp122 = tl.where(tmp117, tmp120, tmp121)
    tmp123 = tmp105 >= tmp14
    tmp124 = tmp105 < tmp3
    tmp125 = tmp123 & tmp102
    tmp126 = tl.load(in_ptr0 + (240 + x0), tmp125 & xmask, eviction_policy='evict_last', other=0.0)
    tmp127 = tl.load(in_ptr0 + (224 + x0), tmp125 & xmask, eviction_policy='evict_last', other=0.0)
    tmp128 = tmp126 - tmp127
    tmp129 = tl.full(tmp128.shape, 0.0, tmp128.dtype)
    tmp130 = tl.where(tmp125, tmp128, tmp129)
    tmp131 = tl.where(tmp116, tmp122, tmp130)
    tmp132 = tl.where(tmp107, tmp113, tmp131)
    tmp133 = tl.full(tmp132.shape, 0.0, tmp132.dtype)
    tmp134 = tl.where(tmp102, tmp132, tmp133)
    tmp135 = tl.where(tmp71, tmp101, tmp134)
    tmp136 = tl.where(tmp37, tmp67, tmp135)
    tmp137 = tl.where(tmp4, tmp33, tmp136)
    tl.store(out_ptr0 + (x2), tmp137, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/oc/cocd2pubf7vikf7qminwol7u2vqus6rplgvk7cooo7ut332663w4.py
# Topologically Sorted Source Nodes: [l1_loss_2], Original ATen: [aten.sub, aten.abs, aten.mean]
# Source node to ATen node mapping:
#   l1_loss_2 => abs_3, mean_2, sub_26
# Graph fragment:
#   %sub_26 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%slice_10, %slice_12), kwargs = {})
#   %abs_3 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_26,), kwargs = {})
#   %mean_2 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_3,), kwargs = {})
triton_per_fused_abs_mean_sub_3 = async_compile.triton('triton_per_fused_abs_mean_sub_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.persistent_reduction(
    size_hints=[1, 256],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 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': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 4), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_abs_mean_sub_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 1, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_abs_mean_sub_3(in_ptr0, in_ptr1, out_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 144
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = rindex < rnumel
    r0 = rindex % 12
    r1 = (rindex // 12)
    tmp0 = tl.load(in_ptr0 + (r0 + (16*r1)), rmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r0 + (16*r1)), rmask, other=0.0)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.where(rmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tl.store(out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp7, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/yr/cyr3fi7tlpsowmdwtop2ggnpj7nr3lbnvoktkosfws77adzbi4d7.py
# Topologically Sorted Source Nodes: [neg, exp, l1_loss, mul, add, neg_1, exp_1, l1_loss_1, mul_1, add_1, abs_loss, neg_2, exp_2, l1_loss_2, mul_2, add_3, neg_3, exp_3, l1_loss_3, mul_3, add_4, vo_loss, loss], Original ATen: [aten.neg, aten.exp, aten.sub, aten.abs, aten.mean, aten.mul, aten.add]
# Source node to ATen node mapping:
#   abs_loss => add_2
#   add => add
#   add_1 => add_1
#   add_3 => add_3
#   add_4 => add_4
#   exp => exp
#   exp_1 => exp_1
#   exp_2 => exp_2
#   exp_3 => exp_3
#   l1_loss => abs_1, mean, sub
#   l1_loss_1 => abs_2, mean_1, sub_1
#   l1_loss_2 => abs_3, mean_2, sub_26
#   l1_loss_3 => abs_4, mean_3, sub_27
#   loss => add_6
#   mul => mul
#   mul_1 => mul_1
#   mul_2 => mul_2
#   mul_3 => mul_3
#   neg => neg
#   neg_1 => neg_1
#   neg_2 => neg_2
#   neg_3 => neg_3
#   vo_loss => add_5
# Graph fragment:
#   %neg : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%arg1_1,), kwargs = {})
#   %exp : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%neg,), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%slice_2, %slice_4), kwargs = {})
#   %abs_1 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub,), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_1,), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp, %mean), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul, %arg1_1), kwargs = {})
#   %neg_1 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%arg3_1,), kwargs = {})
#   %exp_1 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%neg_1,), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%slice_6, %slice_8), kwargs = {})
#   %abs_2 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_1,), kwargs = {})
#   %mean_1 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_2,), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_1, %mean_1), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add, %mul_1), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_1, %arg3_1), kwargs = {})
#   %neg_2 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%arg4_1,), kwargs = {})
#   %exp_2 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%neg_2,), kwargs = {})
#   %sub_26 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%slice_10, %slice_12), kwargs = {})
#   %abs_3 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_26,), kwargs = {})
#   %mean_2 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_3,), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_2, %mean_2), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_2, %arg4_1), kwargs = {})
#   %neg_3 : [num_users=1] = call_function[target=torch.ops.aten.neg.default](args = (%arg5_1,), kwargs = {})
#   %exp_3 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%neg_3,), kwargs = {})
#   %sub_27 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%slice_14, %slice_16), kwargs = {})
#   %abs_4 : [num_users=1] = call_function[target=torch.ops.aten.abs.default](args = (%sub_27,), kwargs = {})
#   %mean_3 : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%abs_4,), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%exp_3, %mean_3), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_3, %mul_3), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_4, %arg5_1), kwargs = {})
#   %add_6 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_2, %add_5), kwargs = {})
triton_per_fused_abs_add_exp_mean_mul_neg_sub_4 = async_compile.triton('triton_per_fused_abs_add_exp_mean_mul_neg_sub_4', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.persistent_reduction(
    size_hints=[1, 64],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: '*fp32', 8: '*fp32', 9: 'i32', 10: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {9: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7, 8, 10), equal_to_1=(9,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_abs_add_exp_mean_mul_neg_sub_4', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 9, 'num_reduction': 1, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_abs_add_exp_mean_mul_neg_sub_4(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 48
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = rindex < rnumel
    r0 = rindex % 4
    r1 = (rindex // 4)
    tmp0 = tl.load(in_ptr0 + (12 + r0 + (16*r1)), rmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (12 + r0 + (16*r1)), rmask, other=0.0)
    tmp8 = tl.load(in_ptr2 + (0))
    tmp9 = tl.broadcast_to(tmp8, [XBLOCK, 1])
    tmp12 = tl.load(in_out_ptr0 + (0))
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK, 1])
    tmp18 = tl.load(in_ptr3 + (0))
    tmp19 = tl.broadcast_to(tmp18, [XBLOCK, 1])
    tmp22 = tl.load(in_ptr4 + (0))
    tmp23 = tl.broadcast_to(tmp22, [XBLOCK, 1])
    tmp29 = tl.load(in_ptr5 + (0))
    tmp30 = tl.broadcast_to(tmp29, [XBLOCK, 1])
    tmp33 = tl.load(in_ptr6 + (0))
    tmp34 = tl.broadcast_to(tmp33, [XBLOCK, 1])
    tmp39 = tl.load(in_ptr7 + (0))
    tmp40 = tl.broadcast_to(tmp39, [XBLOCK, 1])
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.where(rmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tmp10 = -tmp9
    tmp11 = tl_math.exp(tmp10)
    tmp14 = 192.0
    tmp15 = tmp13 / tmp14
    tmp16 = tmp11 * tmp15
    tmp17 = tmp16 + tmp9
    tmp20 = -tmp19
    tmp21 = tl_math.exp(tmp20)
    tmp24 = 64.0
    tmp25 = tmp23 / tmp24
    tmp26 = tmp21 * tmp25
    tmp27 = tmp17 + tmp26
    tmp28 = tmp27 + tmp19
    tmp31 = -tmp30
    tmp32 = tl_math.exp(tmp31)
    tmp35 = 144.0
    tmp36 = tmp34 / tmp35
    tmp37 = tmp32 * tmp36
    tmp38 = tmp37 + tmp30
    tmp41 = -tmp40
    tmp42 = tl_math.exp(tmp41)
    tmp43 = 48.0
    tmp44 = tmp7 / tmp43
    tmp45 = tmp42 * tmp44
    tmp46 = tmp38 + tmp45
    tmp47 = tmp46 + tmp40
    tmp48 = tmp28 + tmp47
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp48, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (1, ), (1, ))
    assert_size_stride(arg2_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg3_1, (1, ), (1, ))
    assert_size_stride(arg4_1, (1, ), (1, ))
    assert_size_stride(arg5_1, (1, ), (1, ))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((), (), torch.float32)
        # Topologically Sorted Source Nodes: [l1_loss], Original ATen: [aten.sub, aten.abs, aten.mean]
        stream0 = get_raw_stream(0)
        triton_per_fused_abs_mean_sub_0.run(arg0_1, arg2_1, buf0, 1, 192, grid=grid(1), stream=stream0)
        buf1 = empty_strided_cuda((), (), torch.float32)
        # Topologically Sorted Source Nodes: [l1_loss_1], Original ATen: [aten.sub, aten.abs, aten.mean]
        triton_per_fused_abs_mean_sub_1.run(arg0_1, arg2_1, buf1, 1, 64, grid=grid(1), stream=stream0)
        buf2 = empty_strided_cuda((12, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [vos], Original ATen: [aten.stack]
        triton_poi_fused_stack_2.run(arg0_1, buf2, 192, grid=grid(192), stream=stream0)
        del arg0_1
        buf3 = empty_strided_cuda((12, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [vos_1], Original ATen: [aten.stack]
        triton_poi_fused_stack_2.run(arg2_1, buf3, 192, grid=grid(192), stream=stream0)
        del arg2_1
        buf4 = empty_strided_cuda((), (), torch.float32)
        # Topologically Sorted Source Nodes: [l1_loss_2], Original ATen: [aten.sub, aten.abs, aten.mean]
        triton_per_fused_abs_mean_sub_3.run(buf2, buf3, buf4, 1, 144, grid=grid(1), stream=stream0)
        buf6 = reinterpret_tensor(buf0, (1, ), (1, ), 0); del buf0  # reuse
        # Topologically Sorted Source Nodes: [neg, exp, l1_loss, mul, add, neg_1, exp_1, l1_loss_1, mul_1, add_1, abs_loss, neg_2, exp_2, l1_loss_2, mul_2, add_3, neg_3, exp_3, l1_loss_3, mul_3, add_4, vo_loss, loss], Original ATen: [aten.neg, aten.exp, aten.sub, aten.abs, aten.mean, aten.mul, aten.add]
        triton_per_fused_abs_add_exp_mean_mul_neg_sub_4.run(buf6, buf2, buf3, arg1_1, arg3_1, buf1, arg4_1, buf4, arg5_1, 1, 48, grid=grid(1), stream=stream0)
        del arg1_1
        del arg3_1
        del arg4_1
        del arg5_1
        del buf1
        del buf2
        del buf3
        del buf4
    return (buf6, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    arg0_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    arg2_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg3_1 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    arg4_1 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    arg5_1 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_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.nn.init


def calc_vos_simple(poses):
    vos = []
    for p in poses:
        pvos = [(p[i + 1].unsqueeze(0) - p[i].unsqueeze(0)) for i in range(
            len(p) - 1)]
        vos.append(torch.cat(pvos, dim=0))
    vos = torch.stack(vos, dim=0)
    return vos


class AtLocPlusCriterion(nn.Module):

    def __init__(self, t_loss_fn=nn.L1Loss(), q_loss_fn=nn.L1Loss(), sax=
        0.0, saq=0.0, srx=0.0, srq=0.0, learn_beta=False, learn_gamma=False):
        super(AtLocPlusCriterion, self).__init__()
        self.t_loss_fn = t_loss_fn
        self.q_loss_fn = q_loss_fn
        self.sax = nn.Parameter(torch.Tensor([sax]), requires_grad=learn_beta)
        self.saq = nn.Parameter(torch.Tensor([saq]), requires_grad=learn_beta)
        self.srx = nn.Parameter(torch.Tensor([srx]), requires_grad=learn_gamma)
        self.srq = nn.Parameter(torch.Tensor([srq]), requires_grad=learn_gamma)

    def forward(self, pred, targ):
        s = pred.size()
        abs_loss = torch.exp(-self.sax) * self.t_loss_fn(pred.view(-1, *s[2
            :])[:, :3], targ.view(-1, *s[2:])[:, :3]) + self.sax + torch.exp(
            -self.saq) * self.q_loss_fn(pred.view(-1, *s[2:])[:, 3:], targ.
            view(-1, *s[2:])[:, 3:]) + self.saq
        pred_vos = calc_vos_simple(pred)
        targ_vos = calc_vos_simple(targ)
        s = pred_vos.size()
        vo_loss = torch.exp(-self.srx) * self.t_loss_fn(pred_vos.view(-1, *
            s[2:])[:, :3], targ_vos.view(-1, *s[2:])[:, :3]
            ) + self.srx + torch.exp(-self.srq) * self.q_loss_fn(pred_vos.
            view(-1, *s[2:])[:, 3:], targ_vos.view(-1, *s[2:])[:, 3:]
            ) + self.srq
        loss = abs_loss + vo_loss
        return loss


def get_inputs():
    return [torch.rand([4, 4, 4, 4]), torch.rand([4, 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.nn.init
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_per_fused_abs_mean_sub_0(in_ptr0, in_ptr1, out_ptr0, xnumel,
    rnumel, XBLOCK: tl.constexpr):
    rnumel = 192
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    rmask = rindex < rnumel
    r0 = rindex % 12
    r1 = rindex // 12
    tmp0 = tl.load(in_ptr0 + (r0 + 16 * r1), rmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r0 + 16 * r1), rmask, other=0.0)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.where(rmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp7, None)


@triton.jit
def triton_per_fused_abs_mean_sub_1(in_ptr0, in_ptr1, out_ptr0, xnumel,
    rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex % 4
    r1 = rindex // 4
    tmp0 = tl.load(in_ptr0 + (12 + r0 + 16 * r1), None)
    tmp1 = tl.load(in_ptr1 + (12 + r0 + 16 * r1), None)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.sum(tmp4, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp6, None)


@triton.jit
def triton_poi_fused_stack_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16
    x0 = xindex % 16
    x2 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 3, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.full([1], 1, tl.int64)
    tmp6 = tmp0 < tmp5
    tmp7 = tmp6 & tmp4
    tmp8 = tl.load(in_ptr0 + (16 + x0), tmp7 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp9 = tl.load(in_ptr0 + x0, tmp7 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp10 = tmp8 - tmp9
    tmp11 = tl.full(tmp10.shape, 0.0, tmp10.dtype)
    tmp12 = tl.where(tmp7, tmp10, tmp11)
    tmp13 = tmp0 >= tmp5
    tmp14 = tl.full([1], 2, tl.int64)
    tmp15 = tmp0 < tmp14
    tmp16 = tmp13 & tmp15
    tmp17 = tmp16 & tmp4
    tmp18 = tl.load(in_ptr0 + (32 + x0), tmp17 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp19 = tl.load(in_ptr0 + (16 + x0), tmp17 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp20 = tmp18 - tmp19
    tmp21 = tl.full(tmp20.shape, 0.0, tmp20.dtype)
    tmp22 = tl.where(tmp17, tmp20, tmp21)
    tmp23 = tmp0 >= tmp14
    tmp24 = tmp23 & tmp4
    tmp25 = tl.load(in_ptr0 + (48 + x0), tmp24 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp26 = tl.load(in_ptr0 + (32 + x0), tmp24 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp27 = tmp25 - tmp26
    tmp28 = tl.full(tmp27.shape, 0.0, tmp27.dtype)
    tmp29 = tl.where(tmp24, tmp27, tmp28)
    tmp30 = tl.where(tmp16, tmp22, tmp29)
    tmp31 = tl.where(tmp6, tmp12, tmp30)
    tmp32 = tl.full(tmp31.shape, 0.0, tmp31.dtype)
    tmp33 = tl.where(tmp4, tmp31, tmp32)
    tmp34 = tmp0 >= tmp3
    tmp35 = tl.full([1], 6, tl.int64)
    tmp36 = tmp0 < tmp35
    tmp37 = tmp34 & tmp36
    tmp38 = -3 + x1
    tmp40 = tmp38 < tmp5
    tmp41 = tmp40 & tmp37
    tmp42 = tl.load(in_ptr0 + (80 + x0), tmp41 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp43 = tl.load(in_ptr0 + (64 + x0), tmp41 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp44 = tmp42 - tmp43
    tmp45 = tl.full(tmp44.shape, 0.0, tmp44.dtype)
    tmp46 = tl.where(tmp41, tmp44, tmp45)
    tmp47 = tmp38 >= tmp5
    tmp48 = tmp38 < tmp14
    tmp49 = tmp47 & tmp48
    tmp50 = tmp49 & tmp37
    tmp51 = tl.load(in_ptr0 + (96 + x0), tmp50 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp52 = tl.load(in_ptr0 + (80 + x0), tmp50 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp53 = tmp51 - tmp52
    tmp54 = tl.full(tmp53.shape, 0.0, tmp53.dtype)
    tmp55 = tl.where(tmp50, tmp53, tmp54)
    tmp56 = tmp38 >= tmp14
    tmp58 = tmp56 & tmp37
    tmp59 = tl.load(in_ptr0 + (112 + x0), tmp58 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp60 = tl.load(in_ptr0 + (96 + x0), tmp58 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp61 = tmp59 - tmp60
    tmp62 = tl.full(tmp61.shape, 0.0, tmp61.dtype)
    tmp63 = tl.where(tmp58, tmp61, tmp62)
    tmp64 = tl.where(tmp49, tmp55, tmp63)
    tmp65 = tl.where(tmp40, tmp46, tmp64)
    tmp66 = tl.full(tmp65.shape, 0.0, tmp65.dtype)
    tmp67 = tl.where(tmp37, tmp65, tmp66)
    tmp68 = tmp0 >= tmp35
    tmp69 = tl.full([1], 9, tl.int64)
    tmp70 = tmp0 < tmp69
    tmp71 = tmp68 & tmp70
    tmp72 = -6 + x1
    tmp74 = tmp72 < tmp5
    tmp75 = tmp74 & tmp71
    tmp76 = tl.load(in_ptr0 + (144 + x0), tmp75 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp77 = tl.load(in_ptr0 + (128 + x0), tmp75 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp78 = tmp76 - tmp77
    tmp79 = tl.full(tmp78.shape, 0.0, tmp78.dtype)
    tmp80 = tl.where(tmp75, tmp78, tmp79)
    tmp81 = tmp72 >= tmp5
    tmp82 = tmp72 < tmp14
    tmp83 = tmp81 & tmp82
    tmp84 = tmp83 & tmp71
    tmp85 = tl.load(in_ptr0 + (160 + x0), tmp84 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp86 = tl.load(in_ptr0 + (144 + x0), tmp84 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp87 = tmp85 - tmp86
    tmp88 = tl.full(tmp87.shape, 0.0, tmp87.dtype)
    tmp89 = tl.where(tmp84, tmp87, tmp88)
    tmp90 = tmp72 >= tmp14
    tmp92 = tmp90 & tmp71
    tmp93 = tl.load(in_ptr0 + (176 + x0), tmp92 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp94 = tl.load(in_ptr0 + (160 + x0), tmp92 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp95 = tmp93 - tmp94
    tmp96 = tl.full(tmp95.shape, 0.0, tmp95.dtype)
    tmp97 = tl.where(tmp92, tmp95, tmp96)
    tmp98 = tl.where(tmp83, tmp89, tmp97)
    tmp99 = tl.where(tmp74, tmp80, tmp98)
    tmp100 = tl.full(tmp99.shape, 0.0, tmp99.dtype)
    tmp101 = tl.where(tmp71, tmp99, tmp100)
    tmp102 = tmp0 >= tmp69
    tl.full([1], 12, tl.int64)
    tmp105 = -9 + x1
    tmp107 = tmp105 < tmp5
    tmp108 = tmp107 & tmp102
    tmp109 = tl.load(in_ptr0 + (208 + x0), tmp108 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp110 = tl.load(in_ptr0 + (192 + x0), tmp108 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp111 = tmp109 - tmp110
    tmp112 = tl.full(tmp111.shape, 0.0, tmp111.dtype)
    tmp113 = tl.where(tmp108, tmp111, tmp112)
    tmp114 = tmp105 >= tmp5
    tmp115 = tmp105 < tmp14
    tmp116 = tmp114 & tmp115
    tmp117 = tmp116 & tmp102
    tmp118 = tl.load(in_ptr0 + (224 + x0), tmp117 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp119 = tl.load(in_ptr0 + (208 + x0), tmp117 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp120 = tmp118 - tmp119
    tmp121 = tl.full(tmp120.shape, 0.0, tmp120.dtype)
    tmp122 = tl.where(tmp117, tmp120, tmp121)
    tmp123 = tmp105 >= tmp14
    tmp125 = tmp123 & tmp102
    tmp126 = tl.load(in_ptr0 + (240 + x0), tmp125 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp127 = tl.load(in_ptr0 + (224 + x0), tmp125 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp128 = tmp126 - tmp127
    tmp129 = tl.full(tmp128.shape, 0.0, tmp128.dtype)
    tmp130 = tl.where(tmp125, tmp128, tmp129)
    tmp131 = tl.where(tmp116, tmp122, tmp130)
    tmp132 = tl.where(tmp107, tmp113, tmp131)
    tmp133 = tl.full(tmp132.shape, 0.0, tmp132.dtype)
    tmp134 = tl.where(tmp102, tmp132, tmp133)
    tmp135 = tl.where(tmp71, tmp101, tmp134)
    tmp136 = tl.where(tmp37, tmp67, tmp135)
    tmp137 = tl.where(tmp4, tmp33, tmp136)
    tl.store(out_ptr0 + x2, tmp137, xmask)


@triton.jit
def triton_per_fused_abs_mean_sub_3(in_ptr0, in_ptr1, out_ptr0, xnumel,
    rnumel, XBLOCK: tl.constexpr):
    rnumel = 144
    RBLOCK: tl.constexpr = 256
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    rmask = rindex < rnumel
    r0 = rindex % 12
    r1 = rindex // 12
    tmp0 = tl.load(in_ptr0 + (r0 + 16 * r1), rmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r0 + 16 * r1), rmask, other=0.0)
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.where(rmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tl.store(out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp7, None)


@triton.jit
def triton_per_fused_abs_add_exp_mean_mul_neg_sub_4(in_out_ptr0, in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, in_ptr5, in_ptr6, in_ptr7, xnumel,
    rnumel, XBLOCK: tl.constexpr):
    rnumel = 48
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    rmask = rindex < rnumel
    r0 = rindex % 4
    r1 = rindex // 4
    tmp0 = tl.load(in_ptr0 + (12 + r0 + 16 * r1), rmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (12 + r0 + 16 * r1), rmask, other=0.0)
    tmp8 = tl.load(in_ptr2 + 0)
    tmp9 = tl.broadcast_to(tmp8, [XBLOCK, 1])
    tmp12 = tl.load(in_out_ptr0 + 0)
    tmp13 = tl.broadcast_to(tmp12, [XBLOCK, 1])
    tmp18 = tl.load(in_ptr3 + 0)
    tmp19 = tl.broadcast_to(tmp18, [XBLOCK, 1])
    tmp22 = tl.load(in_ptr4 + 0)
    tmp23 = tl.broadcast_to(tmp22, [XBLOCK, 1])
    tmp29 = tl.load(in_ptr5 + 0)
    tmp30 = tl.broadcast_to(tmp29, [XBLOCK, 1])
    tmp33 = tl.load(in_ptr6 + 0)
    tmp34 = tl.broadcast_to(tmp33, [XBLOCK, 1])
    tmp39 = tl.load(in_ptr7 + 0)
    tmp40 = tl.broadcast_to(tmp39, [XBLOCK, 1])
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp4 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp6 = tl.where(rmask, tmp4, 0)
    tmp7 = tl.sum(tmp6, 1)[:, None]
    tmp10 = -tmp9
    tmp11 = tl_math.exp(tmp10)
    tmp14 = 192.0
    tmp15 = tmp13 / tmp14
    tmp16 = tmp11 * tmp15
    tmp17 = tmp16 + tmp9
    tmp20 = -tmp19
    tmp21 = tl_math.exp(tmp20)
    tmp24 = 64.0
    tmp25 = tmp23 / tmp24
    tmp26 = tmp21 * tmp25
    tmp27 = tmp17 + tmp26
    tmp28 = tmp27 + tmp19
    tmp31 = -tmp30
    tmp32 = tl_math.exp(tmp31)
    tmp35 = 144.0
    tmp36 = tmp34 / tmp35
    tmp37 = tmp32 * tmp36
    tmp38 = tmp37 + tmp30
    tmp41 = -tmp40
    tmp42 = tl_math.exp(tmp41)
    tmp43 = 48.0
    tmp44 = tmp7 / tmp43
    tmp45 = tmp42 * tmp44
    tmp46 = tmp38 + tmp45
    tmp47 = tmp46 + tmp40
    tmp48 = tmp28 + tmp47
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp48, None)


def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (1,), (1,))
    assert_size_stride(arg2_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg3_1, (1,), (1,))
    assert_size_stride(arg4_1, (1,), (1,))
    assert_size_stride(arg5_1, (1,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((), (), torch.float32)
        get_raw_stream(0)
        triton_per_fused_abs_mean_sub_0[grid(1)](arg0_1, arg2_1, buf0, 1, 
            192, XBLOCK=1, num_warps=2, num_stages=1)
        buf1 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_abs_mean_sub_1[grid(1)](arg0_1, arg2_1, buf1, 1, 
            64, XBLOCK=1, num_warps=2, num_stages=1)
        buf2 = empty_strided_cuda((12, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_stack_2[grid(192)](arg0_1, buf2, 192, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg0_1
        buf3 = empty_strided_cuda((12, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_stack_2[grid(192)](arg2_1, buf3, 192, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg2_1
        buf4 = empty_strided_cuda((), (), torch.float32)
        triton_per_fused_abs_mean_sub_3[grid(1)](buf2, buf3, buf4, 1, 144,
            XBLOCK=1, num_warps=2, num_stages=1)
        buf6 = reinterpret_tensor(buf0, (1,), (1,), 0)
        del buf0
        triton_per_fused_abs_add_exp_mean_mul_neg_sub_4[grid(1)](buf6, buf2,
            buf3, arg1_1, arg3_1, buf1, arg4_1, buf4, arg5_1, 1, 48, XBLOCK
            =1, num_warps=2, num_stages=1)
        del arg1_1
        del arg3_1
        del arg4_1
        del arg5_1
        del buf1
        del buf2
        del buf3
        del buf4
    return buf6,


def calc_vos_simple(poses):
    vos = []
    for p in poses:
        pvos = [(p[i + 1].unsqueeze(0) - p[i].unsqueeze(0)) for i in range(
            len(p) - 1)]
        vos.append(torch.cat(pvos, dim=0))
    vos = torch.stack(vos, dim=0)
    return vos


class AtLocPlusCriterionNew(nn.Module):

    def __init__(self, t_loss_fn=nn.L1Loss(), q_loss_fn=nn.L1Loss(), sax=
        0.0, saq=0.0, srx=0.0, srq=0.0, learn_beta=False, learn_gamma=False):
        super(AtLocPlusCriterionNew, self).__init__()
        self.t_loss_fn = t_loss_fn
        self.q_loss_fn = q_loss_fn
        self.sax = nn.Parameter(torch.Tensor([sax]), requires_grad=learn_beta)
        self.saq = nn.Parameter(torch.Tensor([saq]), requires_grad=learn_beta)
        self.srx = nn.Parameter(torch.Tensor([srx]), requires_grad=learn_gamma)
        self.srq = nn.Parameter(torch.Tensor([srq]), requires_grad=learn_gamma)

    def forward(self, input_0, input_1):
        arg1_1 = self.sax
        arg3_1 = self.saq
        arg4_1 = self.srx
        arg5_1 = self.srq
        arg0_1 = input_0
        arg2_1 = input_1
        output = call([arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1])
        return output[0]
