# 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_0/inductor_cache/eb/cebif7n46pnveudkauh2e6eqfvhyna4txmr2zqwf4dgc22bthlfo.py
# Topologically Sorted Source Nodes: [teacher_softmax], Original ATen: [aten._softmax]
# Source node to ATen node mapping:
#   teacher_softmax => exp_1
# Graph fragment:
#   %mul_tensor : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg1_1, 1), kwargs = {})
#   %amax_default : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%mul_tensor, [-1], True), kwargs = {})
#   %sub_tensor : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mul_tensor, %amax_default), kwargs = {})
#   %div_tensor : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_tensor, 4), kwargs = {})
#   %exp_1 : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%div_tensor,), 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=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__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 = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = (xindex // 4)
    tmp0 = tl.load(in_ptr0 + (x2), xmask)
    tmp3 = tl.load(in_ptr0 + (4*x1), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (1 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (2 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (3 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp1 = 1.0
    tmp2 = tmp0 * tmp1
    tmp4 = tmp3 * tmp1
    tmp6 = tmp5 * tmp1
    tmp7 = triton_helpers.maximum(tmp4, tmp6)
    tmp9 = tmp8 * tmp1
    tmp10 = triton_helpers.maximum(tmp7, tmp9)
    tmp12 = tmp11 * tmp1
    tmp13 = triton_helpers.maximum(tmp10, tmp12)
    tmp14 = tmp2 - tmp13
    tmp15 = 0.25
    tmp16 = tmp14 * tmp15
    tmp17 = tl_math.exp(tmp16)
    tl.store(out_ptr0 + (x2), tmp17, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_0/inductor_cache/fj/cfjl47pvhwbpfbvh6rfehwy5ijxc5p3zgkld2lwf3mw5bl6pbkak.py
# Topologically Sorted Source Nodes: [teacher_softmax], Original ATen: [aten._softmax]
# Source node to ATen node mapping:
#   teacher_softmax => div_2, sum_2
# Graph fragment:
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp_1, [-1], True), kwargs = {})
#   %div_2 : [num_users=5] = call_function[target=torch.ops.aten.div.Tensor](args = (%exp_1, %sum_2), 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=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__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 = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = (xindex // 4)
    tmp0 = tl.load(in_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr0 + (4*x1), xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (2 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (3 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + (x2), tmp8, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_0/inductor_cache/cs/ccsdey4z3rljsdh6wjalocdtxzf372booab4kvyfdqm52ddage5k.py
# Topologically Sorted Source Nodes: [], Original ATen: []
# Source node to ATen node mapping:
# Graph fragment:
#   %mul_tensor_1 : [num_users=2] = call_function[target=torch.ops.aten.mul.Tensor](args = (%arg0_1, 1), kwargs = {})
#   %amax_default_1 : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%mul_tensor_1, [-1], True), kwargs = {})
#   %sub_tensor_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mul_tensor_1, %amax_default_1), kwargs = {})
#   %div_tensor_1 : [num_users=2] = call_function[target=torch.ops.aten.div.Tensor](args = (%sub_tensor_1, 4), kwargs = {})
triton_poi_fused_2 = async_compile.triton('triton_poi_fused_2', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_2', '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_2(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = (xindex // 4)
    tmp0 = tl.load(in_ptr0 + (x2), xmask)
    tmp3 = tl.load(in_ptr0 + (4*x1), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (1 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (2 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (3 + (4*x1)), xmask, eviction_policy='evict_last')
    tmp1 = 1.0
    tmp2 = tmp0 * tmp1
    tmp4 = tmp3 * tmp1
    tmp6 = tmp5 * tmp1
    tmp7 = triton_helpers.maximum(tmp4, tmp6)
    tmp9 = tmp8 * tmp1
    tmp10 = triton_helpers.maximum(tmp7, tmp9)
    tmp12 = tmp11 * tmp1
    tmp13 = triton_helpers.maximum(tmp10, tmp12)
    tmp14 = tmp2 - tmp13
    tmp15 = 0.25
    tmp16 = tmp14 * tmp15
    tl.store(out_ptr0 + (x2), tmp16, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_0/inductor_cache/eq/ceqdhqt5sg2wxfptmmml44nitbncktzjantn3myd3v7ysa4mdry4.py
# Topologically Sorted Source Nodes: [kl, student_softmax, sum_1, kl_1, kl_2], Original ATen: [aten.xlogy, aten._log_softmax, aten.mul, aten.sub, aten.sum, aten.mean]
# Source node to ATen node mapping:
#   kl => eq, full_default, full_default_1, isnan, log_1, mul, mul_1, sub_3, where, where_1
#   kl_1 => mean
#   kl_2 => mul_2
#   student_softmax => exp, log, sub_1, sum_1
#   sum_1 => sum_3
# Graph fragment:
#   %isnan : [num_users=1] = call_function[target=torch.ops.aten.isnan.default](args = (%div_2,), kwargs = {})
#   %full_default_1 : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], nan), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %eq : [num_users=1] = call_function[target=torch.ops.aten.eq.Scalar](args = (%div_2, 0), kwargs = {})
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], 0.0), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%div_2,), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div_2, %log_1), kwargs = {})
#   %where : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%eq, %full_default, %mul_1), kwargs = {})
#   %where_1 : [num_users=1] = call_function[target=torch.ops.aten.where.self](args = (%isnan, %full_default_1, %where), kwargs = {})
#   %exp : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%div_tensor_1,), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp, [-1], True), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sum_1,), kwargs = {})
#   %sub_1 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%div_tensor_1, %log), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div_2, %sub_1), kwargs = {})
#   %sub_3 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%where_1, %mul), kwargs = {})
#   %sum_3 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%sub_3, [1]), kwargs = {})
#   %mean : [num_users=1] = call_function[target=torch.ops.aten.mean.default](args = (%sum_3,), kwargs = {})
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%mean, 16), kwargs = {})
triton_per_fused__log_softmax_mean_mul_sub_sum_xlogy_3 = async_compile.triton('triton_per_fused__log_softmax_mean_mul_sub_sum_xlogy_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, 64],
    reduction_hint=ReductionHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 4), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__log_softmax_mean_mul_sub_sum_xlogy_3', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 24, 'num_reduction': 1, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused__log_softmax_mean_mul_sub_sum_xlogy_3(in_out_ptr0, in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 64
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r2 = (rindex // 16)
    r4 = rindex % 16
    r1 = (rindex // 4) % 4
    r3 = rindex
    tmp0 = tl.load(in_ptr0 + (r4 + (64*r2)), None)
    tmp9 = tl.load(in_ptr1 + (r4 + (64*r2)), None)
    tmp10 = tl.load(in_ptr1 + ((4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr1 + (1 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp15 = tl.load(in_ptr1 + (2 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp18 = tl.load(in_ptr1 + (3 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp25 = tl.load(in_ptr0 + (16 + r4 + (64*r2)), None)
    tmp32 = tl.load(in_ptr1 + (16 + r4 + (64*r2)), None)
    tmp33 = tl.load(in_ptr1 + (16 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp35 = tl.load(in_ptr1 + (17 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp38 = tl.load(in_ptr1 + (18 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp41 = tl.load(in_ptr1 + (19 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp49 = tl.load(in_ptr0 + (32 + r4 + (64*r2)), None)
    tmp56 = tl.load(in_ptr1 + (32 + r4 + (64*r2)), None)
    tmp57 = tl.load(in_ptr1 + (32 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp59 = tl.load(in_ptr1 + (33 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp62 = tl.load(in_ptr1 + (34 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp65 = tl.load(in_ptr1 + (35 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp73 = tl.load(in_ptr0 + (48 + r4 + (64*r2)), None)
    tmp80 = tl.load(in_ptr1 + (48 + r4 + (64*r2)), None)
    tmp81 = tl.load(in_ptr1 + (48 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp83 = tl.load(in_ptr1 + (49 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp86 = tl.load(in_ptr1 + (50 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp89 = tl.load(in_ptr1 + (51 + (4*r1) + (64*r2)), None, eviction_policy='evict_last')
    tmp1 = libdevice.isnan(tmp0).to(tl.int1)
    tmp2 = 0.0
    tmp3 = tmp0 == tmp2
    tmp4 = tl_math.log(tmp0)
    tmp5 = tmp0 * tmp4
    tmp6 = tl.where(tmp3, tmp2, tmp5)
    tmp7 = float("nan")
    tmp8 = tl.where(tmp1, tmp7, tmp6)
    tmp11 = tl_math.exp(tmp10)
    tmp13 = tl_math.exp(tmp12)
    tmp14 = tmp11 + tmp13
    tmp16 = tl_math.exp(tmp15)
    tmp17 = tmp14 + tmp16
    tmp19 = tl_math.exp(tmp18)
    tmp20 = tmp17 + tmp19
    tmp21 = tl_math.log(tmp20)
    tmp22 = tmp9 - tmp21
    tmp23 = tmp0 * tmp22
    tmp24 = tmp8 - tmp23
    tmp26 = libdevice.isnan(tmp25).to(tl.int1)
    tmp27 = tmp25 == tmp2
    tmp28 = tl_math.log(tmp25)
    tmp29 = tmp25 * tmp28
    tmp30 = tl.where(tmp27, tmp2, tmp29)
    tmp31 = tl.where(tmp26, tmp7, tmp30)
    tmp34 = tl_math.exp(tmp33)
    tmp36 = tl_math.exp(tmp35)
    tmp37 = tmp34 + tmp36
    tmp39 = tl_math.exp(tmp38)
    tmp40 = tmp37 + tmp39
    tmp42 = tl_math.exp(tmp41)
    tmp43 = tmp40 + tmp42
    tmp44 = tl_math.log(tmp43)
    tmp45 = tmp32 - tmp44
    tmp46 = tmp25 * tmp45
    tmp47 = tmp31 - tmp46
    tmp48 = tmp24 + tmp47
    tmp50 = libdevice.isnan(tmp49).to(tl.int1)
    tmp51 = tmp49 == tmp2
    tmp52 = tl_math.log(tmp49)
    tmp53 = tmp49 * tmp52
    tmp54 = tl.where(tmp51, tmp2, tmp53)
    tmp55 = tl.where(tmp50, tmp7, tmp54)
    tmp58 = tl_math.exp(tmp57)
    tmp60 = tl_math.exp(tmp59)
    tmp61 = tmp58 + tmp60
    tmp63 = tl_math.exp(tmp62)
    tmp64 = tmp61 + tmp63
    tmp66 = tl_math.exp(tmp65)
    tmp67 = tmp64 + tmp66
    tmp68 = tl_math.log(tmp67)
    tmp69 = tmp56 - tmp68
    tmp70 = tmp49 * tmp69
    tmp71 = tmp55 - tmp70
    tmp72 = tmp48 + tmp71
    tmp74 = libdevice.isnan(tmp73).to(tl.int1)
    tmp75 = tmp73 == tmp2
    tmp76 = tl_math.log(tmp73)
    tmp77 = tmp73 * tmp76
    tmp78 = tl.where(tmp75, tmp2, tmp77)
    tmp79 = tl.where(tmp74, tmp7, tmp78)
    tmp82 = tl_math.exp(tmp81)
    tmp84 = tl_math.exp(tmp83)
    tmp85 = tmp82 + tmp84
    tmp87 = tl_math.exp(tmp86)
    tmp88 = tmp85 + tmp87
    tmp90 = tl_math.exp(tmp89)
    tmp91 = tmp88 + tmp90
    tmp92 = tl_math.log(tmp91)
    tmp93 = tmp80 - tmp92
    tmp94 = tmp73 * tmp93
    tmp95 = tmp79 - tmp94
    tmp96 = tmp72 + tmp95
    tmp97 = tl.broadcast_to(tmp96, [XBLOCK, RBLOCK])
    tmp99 = tl.sum(tmp97, 1)[:, None]
    tmp100 = 64.0
    tmp101 = tmp99 / tmp100
    tmp102 = 16.0
    tmp103 = tmp101 * tmp102
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (tl.full([XBLOCK, 1], 0, tl.int32)), tmp103, 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, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_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, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [teacher_softmax], Original ATen: [aten._softmax]
        stream0 = get_raw_stream(0)
        triton_poi_fused__softmax_0.run(arg1_1, buf0, 256, grid=grid(256), stream=stream0)
        del arg1_1
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [teacher_softmax], Original ATen: [aten._softmax]
        triton_poi_fused__softmax_1.run(buf0, buf1, 256, grid=grid(256), stream=stream0)
        buf2 = buf0; del buf0  # reuse
        # Topologically Sorted Source Nodes: [], Original ATen: []
        triton_poi_fused_2.run(arg0_1, buf2, 256, grid=grid(256), stream=stream0)
        del arg0_1
        buf4 = empty_strided_cuda((), (), torch.float32)
        buf5 = buf4; del buf4  # reuse
        # Topologically Sorted Source Nodes: [kl, student_softmax, sum_1, kl_1, kl_2], Original ATen: [aten.xlogy, aten._log_softmax, aten.mul, aten.sub, aten.sum, aten.mean]
        triton_per_fused__log_softmax_mean_mul_sub_sum_xlogy_3.run(buf5, buf1, buf2, 1, 64, grid=grid(1), stream=stream0)
        del buf1
        del buf2
    return (buf5, )


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)
    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 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 libdevice, 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
    ):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp3 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp1 = 1.0
    tmp2 = tmp0 * tmp1
    tmp4 = tmp3 * tmp1
    tmp6 = tmp5 * tmp1
    tmp7 = triton_helpers.maximum(tmp4, tmp6)
    tmp9 = tmp8 * tmp1
    tmp10 = triton_helpers.maximum(tmp7, tmp9)
    tmp12 = tmp11 * tmp1
    tmp13 = triton_helpers.maximum(tmp10, tmp12)
    tmp14 = tmp2 - tmp13
    tmp15 = 0.25
    tmp16 = tmp14 * tmp15
    tmp17 = tl_math.exp(tmp16)
    tl.store(out_ptr0 + x2, tmp17, xmask)


@triton.jit
def triton_poi_fused__softmax_1(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + x2, tmp8, xmask)


@triton.jit
def triton_poi_fused_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp3 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp1 = 1.0
    tmp2 = tmp0 * tmp1
    tmp4 = tmp3 * tmp1
    tmp6 = tmp5 * tmp1
    tmp7 = triton_helpers.maximum(tmp4, tmp6)
    tmp9 = tmp8 * tmp1
    tmp10 = triton_helpers.maximum(tmp7, tmp9)
    tmp12 = tmp11 * tmp1
    tmp13 = triton_helpers.maximum(tmp10, tmp12)
    tmp14 = tmp2 - tmp13
    tmp15 = 0.25
    tmp16 = tmp14 * tmp15
    tl.store(out_ptr0 + x2, tmp16, xmask)


@triton.jit
def triton_per_fused__log_softmax_mean_mul_sub_sum_xlogy_3(in_out_ptr0,
    in_ptr0, in_ptr1, xnumel, rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r2 = rindex // 16
    r4 = rindex % 16
    r1 = rindex // 4 % 4
    tmp0 = tl.load(in_ptr0 + (r4 + 64 * r2), None)
    tmp9 = tl.load(in_ptr1 + (r4 + 64 * r2), None)
    tmp10 = tl.load(in_ptr1 + (4 * r1 + 64 * r2), None, eviction_policy=
        'evict_last')
    tmp12 = tl.load(in_ptr1 + (1 + 4 * r1 + 64 * r2), None, eviction_policy
        ='evict_last')
    tmp15 = tl.load(in_ptr1 + (2 + 4 * r1 + 64 * r2), None, eviction_policy
        ='evict_last')
    tmp18 = tl.load(in_ptr1 + (3 + 4 * r1 + 64 * r2), None, eviction_policy
        ='evict_last')
    tmp25 = tl.load(in_ptr0 + (16 + r4 + 64 * r2), None)
    tmp32 = tl.load(in_ptr1 + (16 + r4 + 64 * r2), None)
    tmp33 = tl.load(in_ptr1 + (16 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp35 = tl.load(in_ptr1 + (17 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp38 = tl.load(in_ptr1 + (18 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp41 = tl.load(in_ptr1 + (19 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp49 = tl.load(in_ptr0 + (32 + r4 + 64 * r2), None)
    tmp56 = tl.load(in_ptr1 + (32 + r4 + 64 * r2), None)
    tmp57 = tl.load(in_ptr1 + (32 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp59 = tl.load(in_ptr1 + (33 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp62 = tl.load(in_ptr1 + (34 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp65 = tl.load(in_ptr1 + (35 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp73 = tl.load(in_ptr0 + (48 + r4 + 64 * r2), None)
    tmp80 = tl.load(in_ptr1 + (48 + r4 + 64 * r2), None)
    tmp81 = tl.load(in_ptr1 + (48 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp83 = tl.load(in_ptr1 + (49 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp86 = tl.load(in_ptr1 + (50 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp89 = tl.load(in_ptr1 + (51 + 4 * r1 + 64 * r2), None,
        eviction_policy='evict_last')
    tmp1 = libdevice.isnan(tmp0).to(tl.int1)
    tmp2 = 0.0
    tmp3 = tmp0 == tmp2
    tmp4 = tl_math.log(tmp0)
    tmp5 = tmp0 * tmp4
    tmp6 = tl.where(tmp3, tmp2, tmp5)
    tmp7 = float('nan')
    tmp8 = tl.where(tmp1, tmp7, tmp6)
    tmp11 = tl_math.exp(tmp10)
    tmp13 = tl_math.exp(tmp12)
    tmp14 = tmp11 + tmp13
    tmp16 = tl_math.exp(tmp15)
    tmp17 = tmp14 + tmp16
    tmp19 = tl_math.exp(tmp18)
    tmp20 = tmp17 + tmp19
    tmp21 = tl_math.log(tmp20)
    tmp22 = tmp9 - tmp21
    tmp23 = tmp0 * tmp22
    tmp24 = tmp8 - tmp23
    tmp26 = libdevice.isnan(tmp25).to(tl.int1)
    tmp27 = tmp25 == tmp2
    tmp28 = tl_math.log(tmp25)
    tmp29 = tmp25 * tmp28
    tmp30 = tl.where(tmp27, tmp2, tmp29)
    tmp31 = tl.where(tmp26, tmp7, tmp30)
    tmp34 = tl_math.exp(tmp33)
    tmp36 = tl_math.exp(tmp35)
    tmp37 = tmp34 + tmp36
    tmp39 = tl_math.exp(tmp38)
    tmp40 = tmp37 + tmp39
    tmp42 = tl_math.exp(tmp41)
    tmp43 = tmp40 + tmp42
    tmp44 = tl_math.log(tmp43)
    tmp45 = tmp32 - tmp44
    tmp46 = tmp25 * tmp45
    tmp47 = tmp31 - tmp46
    tmp48 = tmp24 + tmp47
    tmp50 = libdevice.isnan(tmp49).to(tl.int1)
    tmp51 = tmp49 == tmp2
    tmp52 = tl_math.log(tmp49)
    tmp53 = tmp49 * tmp52
    tmp54 = tl.where(tmp51, tmp2, tmp53)
    tmp55 = tl.where(tmp50, tmp7, tmp54)
    tmp58 = tl_math.exp(tmp57)
    tmp60 = tl_math.exp(tmp59)
    tmp61 = tmp58 + tmp60
    tmp63 = tl_math.exp(tmp62)
    tmp64 = tmp61 + tmp63
    tmp66 = tl_math.exp(tmp65)
    tmp67 = tmp64 + tmp66
    tmp68 = tl_math.log(tmp67)
    tmp69 = tmp56 - tmp68
    tmp70 = tmp49 * tmp69
    tmp71 = tmp55 - tmp70
    tmp72 = tmp48 + tmp71
    tmp74 = libdevice.isnan(tmp73).to(tl.int1)
    tmp75 = tmp73 == tmp2
    tmp76 = tl_math.log(tmp73)
    tmp77 = tmp73 * tmp76
    tmp78 = tl.where(tmp75, tmp2, tmp77)
    tmp79 = tl.where(tmp74, tmp7, tmp78)
    tmp82 = tl_math.exp(tmp81)
    tmp84 = tl_math.exp(tmp83)
    tmp85 = tmp82 + tmp84
    tmp87 = tl_math.exp(tmp86)
    tmp88 = tmp85 + tmp87
    tmp90 = tl_math.exp(tmp89)
    tmp91 = tmp88 + tmp90
    tmp92 = tl_math.log(tmp91)
    tmp93 = tmp80 - tmp92
    tmp94 = tmp73 * tmp93
    tmp95 = tmp79 - tmp94
    tmp96 = tmp72 + tmp95
    tmp97 = tl.broadcast_to(tmp96, [XBLOCK, RBLOCK])
    tmp99 = tl.sum(tmp97, 1)[:, None]
    tmp100 = 64.0
    tmp101 = tmp99 / tmp100
    tmp102 = 16.0
    tmp103 = tmp101 * tmp102
    tl.debug_barrier()
    tl.store(in_out_ptr0 + tl.full([XBLOCK, 1], 0, tl.int32), tmp103, None)


def call(args):
    arg0_1, arg1_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))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused__softmax_0[grid(256)](arg1_1, buf0, 256, XBLOCK=
            256, num_warps=4, num_stages=1)
        del arg1_1
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused__softmax_1[grid(256)](buf0, buf1, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf2 = buf0
        del buf0
        triton_poi_fused_2[grid(256)](arg0_1, buf2, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        del arg0_1
        buf4 = empty_strided_cuda((), (), torch.float32)
        buf5 = buf4
        del buf4
        triton_per_fused__log_softmax_mean_mul_sub_sum_xlogy_3[grid(1)](buf5,
            buf1, buf2, 1, 64, XBLOCK=1, num_warps=2, num_stages=1)
        del buf1
        del buf2
    return buf5,


class KDLossNew(nn.Module):

    def __init__(self, temp: 'float', reduction: 'str'):
        super(KDLossNew, self).__init__()
        self.temp = temp
        self.reduction = reduction
        self.kl_loss = nn.KLDivLoss(reduction=reduction)

    def __call__(self, *args, **kwargs):
        return super(KDLossNew, self).__call__(*args, **kwargs)

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