# AOT ID: ['0_forward']
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/fr/cfryngohucewjbkub6qgrmqwak65abop4zucnelbxhy7x7dopyip.py
# Topologically Sorted Source Nodes: [s], Original ATen: [aten.tanh]
# Source node to ATen node mapping:
#   s => tanh
# Graph fragment:
#   %tanh : [num_users=2] = call_function[target=torch.ops.aten.tanh.default](args = (%mm,), kwargs = {})
triton_poi_fused_tanh_0 = async_compile.triton('triton_poi_fused_tanh_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=[512], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '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,), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_tanh_0', 'mutated_arg_names': ['in_out_ptr0'], '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_tanh_0(in_out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 300
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_out_ptr0 + (x0), xmask)
    tmp1 = libdevice.tanh(tmp0)
    tl.store(in_out_ptr0 + (x0), tmp1, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/tw/ctw3oqmighlvetwoxxvzlxibyermfeatljle5hkwpo2n5r4vgkeu.py
# Topologically Sorted Source Nodes: [a, r, h_a], Original ATen: [aten._softmax, aten.mul, aten.sum]
# Source node to ATen node mapping:
#   a => amax, div, exp, sub, sum_1
#   h_a => sum_2
#   r => mul
# Graph fragment:
#   %amax : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%addmm, [0], True), kwargs = {})
#   %sub : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%addmm, %amax), kwargs = {})
#   %exp : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%sub,), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp, [0], True), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%exp, %sum_1), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div, %primals_2), kwargs = {})
#   %sum_2 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul, [0]), kwargs = {})
triton_per_fused__softmax_mul_sum_1 = async_compile.triton('triton_per_fused__softmax_mul_sum_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.persistent_reduction(
    size_hints=[1, 4],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__softmax_mul_sum_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 9, 'num_reduction': 2, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused__softmax_mul_sum_1(in_ptr0, in_ptr1, out_ptr2, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 4
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (r0), None)
    tmp9 = tl.load(in_ptr0 + (0))
    tmp10 = tl.broadcast_to(tmp9, [XBLOCK, RBLOCK])
    tmp14 = tl.load(in_ptr1 + (r0), None)
    tmp16 = tl.load(in_ptr0 + (1))
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp21 = tl.load(in_ptr1 + (4 + r0), None)
    tmp24 = tl.load(in_ptr0 + (2))
    tmp25 = tl.broadcast_to(tmp24, [XBLOCK, RBLOCK])
    tmp29 = tl.load(in_ptr1 + (8 + r0), None)
    tmp32 = tl.load(in_ptr0 + (3))
    tmp33 = tl.broadcast_to(tmp32, [XBLOCK, RBLOCK])
    tmp37 = tl.load(in_ptr1 + (12 + r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.max2(tmp1, 1)[:, None]
    tmp4 = tmp0 - tmp3
    tmp5 = tl_math.exp(tmp4)
    tmp6 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp8 = tl.sum(tmp6, 1)[:, None]
    tmp11 = tmp10 - tmp3
    tmp12 = tl_math.exp(tmp11)
    tmp13 = tmp12 / tmp8
    tmp15 = tmp13 * tmp14
    tmp18 = tmp17 - tmp3
    tmp19 = tl_math.exp(tmp18)
    tmp20 = tmp19 / tmp8
    tmp22 = tmp20 * tmp21
    tmp23 = tmp15 + tmp22
    tmp26 = tmp25 - tmp3
    tmp27 = tl_math.exp(tmp26)
    tmp28 = tmp27 / tmp8
    tmp30 = tmp28 * tmp29
    tmp31 = tmp23 + tmp30
    tmp34 = tmp33 - tmp3
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 / tmp8
    tmp38 = tmp36 * tmp37
    tmp39 = tmp31 + tmp38
    tl.store(out_ptr2 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp39, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/v6/cv6u3y45nticyr5vgeia7u5ckjnwjp2amwy3vb6o7ou6m63yblsb.py
# Topologically Sorted Source Nodes: [add, s_2], Original ATen: [aten.add, aten.tanh]
# Source node to ATen node mapping:
#   add => add
#   s_2 => tanh_1
# Graph fragment:
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mm_1, %squeeze), kwargs = {})
#   %tanh_1 : [num_users=2] = call_function[target=torch.ops.aten.tanh.default](args = (%add,), kwargs = {})
triton_poi_fused_add_tanh_2 = async_compile.triton('triton_poi_fused_add_tanh_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=[512], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '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_add_tanh_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_tanh_2(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 300
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 75
    tmp0 = tl.load(in_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(out_ptr0 + (x2), tmp3, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/2p/c2phlbypf366ejw6z4vj5gdbcfplryoknputlis3spzfojz6brwg.py
# Topologically Sorted Source Nodes: [p1, log_softmax, mul_1, c], Original ATen: [aten._softmax, aten._log_softmax, aten.mul, aten.sum, aten._log_softmax_backward_data]
# Source node to ATen node mapping:
#   c => sum_5
#   log_softmax => log, sub_3
#   mul_1 => mul_1
#   p1 => amax_1, div_1, exp_1, sub_1, sum_3
# Graph fragment:
#   %amax_1 : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%mm_3, [0], True), kwargs = {})
#   %sub_1 : [num_users=2] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mm_3, %amax_1), kwargs = {})
#   %exp_1 : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%sub_1,), kwargs = {})
#   %sum_3 : [num_users=2] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp_1, [0], True), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%exp_1, %sum_3), kwargs = {})
#   %log : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sum_3,), kwargs = {})
#   %sub_3 : [num_users=2] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_1, %log), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%div_1, %primals_6), kwargs = {})
#   %sum_5 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%mul_1, [0]), kwargs = {})
#   %exp_5 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%sub_3,), kwargs = {})
triton_per_fused__log_softmax__log_softmax_backward_data__softmax_mul_sum_3 = async_compile.triton('triton_per_fused__log_softmax__log_softmax_backward_data__softmax_mul_sum_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, 4],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: 'i32', 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': {5: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=(5,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__log_softmax__log_softmax_backward_data__softmax_mul_sum_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 9, 'num_reduction': 2, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused__log_softmax__log_softmax_backward_data__softmax_mul_sum_3(in_ptr0, in_ptr1, out_ptr2, out_ptr3, out_ptr4, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 4
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (r0), None)
    tmp9 = tl.load(in_ptr0 + (0))
    tmp10 = tl.broadcast_to(tmp9, [XBLOCK, RBLOCK])
    tmp14 = tl.load(in_ptr1 + (r0), None)
    tmp16 = tl.load(in_ptr0 + (1))
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp21 = tl.load(in_ptr1 + (4 + r0), None)
    tmp24 = tl.load(in_ptr0 + (2))
    tmp25 = tl.broadcast_to(tmp24, [XBLOCK, RBLOCK])
    tmp29 = tl.load(in_ptr1 + (8 + r0), None)
    tmp32 = tl.load(in_ptr0 + (3))
    tmp33 = tl.broadcast_to(tmp32, [XBLOCK, RBLOCK])
    tmp37 = tl.load(in_ptr1 + (12 + r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.max2(tmp1, 1)[:, None]
    tmp4 = tmp0 - tmp3
    tmp5 = tl_math.exp(tmp4)
    tmp6 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp8 = tl.sum(tmp6, 1)[:, None]
    tmp11 = tmp10 - tmp3
    tmp12 = tl_math.exp(tmp11)
    tmp13 = tmp12 / tmp8
    tmp15 = tmp13 * tmp14
    tmp18 = tmp17 - tmp3
    tmp19 = tl_math.exp(tmp18)
    tmp20 = tmp19 / tmp8
    tmp22 = tmp20 * tmp21
    tmp23 = tmp15 + tmp22
    tmp26 = tmp25 - tmp3
    tmp27 = tl_math.exp(tmp26)
    tmp28 = tmp27 / tmp8
    tmp30 = tmp28 * tmp29
    tmp31 = tmp23 + tmp30
    tmp34 = tmp33 - tmp3
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 / tmp8
    tmp38 = tmp36 * tmp37
    tmp39 = tmp31 + tmp38
    tmp40 = tl_math.log(tmp8)
    tmp41 = tmp4 - tmp40
    tmp42 = tl_math.exp(tmp41)
    tl.store(out_ptr2 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp39, None)
    tl.store(out_ptr3 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp41, None)
    tl.store(out_ptr4 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp42, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/25/c25zffbsanrum4z3rffpnrg2h4k3lxiwob3mvghw5knox2fnslnf.py
# Topologically Sorted Source Nodes: [add_1, s_4], Original ATen: [aten.add, aten.tanh]
# Source node to ATen node mapping:
#   add_1 => add_1
#   s_4 => tanh_2
# Graph fragment:
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%mm_1, %squeeze_2), kwargs = {})
#   %tanh_2 : [num_users=2] = call_function[target=torch.ops.aten.tanh.default](args = (%add_1,), kwargs = {})
triton_poi_fused_add_tanh_4 = async_compile.triton('triton_poi_fused_add_tanh_4', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

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

@triton_heuristics.pointwise(
    size_hints=[512], 
    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), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_tanh_4', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_tanh_4(in_out_ptr0, in_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 300
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 75
    tmp0 = tl.load(in_out_ptr0 + (x2), xmask)
    tmp1 = tl.load(in_ptr0 + (x0), xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + (x2), tmp3, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/bu/cbupf3zlbcvl3wmwwd4cqliwgdsvdey4ojkgjbd7xumln5g3xarf.py
# Topologically Sorted Source Nodes: [log_softmax_1], Original ATen: [aten._log_softmax, aten._log_softmax_backward_data]
# Source node to ATen node mapping:
#   log_softmax_1 => amax_3, exp_3, log_1, sub_4, sub_5, sum_6
# Graph fragment:
#   %amax_3 : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%mm_7, [0], True), kwargs = {})
#   %sub_4 : [num_users=2] = call_function[target=torch.ops.aten.sub.Tensor](args = (%mm_7, %amax_3), kwargs = {})
#   %exp_3 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%sub_4,), kwargs = {})
#   %sum_6 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp_3, [0], True), kwargs = {})
#   %log_1 : [num_users=1] = call_function[target=torch.ops.aten.log.default](args = (%sum_6,), kwargs = {})
#   %sub_5 : [num_users=2] = call_function[target=torch.ops.aten.sub.Tensor](args = (%sub_4, %log_1), kwargs = {})
#   %exp_4 : [num_users=1] = call_function[target=torch.ops.aten.exp.default](args = (%sub_5,), kwargs = {})
triton_per_fused__log_softmax__log_softmax_backward_data_5 = async_compile.triton('triton_per_fused__log_softmax__log_softmax_backward_data_5', '''
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, 4],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {3: 1}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=(3,))]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused__log_softmax__log_softmax_backward_data_5', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 2, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused__log_softmax__log_softmax_backward_data_5(in_ptr0, out_ptr2, out_ptr3, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 1
    rnumel = 4
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + (r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.max2(tmp1, 1)[:, None]
    tmp4 = tmp0 - tmp3
    tmp5 = tl_math.exp(tmp4)
    tmp6 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp8 = tl.sum(tmp6, 1)[:, None]
    tmp9 = tl_math.log(tmp8)
    tmp10 = tmp4 - tmp9
    tmp11 = tl_math.exp(tmp10)
    tl.store(out_ptr2 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp10, None)
    tl.store(out_ptr3 + (tl.broadcast_to(r0, [XBLOCK, RBLOCK])), tmp11, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5, primals_6, primals_7, primals_8, primals_9, primals_10 = args
    args.clear()
    assert_size_stride(primals_1, (75, 4), (4, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (1, 75), (75, 1))
    assert_size_stride(primals_4, (1, ), (1, ))
    assert_size_stride(primals_5, (75, 4), (4, 1))
    assert_size_stride(primals_6, (4, 4), (4, 1))
    assert_size_stride(primals_7, (75, 4), (4, 1))
    assert_size_stride(primals_8, (1, 75), (75, 1))
    assert_size_stride(primals_9, (12, 4), (4, 1))
    assert_size_stride(primals_10, (12, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 75), (75, 1), torch.float32)
        # Topologically Sorted Source Nodes: [linear], Original ATen: [aten.mm]
        extern_kernels.mm(primals_2, reinterpret_tensor(primals_1, (4, 75), (1, 4), 0), out=buf0)
        del primals_1
        buf1 = buf0; del buf0  # reuse
        # Topologically Sorted Source Nodes: [s], Original ATen: [aten.tanh]
        stream0 = get_raw_stream(0)
        triton_poi_fused_tanh_0.run(buf1, 300, grid=grid(300), stream=stream0)
        buf3 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [s_1], Original ATen: [aten.addmm]
        extern_kernels.addmm(primals_4, buf1, reinterpret_tensor(primals_3, (75, 1), (1, 75), 0), alpha=1, beta=1, out=buf3)
        del primals_4
        buf6 = empty_strided_cuda((4, ), (1, ), torch.float32)
        # Topologically Sorted Source Nodes: [a, r, h_a], Original ATen: [aten._softmax, aten.mul, aten.sum]
        triton_per_fused__softmax_mul_sum_1.run(buf3, primals_2, buf6, 1, 4, grid=grid(1), stream=stream0)
        buf7 = empty_strided_cuda((4, 75), (75, 1), torch.float32)
        # Topologically Sorted Source Nodes: [Wh], Original ATen: [aten.mm]
        extern_kernels.mm(primals_6, reinterpret_tensor(primals_5, (4, 75), (1, 4), 0), out=buf7)
        del primals_5
        buf8 = empty_strided_cuda((1, 75), (75, 1), torch.float32)
        # Topologically Sorted Source Nodes: [linear_3], Original ATen: [aten.mm]
        extern_kernels.mm(reinterpret_tensor(buf6, (1, 4), (4, 1), 0), reinterpret_tensor(primals_7, (4, 75), (1, 4), 0), out=buf8)
        buf9 = empty_strided_cuda((4, 75), (75, 1), torch.float32)
        # Topologically Sorted Source Nodes: [add, s_2], Original ATen: [aten.add, aten.tanh]
        triton_poi_fused_add_tanh_2.run(buf7, buf8, buf9, 300, grid=grid(300), stream=stream0)
        buf10 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [s_3], Original ATen: [aten.mm]
        extern_kernels.mm(buf9, reinterpret_tensor(primals_8, (75, 1), (1, 75), 0), out=buf10)
        buf13 = empty_strided_cuda((4, ), (1, ), torch.float32)
        buf24 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        buf27 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [p1, log_softmax, mul_1, c], Original ATen: [aten._softmax, aten._log_softmax, aten.mul, aten.sum, aten._log_softmax_backward_data]
        triton_per_fused__log_softmax__log_softmax_backward_data__softmax_mul_sum_3.run(buf10, primals_6, buf13, buf24, buf27, 1, 4, grid=grid(1), stream=stream0)
        buf14 = empty_strided_cuda((1, 12), (12, 1), torch.float32)
        # Topologically Sorted Source Nodes: [ret], Original ATen: [aten.mm]
        extern_kernels.mm(reinterpret_tensor(buf13, (1, 4), (4, 1), 0), reinterpret_tensor(primals_9, (4, 12), (1, 4), 0), out=buf14)
        buf15 = empty_strided_cuda((1, 12), (12, 1), torch.float32)
        # Topologically Sorted Source Nodes: [ret], Original ATen: [aten.mm]
        extern_kernels.mm(reinterpret_tensor(buf6, (1, 4), (4, 1), 0), reinterpret_tensor(primals_10, (4, 12), (1, 4), 0), out=buf15)
        # Topologically Sorted Source Nodes: [ret], Original ATen: [aten._thnn_fused_gru_cell]
        buf16 = torch.ops.aten._thnn_fused_gru_cell.default(buf14, buf15, reinterpret_tensor(buf6, (1, 4), (4, 1), 0))
        del buf14
        del buf15
        buf17 = buf16[0]
        buf18 = buf16[1]
        del buf16
        buf19 = buf8; del buf8  # reuse
        # Topologically Sorted Source Nodes: [linear_5], Original ATen: [aten.mm]
        extern_kernels.mm(buf17, reinterpret_tensor(primals_7, (4, 75), (1, 4), 0), out=buf19)
        buf20 = buf7; del buf7  # reuse
        # Topologically Sorted Source Nodes: [add_1, s_4], Original ATen: [aten.add, aten.tanh]
        triton_poi_fused_add_tanh_4.run(buf20, buf19, 300, grid=grid(300), stream=stream0)
        del buf19
        buf21 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [s_5], Original ATen: [aten.mm]
        extern_kernels.mm(buf20, reinterpret_tensor(primals_8, (75, 1), (1, 75), 0), out=buf21)
        buf25 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        buf26 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [log_softmax_1], Original ATen: [aten._log_softmax, aten._log_softmax_backward_data]
        triton_per_fused__log_softmax__log_softmax_backward_data_5.run(buf21, buf25, buf26, 1, 4, grid=grid(1), stream=stream0)
        del buf21
    return (reinterpret_tensor(buf24, (4, ), (1, ), 0), reinterpret_tensor(buf25, (4, ), (1, ), 0), primals_2, primals_6, buf1, buf3, reinterpret_tensor(buf6, (1, 4), (4, 1), 0), buf9, buf10, reinterpret_tensor(buf13, (1, 4), (4, 1), 0), buf18, buf17, buf20, buf26, primals_8, primals_7, primals_10, primals_9, buf27, primals_3, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    primals_1 = rand_strided((75, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((1, 75), (75, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((1, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((75, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_7 = rand_strided((75, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_8 = rand_strided((1, 75), (75, 1), device='cuda:0', dtype=torch.float32)
    primals_9 = rand_strided((12, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_10 = rand_strided((12, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([primals_1, primals_2, primals_3, primals_4, primals_5, primals_6, primals_7, primals_8, primals_9, primals_10])
    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
from torch import nn


class PointerNetwork(nn.Module):

    def __init__(self, input_size, model_dim, attn_size=75, dropout=0.2):
        """ Pointer Network
                Args:
                    input_size(int): size of input
                Input:
                    - **H** of shape `(passage_legth, batch, input_size)`: a float tensor in which we determine
                    the importance of information in the passage regarding a question
                    - **question** of shape `(question_length, batch, input_size)`: a float tensor containing question
                    representation
                Output:
                    - start(torch.tensor of shape (batch_size, passage_length, 1)): start position of the answer
                    - end(torch.tensor of shape (batch_size, passage_length, 1)): end position of the answer

        """
        super(PointerNetwork, self).__init__()
        self.Whp = nn.Linear(input_size, attn_size, bias=False)
        self.Wha1 = nn.Linear(model_dim, attn_size, bias=False)
        self.v = nn.Linear(attn_size, 1, bias=False)
        self.cell = nn.GRUCell(input_size, model_dim, False)
        self.Wuq = nn.Linear(model_dim, attn_size, bias=False)
        self.v1 = nn.Linear(attn_size, 1)

    def get_initial_state(self, question):
        s = torch.tanh(self.Wuq(question))
        s = self.v1(s)
        a = nn.functional.softmax(s, 0)
        r = a * question
        return r.sum(0)

    def forward(self, h, question):
        h_a = self.get_initial_state(question)
        Wh = self.Whp(h)
        s = torch.tanh(Wh + self.Wha1(h_a))
        s = self.v(s)
        p1 = nn.functional.softmax(s, 0)
        start = nn.functional.log_softmax(s, 0).transpose(0, 1)
        c = (p1 * h).sum(0)
        h_a = self.cell(c, h_a)
        s = torch.tanh(Wh + self.Wha1(h_a))
        s = self.v(s)
        end = nn.functional.log_softmax(s, 0).transpose(0, 1)
        return start.squeeze(), end.squeeze()


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


def get_init_inputs():
    return [[], {'input_size': 4, 'model_dim': 4}]

import torch
from torch._inductor.select_algorithm import extern_kernels
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
from torch import 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_tanh_0(in_out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 300
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_out_ptr0 + x0, xmask)
    tmp1 = libdevice.tanh(tmp0)
    tl.store(in_out_ptr0 + x0, tmp1, xmask)


@triton.jit
def triton_per_fused__softmax_mul_sum_1(in_ptr0, in_ptr1, out_ptr2, xnumel,
    rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp9 = tl.load(in_ptr0 + 0)
    tmp10 = tl.broadcast_to(tmp9, [XBLOCK, RBLOCK])
    tmp14 = tl.load(in_ptr1 + r0, None)
    tmp16 = tl.load(in_ptr0 + 1)
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp21 = tl.load(in_ptr1 + (4 + r0), None)
    tmp24 = tl.load(in_ptr0 + 2)
    tmp25 = tl.broadcast_to(tmp24, [XBLOCK, RBLOCK])
    tmp29 = tl.load(in_ptr1 + (8 + r0), None)
    tmp32 = tl.load(in_ptr0 + 3)
    tmp33 = tl.broadcast_to(tmp32, [XBLOCK, RBLOCK])
    tmp37 = tl.load(in_ptr1 + (12 + r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.max2(tmp1, 1)[:, None]
    tmp4 = tmp0 - tmp3
    tmp5 = tl_math.exp(tmp4)
    tmp6 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp8 = tl.sum(tmp6, 1)[:, None]
    tmp11 = tmp10 - tmp3
    tmp12 = tl_math.exp(tmp11)
    tmp13 = tmp12 / tmp8
    tmp15 = tmp13 * tmp14
    tmp18 = tmp17 - tmp3
    tmp19 = tl_math.exp(tmp18)
    tmp20 = tmp19 / tmp8
    tmp22 = tmp20 * tmp21
    tmp23 = tmp15 + tmp22
    tmp26 = tmp25 - tmp3
    tmp27 = tl_math.exp(tmp26)
    tmp28 = tmp27 / tmp8
    tmp30 = tmp28 * tmp29
    tmp31 = tmp23 + tmp30
    tmp34 = tmp33 - tmp3
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 / tmp8
    tmp38 = tmp36 * tmp37
    tmp39 = tmp31 + tmp38
    tl.store(out_ptr2 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp39, None)


@triton.jit
def triton_poi_fused_add_tanh_2(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 300
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 75
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(out_ptr0 + x2, tmp3, xmask)


@triton.jit
def triton_per_fused__log_softmax__log_softmax_backward_data__softmax_mul_sum_3(
    in_ptr0, in_ptr1, out_ptr2, out_ptr3, out_ptr4, xnumel, rnumel, XBLOCK:
    tl.constexpr):
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp9 = tl.load(in_ptr0 + 0)
    tmp10 = tl.broadcast_to(tmp9, [XBLOCK, RBLOCK])
    tmp14 = tl.load(in_ptr1 + r0, None)
    tmp16 = tl.load(in_ptr0 + 1)
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp21 = tl.load(in_ptr1 + (4 + r0), None)
    tmp24 = tl.load(in_ptr0 + 2)
    tmp25 = tl.broadcast_to(tmp24, [XBLOCK, RBLOCK])
    tmp29 = tl.load(in_ptr1 + (8 + r0), None)
    tmp32 = tl.load(in_ptr0 + 3)
    tmp33 = tl.broadcast_to(tmp32, [XBLOCK, RBLOCK])
    tmp37 = tl.load(in_ptr1 + (12 + r0), None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.max2(tmp1, 1)[:, None]
    tmp4 = tmp0 - tmp3
    tmp5 = tl_math.exp(tmp4)
    tmp6 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp8 = tl.sum(tmp6, 1)[:, None]
    tmp11 = tmp10 - tmp3
    tmp12 = tl_math.exp(tmp11)
    tmp13 = tmp12 / tmp8
    tmp15 = tmp13 * tmp14
    tmp18 = tmp17 - tmp3
    tmp19 = tl_math.exp(tmp18)
    tmp20 = tmp19 / tmp8
    tmp22 = tmp20 * tmp21
    tmp23 = tmp15 + tmp22
    tmp26 = tmp25 - tmp3
    tmp27 = tl_math.exp(tmp26)
    tmp28 = tmp27 / tmp8
    tmp30 = tmp28 * tmp29
    tmp31 = tmp23 + tmp30
    tmp34 = tmp33 - tmp3
    tmp35 = tl_math.exp(tmp34)
    tmp36 = tmp35 / tmp8
    tmp38 = tmp36 * tmp37
    tmp39 = tmp31 + tmp38
    tmp40 = tl_math.log(tmp8)
    tmp41 = tmp4 - tmp40
    tmp42 = tl_math.exp(tmp41)
    tl.store(out_ptr2 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp39, None)
    tl.store(out_ptr3 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp41, None)
    tl.store(out_ptr4 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp42, None)


@triton.jit
def triton_poi_fused_add_tanh_4(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 300
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 75
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x2, tmp3, xmask)


@triton.jit
def triton_per_fused__log_softmax__log_softmax_backward_data_5(in_ptr0,
    out_ptr2, out_ptr3, xnumel, rnumel, XBLOCK: tl.constexpr):
    RBLOCK: tl.constexpr = 4
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r0 = rindex
    tmp0 = tl.load(in_ptr0 + r0, None)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = triton_helpers.max2(tmp1, 1)[:, None]
    tmp4 = tmp0 - tmp3
    tmp5 = tl_math.exp(tmp4)
    tmp6 = tl.broadcast_to(tmp5, [XBLOCK, RBLOCK])
    tmp8 = tl.sum(tmp6, 1)[:, None]
    tmp9 = tl_math.log(tmp8)
    tmp10 = tmp4 - tmp9
    tmp11 = tl_math.exp(tmp10)
    tl.store(out_ptr2 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp10, None)
    tl.store(out_ptr3 + tl.broadcast_to(r0, [XBLOCK, RBLOCK]), tmp11, None)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10) = args
    args.clear()
    assert_size_stride(primals_1, (75, 4), (4, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (1, 75), (75, 1))
    assert_size_stride(primals_4, (1,), (1,))
    assert_size_stride(primals_5, (75, 4), (4, 1))
    assert_size_stride(primals_6, (4, 4), (4, 1))
    assert_size_stride(primals_7, (75, 4), (4, 1))
    assert_size_stride(primals_8, (1, 75), (75, 1))
    assert_size_stride(primals_9, (12, 4), (4, 1))
    assert_size_stride(primals_10, (12, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 75), (75, 1), torch.float32)
        extern_kernels.mm(primals_2, reinterpret_tensor(primals_1, (4, 75),
            (1, 4), 0), out=buf0)
        del primals_1
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_tanh_0[grid(300)](buf1, 300, XBLOCK=128, num_warps
            =4, num_stages=1)
        buf3 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        extern_kernels.addmm(primals_4, buf1, reinterpret_tensor(primals_3,
            (75, 1), (1, 75), 0), alpha=1, beta=1, out=buf3)
        del primals_4
        buf6 = empty_strided_cuda((4,), (1,), torch.float32)
        triton_per_fused__softmax_mul_sum_1[grid(1)](buf3, primals_2, buf6,
            1, 4, XBLOCK=1, num_warps=2, num_stages=1)
        buf7 = empty_strided_cuda((4, 75), (75, 1), torch.float32)
        extern_kernels.mm(primals_6, reinterpret_tensor(primals_5, (4, 75),
            (1, 4), 0), out=buf7)
        del primals_5
        buf8 = empty_strided_cuda((1, 75), (75, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf6, (1, 4), (4, 1), 0),
            reinterpret_tensor(primals_7, (4, 75), (1, 4), 0), out=buf8)
        buf9 = empty_strided_cuda((4, 75), (75, 1), torch.float32)
        triton_poi_fused_add_tanh_2[grid(300)](buf7, buf8, buf9, 300,
            XBLOCK=128, num_warps=4, num_stages=1)
        buf10 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf9, reinterpret_tensor(primals_8, (75, 1), (1, 
            75), 0), out=buf10)
        buf13 = empty_strided_cuda((4,), (1,), torch.float32)
        buf24 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        buf27 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        triton_per_fused__log_softmax__log_softmax_backward_data__softmax_mul_sum_3[
            grid(1)](buf10, primals_6, buf13, buf24, buf27, 1, 4, XBLOCK=1,
            num_warps=2, num_stages=1)
        buf14 = empty_strided_cuda((1, 12), (12, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf13, (1, 4), (4, 1), 0),
            reinterpret_tensor(primals_9, (4, 12), (1, 4), 0), out=buf14)
        buf15 = empty_strided_cuda((1, 12), (12, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf6, (1, 4), (4, 1), 0),
            reinterpret_tensor(primals_10, (4, 12), (1, 4), 0), out=buf15)
        buf16 = torch.ops.aten._thnn_fused_gru_cell.default(buf14, buf15,
            reinterpret_tensor(buf6, (1, 4), (4, 1), 0))
        del buf14
        del buf15
        buf17 = buf16[0]
        buf18 = buf16[1]
        del buf16
        buf19 = buf8
        del buf8
        extern_kernels.mm(buf17, reinterpret_tensor(primals_7, (4, 75), (1,
            4), 0), out=buf19)
        buf20 = buf7
        del buf7
        triton_poi_fused_add_tanh_4[grid(300)](buf20, buf19, 300, XBLOCK=
            128, num_warps=4, num_stages=1)
        del buf19
        buf21 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        extern_kernels.mm(buf20, reinterpret_tensor(primals_8, (75, 1), (1,
            75), 0), out=buf21)
        buf25 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        buf26 = empty_strided_cuda((4, 1), (1, 1), torch.float32)
        triton_per_fused__log_softmax__log_softmax_backward_data_5[grid(1)](
            buf21, buf25, buf26, 1, 4, XBLOCK=1, num_warps=2, num_stages=1)
        del buf21
    return (reinterpret_tensor(buf24, (4,), (1,), 0), reinterpret_tensor(
        buf25, (4,), (1,), 0), primals_2, primals_6, buf1, buf3,
        reinterpret_tensor(buf6, (1, 4), (4, 1), 0), buf9, buf10,
        reinterpret_tensor(buf13, (1, 4), (4, 1), 0), buf18, buf17, buf20,
        buf26, primals_8, primals_7, primals_10, primals_9, buf27, primals_3)


class PointerNetworkNew(nn.Module):

    def __init__(self, input_size, model_dim, attn_size=75, dropout=0.2):
        """ Pointer Network
                Args:
                    input_size(int): size of input
                Input:
                    - **H** of shape `(passage_legth, batch, input_size)`: a float tensor in which we determine
                    the importance of information in the passage regarding a question
                    - **question** of shape `(question_length, batch, input_size)`: a float tensor containing question
                    representation
                Output:
                    - start(torch.tensor of shape (batch_size, passage_length, 1)): start position of the answer
                    - end(torch.tensor of shape (batch_size, passage_length, 1)): end position of the answer

        """
        super(PointerNetworkNew, self).__init__()
        self.Whp = nn.Linear(input_size, attn_size, bias=False)
        self.Wha1 = nn.Linear(model_dim, attn_size, bias=False)
        self.v = nn.Linear(attn_size, 1, bias=False)
        self.cell = nn.GRUCell(input_size, model_dim, False)
        self.Wuq = nn.Linear(model_dim, attn_size, bias=False)
        self.v1 = nn.Linear(attn_size, 1)

    def get_initial_state(self, question):
        s = torch.tanh(self.Wuq(question))
        s = self.v1(s)
        a = nn.functional.softmax(s, 0)
        r = a * question
        return r.sum(0)

    def forward(self, input_0, input_1):
        primals_1 = self.Whp.weight
        primals_5 = self.Wha1.weight
        primals_3 = self.v.weight
        primals_9 = self.cell.weight_ih
        primals_10 = self.cell.weight_hh
        primals_7 = self.Wuq.weight
        primals_8 = self.v1.weight
        primals_4 = self.v1.bias
        primals_2 = input_0
        primals_6 = input_1
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9, primals_10])
        return output[0], output[1]
