# 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_1/inductor_cache/an/canhl4oh4gh4nxuxaqxknorbaccui7w3elxowpgpeeyq6r76trdn.py
# Topologically Sorted Source Nodes: [input1], Original ATen: [aten.cat]
# Source node to ATen node mapping:
#   input1 => cat
# Graph fragment:
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%where, %full_default], -1), kwargs = {})
triton_poi_fused_cat_0 = async_compile.triton('triton_poi_fused_cat_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=[128], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_cat_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_cat_0(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 80
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 5
    x1 = (xindex // 5)
    x2 = xindex
    tmp0 = x0
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + ((4*x1) + x0), tmp4 & xmask, eviction_policy='evict_last', other=0.0)
    tmp6 = 0.0
    tmp7 = tmp5 > tmp6
    tmp8 = 1.0
    tmp9 = tmp5 * tmp8
    tmp10 = libdevice.expm1(tmp9)
    tmp11 = tmp10 * tmp8
    tmp12 = tl.where(tmp7, tmp9, tmp11)
    tmp13 = tl.full(tmp12.shape, 0.0, tmp12.dtype)
    tmp14 = tl.where(tmp4, tmp12, tmp13)
    tmp15 = tmp0 >= tmp3
    tmp16 = tl.full([1], 5, tl.int64)
    tmp17 = tmp0 < tmp16
    tmp18 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
    tmp19 = tl.where(tmp15, tmp8, tmp18)
    tmp20 = tl.where(tmp4, tmp14, tmp19)
    tl.store(out_ptr0 + (x2), tmp20, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_1/inductor_cache/pt/cptaddavhv2oytblnrd523iahobbaw5xwxblz3exzrxoz7xe6bfc.py
# Topologically Sorted Source Nodes: [biaffine], Original ATen: [aten.clone]
# Source node to ATen node mapping:
#   biaffine => clone
# Graph fragment:
#   %clone : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%permute_4,), kwargs = {memory_format: torch.contiguous_format})
triton_poi_fused_clone_1 = async_compile.triton('triton_poi_fused_clone_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=[16, 16], tile_hint=TileHint.SQUARE,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=90, major=9, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=132), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': 'B098E03CDA7B8ADC90DAFFDF24A2956451D1B13F297756A5DCC209498AA53705', '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_clone_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
    ynumel = 16
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4
    y1 = (yindex // 4)
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + (4*x2) + (64*y1)), xmask & ymask)
    tl.store(out_ptr0 + (x2 + (16*y3)), tmp0, xmask & ymask)
''', 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 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4, ), (1, ))
    assert_size_stride(primals_3, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_4, (4, 4), (4, 1))
    assert_size_stride(primals_5, (4, ), (1, ))
    assert_size_stride(primals_6, (20, 5), (5, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [linear_out], Original ATen: [aten.addmm]
        extern_kernels.addmm(primals_2, reinterpret_tensor(primals_3, (16, 4), (4, 1), 0), reinterpret_tensor(primals_1, (4, 4), (1, 4), 0), alpha=1, beta=1, out=buf0)
        del primals_1
        del primals_2
        buf1 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [linear_out_1], Original ATen: [aten.addmm]
        extern_kernels.addmm(primals_5, reinterpret_tensor(primals_3, (16, 4), (4, 1), 0), reinterpret_tensor(primals_4, (4, 4), (1, 4), 0), alpha=1, beta=1, out=buf1)
        del primals_4
        del primals_5
        buf2 = empty_strided_cuda((4, 4, 5), (20, 5, 1), torch.float32)
        # Topologically Sorted Source Nodes: [input1], Original ATen: [aten.cat]
        stream0 = get_raw_stream(0)
        triton_poi_fused_cat_0.run(buf0, buf2, 80, grid=grid(80), stream=stream0)
        buf3 = empty_strided_cuda((16, 20), (20, 1), torch.float32)
        # Topologically Sorted Source Nodes: [affine], Original ATen: [aten.mm]
        extern_kernels.mm(reinterpret_tensor(buf2, (16, 5), (5, 1), 0), reinterpret_tensor(primals_6, (5, 20), (1, 5), 0), out=buf3)
        buf4 = empty_strided_cuda((4, 4, 5), (20, 5, 1), torch.float32)
        # Topologically Sorted Source Nodes: [input2], Original ATen: [aten.cat]
        triton_poi_fused_cat_0.run(buf1, buf4, 80, grid=grid(80), stream=stream0)
        buf5 = empty_strided_cuda((4, 16, 4), (64, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [bmm], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf3, (4, 16, 5), (80, 5, 1), 0), reinterpret_tensor(buf4, (4, 5, 4), (20, 1, 5), 0), out=buf5)
        buf6 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [biaffine], Original ATen: [aten.clone]
        triton_poi_fused_clone_1.run(buf5, buf6, 16, 16, grid=grid(16, 16), stream=stream0)
        del buf5
    return (reinterpret_tensor(buf6, (4, 4, 4, 4), (64, 16, 4, 1), 0), reinterpret_tensor(primals_3, (16, 4), (4, 1), 0), buf0, buf1, reinterpret_tensor(buf2, (16, 5), (5, 1), 0), reinterpret_tensor(buf3, (4, 5, 16), (80, 1, 5), 0), buf4, primals_6, )


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((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((4, 4, 4), (16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((4, 4), (4, 1), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((4, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((20, 5), (5, 1), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([primals_1, primals_2, primals_3, primals_4, primals_5, primals_6])
    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


def timestep_dropout(inputs, p=0.5, batch_first=True):
    """
    :param inputs: (bz, time_step, feature_size)
    :param p: probability p mask out output nodes
    :param batch_first: default True
    :return:
    """
    if not batch_first:
        inputs = inputs.transpose(0, 1)
    batch_size, _time_step, feature_size = inputs.size()
    drop_mask = inputs.data.new_full((batch_size, feature_size), 1 - p)
    drop_mask = torch.bernoulli(drop_mask).div(1 - p)
    drop_mask = drop_mask.unsqueeze(1)
    return inputs * drop_mask


class Biaffine(nn.Module):

    def __init__(self, in_features, out_features=1, bias=(True, True)):
        super(Biaffine, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.bias = bias
        self.linear_input_size = in_features + bias[0]
        self.linear_output_size = out_features * (in_features + bias[1])
        self.linear = nn.Linear(in_features=self.linear_input_size,
            out_features=self.linear_output_size, bias=False)
        self.reset_params()

    def reset_params(self):
        nn.init.xavier_uniform_(self.linear.weight)

    def forward(self, input1, input2):
        batch_size, len1, _dim1 = input1.size()
        batch_size, len2, _dim2 = input2.size()
        if self.bias[0]:
            ones = input1.data.new_ones(batch_size, len1, 1)
            input1 = torch.cat((input1, ones), dim=-1)
        if self.bias[1]:
            ones = input2.data.new_ones(batch_size, len2, 1)
            input2 = torch.cat((input2, ones), dim=-1)
        affine = self.linear(input1)
        affine = affine.reshape(batch_size, len1 * self.out_features, -1)
        biaffine = torch.bmm(affine, input2.transpose(1, 2)).transpose(1, 2
            ).contiguous()
        biaffine = biaffine.reshape((batch_size, len2, len1, -1)).squeeze(-1)
        return biaffine


class NonlinearMLP(nn.Module):

    def __init__(self, in_feature, out_feature, activation=None, bias=True):
        super(NonlinearMLP, self).__init__()
        if activation is None:
            self.activation = lambda x: x
        else:
            assert callable(activation)
            self.activation = activation
        self.bias = bias
        self.linear = nn.Linear(in_features=in_feature, out_features=
            out_feature, bias=bias)
        self.reset_params()

    def reset_params(self):
        nn.init.xavier_uniform_(self.linear.weight)
        if self.bias:
            nn.init.zeros_(self.linear.bias)

    def forward(self, inputs):
        linear_out = self.linear(inputs)
        return self.activation(linear_out)


class BiaffineScorer(nn.Module):

    def __init__(self, input_size, ffnn_size, num_cls, ffnn_drop=0.33):
        super(BiaffineScorer, self).__init__()
        self.ffnn_size = ffnn_size
        self.ffnn_drop = ffnn_drop
        self._act = nn.ELU()
        self.mlp_start = NonlinearMLP(in_feature=input_size, out_feature=
            ffnn_size, activation=self._act)
        self.mlp_end = NonlinearMLP(in_feature=input_size, out_feature=
            ffnn_size, activation=self._act)
        self.span_biaff = Biaffine(ffnn_size, num_cls, bias=(True, True))

    def forward(self, enc_hn):
        start_feat = self.mlp_start(enc_hn)
        end_feat = self.mlp_end(enc_hn)
        if self.training:
            start_feat = timestep_dropout(start_feat, self.ffnn_drop)
            end_feat = timestep_dropout(end_feat, self.ffnn_drop)
        span_score = self.span_biaff(start_feat, end_feat)
        return span_score


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


def get_init_inputs():
    return [[], {'input_size': 4, 'ffnn_size': 4, 'num_cls': 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.triton_helpers import libdevice
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_cat_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 80
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 5
    x1 = xindex // 5
    x2 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (4 * x1 + x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = 0.0
    tmp7 = tmp5 > tmp6
    tmp8 = 1.0
    tmp9 = tmp5 * tmp8
    tmp10 = libdevice.expm1(tmp9)
    tmp11 = tmp10 * tmp8
    tmp12 = tl.where(tmp7, tmp9, tmp11)
    tmp13 = tl.full(tmp12.shape, 0.0, tmp12.dtype)
    tmp14 = tl.where(tmp4, tmp12, tmp13)
    tmp15 = tmp0 >= tmp3
    tl.full([1], 5, tl.int64)
    tmp18 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
    tmp19 = tl.where(tmp15, tmp8, tmp18)
    tmp20 = tl.where(tmp4, tmp14, tmp19)
    tl.store(out_ptr0 + x2, tmp20, xmask)


@triton.jit
def triton_poi_fused_clone_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4
    y1 = yindex // 4
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 4 * x2 + 64 * y1), xmask & ymask)
    tl.store(out_ptr0 + (x2 + 16 * y3), tmp0, xmask & ymask)


def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5, primals_6 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4,), (1,))
    assert_size_stride(primals_3, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_4, (4, 4), (4, 1))
    assert_size_stride(primals_5, (4,), (1,))
    assert_size_stride(primals_6, (20, 5), (5, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_2, reinterpret_tensor(primals_3, (16, 
            4), (4, 1), 0), reinterpret_tensor(primals_1, (4, 4), (1, 4), 0
            ), alpha=1, beta=1, out=buf0)
        del primals_1
        del primals_2
        buf1 = empty_strided_cuda((16, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_5, reinterpret_tensor(primals_3, (16, 
            4), (4, 1), 0), reinterpret_tensor(primals_4, (4, 4), (1, 4), 0
            ), alpha=1, beta=1, out=buf1)
        del primals_4
        del primals_5
        buf2 = empty_strided_cuda((4, 4, 5), (20, 5, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(80)](buf0, buf2, 80, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf3 = empty_strided_cuda((16, 20), (20, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf2, (16, 5), (5, 1), 0),
            reinterpret_tensor(primals_6, (5, 20), (1, 5), 0), out=buf3)
        buf4 = empty_strided_cuda((4, 4, 5), (20, 5, 1), torch.float32)
        triton_poi_fused_cat_0[grid(80)](buf1, buf4, 80, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf5 = empty_strided_cuda((4, 16, 4), (64, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf3, (4, 16, 5), (80, 5, 1),
            0), reinterpret_tensor(buf4, (4, 5, 4), (20, 1, 5), 0), out=buf5)
        buf6 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        triton_poi_fused_clone_1[grid(16, 16)](buf5, buf6, 16, 16, XBLOCK=
            16, YBLOCK=16, num_warps=4, num_stages=1)
        del buf5
    return reinterpret_tensor(buf6, (4, 4, 4, 4), (64, 16, 4, 1), 0
        ), reinterpret_tensor(primals_3, (16, 4), (4, 1), 0
        ), buf0, buf1, reinterpret_tensor(buf2, (16, 5), (5, 1), 0
        ), reinterpret_tensor(buf3, (4, 5, 16), (80, 1, 5), 0), buf4, primals_6


def timestep_dropout(inputs, p=0.5, batch_first=True):
    """
    :param inputs: (bz, time_step, feature_size)
    :param p: probability p mask out output nodes
    :param batch_first: default True
    :return:
    """
    if not batch_first:
        inputs = inputs.transpose(0, 1)
    batch_size, _time_step, feature_size = inputs.size()
    drop_mask = inputs.data.new_full((batch_size, feature_size), 1 - p)
    drop_mask = torch.bernoulli(drop_mask).div(1 - p)
    drop_mask = drop_mask.unsqueeze(1)
    return inputs * drop_mask


class Biaffine(nn.Module):

    def __init__(self, in_features, out_features=1, bias=(True, True)):
        super(Biaffine, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.bias = bias
        self.linear_input_size = in_features + bias[0]
        self.linear_output_size = out_features * (in_features + bias[1])
        self.linear = nn.Linear(in_features=self.linear_input_size,
            out_features=self.linear_output_size, bias=False)
        self.reset_params()

    def reset_params(self):
        nn.init.xavier_uniform_(self.linear.weight)

    def forward(self, input1, input2):
        batch_size, len1, _dim1 = input1.size()
        batch_size, len2, _dim2 = input2.size()
        if self.bias[0]:
            ones = input1.data.new_ones(batch_size, len1, 1)
            input1 = torch.cat((input1, ones), dim=-1)
        if self.bias[1]:
            ones = input2.data.new_ones(batch_size, len2, 1)
            input2 = torch.cat((input2, ones), dim=-1)
        affine = self.linear(input1)
        affine = affine.reshape(batch_size, len1 * self.out_features, -1)
        biaffine = torch.bmm(affine, input2.transpose(1, 2)).transpose(1, 2
            ).contiguous()
        biaffine = biaffine.reshape((batch_size, len2, len1, -1)).squeeze(-1)
        return biaffine


class NonlinearMLP(nn.Module):

    def __init__(self, in_feature, out_feature, activation=None, bias=True):
        super(NonlinearMLP, self).__init__()
        if activation is None:
            self.activation = lambda x: x
        else:
            assert callable(activation)
            self.activation = activation
        self.bias = bias
        self.linear = nn.Linear(in_features=in_feature, out_features=
            out_feature, bias=bias)
        self.reset_params()

    def reset_params(self):
        nn.init.xavier_uniform_(self.linear.weight)
        if self.bias:
            nn.init.zeros_(self.linear.bias)

    def forward(self, inputs):
        linear_out = self.linear(inputs)
        return self.activation(linear_out)


class BiaffineScorerNew(nn.Module):

    def __init__(self, input_size, ffnn_size, num_cls, ffnn_drop=0.33):
        super(BiaffineScorerNew, self).__init__()
        self.ffnn_size = ffnn_size
        self.ffnn_drop = ffnn_drop
        self._act = nn.ELU()
        self.mlp_start = NonlinearMLP(in_feature=input_size, out_feature=
            ffnn_size, activation=self._act)
        self.mlp_end = NonlinearMLP(in_feature=input_size, out_feature=
            ffnn_size, activation=self._act)
        self.span_biaff = Biaffine(ffnn_size, num_cls, bias=(True, True))

    def forward(self, input_0):
        primals_1 = self.mlp_start.linear.weight
        primals_2 = self.mlp_start.linear.bias
        primals_4 = self.mlp_end.linear.weight
        primals_5 = self.mlp_end.linear.bias
        primals_6 = self.span_biaff.linear.weight
        primals_3 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6])
        return output[0]
