# 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_4/inductor_cache/yv/cyvap7j3rcqrtuv3wrc3n4rlhc4wagsezo7s4lrfe53ili5imvei.py
# Topologically Sorted Source Nodes: [out], Original ATen: [aten._to_copy, aten.arange, aten.mul, aten.clamp, aten._unsafe_index, aten.sub, aten.add]
# Source node to ATen node mapping:
#   out => _unsafe_index, _unsafe_index_1, _unsafe_index_2, _unsafe_index_3, add_2, add_3, add_4, clamp_max_2, clamp_max_3, clamp_min_1, clamp_min_2, clamp_min_3, convert_element_type_1, convert_element_type_2, convert_element_type_3, iota_1, mul_1, mul_2, mul_3, mul_4, sub, sub_1, sub_2, sub_3, sub_4
# Graph fragment:
#   %convert_element_type_1 : [num_users=4] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%view, torch.int64), kwargs = {})
#   %iota_1 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (8,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %convert_element_type_2 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%iota_1, torch.float32), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%convert_element_type_2, 0.42857142857142855), kwargs = {})
#   %clamp_min_1 : [num_users=2] = call_function[target=torch.ops.aten.clamp_min.default](args = (%mul_1, 0.0), kwargs = {})
#   %convert_element_type_3 : [num_users=4] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%clamp_min_1, torch.int64), kwargs = {})
#   %_unsafe_index_3 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %clamp_max, %clamp_max_1]), kwargs = {})
#   %_unsafe_index_2 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %clamp_max, %convert_element_type_3]), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_3, %_unsafe_index_2), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_min_1, %convert_element_type_3), kwargs = {})
#   %clamp_min_2 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub, 0.0), kwargs = {})
#   %clamp_max_2 : [num_users=2] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_2, 1.0), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_2, %clamp_max_2), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_2, %mul_3), kwargs = {})
#   %_unsafe_index_1 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %convert_element_type_1, %clamp_max_1]), kwargs = {})
#   %_unsafe_index : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%arg0_1, [None, None, %convert_element_type_1, %convert_element_type_3]), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_1, %_unsafe_index), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_1, %clamp_max_2), kwargs = {})
#   %add_2 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index, %mul_2), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_3, %add_2), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%view, %convert_element_type_1), kwargs = {})
#   %clamp_min_3 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_3, 0.0), kwargs = {})
#   %clamp_max_3 : [num_users=1] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_3, 1.0), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_4, %clamp_max_3), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_2, %mul_4), kwargs = {})
triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0 = async_compile.triton('triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_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.pointwise(
    size_hints=[1024], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 0, '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__to_copy__unsafe_index_add_arange_clamp_mul_sub_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 8) % 8
    x0 = xindex % 8
    x2 = (xindex // 64)
    x4 = xindex
    tmp0 = x1
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.42857142857142855
    tmp3 = tmp1 * tmp2
    tmp4 = 0.0
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp6 = tmp5.to(tl.int32)
    tmp7 = tl.full([1], 1, tl.int64)
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 3, tl.int64)
    tmp10 = triton_helpers.minimum(tmp8, tmp9)
    tmp11 = x0
    tmp12 = tmp11.to(tl.float32)
    tmp13 = tmp12 * tmp2
    tmp14 = triton_helpers.maximum(tmp13, tmp4)
    tmp15 = tmp14.to(tl.int32)
    tmp16 = tl.load(in_ptr0 + (tmp15 + (4*tmp10) + (16*x2)), xmask, eviction_policy='evict_last')
    tmp17 = tmp15 + tmp7
    tmp18 = triton_helpers.minimum(tmp17, tmp9)
    tmp19 = tl.load(in_ptr0 + (tmp18 + (4*tmp10) + (16*x2)), xmask, eviction_policy='evict_last')
    tmp20 = tmp19 - tmp16
    tmp21 = tmp15.to(tl.float32)
    tmp22 = tmp14 - tmp21
    tmp23 = triton_helpers.maximum(tmp22, tmp4)
    tmp24 = 1.0
    tmp25 = triton_helpers.minimum(tmp23, tmp24)
    tmp26 = tmp20 * tmp25
    tmp27 = tmp16 + tmp26
    tmp28 = tl.load(in_ptr0 + (tmp15 + (4*tmp6) + (16*x2)), xmask, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr0 + (tmp18 + (4*tmp6) + (16*x2)), xmask, eviction_policy='evict_last')
    tmp30 = tmp29 - tmp28
    tmp31 = tmp30 * tmp25
    tmp32 = tmp28 + tmp31
    tmp33 = tmp27 - tmp32
    tmp34 = tmp6.to(tl.float32)
    tmp35 = tmp5 - tmp34
    tmp36 = triton_helpers.maximum(tmp35, tmp4)
    tmp37 = triton_helpers.minimum(tmp36, tmp24)
    tmp38 = tmp33 * tmp37
    tmp39 = tmp32 + tmp38
    tl.store(in_out_ptr0 + (x4), tmp39, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/km/ckmejwyh54enpg64wjr3q5vtz5xhxvr6ss5bn4i72xzdlbdlifi7.py
# Topologically Sorted Source Nodes: [cat, out_2], Original ATen: [aten.cat, aten.arange, aten._to_copy, aten.mul, aten.clamp, aten._unsafe_index, aten.sub, aten.add]
# Source node to ATen node mapping:
#   cat => cat
#   out_2 => _unsafe_index_4, _unsafe_index_5, _unsafe_index_6, _unsafe_index_7, add_7, add_8, clamp_max_6, clamp_min_5, clamp_min_6, convert_element_type_6, convert_element_type_7, iota_3, mul_6, mul_7, mul_8, sub_5, sub_6, sub_7
# Graph fragment:
#   %cat : [num_users=4] = call_function[target=torch.ops.aten.cat.default](args = ([%arg1_1, %slice_2], 1), kwargs = {})
#   %iota_3 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (8,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %convert_element_type_6 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%iota_3, torch.float32), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%convert_element_type_6, 0.42857142857142855), kwargs = {})
#   %clamp_min_5 : [num_users=2] = call_function[target=torch.ops.aten.clamp_min.default](args = (%mul_6, 0.0), kwargs = {})
#   %convert_element_type_7 : [num_users=4] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%clamp_min_5, torch.int64), kwargs = {})
#   %_unsafe_index_7 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat, [None, None, %clamp_max_4, %clamp_max_5]), kwargs = {})
#   %_unsafe_index_6 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat, [None, None, %clamp_max_4, %convert_element_type_7]), kwargs = {})
#   %sub_7 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_7, %_unsafe_index_6), kwargs = {})
#   %sub_5 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_min_5, %convert_element_type_7), kwargs = {})
#   %clamp_min_6 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_5, 0.0), kwargs = {})
#   %clamp_max_6 : [num_users=2] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_6, 1.0), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_7, %clamp_max_6), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_6, %mul_8), kwargs = {})
#   %_unsafe_index_5 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat, [None, None, %convert_element_type_5, %clamp_max_5]), kwargs = {})
#   %_unsafe_index_4 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat, [None, None, %convert_element_type_5, %convert_element_type_7]), kwargs = {})
#   %sub_6 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_5, %_unsafe_index_4), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_6, %clamp_max_6), kwargs = {})
#   %add_7 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_4, %mul_7), kwargs = {})
triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_1 = async_compile.triton('triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_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.pointwise(
    size_hints=[2048], 
    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__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_1', 'mutated_arg_names': ['in_out_ptr0', 'in_out_ptr1'], 'no_x_dim': False, 'num_load': 0, '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__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_1(in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 2048
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x1 = (xindex // 8) % 8
    x0 = xindex % 8
    x2 = (xindex // 64) % 8
    x3 = (xindex // 512)
    x5 = xindex
    tmp0 = x1
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.42857142857142855
    tmp3 = tmp1 * tmp2
    tmp4 = 0.0
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp6 = tmp5.to(tl.int32)
    tmp7 = tl.full([1], 1, tl.int64)
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 3, tl.int64)
    tmp10 = triton_helpers.minimum(tmp8, tmp9)
    tmp11 = x0
    tmp12 = tmp11.to(tl.float32)
    tmp13 = tmp12 * tmp2
    tmp14 = triton_helpers.maximum(tmp13, tmp4)
    tmp15 = tmp14.to(tl.int32)
    tmp16 = tmp15 + tmp7
    tmp17 = triton_helpers.minimum(tmp16, tmp9)
    tmp18 = x2
    tmp19 = tl.full([1], 0, tl.int64)
    tmp20 = tmp18 >= tmp19
    tmp21 = tl.full([1], 4, tl.int64)
    tmp22 = tmp18 < tmp21
    tmp23 = tl.load(in_ptr0 + (tmp17 + (4*tmp10) + (16*x2) + (64*x3)), tmp22, eviction_policy='evict_last', other=0.0)
    tmp24 = tmp18 >= tmp21
    tmp25 = tl.full([1], 8, tl.int64)
    tmp26 = tmp18 < tmp25
    tmp27 = tl.load(in_ptr1 + (18 + tmp17 + (8*tmp10) + (64*((-4) + x2)) + (256*x3)), tmp24, eviction_policy='evict_last', other=0.0)
    tmp28 = tl.where(tmp22, tmp23, tmp27)
    tmp29 = tl.load(in_ptr0 + (tmp15 + (4*tmp10) + (16*x2) + (64*x3)), tmp22, eviction_policy='evict_last', other=0.0)
    tmp30 = tl.load(in_ptr1 + (18 + tmp15 + (8*tmp10) + (64*((-4) + x2)) + (256*x3)), tmp24, eviction_policy='evict_last', other=0.0)
    tmp31 = tl.where(tmp22, tmp29, tmp30)
    tmp32 = tmp28 - tmp31
    tmp33 = tmp15.to(tl.float32)
    tmp34 = tmp14 - tmp33
    tmp35 = triton_helpers.maximum(tmp34, tmp4)
    tmp36 = 1.0
    tmp37 = triton_helpers.minimum(tmp35, tmp36)
    tmp38 = tmp32 * tmp37
    tmp39 = tmp31 + tmp38
    tmp40 = tl.load(in_ptr0 + (tmp17 + (4*tmp6) + (16*x2) + (64*x3)), tmp22, eviction_policy='evict_last', other=0.0)
    tmp41 = tl.load(in_ptr1 + (18 + tmp17 + (8*tmp6) + (64*((-4) + x2)) + (256*x3)), tmp24, eviction_policy='evict_last', other=0.0)
    tmp42 = tl.where(tmp22, tmp40, tmp41)
    tmp43 = tl.load(in_ptr0 + (tmp15 + (4*tmp6) + (16*x2) + (64*x3)), tmp22, eviction_policy='evict_last', other=0.0)
    tmp44 = tl.load(in_ptr1 + (18 + tmp15 + (8*tmp6) + (64*((-4) + x2)) + (256*x3)), tmp24, eviction_policy='evict_last', other=0.0)
    tmp45 = tl.where(tmp22, tmp43, tmp44)
    tmp46 = tmp42 - tmp45
    tmp47 = tmp46 * tmp37
    tmp48 = tmp45 + tmp47
    tl.store(in_out_ptr0 + (x5), tmp39, None)
    tl.store(in_out_ptr1 + (x5), tmp48, None)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/zi/czipwlrer7yngruenvrqslolhgcsx5r3sl55ve6v5vavpgceuobi.py
# Topologically Sorted Source Nodes: [cat_1, out_4], Original ATen: [aten.cat, aten._to_copy, aten.arange, aten.mul, aten.clamp, aten._unsafe_index, aten.sub, aten.add]
# Source node to ATen node mapping:
#   cat_1 => cat_1
#   out_4 => _unsafe_index_10, _unsafe_index_11, _unsafe_index_8, _unsafe_index_9, add_12, add_13, clamp_max_10, clamp_max_11, clamp_min_10, clamp_min_11, clamp_min_9, convert_element_type_10, convert_element_type_11, convert_element_type_9, iota_5, mul_11, mul_12, mul_13, mul_14, sub_10, sub_11, sub_12, sub_13, sub_14
# Graph fragment:
#   %cat_1 : [num_users=4] = call_function[target=torch.ops.aten.cat.default](args = ([%arg2_1, %slice_4], 1), kwargs = {})
#   %convert_element_type_9 : [num_users=4] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%view_4, torch.int64), kwargs = {})
#   %iota_5 : [num_users=1] = call_function[target=torch.ops.prims.iota.default](args = (8,), kwargs = {start: 0, step: 1, dtype: torch.int64, device: cuda:0, requires_grad: False})
#   %convert_element_type_10 : [num_users=1] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%iota_5, torch.float32), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%convert_element_type_10, 0.42857142857142855), kwargs = {})
#   %clamp_min_9 : [num_users=2] = call_function[target=torch.ops.aten.clamp_min.default](args = (%mul_11, 0.0), kwargs = {})
#   %convert_element_type_11 : [num_users=4] = call_function[target=torch.ops.prims.convert_element_type.default](args = (%clamp_min_9, torch.int64), kwargs = {})
#   %_unsafe_index_11 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat_1, [None, None, %clamp_max_8, %clamp_max_9]), kwargs = {})
#   %_unsafe_index_10 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat_1, [None, None, %clamp_max_8, %convert_element_type_11]), kwargs = {})
#   %sub_12 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_11, %_unsafe_index_10), kwargs = {})
#   %sub_10 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%clamp_min_9, %convert_element_type_11), kwargs = {})
#   %clamp_min_10 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_10, 0.0), kwargs = {})
#   %clamp_max_10 : [num_users=2] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_10, 1.0), kwargs = {})
#   %mul_13 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_12, %clamp_max_10), kwargs = {})
#   %add_13 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_10, %mul_13), kwargs = {})
#   %_unsafe_index_9 : [num_users=1] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat_1, [None, None, %convert_element_type_9, %clamp_max_9]), kwargs = {})
#   %_unsafe_index_8 : [num_users=2] = call_function[target=torch.ops.aten._unsafe_index.Tensor](args = (%cat_1, [None, None, %convert_element_type_9, %convert_element_type_11]), kwargs = {})
#   %sub_11 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%_unsafe_index_9, %_unsafe_index_8), kwargs = {})
#   %mul_12 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_11, %clamp_max_10), kwargs = {})
#   %add_12 : [num_users=2] = call_function[target=torch.ops.aten.add.Tensor](args = (%_unsafe_index_8, %mul_12), kwargs = {})
#   %sub_14 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_13, %add_12), kwargs = {})
#   %sub_13 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%view_4, %convert_element_type_9), kwargs = {})
#   %clamp_min_11 : [num_users=1] = call_function[target=torch.ops.aten.clamp_min.default](args = (%sub_13, 0.0), kwargs = {})
#   %clamp_max_11 : [num_users=1] = call_function[target=torch.ops.aten.clamp_max.default](args = (%clamp_min_11, 1.0), kwargs = {})
#   %mul_14 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sub_14, %clamp_max_11), kwargs = {})
triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_2 = async_compile.triton('triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_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=[4096], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_2', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 0, '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__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_2(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, out_ptr1, out_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 3072
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 8) % 8
    x0 = xindex % 8
    x2 = (xindex // 64) % 12
    x3 = (xindex // 768)
    x6 = xindex
    tmp0 = x1
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.42857142857142855
    tmp3 = tmp1 * tmp2
    tmp4 = 0.0
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp6 = tmp5.to(tl.int32)
    tmp7 = tl.full([1], 1, tl.int64)
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 3, tl.int64)
    tmp10 = triton_helpers.minimum(tmp8, tmp9)
    tmp11 = x0
    tmp12 = tmp11.to(tl.float32)
    tmp13 = tmp12 * tmp2
    tmp14 = triton_helpers.maximum(tmp13, tmp4)
    tmp15 = tmp14.to(tl.int32)
    tmp16 = tmp15 + tmp7
    tmp17 = triton_helpers.minimum(tmp16, tmp9)
    tmp18 = x2
    tmp19 = tl.full([1], 0, tl.int64)
    tmp20 = tmp18 >= tmp19
    tmp21 = tl.full([1], 4, tl.int64)
    tmp22 = tmp18 < tmp21
    tmp23 = tl.load(in_ptr0 + (tmp17 + (4*tmp10) + (16*x2) + (64*x3)), tmp22 & xmask, eviction_policy='evict_last', other=0.0)
    tmp24 = tmp18 >= tmp21
    tmp25 = tl.full([1], 12, tl.int64)
    tmp26 = tmp18 < tmp25
    tmp27 = tl.load(in_ptr1 + (18 + tmp17 + (8*tmp10) + (64*((-4) + x2)) + (512*x3)), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp28 = tl.load(in_ptr2 + (18 + tmp17 + (8*tmp10) + (64*((-4) + x2)) + (512*x3)), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp29 = tmp28 - tmp27
    tmp30 = tl.broadcast_to(2 + tmp10, [XBLOCK])
    tmp31 = tmp30.to(tl.float32)
    tmp32 = tmp31 * tmp2
    tmp33 = triton_helpers.maximum(tmp32, tmp4)
    tmp34 = tmp33.to(tl.int32)
    tmp35 = tmp34.to(tl.float32)
    tmp36 = tmp33 - tmp35
    tmp37 = triton_helpers.maximum(tmp36, tmp4)
    tmp38 = 1.0
    tmp39 = triton_helpers.minimum(tmp37, tmp38)
    tmp40 = tmp29 * tmp39
    tmp41 = tmp27 + tmp40
    tmp42 = tl.full(tmp41.shape, 0.0, tmp41.dtype)
    tmp43 = tl.where(tmp24, tmp41, tmp42)
    tmp44 = tl.where(tmp22, tmp23, tmp43)
    tmp45 = tl.load(in_ptr0 + (tmp15 + (4*tmp10) + (16*x2) + (64*x3)), tmp22 & xmask, eviction_policy='evict_last', other=0.0)
    tmp46 = tl.load(in_ptr1 + (18 + tmp15 + (8*tmp10) + (64*((-4) + x2)) + (512*x3)), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp47 = tl.load(in_ptr2 + (18 + tmp15 + (8*tmp10) + (64*((-4) + x2)) + (512*x3)), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp48 = tmp47 - tmp46
    tmp49 = tmp48 * tmp39
    tmp50 = tmp46 + tmp49
    tmp51 = tl.full(tmp50.shape, 0.0, tmp50.dtype)
    tmp52 = tl.where(tmp24, tmp50, tmp51)
    tmp53 = tl.where(tmp22, tmp45, tmp52)
    tmp54 = tl.load(in_ptr0 + (tmp17 + (4*tmp6) + (16*x2) + (64*x3)), tmp22 & xmask, eviction_policy='evict_last', other=0.0)
    tmp55 = tl.load(in_ptr1 + (18 + tmp17 + (8*tmp6) + (64*((-4) + x2)) + (512*x3)), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp56 = tl.load(in_ptr2 + (18 + tmp17 + (8*tmp6) + (64*((-4) + x2)) + (512*x3)), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp57 = tmp56 - tmp55
    tmp58 = tl.broadcast_to(2 + tmp6, [XBLOCK])
    tmp59 = tmp58.to(tl.float32)
    tmp60 = tmp59 * tmp2
    tmp61 = triton_helpers.maximum(tmp60, tmp4)
    tmp62 = tmp61.to(tl.int32)
    tmp63 = tmp62.to(tl.float32)
    tmp64 = tmp61 - tmp63
    tmp65 = triton_helpers.maximum(tmp64, tmp4)
    tmp66 = triton_helpers.minimum(tmp65, tmp38)
    tmp67 = tmp57 * tmp66
    tmp68 = tmp55 + tmp67
    tmp69 = tl.full(tmp68.shape, 0.0, tmp68.dtype)
    tmp70 = tl.where(tmp24, tmp68, tmp69)
    tmp71 = tl.where(tmp22, tmp54, tmp70)
    tmp72 = tl.load(in_ptr0 + (tmp15 + (4*tmp6) + (16*x2) + (64*x3)), tmp22 & xmask, eviction_policy='evict_last', other=0.0)
    tmp73 = tl.load(in_ptr1 + (18 + tmp15 + (8*tmp6) + (64*((-4) + x2)) + (512*x3)), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp74 = tl.load(in_ptr2 + (18 + tmp15 + (8*tmp6) + (64*((-4) + x2)) + (512*x3)), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp75 = tmp74 - tmp73
    tmp76 = tmp75 * tmp66
    tmp77 = tmp73 + tmp76
    tmp78 = tl.full(tmp77.shape, 0.0, tmp77.dtype)
    tmp79 = tl.where(tmp24, tmp77, tmp78)
    tmp80 = tl.where(tmp22, tmp72, tmp79)
    tmp81 = tmp44 - tmp53
    tmp82 = tmp15.to(tl.float32)
    tmp83 = tmp14 - tmp82
    tmp84 = triton_helpers.maximum(tmp83, tmp4)
    tmp85 = triton_helpers.minimum(tmp84, tmp38)
    tmp86 = tmp81 * tmp85
    tmp87 = tmp53 + tmp86
    tmp88 = tmp71 - tmp80
    tmp89 = tmp88 * tmp85
    tmp90 = tmp80 + tmp89
    tmp91 = tmp87 - tmp90
    tmp92 = tmp6.to(tl.float32)
    tmp93 = tmp5 - tmp92
    tmp94 = triton_helpers.maximum(tmp93, tmp4)
    tmp95 = triton_helpers.minimum(tmp94, tmp38)
    tmp96 = tmp91 * tmp95
    tl.store(out_ptr1 + (x6), tmp71, xmask)
    tl.store(out_ptr2 + (x6), tmp80, xmask)
    tl.store(in_out_ptr0 + (x6), tmp96, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_4/inductor_cache/dw/cdwhkkigkqcwthccttxm2auz3imjlysypx2bak5ym4zdgiskebvl.py
# Topologically Sorted Source Nodes: [out_6], Original ATen: [aten.cat]
# Source node to ATen node mapping:
#   out_6 => cat_2
# Graph fragment:
#   %cat_2 : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%arg3_1, %slice_6], 1), kwargs = {})
triton_poi_fused_cat_3 = async_compile.triton('triton_poi_fused_cat_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=[1024], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_cat_3', '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_cat_3(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = (xindex // 16) % 16
    x3 = (xindex // 256)
    x4 = xindex % 16
    x0 = xindex % 4
    x1 = (xindex // 4) % 4
    x6 = xindex
    tmp0 = x2
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x4 + (16*x2) + (64*x3)), tmp4 & xmask, other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 16, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tl.load(in_ptr1 + (18 + x0 + (8*x1) + (64*((-4) + x2)) + (768*x3)), tmp6 & xmask, other=0.0)
    tmp10 = tl.load(in_ptr2 + (18 + x0 + (8*x1) + (64*((-4) + x2)) + (768*x3)), tmp6 & xmask, other=0.0)
    tmp11 = tmp10 - tmp9
    tmp12 = 2 + x0
    tmp13 = tmp12.to(tl.float32)
    tmp14 = 0.42857142857142855
    tmp15 = tmp13 * tmp14
    tmp16 = 0.0
    tmp17 = triton_helpers.maximum(tmp15, tmp16)
    tmp18 = tmp17.to(tl.int32)
    tmp19 = tmp18.to(tl.float32)
    tmp20 = tmp17 - tmp19
    tmp21 = triton_helpers.maximum(tmp20, tmp16)
    tmp22 = 1.0
    tmp23 = triton_helpers.minimum(tmp21, tmp22)
    tmp24 = tmp11 * tmp23
    tmp25 = tmp9 + tmp24
    tmp26 = tl.load(in_ptr3 + (18 + x0 + (8*x1) + (64*((-4) + x2)) + (768*x3)), tmp6 & xmask, other=0.0)
    tmp27 = tmp25 + tmp26
    tmp28 = tl.full(tmp27.shape, 0.0, tmp27.dtype)
    tmp29 = tl.where(tmp6, tmp27, tmp28)
    tmp30 = tl.where(tmp4, tmp5, tmp29)
    tl.store(out_ptr0 + (x6), tmp30, xmask)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg2_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg3_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 8, 8), (256, 64, 8, 1), torch.float32)
        buf1 = buf0; del buf0  # reuse
        # Topologically Sorted Source Nodes: [out], Original ATen: [aten._to_copy, aten.arange, aten.mul, aten.clamp, aten._unsafe_index, aten.sub, aten.add]
        stream0 = get_raw_stream(0)
        triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0.run(buf1, arg0_1, 1024, grid=grid(1024), stream=stream0)
        del arg0_1
        buf2 = empty_strided_cuda((4, 8, 8, 8), (512, 64, 8, 1), torch.float32)
        buf3 = buf2; del buf2  # reuse
        buf4 = buf3; del buf3  # reuse
        buf5 = empty_strided_cuda((4, 8, 8, 8), (512, 64, 8, 1), torch.float32)
        buf6 = buf5; del buf5  # reuse
        # Topologically Sorted Source Nodes: [cat, out_2], Original ATen: [aten.cat, aten.arange, aten._to_copy, aten.mul, aten.clamp, aten._unsafe_index, aten.sub, aten.add]
        triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_1.run(buf4, buf6, arg1_1, buf1, 2048, grid=grid(2048), stream=stream0)
        del arg1_1
        buf7 = empty_strided_cuda((4, 12, 8, 8), (768, 64, 8, 1), torch.float32)
        buf9 = empty_strided_cuda((4, 12, 8, 8), (768, 64, 8, 1), torch.float32)
        buf10 = empty_strided_cuda((4, 12, 8, 8), (768, 64, 8, 1), torch.float32)
        buf11 = buf7; del buf7  # reuse
        # Topologically Sorted Source Nodes: [cat_1, out_4], Original ATen: [aten.cat, aten._to_copy, aten.arange, aten.mul, aten.clamp, aten._unsafe_index, aten.sub, aten.add]
        triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_2.run(buf11, arg2_1, buf6, buf4, buf9, buf10, 3072, grid=grid(3072), stream=stream0)
        del arg2_1
        del buf4
        del buf6
        buf12 = reinterpret_tensor(buf1, (4, 16, 4, 4), (256, 16, 4, 1), 0); del buf1  # reuse
        # Topologically Sorted Source Nodes: [out_6], Original ATen: [aten.cat]
        triton_poi_fused_cat_3.run(arg3_1, buf10, buf9, buf11, buf12, 1024, grid=grid(1024), stream=stream0)
        del arg3_1
        del buf10
        del buf11
        del buf9
    return (buf12, )


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


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

import torch
import torch.nn as nn


class DeepSupervisionModule(nn.Module):

    def __init__(self, up_sampling_factors=(2, 2, 2)):
        super(DeepSupervisionModule, self).__init__()
        self.up = nn.UpsamplingBilinear2d(scale_factor=2)
        self.up_sampling_factors = up_sampling_factors

    def forward(self, dec4, dec3, dec2, dec1):
        out = self.up(dec4)
        if self.up_sampling_factors[0] == 4:
            out = self.up(out)
        start = [(out.shape[-2] - dec3.shape[-2]) // 2, (out.shape[-1] -
            dec3.shape[-1]) // 2]
        length = [dec3.shape[-2], dec3.shape[-1]]
        out = torch.narrow(torch.narrow(out, dim=2, start=start[0], length=
            length[0]), dim=3, start=start[1], length=length[1])
        out = self.up(torch.cat(tensors=(dec3, out), dim=1))
        if self.up_sampling_factors[1] == 4:
            out = self.up(out)
        start = [(out.shape[-2] - dec2.shape[-2]) // 2, (out.shape[-1] -
            dec2.shape[-1]) // 2]
        length = [dec2.shape[-2], dec2.shape[-1]]
        out = torch.narrow(torch.narrow(out, dim=2, start=start[0], length=
            length[0]), dim=3, start=start[1], length=length[1])
        out = self.up(torch.cat(tensors=(dec2, out), dim=1))
        if self.up_sampling_factors[2] == 4:
            out = self.up(out)
        start = [(out.shape[-2] - dec1.shape[-2]) // 2, (out.shape[-1] -
            dec1.shape[-1]) // 2]
        length = [dec1.shape[-2], dec1.shape[-1]]
        out = torch.narrow(torch.narrow(out, dim=2, start=start[0], length=
            length[0]), dim=3, start=start[1], length=length[1])
        out = torch.cat(tensors=(dec1, out), dim=1)
        return out


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


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

import torch
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0(
    in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 8 % 8
    x0 = xindex % 8
    x2 = xindex // 64
    x4 = xindex
    tmp0 = x1
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.42857142857142855
    tmp3 = tmp1 * tmp2
    tmp4 = 0.0
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp6 = tmp5.to(tl.int32)
    tmp7 = tl.full([1], 1, tl.int64)
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 3, tl.int64)
    tmp10 = triton_helpers.minimum(tmp8, tmp9)
    tmp11 = x0
    tmp12 = tmp11.to(tl.float32)
    tmp13 = tmp12 * tmp2
    tmp14 = triton_helpers.maximum(tmp13, tmp4)
    tmp15 = tmp14.to(tl.int32)
    tmp16 = tl.load(in_ptr0 + (tmp15 + 4 * tmp10 + 16 * x2), xmask,
        eviction_policy='evict_last')
    tmp17 = tmp15 + tmp7
    tmp18 = triton_helpers.minimum(tmp17, tmp9)
    tmp19 = tl.load(in_ptr0 + (tmp18 + 4 * tmp10 + 16 * x2), xmask,
        eviction_policy='evict_last')
    tmp20 = tmp19 - tmp16
    tmp21 = tmp15.to(tl.float32)
    tmp22 = tmp14 - tmp21
    tmp23 = triton_helpers.maximum(tmp22, tmp4)
    tmp24 = 1.0
    tmp25 = triton_helpers.minimum(tmp23, tmp24)
    tmp26 = tmp20 * tmp25
    tmp27 = tmp16 + tmp26
    tmp28 = tl.load(in_ptr0 + (tmp15 + 4 * tmp6 + 16 * x2), xmask,
        eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr0 + (tmp18 + 4 * tmp6 + 16 * x2), xmask,
        eviction_policy='evict_last')
    tmp30 = tmp29 - tmp28
    tmp31 = tmp30 * tmp25
    tmp32 = tmp28 + tmp31
    tmp33 = tmp27 - tmp32
    tmp34 = tmp6.to(tl.float32)
    tmp35 = tmp5 - tmp34
    tmp36 = triton_helpers.maximum(tmp35, tmp4)
    tmp37 = triton_helpers.minimum(tmp36, tmp24)
    tmp38 = tmp33 * tmp37
    tmp39 = tmp32 + tmp38
    tl.store(in_out_ptr0 + x4, tmp39, xmask)


@triton.jit
def triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_1(
    in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 8 % 8
    x0 = xindex % 8
    x2 = xindex // 64 % 8
    x3 = xindex // 512
    x5 = xindex
    tmp0 = x1
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.42857142857142855
    tmp3 = tmp1 * tmp2
    tmp4 = 0.0
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp6 = tmp5.to(tl.int32)
    tmp7 = tl.full([1], 1, tl.int64)
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 3, tl.int64)
    tmp10 = triton_helpers.minimum(tmp8, tmp9)
    tmp11 = x0
    tmp12 = tmp11.to(tl.float32)
    tmp13 = tmp12 * tmp2
    tmp14 = triton_helpers.maximum(tmp13, tmp4)
    tmp15 = tmp14.to(tl.int32)
    tmp16 = tmp15 + tmp7
    tmp17 = triton_helpers.minimum(tmp16, tmp9)
    tmp18 = x2
    tl.full([1], 0, tl.int64)
    tmp21 = tl.full([1], 4, tl.int64)
    tmp22 = tmp18 < tmp21
    tmp23 = tl.load(in_ptr0 + (tmp17 + 4 * tmp10 + 16 * x2 + 64 * x3),
        tmp22, eviction_policy='evict_last', other=0.0)
    tmp24 = tmp18 >= tmp21
    tl.full([1], 8, tl.int64)
    tmp27 = tl.load(in_ptr1 + (18 + tmp17 + 8 * tmp10 + 64 * (-4 + x2) + 
        256 * x3), tmp24, eviction_policy='evict_last', other=0.0)
    tmp28 = tl.where(tmp22, tmp23, tmp27)
    tmp29 = tl.load(in_ptr0 + (tmp15 + 4 * tmp10 + 16 * x2 + 64 * x3),
        tmp22, eviction_policy='evict_last', other=0.0)
    tmp30 = tl.load(in_ptr1 + (18 + tmp15 + 8 * tmp10 + 64 * (-4 + x2) + 
        256 * x3), tmp24, eviction_policy='evict_last', other=0.0)
    tmp31 = tl.where(tmp22, tmp29, tmp30)
    tmp32 = tmp28 - tmp31
    tmp33 = tmp15.to(tl.float32)
    tmp34 = tmp14 - tmp33
    tmp35 = triton_helpers.maximum(tmp34, tmp4)
    tmp36 = 1.0
    tmp37 = triton_helpers.minimum(tmp35, tmp36)
    tmp38 = tmp32 * tmp37
    tmp39 = tmp31 + tmp38
    tmp40 = tl.load(in_ptr0 + (tmp17 + 4 * tmp6 + 16 * x2 + 64 * x3), tmp22,
        eviction_policy='evict_last', other=0.0)
    tmp41 = tl.load(in_ptr1 + (18 + tmp17 + 8 * tmp6 + 64 * (-4 + x2) + 256 *
        x3), tmp24, eviction_policy='evict_last', other=0.0)
    tmp42 = tl.where(tmp22, tmp40, tmp41)
    tmp43 = tl.load(in_ptr0 + (tmp15 + 4 * tmp6 + 16 * x2 + 64 * x3), tmp22,
        eviction_policy='evict_last', other=0.0)
    tmp44 = tl.load(in_ptr1 + (18 + tmp15 + 8 * tmp6 + 64 * (-4 + x2) + 256 *
        x3), tmp24, eviction_policy='evict_last', other=0.0)
    tmp45 = tl.where(tmp22, tmp43, tmp44)
    tmp46 = tmp42 - tmp45
    tmp47 = tmp46 * tmp37
    tmp48 = tmp45 + tmp47
    tl.store(in_out_ptr0 + x5, tmp39, None)
    tl.store(in_out_ptr1 + x5, tmp48, None)


@triton.jit
def triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_2(
    in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, out_ptr1, out_ptr2, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 3072
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 8 % 8
    x0 = xindex % 8
    x2 = xindex // 64 % 12
    x3 = xindex // 768
    x6 = xindex
    tmp0 = x1
    tmp1 = tmp0.to(tl.float32)
    tmp2 = 0.42857142857142855
    tmp3 = tmp1 * tmp2
    tmp4 = 0.0
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp6 = tmp5.to(tl.int32)
    tmp7 = tl.full([1], 1, tl.int64)
    tmp8 = tmp6 + tmp7
    tmp9 = tl.full([1], 3, tl.int64)
    tmp10 = triton_helpers.minimum(tmp8, tmp9)
    tmp11 = x0
    tmp12 = tmp11.to(tl.float32)
    tmp13 = tmp12 * tmp2
    tmp14 = triton_helpers.maximum(tmp13, tmp4)
    tmp15 = tmp14.to(tl.int32)
    tmp16 = tmp15 + tmp7
    tmp17 = triton_helpers.minimum(tmp16, tmp9)
    tmp18 = x2
    tl.full([1], 0, tl.int64)
    tmp21 = tl.full([1], 4, tl.int64)
    tmp22 = tmp18 < tmp21
    tmp23 = tl.load(in_ptr0 + (tmp17 + 4 * tmp10 + 16 * x2 + 64 * x3), 
        tmp22 & xmask, eviction_policy='evict_last', other=0.0)
    tmp24 = tmp18 >= tmp21
    tl.full([1], 12, tl.int64)
    tmp27 = tl.load(in_ptr1 + (18 + tmp17 + 8 * tmp10 + 64 * (-4 + x2) + 
        512 * x3), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp28 = tl.load(in_ptr2 + (18 + tmp17 + 8 * tmp10 + 64 * (-4 + x2) + 
        512 * x3), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp29 = tmp28 - tmp27
    tmp30 = tl.broadcast_to(2 + tmp10, [XBLOCK])
    tmp31 = tmp30.to(tl.float32)
    tmp32 = tmp31 * tmp2
    tmp33 = triton_helpers.maximum(tmp32, tmp4)
    tmp34 = tmp33.to(tl.int32)
    tmp35 = tmp34.to(tl.float32)
    tmp36 = tmp33 - tmp35
    tmp37 = triton_helpers.maximum(tmp36, tmp4)
    tmp38 = 1.0
    tmp39 = triton_helpers.minimum(tmp37, tmp38)
    tmp40 = tmp29 * tmp39
    tmp41 = tmp27 + tmp40
    tmp42 = tl.full(tmp41.shape, 0.0, tmp41.dtype)
    tmp43 = tl.where(tmp24, tmp41, tmp42)
    tmp44 = tl.where(tmp22, tmp23, tmp43)
    tmp45 = tl.load(in_ptr0 + (tmp15 + 4 * tmp10 + 16 * x2 + 64 * x3), 
        tmp22 & xmask, eviction_policy='evict_last', other=0.0)
    tmp46 = tl.load(in_ptr1 + (18 + tmp15 + 8 * tmp10 + 64 * (-4 + x2) + 
        512 * x3), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp47 = tl.load(in_ptr2 + (18 + tmp15 + 8 * tmp10 + 64 * (-4 + x2) + 
        512 * x3), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp48 = tmp47 - tmp46
    tmp49 = tmp48 * tmp39
    tmp50 = tmp46 + tmp49
    tmp51 = tl.full(tmp50.shape, 0.0, tmp50.dtype)
    tmp52 = tl.where(tmp24, tmp50, tmp51)
    tmp53 = tl.where(tmp22, tmp45, tmp52)
    tmp54 = tl.load(in_ptr0 + (tmp17 + 4 * tmp6 + 16 * x2 + 64 * x3), tmp22 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp55 = tl.load(in_ptr1 + (18 + tmp17 + 8 * tmp6 + 64 * (-4 + x2) + 512 *
        x3), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp56 = tl.load(in_ptr2 + (18 + tmp17 + 8 * tmp6 + 64 * (-4 + x2) + 512 *
        x3), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp57 = tmp56 - tmp55
    tmp58 = tl.broadcast_to(2 + tmp6, [XBLOCK])
    tmp59 = tmp58.to(tl.float32)
    tmp60 = tmp59 * tmp2
    tmp61 = triton_helpers.maximum(tmp60, tmp4)
    tmp62 = tmp61.to(tl.int32)
    tmp63 = tmp62.to(tl.float32)
    tmp64 = tmp61 - tmp63
    tmp65 = triton_helpers.maximum(tmp64, tmp4)
    tmp66 = triton_helpers.minimum(tmp65, tmp38)
    tmp67 = tmp57 * tmp66
    tmp68 = tmp55 + tmp67
    tmp69 = tl.full(tmp68.shape, 0.0, tmp68.dtype)
    tmp70 = tl.where(tmp24, tmp68, tmp69)
    tmp71 = tl.where(tmp22, tmp54, tmp70)
    tmp72 = tl.load(in_ptr0 + (tmp15 + 4 * tmp6 + 16 * x2 + 64 * x3), tmp22 &
        xmask, eviction_policy='evict_last', other=0.0)
    tmp73 = tl.load(in_ptr1 + (18 + tmp15 + 8 * tmp6 + 64 * (-4 + x2) + 512 *
        x3), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp74 = tl.load(in_ptr2 + (18 + tmp15 + 8 * tmp6 + 64 * (-4 + x2) + 512 *
        x3), tmp24 & xmask, eviction_policy='evict_last', other=0.0)
    tmp75 = tmp74 - tmp73
    tmp76 = tmp75 * tmp66
    tmp77 = tmp73 + tmp76
    tmp78 = tl.full(tmp77.shape, 0.0, tmp77.dtype)
    tmp79 = tl.where(tmp24, tmp77, tmp78)
    tmp80 = tl.where(tmp22, tmp72, tmp79)
    tmp81 = tmp44 - tmp53
    tmp82 = tmp15.to(tl.float32)
    tmp83 = tmp14 - tmp82
    tmp84 = triton_helpers.maximum(tmp83, tmp4)
    tmp85 = triton_helpers.minimum(tmp84, tmp38)
    tmp86 = tmp81 * tmp85
    tmp87 = tmp53 + tmp86
    tmp88 = tmp71 - tmp80
    tmp89 = tmp88 * tmp85
    tmp90 = tmp80 + tmp89
    tmp91 = tmp87 - tmp90
    tmp92 = tmp6.to(tl.float32)
    tmp93 = tmp5 - tmp92
    tmp94 = triton_helpers.maximum(tmp93, tmp4)
    tmp95 = triton_helpers.minimum(tmp94, tmp38)
    tmp96 = tmp91 * tmp95
    tl.store(out_ptr1 + x6, tmp71, xmask)
    tl.store(out_ptr2 + x6, tmp80, xmask)
    tl.store(in_out_ptr0 + x6, tmp96, xmask)


@triton.jit
def triton_poi_fused_cat_3(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex // 16 % 16
    x3 = xindex // 256
    x4 = xindex % 16
    x0 = xindex % 4
    x1 = xindex // 4 % 4
    x6 = xindex
    tmp0 = x2
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x4 + 16 * x2 + 64 * x3), tmp4 & xmask, other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 16, tl.int64)
    tmp9 = tl.load(in_ptr1 + (18 + x0 + 8 * x1 + 64 * (-4 + x2) + 768 * x3),
        tmp6 & xmask, other=0.0)
    tmp10 = tl.load(in_ptr2 + (18 + x0 + 8 * x1 + 64 * (-4 + x2) + 768 * x3
        ), tmp6 & xmask, other=0.0)
    tmp11 = tmp10 - tmp9
    tmp12 = 2 + x0
    tmp13 = tmp12.to(tl.float32)
    tmp14 = 0.42857142857142855
    tmp15 = tmp13 * tmp14
    tmp16 = 0.0
    tmp17 = triton_helpers.maximum(tmp15, tmp16)
    tmp18 = tmp17.to(tl.int32)
    tmp19 = tmp18.to(tl.float32)
    tmp20 = tmp17 - tmp19
    tmp21 = triton_helpers.maximum(tmp20, tmp16)
    tmp22 = 1.0
    tmp23 = triton_helpers.minimum(tmp21, tmp22)
    tmp24 = tmp11 * tmp23
    tmp25 = tmp9 + tmp24
    tmp26 = tl.load(in_ptr3 + (18 + x0 + 8 * x1 + 64 * (-4 + x2) + 768 * x3
        ), tmp6 & xmask, other=0.0)
    tmp27 = tmp25 + tmp26
    tmp28 = tl.full(tmp27.shape, 0.0, tmp27.dtype)
    tmp29 = tl.where(tmp6, tmp27, tmp28)
    tmp30 = tl.where(tmp4, tmp5, tmp29)
    tl.store(out_ptr0 + x6, tmp30, xmask)


def call(args):
    arg0_1, arg1_1, arg2_1, arg3_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg2_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg3_1, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 8, 8), (256, 64, 8, 1), torch.float32)
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused__to_copy__unsafe_index_add_arange_clamp_mul_sub_0[grid
            (1024)](buf1, arg0_1, 1024, XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
        buf2 = empty_strided_cuda((4, 8, 8, 8), (512, 64, 8, 1), torch.float32)
        buf3 = buf2
        del buf2
        buf4 = buf3
        del buf3
        buf5 = empty_strided_cuda((4, 8, 8, 8), (512, 64, 8, 1), torch.float32)
        buf6 = buf5
        del buf5
        triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_1[
            grid(2048)](buf4, buf6, arg1_1, buf1, 2048, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg1_1
        buf7 = empty_strided_cuda((4, 12, 8, 8), (768, 64, 8, 1), torch.float32
            )
        buf9 = empty_strided_cuda((4, 12, 8, 8), (768, 64, 8, 1), torch.float32
            )
        buf10 = empty_strided_cuda((4, 12, 8, 8), (768, 64, 8, 1), torch.
            float32)
        buf11 = buf7
        del buf7
        triton_poi_fused__to_copy__unsafe_index_add_arange_cat_clamp_mul_sub_2[
            grid(3072)](buf11, arg2_1, buf6, buf4, buf9, buf10, 3072,
            XBLOCK=128, num_warps=4, num_stages=1)
        del arg2_1
        del buf4
        del buf6
        buf12 = reinterpret_tensor(buf1, (4, 16, 4, 4), (256, 16, 4, 1), 0)
        del buf1
        triton_poi_fused_cat_3[grid(1024)](arg3_1, buf10, buf9, buf11,
            buf12, 1024, XBLOCK=256, num_warps=4, num_stages=1)
        del arg3_1
        del buf10
        del buf11
        del buf9
    return buf12,


class DeepSupervisionModuleNew(nn.Module):

    def __init__(self, up_sampling_factors=(2, 2, 2)):
        super(DeepSupervisionModuleNew, self).__init__()
        self.up = nn.UpsamplingBilinear2d(scale_factor=2)
        self.up_sampling_factors = up_sampling_factors

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