# 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/mt/cmtrzhde3xvkbbrbxbhlpwzr6zziv6z7o2vl6xhkqbvvxtyrdmk5.py
# Topologically Sorted Source Nodes: [max_d, index, setitem, setitem_1, prob, index_1, setitem_2, setitem_3, prob_1, index_2, setitem_4, setitem_5, prob_2, index_3, setitem_6, setitem_7, prob_3, index_4, setitem_8, setitem_9, prob_4, index_5, setitem_10, setitem_11, prob_5, index_6, setitem_12, setitem_13, prob_6, index_7, setitem_14, setitem_15, prob_7, index_8, setitem_16, setitem_17, prob_8], Original ATen: [aten.argmax, aten.add, aten.lift_fresh, aten.index_put, aten.gather]
# Source node to ATen node mapping:
#   index => add
#   index_1 => add_1
#   index_2 => add_2
#   index_3 => add_3
#   index_4 => add_4
#   index_5 => add_5
#   index_6 => add_6
#   index_7 => add_7
#   index_8 => add_8
#   max_d => argmax
#   prob => gather
#   prob_1 => gather_1
#   prob_2 => gather_2
#   prob_3 => gather_3
#   prob_4 => gather_4
#   prob_5 => gather_5
#   prob_6 => gather_6
#   prob_7 => gather_7
#   prob_8 => gather_8
#   setitem => full_default, index_put
#   setitem_1 => full_default_1, index_put_1
#   setitem_10 => full_default_10, index_put_10
#   setitem_11 => full_default_11, index_put_11
#   setitem_12 => full_default_12, index_put_12
#   setitem_13 => full_default_13, index_put_13
#   setitem_14 => full_default_14, index_put_14
#   setitem_15 => full_default_15, index_put_15
#   setitem_16 => full_default_16, index_put_16
#   setitem_17 => full_default_17, index_put_17
#   setitem_2 => full_default_2, index_put_2
#   setitem_3 => full_default_3, index_put_3
#   setitem_4 => full_default_4, index_put_4
#   setitem_5 => full_default_5, index_put_5
#   setitem_6 => full_default_6, index_put_6
#   setitem_7 => full_default_7, index_put_7
#   setitem_8 => full_default_8, index_put_8
#   setitem_9 => full_default_9, index_put_9
# Graph fragment:
#   %argmax : [num_users=9] = call_function[target=torch.ops.aten.argmax.default](args = (%arg0_1, 1, True), kwargs = {})
#   %add : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, -4), kwargs = {})
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add, [%lt], %full_default), kwargs = {})
#   %full_default_1 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_1 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put, [%gt], %full_default_1), kwargs = {})
#   %gather : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_1), kwargs = {})
#   %add_1 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, -3), kwargs = {})
#   %full_default_2 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_2 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add_1, [%lt_1], %full_default_2), kwargs = {})
#   %full_default_3 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_3 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put_2, [%gt_1], %full_default_3), kwargs = {})
#   %gather_1 : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_3), kwargs = {})
#   %add_2 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, -2), kwargs = {})
#   %full_default_4 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_4 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add_2, [%lt_2], %full_default_4), kwargs = {})
#   %full_default_5 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_5 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put_4, [%gt_2], %full_default_5), kwargs = {})
#   %gather_2 : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_5), kwargs = {})
#   %add_3 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, -1), kwargs = {})
#   %full_default_6 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_6 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add_3, [%lt_3], %full_default_6), kwargs = {})
#   %full_default_7 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_7 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put_6, [%gt_3], %full_default_7), kwargs = {})
#   %gather_3 : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_7), kwargs = {})
#   %add_4 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, 0), kwargs = {})
#   %full_default_8 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_8 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add_4, [%lt_4], %full_default_8), kwargs = {})
#   %full_default_9 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_9 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put_8, [%gt_4], %full_default_9), kwargs = {})
#   %gather_4 : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_9), kwargs = {})
#   %add_5 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, 1), kwargs = {})
#   %full_default_10 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_10 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add_5, [%lt_5], %full_default_10), kwargs = {})
#   %full_default_11 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_11 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put_10, [%gt_5], %full_default_11), kwargs = {})
#   %gather_5 : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_11), kwargs = {})
#   %add_6 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, 2), kwargs = {})
#   %full_default_12 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_12 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add_6, [%lt_6], %full_default_12), kwargs = {})
#   %full_default_13 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_13 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put_12, [%gt_6], %full_default_13), kwargs = {})
#   %gather_6 : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_13), kwargs = {})
#   %add_7 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, 3), kwargs = {})
#   %full_default_14 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_14 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add_7, [%lt_7], %full_default_14), kwargs = {})
#   %full_default_15 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_15 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put_14, [%gt_7], %full_default_15), kwargs = {})
#   %gather_7 : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_15), kwargs = {})
#   %add_8 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%argmax, 4), kwargs = {})
#   %full_default_16 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_16 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%add_8, [%lt_8], %full_default_16), kwargs = {})
#   %full_default_17 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 3), kwargs = {dtype: torch.int64, layout: torch.strided, device: cpu, pin_memory: False})
#   %index_put_17 : [num_users=2] = call_function[target=torch.ops.aten.index_put_.default](args = (%index_put_16, [%gt_8], %full_default_17), kwargs = {})
#   %gather_8 : [num_users=1] = call_function[target=torch.ops.aten.gather.default](args = (%arg0_1, 1, %index_put_17), kwargs = {})
triton_poi_fused_add_argmax_gather_index_put_lift_fresh_0 = async_compile.triton('triton_poi_fused_add_argmax_gather_index_put_lift_fresh_0', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*i64', 2: '*i64', 3: '*i64', 4: '*i64', 5: '*i64', 6: '*i64', 7: '*i64', 8: '*i64', 9: '*i64', 10: '*fp32', 11: '*fp32', 12: '*fp32', 13: '*fp32', 14: '*fp32', 15: '*fp32', 16: '*fp32', 17: '*fp32', 18: '*fp32', 19: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 19), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_argmax_gather_index_put_lift_fresh_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_add_argmax_gather_index_put_lift_fresh_0(in_ptr0, out_ptr2, out_ptr4, out_ptr6, out_ptr8, out_ptr10, out_ptr12, out_ptr14, out_ptr16, out_ptr18, out_ptr19, out_ptr20, out_ptr21, out_ptr22, out_ptr23, out_ptr24, out_ptr25, out_ptr26, out_ptr27, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x1 = (xindex // 16)
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + (64*x1)), xmask)
    tmp1 = tl.load(in_ptr0 + (16 + x0 + (64*x1)), xmask)
    tmp17 = tl.load(in_ptr0 + (32 + x0 + (64*x1)), xmask)
    tmp32 = tl.load(in_ptr0 + (48 + x0 + (64*x1)), xmask)
    tmp2 = tmp0 > tmp1
    tmp3 = tmp0 == tmp1
    tmp4 = tmp0 != tmp0
    tmp5 = tmp1 != tmp1
    tmp6 = tmp4 > tmp5
    tmp7 = tmp2 | tmp6
    tmp8 = tmp4 & tmp5
    tmp9 = tmp3 | tmp8
    tmp10 = tl.full([1], 0, tl.int64)
    tmp11 = tl.full([1], 1, tl.int64)
    tmp12 = tmp10 < tmp11
    tmp13 = tmp9 & tmp12
    tmp14 = tmp7 | tmp13
    tmp15 = tl.where(tmp14, tmp0, tmp1)
    tmp16 = tl.where(tmp14, tmp10, tmp11)
    tmp18 = tmp15 > tmp17
    tmp19 = tmp15 == tmp17
    tmp20 = tmp15 != tmp15
    tmp21 = tmp17 != tmp17
    tmp22 = tmp20 > tmp21
    tmp23 = tmp18 | tmp22
    tmp24 = tmp20 & tmp21
    tmp25 = tmp19 | tmp24
    tmp26 = tl.full([1], 2, tl.int64)
    tmp27 = tmp16 < tmp26
    tmp28 = tmp25 & tmp27
    tmp29 = tmp23 | tmp28
    tmp30 = tl.where(tmp29, tmp15, tmp17)
    tmp31 = tl.where(tmp29, tmp16, tmp26)
    tmp33 = tmp30 > tmp32
    tmp34 = tmp30 == tmp32
    tmp35 = tmp30 != tmp30
    tmp36 = tmp32 != tmp32
    tmp37 = tmp35 > tmp36
    tmp38 = tmp33 | tmp37
    tmp39 = tmp35 & tmp36
    tmp40 = tmp34 | tmp39
    tmp41 = tl.full([1], 3, tl.int64)
    tmp42 = tmp31 < tmp41
    tmp43 = tmp40 & tmp42
    tmp44 = tmp38 | tmp43
    tmp45 = tl.where(tmp44, tmp30, tmp32)
    tmp46 = tl.where(tmp44, tmp31, tmp41)
    tmp47 = tl.full([1], -4, tl.int64)
    tmp48 = tmp46 + tmp47
    tmp49 = tmp48 < tmp10
    tmp50 = tl.where(tmp49, tmp10, tmp48)
    tmp51 = tmp50 > tmp41
    tmp52 = tl.where(tmp51, tmp41, tmp50)
    tmp53 = tl.full([1], -3, tl.int64)
    tmp54 = tmp46 + tmp53
    tmp55 = tmp54 < tmp10
    tmp56 = tl.where(tmp55, tmp10, tmp54)
    tmp57 = tmp56 > tmp41
    tmp58 = tl.where(tmp57, tmp41, tmp56)
    tmp59 = tl.full([1], -2, tl.int64)
    tmp60 = tmp46 + tmp59
    tmp61 = tmp60 < tmp10
    tmp62 = tl.where(tmp61, tmp10, tmp60)
    tmp63 = tmp62 > tmp41
    tmp64 = tl.where(tmp63, tmp41, tmp62)
    tmp65 = tl.full([1], -1, tl.int64)
    tmp66 = tmp46 + tmp65
    tmp67 = tmp66 < tmp10
    tmp68 = tl.where(tmp67, tmp10, tmp66)
    tmp69 = tmp68 > tmp41
    tmp70 = tl.where(tmp69, tmp41, tmp68)
    tmp71 = tmp46 + tmp10
    tmp72 = tmp71 < tmp10
    tmp73 = tl.where(tmp72, tmp10, tmp71)
    tmp74 = tmp73 > tmp41
    tmp75 = tl.where(tmp74, tmp41, tmp73)
    tmp76 = tmp46 + tmp11
    tmp77 = tmp76 < tmp10
    tmp78 = tl.where(tmp77, tmp10, tmp76)
    tmp79 = tmp78 > tmp41
    tmp80 = tl.where(tmp79, tmp41, tmp78)
    tmp81 = tmp46 + tmp26
    tmp82 = tmp81 < tmp10
    tmp83 = tl.where(tmp82, tmp10, tmp81)
    tmp84 = tmp83 > tmp41
    tmp85 = tl.where(tmp84, tmp41, tmp83)
    tmp86 = tmp46 + tmp41
    tmp87 = tmp86 < tmp10
    tmp88 = tl.where(tmp87, tmp10, tmp86)
    tmp89 = tmp88 > tmp41
    tmp90 = tl.where(tmp89, tmp41, tmp88)
    tmp91 = tl.full([1], 4, tl.int64)
    tmp92 = tmp46 + tmp91
    tmp93 = tmp92 < tmp10
    tmp94 = tl.where(tmp93, tmp10, tmp92)
    tmp95 = tmp94 > tmp41
    tmp96 = tl.where(tmp95, tmp41, tmp94)
    tmp97 = tl.full([XBLOCK], 4, tl.int32)
    tmp98 = tmp52 + tmp97
    tmp99 = tmp52 < 0
    tmp100 = tl.where(tmp99, tmp98, tmp52)
    tl.device_assert(((0 <= tmp100) & (tmp100 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp100 < 4")
    tmp102 = tl.load(in_ptr0 + (x0 + (16*tmp100) + (64*x1)), xmask)
    tmp103 = tmp58 + tmp97
    tmp104 = tmp58 < 0
    tmp105 = tl.where(tmp104, tmp103, tmp58)
    tl.device_assert(((0 <= tmp105) & (tmp105 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp105 < 4")
    tmp107 = tl.load(in_ptr0 + (x0 + (16*tmp105) + (64*x1)), xmask)
    tmp108 = tmp64 + tmp97
    tmp109 = tmp64 < 0
    tmp110 = tl.where(tmp109, tmp108, tmp64)
    tl.device_assert(((0 <= tmp110) & (tmp110 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp110 < 4")
    tmp112 = tl.load(in_ptr0 + (x0 + (16*tmp110) + (64*x1)), xmask)
    tmp113 = tmp70 + tmp97
    tmp114 = tmp70 < 0
    tmp115 = tl.where(tmp114, tmp113, tmp70)
    tl.device_assert(((0 <= tmp115) & (tmp115 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp115 < 4")
    tmp117 = tl.load(in_ptr0 + (x0 + (16*tmp115) + (64*x1)), xmask)
    tmp118 = tmp75 + tmp97
    tmp119 = tmp75 < 0
    tmp120 = tl.where(tmp119, tmp118, tmp75)
    tl.device_assert(((0 <= tmp120) & (tmp120 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp120 < 4")
    tmp122 = tl.load(in_ptr0 + (x0 + (16*tmp120) + (64*x1)), xmask)
    tmp123 = tmp80 + tmp97
    tmp124 = tmp80 < 0
    tmp125 = tl.where(tmp124, tmp123, tmp80)
    tl.device_assert(((0 <= tmp125) & (tmp125 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp125 < 4")
    tmp127 = tl.load(in_ptr0 + (x0 + (16*tmp125) + (64*x1)), xmask)
    tmp128 = tmp85 + tmp97
    tmp129 = tmp85 < 0
    tmp130 = tl.where(tmp129, tmp128, tmp85)
    tl.device_assert(((0 <= tmp130) & (tmp130 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp130 < 4")
    tmp132 = tl.load(in_ptr0 + (x0 + (16*tmp130) + (64*x1)), xmask)
    tmp133 = tmp90 + tmp97
    tmp134 = tmp90 < 0
    tmp135 = tl.where(tmp134, tmp133, tmp90)
    tl.device_assert(((0 <= tmp135) & (tmp135 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp135 < 4")
    tmp137 = tl.load(in_ptr0 + (x0 + (16*tmp135) + (64*x1)), xmask)
    tmp138 = tmp96 + tmp97
    tmp139 = tmp96 < 0
    tmp140 = tl.where(tmp139, tmp138, tmp96)
    tl.device_assert(((0 <= tmp140) & (tmp140 < 4)) | ~(xmask), "index out of bounds: 0 <= tmp140 < 4")
    tmp142 = tl.load(in_ptr0 + (x0 + (16*tmp140) + (64*x1)), xmask)
    tl.store(out_ptr2 + (x0 + (144*x1)), tmp52, xmask)
    tl.store(out_ptr4 + (x0 + (144*x1)), tmp58, xmask)
    tl.store(out_ptr6 + (x0 + (144*x1)), tmp64, xmask)
    tl.store(out_ptr8 + (x0 + (144*x1)), tmp70, xmask)
    tl.store(out_ptr10 + (x0 + (144*x1)), tmp75, xmask)
    tl.store(out_ptr12 + (x0 + (144*x1)), tmp80, xmask)
    tl.store(out_ptr14 + (x0 + (144*x1)), tmp85, xmask)
    tl.store(out_ptr16 + (x0 + (144*x1)), tmp90, xmask)
    tl.store(out_ptr18 + (x0 + (144*x1)), tmp96, xmask)
    tl.store(out_ptr19 + (9*x2), tmp102, xmask)
    tl.store(out_ptr20 + (9*x2), tmp107, xmask)
    tl.store(out_ptr21 + (9*x2), tmp112, xmask)
    tl.store(out_ptr22 + (9*x2), tmp117, xmask)
    tl.store(out_ptr23 + (9*x2), tmp122, xmask)
    tl.store(out_ptr24 + (9*x2), tmp127, xmask)
    tl.store(out_ptr25 + (9*x2), tmp132, xmask)
    tl.store(out_ptr26 + (9*x2), tmp137, xmask)
    tl.store(out_ptr27 + (9*x2), tmp142, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_6/inductor_cache/hc/chcrv4z3xuibekjnrpmxzsnizu3g4ubg6rgohy7cmfzimhemq5jp.py
# Topologically Sorted Source Nodes: [sum_1, add_9, part_x_1, part_d, mul, out], Original ATen: [aten.sum, aten.add, aten.div, aten._to_copy, aten.mul]
# Source node to ATen node mapping:
#   add_9 => add_9
#   mul => mul
#   out => sum_2
#   part_d => convert_element_type_1
#   part_x_1 => div
#   sum_1 => sum_1
# Graph fragment:
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%cat, [1], True), kwargs = {})
#   %add_9 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%sum_1, 1e-08), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%cat, %add_9), kwargs = {})
#   %convert_element_type_1 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%cat_1, torch.float32), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div, %convert_element_type_1), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul, [1]), kwargs = {})
triton_per_fused__to_copy_add_div_mul_sum_1 = async_compile.triton('triton_per_fused__to_copy_add_div_mul_sum_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=[64, 16],
    reduction_hint=ReductionHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*i64', 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': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__to_copy_add_div_mul_sum_1', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 2, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused__to_copy_add_div_mul_sum_1(in_out_ptr0, in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    rnumel = 9
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = rindex < rnumel
    r1 = rindex
    x0 = xindex
    x2 = xindex % 16
    x3 = (xindex // 16)
    tmp0 = tl.load(in_ptr0 + (r1 + (9*x0)), rmask & xmask, other=0.0)
    tmp8 = tl.load(in_ptr1 + (x2 + (16*r1) + (144*x3)), rmask & xmask, other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(rmask & xmask, tmp1, 0)
    tmp4 = tl.sum(tmp3, 1)[:, None]
    tmp5 = 1e-08
    tmp6 = tmp4 + tmp5
    tmp7 = tmp0 / tmp6
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 * tmp9
    tmp11 = tl.broadcast_to(tmp10, [XBLOCK, RBLOCK])
    tmp13 = tl.where(rmask & xmask, tmp11, 0)
    tmp14 = tl.sum(tmp13, 1)[:, None]
    tl.store(in_out_ptr0 + (x0), tmp14, 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, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf30 = empty_strided_cuda((4, 9, 4, 4), (144, 16, 4, 1), torch.int64)
        buf2 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 0)  # alias
        buf4 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 16)  # alias
        buf6 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 32)  # alias
        buf8 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 48)  # alias
        buf10 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 64)  # alias
        buf12 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 80)  # alias
        buf14 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 96)  # alias
        buf16 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 112)  # alias
        buf18 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 128)  # alias
        buf28 = empty_strided_cuda((4, 9, 4, 4), (144, 1, 36, 9), torch.float32)
        buf19 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 0)  # alias
        buf20 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 1)  # alias
        buf21 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 2)  # alias
        buf22 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 3)  # alias
        buf23 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 4)  # alias
        buf24 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 5)  # alias
        buf25 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 6)  # alias
        buf26 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 7)  # alias
        buf27 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 8)  # alias
        # Topologically Sorted Source Nodes: [max_d, index, setitem, setitem_1, prob, index_1, setitem_2, setitem_3, prob_1, index_2, setitem_4, setitem_5, prob_2, index_3, setitem_6, setitem_7, prob_3, index_4, setitem_8, setitem_9, prob_4, index_5, setitem_10, setitem_11, prob_5, index_6, setitem_12, setitem_13, prob_6, index_7, setitem_14, setitem_15, prob_7, index_8, setitem_16, setitem_17, prob_8], Original ATen: [aten.argmax, aten.add, aten.lift_fresh, aten.index_put, aten.gather]
        stream0 = get_raw_stream(0)
        triton_poi_fused_add_argmax_gather_index_put_lift_fresh_0.run(arg0_1, buf2, buf4, buf6, buf8, buf10, buf12, buf14, buf16, buf18, buf19, buf20, buf21, buf22, buf23, buf24, buf25, buf26, buf27, 64, grid=grid(64), stream=stream0)
        del arg0_1
        buf29 = empty_strided_cuda((4, 1, 4, 4), (16, 64, 4, 1), torch.float32)
        buf31 = reinterpret_tensor(buf29, (4, 4, 4), (16, 4, 1), 0); del buf29  # reuse
        # Topologically Sorted Source Nodes: [sum_1, add_9, part_x_1, part_d, mul, out], Original ATen: [aten.sum, aten.add, aten.div, aten._to_copy, aten.mul]
        triton_per_fused__to_copy_add_div_mul_sum_1.run(buf31, buf28, buf30, 64, 9, grid=grid(64), stream=stream0)
        del buf10
        del buf12
        del buf14
        del buf16
        del buf18
        del buf19
        del buf2
        del buf20
        del buf21
        del buf22
        del buf23
        del buf24
        del buf25
        del buf26
        del buf27
        del buf28
        del buf30
        del buf4
        del buf6
        del buf8
    return (buf31, )


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)
    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.utils.data


class DisparityRegression(nn.Module):

    def __init__(self, maxdisp, win_size):
        super(DisparityRegression, self).__init__()
        self.max_disp = maxdisp
        self.win_size = win_size

    def forward(self, x):
        disp = torch.arange(0, self.max_disp).view(1, -1, 1, 1).float()
        if self.win_size > 0:
            max_d = torch.argmax(x, dim=1, keepdim=True)
            d_value = []
            prob_value = []
            for d in range(-self.win_size, self.win_size + 1):
                index = max_d + d
                index[index < 0] = 0
                index[index > x.shape[1] - 1] = x.shape[1] - 1
                d_value.append(index)
                prob = torch.gather(x, dim=1, index=index)
                prob_value.append(prob)
            part_x = torch.cat(prob_value, dim=1)
            part_x = part_x / (torch.sum(part_x, dim=1, keepdim=True) + 1e-08)
            part_d = torch.cat(d_value, dim=1).float()
            out = torch.sum(part_x * part_d, dim=1)
        else:
            out = torch.sum(x * disp, 1)
        return out


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


def get_init_inputs():
    return [[], {'maxdisp': 4, 'win_size': 4}]

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
import torch.nn as nn
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_add_argmax_gather_index_put_lift_fresh_0(in_ptr0,
    out_ptr2, out_ptr4, out_ptr6, out_ptr8, out_ptr10, out_ptr12, out_ptr14,
    out_ptr16, out_ptr18, out_ptr19, out_ptr20, out_ptr21, out_ptr22,
    out_ptr23, out_ptr24, out_ptr25, out_ptr26, out_ptr27, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x1 = xindex // 16
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 64 * x1), xmask)
    tmp1 = tl.load(in_ptr0 + (16 + x0 + 64 * x1), xmask)
    tmp17 = tl.load(in_ptr0 + (32 + x0 + 64 * x1), xmask)
    tmp32 = tl.load(in_ptr0 + (48 + x0 + 64 * x1), xmask)
    tmp2 = tmp0 > tmp1
    tmp3 = tmp0 == tmp1
    tmp4 = tmp0 != tmp0
    tmp5 = tmp1 != tmp1
    tmp6 = tmp4 > tmp5
    tmp7 = tmp2 | tmp6
    tmp8 = tmp4 & tmp5
    tmp9 = tmp3 | tmp8
    tmp10 = tl.full([1], 0, tl.int64)
    tmp11 = tl.full([1], 1, tl.int64)
    tmp12 = tmp10 < tmp11
    tmp13 = tmp9 & tmp12
    tmp14 = tmp7 | tmp13
    tmp15 = tl.where(tmp14, tmp0, tmp1)
    tmp16 = tl.where(tmp14, tmp10, tmp11)
    tmp18 = tmp15 > tmp17
    tmp19 = tmp15 == tmp17
    tmp20 = tmp15 != tmp15
    tmp21 = tmp17 != tmp17
    tmp22 = tmp20 > tmp21
    tmp23 = tmp18 | tmp22
    tmp24 = tmp20 & tmp21
    tmp25 = tmp19 | tmp24
    tmp26 = tl.full([1], 2, tl.int64)
    tmp27 = tmp16 < tmp26
    tmp28 = tmp25 & tmp27
    tmp29 = tmp23 | tmp28
    tmp30 = tl.where(tmp29, tmp15, tmp17)
    tmp31 = tl.where(tmp29, tmp16, tmp26)
    tmp33 = tmp30 > tmp32
    tmp34 = tmp30 == tmp32
    tmp35 = tmp30 != tmp30
    tmp36 = tmp32 != tmp32
    tmp37 = tmp35 > tmp36
    tmp38 = tmp33 | tmp37
    tmp39 = tmp35 & tmp36
    tmp40 = tmp34 | tmp39
    tmp41 = tl.full([1], 3, tl.int64)
    tmp42 = tmp31 < tmp41
    tmp43 = tmp40 & tmp42
    tmp44 = tmp38 | tmp43
    tl.where(tmp44, tmp30, tmp32)
    tmp46 = tl.where(tmp44, tmp31, tmp41)
    tmp47 = tl.full([1], -4, tl.int64)
    tmp48 = tmp46 + tmp47
    tmp49 = tmp48 < tmp10
    tmp50 = tl.where(tmp49, tmp10, tmp48)
    tmp51 = tmp50 > tmp41
    tmp52 = tl.where(tmp51, tmp41, tmp50)
    tmp53 = tl.full([1], -3, tl.int64)
    tmp54 = tmp46 + tmp53
    tmp55 = tmp54 < tmp10
    tmp56 = tl.where(tmp55, tmp10, tmp54)
    tmp57 = tmp56 > tmp41
    tmp58 = tl.where(tmp57, tmp41, tmp56)
    tmp59 = tl.full([1], -2, tl.int64)
    tmp60 = tmp46 + tmp59
    tmp61 = tmp60 < tmp10
    tmp62 = tl.where(tmp61, tmp10, tmp60)
    tmp63 = tmp62 > tmp41
    tmp64 = tl.where(tmp63, tmp41, tmp62)
    tmp65 = tl.full([1], -1, tl.int64)
    tmp66 = tmp46 + tmp65
    tmp67 = tmp66 < tmp10
    tmp68 = tl.where(tmp67, tmp10, tmp66)
    tmp69 = tmp68 > tmp41
    tmp70 = tl.where(tmp69, tmp41, tmp68)
    tmp71 = tmp46 + tmp10
    tmp72 = tmp71 < tmp10
    tmp73 = tl.where(tmp72, tmp10, tmp71)
    tmp74 = tmp73 > tmp41
    tmp75 = tl.where(tmp74, tmp41, tmp73)
    tmp76 = tmp46 + tmp11
    tmp77 = tmp76 < tmp10
    tmp78 = tl.where(tmp77, tmp10, tmp76)
    tmp79 = tmp78 > tmp41
    tmp80 = tl.where(tmp79, tmp41, tmp78)
    tmp81 = tmp46 + tmp26
    tmp82 = tmp81 < tmp10
    tmp83 = tl.where(tmp82, tmp10, tmp81)
    tmp84 = tmp83 > tmp41
    tmp85 = tl.where(tmp84, tmp41, tmp83)
    tmp86 = tmp46 + tmp41
    tmp87 = tmp86 < tmp10
    tmp88 = tl.where(tmp87, tmp10, tmp86)
    tmp89 = tmp88 > tmp41
    tmp90 = tl.where(tmp89, tmp41, tmp88)
    tmp91 = tl.full([1], 4, tl.int64)
    tmp92 = tmp46 + tmp91
    tmp93 = tmp92 < tmp10
    tmp94 = tl.where(tmp93, tmp10, tmp92)
    tmp95 = tmp94 > tmp41
    tmp96 = tl.where(tmp95, tmp41, tmp94)
    tmp97 = tl.full([XBLOCK], 4, tl.int32)
    tmp98 = tmp52 + tmp97
    tmp99 = tmp52 < 0
    tmp100 = tl.where(tmp99, tmp98, tmp52)
    tl.device_assert((0 <= tmp100) & (tmp100 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp100 < 4')
    tmp102 = tl.load(in_ptr0 + (x0 + 16 * tmp100 + 64 * x1), xmask)
    tmp103 = tmp58 + tmp97
    tmp104 = tmp58 < 0
    tmp105 = tl.where(tmp104, tmp103, tmp58)
    tl.device_assert((0 <= tmp105) & (tmp105 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp105 < 4')
    tmp107 = tl.load(in_ptr0 + (x0 + 16 * tmp105 + 64 * x1), xmask)
    tmp108 = tmp64 + tmp97
    tmp109 = tmp64 < 0
    tmp110 = tl.where(tmp109, tmp108, tmp64)
    tl.device_assert((0 <= tmp110) & (tmp110 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp110 < 4')
    tmp112 = tl.load(in_ptr0 + (x0 + 16 * tmp110 + 64 * x1), xmask)
    tmp113 = tmp70 + tmp97
    tmp114 = tmp70 < 0
    tmp115 = tl.where(tmp114, tmp113, tmp70)
    tl.device_assert((0 <= tmp115) & (tmp115 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp115 < 4')
    tmp117 = tl.load(in_ptr0 + (x0 + 16 * tmp115 + 64 * x1), xmask)
    tmp118 = tmp75 + tmp97
    tmp119 = tmp75 < 0
    tmp120 = tl.where(tmp119, tmp118, tmp75)
    tl.device_assert((0 <= tmp120) & (tmp120 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp120 < 4')
    tmp122 = tl.load(in_ptr0 + (x0 + 16 * tmp120 + 64 * x1), xmask)
    tmp123 = tmp80 + tmp97
    tmp124 = tmp80 < 0
    tmp125 = tl.where(tmp124, tmp123, tmp80)
    tl.device_assert((0 <= tmp125) & (tmp125 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp125 < 4')
    tmp127 = tl.load(in_ptr0 + (x0 + 16 * tmp125 + 64 * x1), xmask)
    tmp128 = tmp85 + tmp97
    tmp129 = tmp85 < 0
    tmp130 = tl.where(tmp129, tmp128, tmp85)
    tl.device_assert((0 <= tmp130) & (tmp130 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp130 < 4')
    tmp132 = tl.load(in_ptr0 + (x0 + 16 * tmp130 + 64 * x1), xmask)
    tmp133 = tmp90 + tmp97
    tmp134 = tmp90 < 0
    tmp135 = tl.where(tmp134, tmp133, tmp90)
    tl.device_assert((0 <= tmp135) & (tmp135 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp135 < 4')
    tmp137 = tl.load(in_ptr0 + (x0 + 16 * tmp135 + 64 * x1), xmask)
    tmp138 = tmp96 + tmp97
    tmp139 = tmp96 < 0
    tmp140 = tl.where(tmp139, tmp138, tmp96)
    tl.device_assert((0 <= tmp140) & (tmp140 < 4) | ~xmask,
        'index out of bounds: 0 <= tmp140 < 4')
    tmp142 = tl.load(in_ptr0 + (x0 + 16 * tmp140 + 64 * x1), xmask)
    tl.store(out_ptr2 + (x0 + 144 * x1), tmp52, xmask)
    tl.store(out_ptr4 + (x0 + 144 * x1), tmp58, xmask)
    tl.store(out_ptr6 + (x0 + 144 * x1), tmp64, xmask)
    tl.store(out_ptr8 + (x0 + 144 * x1), tmp70, xmask)
    tl.store(out_ptr10 + (x0 + 144 * x1), tmp75, xmask)
    tl.store(out_ptr12 + (x0 + 144 * x1), tmp80, xmask)
    tl.store(out_ptr14 + (x0 + 144 * x1), tmp85, xmask)
    tl.store(out_ptr16 + (x0 + 144 * x1), tmp90, xmask)
    tl.store(out_ptr18 + (x0 + 144 * x1), tmp96, xmask)
    tl.store(out_ptr19 + 9 * x2, tmp102, xmask)
    tl.store(out_ptr20 + 9 * x2, tmp107, xmask)
    tl.store(out_ptr21 + 9 * x2, tmp112, xmask)
    tl.store(out_ptr22 + 9 * x2, tmp117, xmask)
    tl.store(out_ptr23 + 9 * x2, tmp122, xmask)
    tl.store(out_ptr24 + 9 * x2, tmp127, xmask)
    tl.store(out_ptr25 + 9 * x2, tmp132, xmask)
    tl.store(out_ptr26 + 9 * x2, tmp137, xmask)
    tl.store(out_ptr27 + 9 * x2, tmp142, xmask)


@triton.jit
def triton_per_fused__to_copy_add_div_mul_sum_1(in_out_ptr0, in_ptr0,
    in_ptr1, xnumel, rnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    rnumel = 9
    RBLOCK: tl.constexpr = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    rmask = rindex < rnumel
    r1 = rindex
    x0 = xindex
    x2 = xindex % 16
    x3 = xindex // 16
    tmp0 = tl.load(in_ptr0 + (r1 + 9 * x0), rmask & xmask, other=0.0)
    tmp8 = tl.load(in_ptr1 + (x2 + 16 * r1 + 144 * x3), rmask & xmask,
        other=0.0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(rmask & xmask, tmp1, 0)
    tmp4 = tl.sum(tmp3, 1)[:, None]
    tmp5 = 1e-08
    tmp6 = tmp4 + tmp5
    tmp7 = tmp0 / tmp6
    tmp9 = tmp8.to(tl.float32)
    tmp10 = tmp7 * tmp9
    tmp11 = tl.broadcast_to(tmp10, [XBLOCK, RBLOCK])
    tmp13 = tl.where(rmask & xmask, tmp11, 0)
    tmp14 = tl.sum(tmp13, 1)[:, None]
    tl.store(in_out_ptr0 + x0, tmp14, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf30 = empty_strided_cuda((4, 9, 4, 4), (144, 16, 4, 1), torch.int64)
        buf2 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 0)
        buf4 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 16)
        buf6 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 32)
        buf8 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 48)
        buf10 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 64)
        buf12 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 80)
        buf14 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 96)
        buf16 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 112)
        buf18 = reinterpret_tensor(buf30, (4, 1, 4, 4), (144, 16, 4, 1), 128)
        buf28 = empty_strided_cuda((4, 9, 4, 4), (144, 1, 36, 9), torch.float32
            )
        buf19 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 0)
        buf20 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 1)
        buf21 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 2)
        buf22 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 3)
        buf23 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 4)
        buf24 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 5)
        buf25 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 6)
        buf26 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 7)
        buf27 = reinterpret_tensor(buf28, (4, 1, 4, 4), (144, 1, 36, 9), 8)
        get_raw_stream(0)
        triton_poi_fused_add_argmax_gather_index_put_lift_fresh_0[grid(64)](
            arg0_1, buf2, buf4, buf6, buf8, buf10, buf12, buf14, buf16,
            buf18, buf19, buf20, buf21, buf22, buf23, buf24, buf25, buf26,
            buf27, 64, XBLOCK=64, num_warps=1, num_stages=1)
        del arg0_1
        buf29 = empty_strided_cuda((4, 1, 4, 4), (16, 64, 4, 1), torch.float32)
        buf31 = reinterpret_tensor(buf29, (4, 4, 4), (16, 4, 1), 0)
        del buf29
        triton_per_fused__to_copy_add_div_mul_sum_1[grid(64)](buf31, buf28,
            buf30, 64, 9, XBLOCK=8, num_warps=2, num_stages=1)
        del buf10
        del buf12
        del buf14
        del buf16
        del buf18
        del buf19
        del buf2
        del buf20
        del buf21
        del buf22
        del buf23
        del buf24
        del buf25
        del buf26
        del buf27
        del buf28
        del buf30
        del buf4
        del buf6
        del buf8
    return buf31,


class DisparityRegressionNew(nn.Module):

    def __init__(self, maxdisp, win_size):
        super(DisparityRegressionNew, self).__init__()
        self.max_disp = maxdisp
        self.win_size = win_size

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