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

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


# kernel path: runs/run_shard_7/inductor_cache/hw/chwsyrbr5xz57uqk5qm4stgelbvq7mkca2vjd5ttvlwmzqlszhov.py
# Topologically Sorted Source Nodes: [input_1], Original ATen: [aten._softmax]
# Source node to ATen node mapping:
#   input_1 => amax, exp, sub
# Graph fragment:
#   %amax : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%arg0_1, [1], True), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%arg0_1, %amax), kwargs = {})
#   %exp : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%sub,), kwargs = {})
triton_poi_fused__softmax_0 = async_compile.triton('triton_poi_fused__softmax_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=[4096], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__softmax_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused__softmax_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x0 = xindex % 16
    x2 = (xindex // 64)
    tmp0 = tl.load(in_ptr0 + (x3), None)
    tmp1 = tl.load(in_ptr0 + (x0 + (64*x2)), None, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (16 + x0 + (64*x2)), None, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (32 + x0 + (64*x2)), None, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (48 + x0 + (64*x2)), None, eviction_policy='evict_last')
    tmp3 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tmp9 = tl_math.exp(tmp8)
    tl.store(out_ptr0 + (x3), tmp9, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/67/c673bz3rwfem5aesgzu3zrytkp2jysk4psxpvm2c6yrm7xxjwjya.py
# Topologically Sorted Source Nodes: [input_1], Original ATen: [aten._softmax]
# Source node to ATen node mapping:
#   input_1 => div, sum_1
# Graph fragment:
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp, [1], True), kwargs = {})
#   %div : [num_users=4] = call_function[target=torch.ops.aten.div.Tensor](args = (%exp, %sum_1), kwargs = {})
triton_poi_fused__softmax_1 = async_compile.triton('triton_poi_fused__softmax_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=[4096], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__softmax_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused__softmax_1(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x0 = xindex % 16
    x2 = (xindex // 64)
    tmp0 = tl.load(in_ptr0 + (x3), None)
    tmp1 = tl.load(in_ptr0 + (x0 + (64*x2)), None, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (16 + x0 + (64*x2)), None, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (32 + x0 + (64*x2)), None, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (48 + x0 + (64*x2)), None, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + (x3), tmp8, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/e3/ce3yckdjegwszt2np5a2op2phxajpstcaw75t7ymjv4iywbk4p3c.py
# Topologically Sorted Source Nodes: [target_onehot], Original ATen: [aten.index]
# Source node to ATen node mapping:
#   target_onehot => index
# Graph fragment:
#   %index : [num_users=1] = call_function[target=torch.ops.aten.index.Tensor](args = (%select_scatter_default_7, [%arg1_1]), kwargs = {})
triton_poi_fused_index_2 = async_compile.triton('triton_poi_fused_index_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: '*i64', 1: '*i64', 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_index_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, '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_index_2(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x1 = (xindex // 4)
    x0 = xindex % 4
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x1), None, eviction_policy='evict_last')
    tmp1 = tl.full([XBLOCK], 4, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tmp4 = tl.where(tmp3, tmp2, tmp0)
    tl.device_assert((0 <= tmp4) & (tmp4 < 4), "index out of bounds: 0 <= tmp4 < 4")
    tmp6 = tmp4
    tmp7 = tl.full([1], 3, tl.int32)
    tmp8 = tmp6 == tmp7
    tmp9 = x0
    tmp10 = tmp9 == tmp7
    tmp11 = tl.full([1], 2, tl.int32)
    tmp12 = tmp7 == tmp11
    tmp13 = tmp9 == tmp11
    tmp14 = tl.full([1], 1, tl.int32)
    tmp15 = tmp11 == tmp14
    tmp16 = tmp9 == tmp14
    tmp17 = tl.full([1], 0, tl.int32)
    tmp18 = tmp14 == tmp17
    tmp19 = tmp9 == tmp17
    tmp20 = tl.full([1], 1, tl.int64)
    tmp21 = tl.full([1], 0, tl.int64)
    tmp22 = tl.where(tmp19, tmp20, tmp21)
    tmp23 = tl.where(tmp18, tmp22, tmp21)
    tmp24 = tl.where(tmp16, tmp20, tmp23)
    tmp25 = tmp11 == tmp17
    tmp26 = tl.where(tmp25, tmp22, tmp21)
    tmp27 = tl.where(tmp15, tmp24, tmp26)
    tmp28 = tl.where(tmp13, tmp20, tmp27)
    tmp29 = tmp7 == tmp14
    tmp30 = tmp7 == tmp17
    tmp31 = tl.where(tmp30, tmp22, tmp21)
    tmp32 = tl.where(tmp29, tmp24, tmp31)
    tmp33 = tl.where(tmp12, tmp28, tmp32)
    tmp34 = tl.where(tmp10, tmp20, tmp33)
    tmp35 = tmp6 == tmp11
    tmp36 = tmp6 == tmp14
    tmp37 = tmp6 == tmp17
    tmp38 = tl.where(tmp37, tmp22, tmp21)
    tmp39 = tl.where(tmp36, tmp24, tmp38)
    tmp40 = tl.where(tmp35, tmp28, tmp39)
    tmp41 = tl.where(tmp8, tmp34, tmp40)
    tl.store(out_ptr0 + (x2), tmp41, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/f4/cf42esw4imladbwtro353qog2ryt2b47xxpb4fqwrg5iwezkkqog.py
# Topologically Sorted Source Nodes: [w, contiguous_1, tflat, mul, intersection, mul_1, add, sum_2, sum_3, add_1, add_2, truediv, sub, mul_2, loss, w_2, contiguous_3, tflat_1, mul_3, intersection_1, mul_4, add_4, sum_5, sum_6, add_5, add_6, truediv_1, sub_1, mul_5, loss_1, w_4, contiguous_5, tflat_2, mul_6, intersection_2, mul_7, add_7, sum_8, sum_9, add_8, add_9, truediv_2, sub_2, mul_8, loss_2, w_6, contiguous_7, tflat_3, mul_9, intersection_3, mul_10, add_10, sum_11, sum_12, add_11, add_12, truediv_3, sub_3, mul_11, loss_3], Original ATen: [aten.lift_fresh, aten.clone, aten.view, aten.mul, aten.sum, aten.add, aten.div, aten.rsub]
# Source node to ATen node mapping:
#   add => add
#   add_1 => add_1
#   add_10 => add_12
#   add_11 => add_13
#   add_12 => add_14
#   add_2 => add_2
#   add_4 => add_4
#   add_5 => add_5
#   add_6 => add_6
#   add_7 => add_8
#   add_8 => add_9
#   add_9 => add_10
#   contiguous_1 => clone_1
#   contiguous_3 => clone_3
#   contiguous_5 => clone_5
#   contiguous_7 => clone_7
#   intersection => sum_2
#   intersection_1 => sum_5
#   intersection_2 => sum_8
#   intersection_3 => sum_11
#   loss => add_3
#   loss_1 => add_7
#   loss_2 => add_11
#   loss_3 => add_15
#   mul => mul
#   mul_1 => mul_1
#   mul_10 => mul_10
#   mul_11 => mul_11
#   mul_2 => mul_2
#   mul_3 => mul_3
#   mul_4 => mul_4
#   mul_5 => mul_5
#   mul_6 => mul_6
#   mul_7 => mul_7
#   mul_8 => mul_8
#   mul_9 => mul_9
#   sub => sub_1
#   sub_1 => sub_2
#   sub_2 => sub_3
#   sub_3 => sub_4
#   sum_11 => sum_12
#   sum_12 => sum_13
#   sum_2 => sum_3
#   sum_3 => sum_4
#   sum_5 => sum_6
#   sum_6 => sum_7
#   sum_8 => sum_9
#   sum_9 => sum_10
#   tflat => view_1
#   tflat_1 => view_3
#   tflat_2 => view_5
#   tflat_3 => view_7
#   truediv => div_1
#   truediv_1 => div_2
#   truediv_2 => div_3
#   truediv_3 => div_4
#   w => full_default_5
#   w_2 => full_default_6
#   w_4 => full_default_7
#   w_6 => full_default_8
# Graph fragment:
#   %full_default_5 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.25), kwargs = {dtype: torch.float32, layout: torch.strided, device: cpu, pin_memory: False})
#   %clone_1 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%select_29,), kwargs = {memory_format: torch.contiguous_format})
#   %view_1 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%clone_1, [-1]), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view, %view_1), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%mul,), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sum_2, 2.0), kwargs = {})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_1, 1.0), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%view,), kwargs = {})
#   %sum_4 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%view_1,), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%sum_3, %sum_4), kwargs = {})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_1, 1.0), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add, %add_2), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %div_1), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%full_default_5, %sub_1), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_2, 0.0), kwargs = {})
#   %full_default_6 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.25), kwargs = {dtype: torch.float32, layout: torch.strided, device: cpu, pin_memory: False})
#   %clone_3 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%select_31,), kwargs = {memory_format: torch.contiguous_format})
#   %view_3 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%clone_3, [-1]), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_2, %view_3), kwargs = {})
#   %sum_5 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%mul_3,), kwargs = {})
#   %mul_4 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sum_5, 2.0), kwargs = {})
#   %add_4 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_4, 1.0), kwargs = {})
#   %sum_6 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%view_2,), kwargs = {})
#   %sum_7 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%view_3,), kwargs = {})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%sum_6, %sum_7), kwargs = {})
#   %add_6 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_5, 1.0), kwargs = {})
#   %div_2 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_4, %add_6), kwargs = {})
#   %sub_2 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %div_2), kwargs = {})
#   %mul_5 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%full_default_6, %sub_2), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_3, %mul_5), kwargs = {})
#   %full_default_7 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.25), kwargs = {dtype: torch.float32, layout: torch.strided, device: cpu, pin_memory: False})
#   %clone_5 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%select_33,), kwargs = {memory_format: torch.contiguous_format})
#   %view_5 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%clone_5, [-1]), kwargs = {})
#   %mul_6 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_4, %view_5), kwargs = {})
#   %sum_8 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%mul_6,), kwargs = {})
#   %mul_7 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sum_8, 2.0), kwargs = {})
#   %add_8 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_7, 1.0), kwargs = {})
#   %sum_9 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%view_4,), kwargs = {})
#   %sum_10 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%view_5,), kwargs = {})
#   %add_9 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%sum_9, %sum_10), kwargs = {})
#   %add_10 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_9, 1.0), kwargs = {})
#   %div_3 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_8, %add_10), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %div_3), kwargs = {})
#   %mul_8 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%full_default_7, %sub_3), kwargs = {})
#   %add_11 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_7, %mul_8), kwargs = {})
#   %full_default_8 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.25), kwargs = {dtype: torch.float32, layout: torch.strided, device: cpu, pin_memory: False})
#   %clone_7 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%select_35,), kwargs = {memory_format: torch.contiguous_format})
#   %view_7 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%clone_7, [-1]), kwargs = {})
#   %mul_9 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%view_6, %view_7), kwargs = {})
#   %sum_11 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%mul_9,), kwargs = {})
#   %mul_10 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%sum_11, 2.0), kwargs = {})
#   %add_12 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mul_10, 1.0), kwargs = {})
#   %sum_12 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%view_6,), kwargs = {})
#   %sum_13 : [num_users=1] = call_function[target=torch.ops.aten.sum.default](args = (%view_7,), kwargs = {})
#   %add_13 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%sum_12, %sum_13), kwargs = {})
#   %add_14 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_13, 1.0), kwargs = {})
#   %div_4 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%add_12, %add_14), kwargs = {})
#   %sub_4 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (1, %div_4), kwargs = {})
#   %mul_11 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%full_default_8, %sub_4), kwargs = {})
#   %add_15 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_11, %mul_11), kwargs = {})
triton_per_fused_add_clone_div_lift_fresh_mul_rsub_sum_view_3 = async_compile.triton('triton_per_fused_add_clone_div_lift_fresh_mul_rsub_sum_view_3', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.persistent_reduction(
    size_hints=[1, 1024],
    reduction_hint=ReductionHint.INNER,
    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': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 4), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_clone_div_lift_fresh_mul_rsub_sum_view_3', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': True, 'num_load': 8, 'num_reduction': 12, '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_add_clone_div_lift_fresh_mul_rsub_sum_view_3(in_out_ptr0, in_ptr0, in_ptr1, xnumel, rnumel):
    xnumel = 1
    XBLOCK: tl.constexpr = 1
    rnumel = 1024
    RBLOCK: tl.constexpr = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = tl.full([1], xoffset, tl.int32)
    xmask = tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    roffset = 0
    rmask = tl.full([RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + ((64*(r0 // 16)) + (r0 % 16)), None)
    tmp1 = tl.load(in_ptr1 + (4*r0), None, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr0 + (16 + (64*(r0 // 16)) + (r0 % 16)), None)
    tmp14 = tl.load(in_ptr1 + (1 + (4*r0)), None, eviction_policy='evict_last')
    tmp26 = tl.load(in_ptr0 + (48 + (64*(r0 // 16)) + (r0 % 16)), None)
    tmp27 = tl.load(in_ptr1 + (3 + (4*r0)), None, eviction_policy='evict_last')
    tmp39 = tl.load(in_ptr0 + (32 + (64*(r0 // 16)) + (r0 % 16)), None)
    tmp40 = tl.load(in_ptr1 + (2 + (4*r0)), None, eviction_policy='evict_last')
    tmp2 = tmp1.to(tl.float32)
    tmp3 = tmp0 * tmp2
    tmp4 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp6 = triton_helpers.promote_to_tensor(tl.sum(tmp4, 0))
    tmp7 = tl.broadcast_to(tmp2, [RBLOCK])
    tmp9 = triton_helpers.promote_to_tensor(tl.sum(tmp7, 0))
    tmp10 = tl.broadcast_to(tmp0, [RBLOCK])
    tmp12 = triton_helpers.promote_to_tensor(tl.sum(tmp10, 0))
    tmp15 = tmp14.to(tl.float32)
    tmp16 = tmp13 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [RBLOCK])
    tmp19 = triton_helpers.promote_to_tensor(tl.sum(tmp17, 0))
    tmp20 = tl.broadcast_to(tmp15, [RBLOCK])
    tmp22 = triton_helpers.promote_to_tensor(tl.sum(tmp20, 0))
    tmp23 = tl.broadcast_to(tmp13, [RBLOCK])
    tmp25 = triton_helpers.promote_to_tensor(tl.sum(tmp23, 0))
    tmp28 = tmp27.to(tl.float32)
    tmp29 = tmp26 * tmp28
    tmp30 = tl.broadcast_to(tmp29, [RBLOCK])
    tmp32 = triton_helpers.promote_to_tensor(tl.sum(tmp30, 0))
    tmp33 = tl.broadcast_to(tmp28, [RBLOCK])
    tmp35 = triton_helpers.promote_to_tensor(tl.sum(tmp33, 0))
    tmp36 = tl.broadcast_to(tmp26, [RBLOCK])
    tmp38 = triton_helpers.promote_to_tensor(tl.sum(tmp36, 0))
    tmp41 = tmp40.to(tl.float32)
    tmp42 = tmp39 * tmp41
    tmp43 = tl.broadcast_to(tmp42, [RBLOCK])
    tmp45 = triton_helpers.promote_to_tensor(tl.sum(tmp43, 0))
    tmp46 = tl.broadcast_to(tmp41, [RBLOCK])
    tmp48 = triton_helpers.promote_to_tensor(tl.sum(tmp46, 0))
    tmp49 = tl.broadcast_to(tmp39, [RBLOCK])
    tmp51 = triton_helpers.promote_to_tensor(tl.sum(tmp49, 0))
    tmp52 = 2.0
    tmp53 = tmp6 * tmp52
    tmp54 = 1.0
    tmp55 = tmp53 + tmp54
    tmp56 = tmp12 + tmp9
    tmp57 = tmp56 + tmp54
    tmp58 = tmp55 / tmp57
    tmp59 = tmp54 - tmp58
    tmp60 = 0.25
    tmp61 = tmp60 * tmp59
    tmp62 = 0.0
    tmp63 = tmp61 + tmp62
    tmp64 = tmp19 * tmp52
    tmp65 = tmp64 + tmp54
    tmp66 = tmp25 + tmp22
    tmp67 = tmp66 + tmp54
    tmp68 = tmp65 / tmp67
    tmp69 = tmp54 - tmp68
    tmp70 = tmp60 * tmp69
    tmp71 = tmp63 + tmp70
    tmp72 = tmp45 * tmp52
    tmp73 = tmp72 + tmp54
    tmp74 = tmp51 + tmp48
    tmp75 = tmp74 + tmp54
    tmp76 = tmp73 / tmp75
    tmp77 = tmp54 - tmp76
    tmp78 = tmp60 * tmp77
    tmp79 = tmp71 + tmp78
    tmp80 = tmp32 * tmp52
    tmp81 = tmp80 + tmp54
    tmp82 = tmp38 + tmp35
    tmp83 = tmp82 + tmp54
    tmp84 = tmp81 / tmp83
    tmp85 = tmp54 - tmp84
    tmp86 = tmp60 * tmp85
    tmp87 = tmp79 + tmp86
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([1], 0, tl.int32)), tmp87, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (64, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (1024, ), (1, ))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((64, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [input_1], Original ATen: [aten._softmax]
        stream0 = get_raw_stream(0)
        triton_poi_fused__softmax_0.run(arg0_1, buf0, 4096, grid=grid(4096), stream=stream0)
        del arg0_1
        buf1 = empty_strided_cuda((64, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [input_1], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_1.run(buf0, buf1, 4096, grid=grid(4096), stream=stream0)
        del buf0
        buf3 = empty_strided_cuda((1024, 4), (4, 1), torch.int64)
        # Topologically Sorted Source Nodes: [target_onehot], Original ATen: [aten.index]
        triton_poi_fused_index_2.run(arg1_1, buf3, 4096, grid=grid(4096), stream=stream0)
        del arg1_1
        buf10 = empty_strided_cuda((), (), torch.float32)
        buf13 = buf10; del buf10  # reuse
        buf17 = buf13; del buf13  # reuse
        # Topologically Sorted Source Nodes: [w, contiguous_1, tflat, mul, intersection, mul_1, add, sum_2, sum_3, add_1, add_2, truediv, sub, mul_2, loss, w_2, contiguous_3, tflat_1, mul_3, intersection_1, mul_4, add_4, sum_5, sum_6, add_5, add_6, truediv_1, sub_1, mul_5, loss_1, w_4, contiguous_5, tflat_2, mul_6, intersection_2, mul_7, add_7, sum_8, sum_9, add_8, add_9, truediv_2, sub_2, mul_8, loss_2, w_6, contiguous_7, tflat_3, mul_9, intersection_3, mul_10, add_10, sum_11, sum_12, add_11, add_12, truediv_3, sub_3, mul_11, loss_3], Original ATen: [aten.lift_fresh, aten.clone, aten.view, aten.mul, aten.sum, aten.add, aten.div, aten.rsub]
        triton_per_fused_add_clone_div_lift_fresh_mul_rsub_sum_view_3.run(buf17, buf1, buf3, 1, 1024, grid=grid(1), stream=stream0)
        del buf1
        del buf3
    return (buf17, )


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((64, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    arg1_1 = rand_strided((1024, ), (1, ), device='cuda:0', dtype=torch.int64)
    fn = lambda: call([arg0_1, arg1_1])
    return print_performance(fn, times=times, repeat=repeat)


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

import torch
import torch.nn as nn


class DiceLoss(nn.Module):

    def __init__(self, size_average=True, ignore_index=-100, reduce=True):
        super(DiceLoss, self).__init__()
        self.size_average = size_average
        self.ignore_index = ignore_index
        self.reduce = reduce
        self.softMax = nn.Softmax(dim=1)

    def forward(self, input, target, weight=None):
        self.weight = weight
        num_classes = input.size(1)
        input = self.softMax(input)
        one_hot = target.new(num_classes, num_classes).fill_(0)
        for i in range(num_classes):
            one_hot[i, i] = 1
        target_onehot = one_hot[target]
        target_onehot = target_onehot.unsqueeze(1).transpose(1, -1).squeeze(-1)
        target_onehot = target_onehot.float()
        input = input.float()
        loss = self.dice_loss(input, target_onehot, self.weight)
        return loss

    def dice_loss(self, input, target, weight=None):
        smooth = 1.0
        loss = 0.0
        n_classes = input.size(1)
        for c in range(n_classes):
            iflat = input[:, c].contiguous().view(-1)
            tflat = target[:, c].contiguous().view(-1)
            intersection = (iflat * tflat).sum()
            if weight is not None:
                w = weight[c]
            else:
                w = 1 / n_classes
            w = torch.tensor(w)
            w = w.float()
            loss += w * (1 - (2.0 * intersection + smooth) / (iflat.sum() +
                tflat.sum() + smooth))
        return loss


def get_inputs():
    return [torch.rand([64, 4, 4, 4]), torch.ones([1024], dtype=torch.int64)]


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
from torch._inductor.runtime.triton_helpers import math as tl_math
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


@triton.jit
def triton_poi_fused__softmax_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + (x0 + 64 * x2), None, eviction_policy='evict_last'
        )
    tmp2 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), None, eviction_policy=
        'evict_last')
    tmp4 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), None, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), None, eviction_policy=
        'evict_last')
    tmp3 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tmp9 = tl_math.exp(tmp8)
    tl.store(out_ptr0 + x3, tmp9, None)


@triton.jit
def triton_poi_fused__softmax_1(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + (x0 + 64 * x2), None, eviction_policy='evict_last'
        )
    tmp2 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), None, eviction_policy=
        'evict_last')
    tmp4 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), None, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), None, eviction_policy=
        'evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + x3, tmp8, None)


@triton.jit
def triton_poi_fused_index_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 4
    x0 = xindex % 4
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp1 = tl.full([XBLOCK], 4, tl.int32)
    tmp2 = tmp0 + tmp1
    tmp3 = tmp0 < 0
    tmp4 = tl.where(tmp3, tmp2, tmp0)
    tl.device_assert((0 <= tmp4) & (tmp4 < 4),
        'index out of bounds: 0 <= tmp4 < 4')
    tmp6 = tmp4
    tmp7 = tl.full([1], 3, tl.int32)
    tmp8 = tmp6 == tmp7
    tmp9 = x0
    tmp10 = tmp9 == tmp7
    tmp11 = tl.full([1], 2, tl.int32)
    tmp12 = tmp7 == tmp11
    tmp13 = tmp9 == tmp11
    tmp14 = tl.full([1], 1, tl.int32)
    tmp15 = tmp11 == tmp14
    tmp16 = tmp9 == tmp14
    tmp17 = tl.full([1], 0, tl.int32)
    tmp18 = tmp14 == tmp17
    tmp19 = tmp9 == tmp17
    tmp20 = tl.full([1], 1, tl.int64)
    tmp21 = tl.full([1], 0, tl.int64)
    tmp22 = tl.where(tmp19, tmp20, tmp21)
    tmp23 = tl.where(tmp18, tmp22, tmp21)
    tmp24 = tl.where(tmp16, tmp20, tmp23)
    tmp25 = tmp11 == tmp17
    tmp26 = tl.where(tmp25, tmp22, tmp21)
    tmp27 = tl.where(tmp15, tmp24, tmp26)
    tmp28 = tl.where(tmp13, tmp20, tmp27)
    tmp29 = tmp7 == tmp14
    tmp30 = tmp7 == tmp17
    tmp31 = tl.where(tmp30, tmp22, tmp21)
    tmp32 = tl.where(tmp29, tmp24, tmp31)
    tmp33 = tl.where(tmp12, tmp28, tmp32)
    tmp34 = tl.where(tmp10, tmp20, tmp33)
    tmp35 = tmp6 == tmp11
    tmp36 = tmp6 == tmp14
    tmp37 = tmp6 == tmp17
    tmp38 = tl.where(tmp37, tmp22, tmp21)
    tmp39 = tl.where(tmp36, tmp24, tmp38)
    tmp40 = tl.where(tmp35, tmp28, tmp39)
    tmp41 = tl.where(tmp8, tmp34, tmp40)
    tl.store(out_ptr0 + x2, tmp41, None)


@triton.jit
def triton_per_fused_add_clone_div_lift_fresh_mul_rsub_sum_view_3(in_out_ptr0,
    in_ptr0, in_ptr1, xnumel, rnumel):
    XBLOCK: tl.constexpr = 1
    RBLOCK: tl.constexpr = 1024
    xoffset = tl.program_id(0) * XBLOCK
    tl.full([1], xoffset, tl.int32)
    tl.full([RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[:]
    tl.full([RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (64 * (r0 // 16) + r0 % 16), None)
    tmp1 = tl.load(in_ptr1 + 4 * r0, None, eviction_policy='evict_last')
    tmp13 = tl.load(in_ptr0 + (16 + 64 * (r0 // 16) + r0 % 16), None)
    tmp14 = tl.load(in_ptr1 + (1 + 4 * r0), None, eviction_policy='evict_last')
    tmp26 = tl.load(in_ptr0 + (48 + 64 * (r0 // 16) + r0 % 16), None)
    tmp27 = tl.load(in_ptr1 + (3 + 4 * r0), None, eviction_policy='evict_last')
    tmp39 = tl.load(in_ptr0 + (32 + 64 * (r0 // 16) + r0 % 16), None)
    tmp40 = tl.load(in_ptr1 + (2 + 4 * r0), None, eviction_policy='evict_last')
    tmp2 = tmp1.to(tl.float32)
    tmp3 = tmp0 * tmp2
    tmp4 = tl.broadcast_to(tmp3, [RBLOCK])
    tmp6 = triton_helpers.promote_to_tensor(tl.sum(tmp4, 0))
    tmp7 = tl.broadcast_to(tmp2, [RBLOCK])
    tmp9 = triton_helpers.promote_to_tensor(tl.sum(tmp7, 0))
    tmp10 = tl.broadcast_to(tmp0, [RBLOCK])
    tmp12 = triton_helpers.promote_to_tensor(tl.sum(tmp10, 0))
    tmp15 = tmp14.to(tl.float32)
    tmp16 = tmp13 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [RBLOCK])
    tmp19 = triton_helpers.promote_to_tensor(tl.sum(tmp17, 0))
    tmp20 = tl.broadcast_to(tmp15, [RBLOCK])
    tmp22 = triton_helpers.promote_to_tensor(tl.sum(tmp20, 0))
    tmp23 = tl.broadcast_to(tmp13, [RBLOCK])
    tmp25 = triton_helpers.promote_to_tensor(tl.sum(tmp23, 0))
    tmp28 = tmp27.to(tl.float32)
    tmp29 = tmp26 * tmp28
    tmp30 = tl.broadcast_to(tmp29, [RBLOCK])
    tmp32 = triton_helpers.promote_to_tensor(tl.sum(tmp30, 0))
    tmp33 = tl.broadcast_to(tmp28, [RBLOCK])
    tmp35 = triton_helpers.promote_to_tensor(tl.sum(tmp33, 0))
    tmp36 = tl.broadcast_to(tmp26, [RBLOCK])
    tmp38 = triton_helpers.promote_to_tensor(tl.sum(tmp36, 0))
    tmp41 = tmp40.to(tl.float32)
    tmp42 = tmp39 * tmp41
    tmp43 = tl.broadcast_to(tmp42, [RBLOCK])
    tmp45 = triton_helpers.promote_to_tensor(tl.sum(tmp43, 0))
    tmp46 = tl.broadcast_to(tmp41, [RBLOCK])
    tmp48 = triton_helpers.promote_to_tensor(tl.sum(tmp46, 0))
    tmp49 = tl.broadcast_to(tmp39, [RBLOCK])
    tmp51 = triton_helpers.promote_to_tensor(tl.sum(tmp49, 0))
    tmp52 = 2.0
    tmp53 = tmp6 * tmp52
    tmp54 = 1.0
    tmp55 = tmp53 + tmp54
    tmp56 = tmp12 + tmp9
    tmp57 = tmp56 + tmp54
    tmp58 = tmp55 / tmp57
    tmp59 = tmp54 - tmp58
    tmp60 = 0.25
    tmp61 = tmp60 * tmp59
    tmp62 = 0.0
    tmp63 = tmp61 + tmp62
    tmp64 = tmp19 * tmp52
    tmp65 = tmp64 + tmp54
    tmp66 = tmp25 + tmp22
    tmp67 = tmp66 + tmp54
    tmp68 = tmp65 / tmp67
    tmp69 = tmp54 - tmp68
    tmp70 = tmp60 * tmp69
    tmp71 = tmp63 + tmp70
    tmp72 = tmp45 * tmp52
    tmp73 = tmp72 + tmp54
    tmp74 = tmp51 + tmp48
    tmp75 = tmp74 + tmp54
    tmp76 = tmp73 / tmp75
    tmp77 = tmp54 - tmp76
    tmp78 = tmp60 * tmp77
    tmp79 = tmp71 + tmp78
    tmp80 = tmp32 * tmp52
    tmp81 = tmp80 + tmp54
    tmp82 = tmp38 + tmp35
    tmp83 = tmp82 + tmp54
    tmp84 = tmp81 / tmp83
    tmp85 = tmp54 - tmp84
    tmp86 = tmp60 * tmp85
    tmp87 = tmp79 + tmp86
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([1], 0, tl.int32), tmp87, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (64, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (1024,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((64, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused__softmax_0[grid(4096)](arg0_1, buf0, 4096, XBLOCK=
            256, num_warps=4, num_stages=1)
        del arg0_1
        buf1 = empty_strided_cuda((64, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused__softmax_1[grid(4096)](buf0, buf1, 4096, XBLOCK=
            256, num_warps=4, num_stages=1)
        del buf0
        buf3 = empty_strided_cuda((1024, 4), (4, 1), torch.int64)
        triton_poi_fused_index_2[grid(4096)](arg1_1, buf3, 4096, XBLOCK=128,
            num_warps=4, num_stages=1)
        del arg1_1
        buf10 = empty_strided_cuda((), (), torch.float32)
        buf13 = buf10
        del buf10
        buf17 = buf13
        del buf13
        triton_per_fused_add_clone_div_lift_fresh_mul_rsub_sum_view_3[grid(1)](
            buf17, buf1, buf3, 1, 1024, num_warps=8, num_stages=1)
        del buf1
        del buf3
    return buf17,


class DiceLossNew(nn.Module):

    def __init__(self, size_average=True, ignore_index=-100, reduce=True):
        super(DiceLossNew, self).__init__()
        self.size_average = size_average
        self.ignore_index = ignore_index
        self.reduce = reduce
        self.softMax = nn.Softmax(dim=1)

    def dice_loss(self, input, target, weight=None):
        smooth = 1.0
        loss = 0.0
        n_classes = input.size(1)
        for c in range(n_classes):
            iflat = input[:, c].contiguous().view(-1)
            tflat = target[:, c].contiguous().view(-1)
            intersection = (iflat * tflat).sum()
            if weight is not None:
                w = weight[c]
            else:
                w = 1 / n_classes
            w = torch.tensor(w)
            w = w.float()
            loss += w * (1 - (2.0 * intersection + smooth) / (iflat.sum() +
                tflat.sum() + smooth))
        return loss

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