/* Generated by Cython 0.29.32 */

#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
    #error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_29_32"
#define CYTHON_HEX_VERSION 0x001D20F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef HAVE_LONG_LONG
  #if PY_VERSION_HEX >= 0x02070000
    #define HAVE_LONG_LONG
  #endif
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #if PY_VERSION_HEX < 0x03050000
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900)
  #endif
#elif defined(PYSTON_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_ASYNC_SLOTS
  #define CYTHON_USE_ASYNC_SLOTS 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  #endif
#elif defined(PY_NOGIL)
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_NOGIL 1
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #ifndef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE 1
  #endif
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_PYSTON 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #define CYTHON_COMPILING_IN_NOGIL 0
  #ifndef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 0
  #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #if PY_MAJOR_VERSION < 3
    #undef CYTHON_USE_ASYNC_SLOTS
    #define CYTHON_USE_ASYNC_SLOTS 0
  #elif !defined(CYTHON_USE_ASYNC_SLOTS)
    #define CYTHON_USE_ASYNC_SLOTS 1
  #endif
  #if PY_VERSION_HEX < 0x02070000
    #undef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 0
  #elif !defined(CYTHON_FAST_THREAD_STATE)
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000)
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  #endif
  #ifndef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  #endif
  #if PY_VERSION_HEX >= 0x030B00A4
    #undef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK 0
  #elif !defined(CYTHON_USE_EXC_INFO_STACK)
    #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  #endif
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
  #endif
#endif
#if !defined(CYTHON_FAST_PYCCALL)
#define CYTHON_FAST_PYCCALL  (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #if PY_MAJOR_VERSION < 3
    #include "longintrepr.h"
  #endif
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#ifdef _MSC_VER
    #ifndef _MSC_STDINT_H_
        #if _MSC_VER < 1300
           typedef unsigned char     uint8_t;
           typedef unsigned int      uint32_t;
        #else
           typedef unsigned __int8   uint8_t;
           typedef unsigned __int32  uint32_t;
        #endif
    #endif
#else
   #include <stdint.h>
#endif
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus) && __cplusplus >= 201103L
    #if __has_cpp_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH [[fallthrough]]
    #elif __has_cpp_attribute(clang::fallthrough)
      #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
    #elif __has_cpp_attribute(gnu::fallthrough)
      #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__ ) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif

#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_DefaultClassType PyType_Type
#if PY_VERSION_HEX >= 0x030B00A1
    static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
                                                    PyObject *code, PyObject *c, PyObject* n, PyObject *v,
                                                    PyObject *fv, PyObject *cell, PyObject* fn,
                                                    PyObject *name, int fline, PyObject *lnos) {
        PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
        PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
        const char *fn_cstr=NULL;
        const char *name_cstr=NULL;
        PyCodeObject* co=NULL;
        PyObject *type, *value, *traceback;
        PyErr_Fetch(&type, &value, &traceback);
        if (!(kwds=PyDict_New())) goto end;
        if (!(argcount=PyLong_FromLong(a))) goto end;
        if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
        if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
        if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
        if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
        if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
        if (!(nlocals=PyLong_FromLong(l))) goto end;
        if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
        if (!(stacksize=PyLong_FromLong(s))) goto end;
        if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
        if (!(flags=PyLong_FromLong(f))) goto end;
        if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
        if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
        if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
        if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
        if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
        if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
        if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
        if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
        Py_XDECREF((PyObject*)co);
        co = (PyCodeObject*)call_result;
        call_result = NULL;
        if (0) {
            cleanup_code_too:
            Py_XDECREF((PyObject*)co);
            co = NULL;
        }
        end:
        Py_XDECREF(kwds);
        Py_XDECREF(argcount);
        Py_XDECREF(posonlyargcount);
        Py_XDECREF(kwonlyargcount);
        Py_XDECREF(nlocals);
        Py_XDECREF(stacksize);
        Py_XDECREF(replace);
        Py_XDECREF(call_result);
        Py_XDECREF(empty);
        if (type) {
            PyErr_Restore(type, value, traceback);
        }
        return co;
    }
#else
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
  #define __Pyx_DefaultClassType PyType_Type
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #define __Pyx_PyCFunctionFast _PyCFunctionFast
  #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
#endif
#if CYTHON_FAST_PYCCALL
#define __Pyx_PyFastCFunction_Check(func)\
    ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
#else
#define __Pyx_PyFastCFunction_Check(func) 0
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  #define PyMem_RawMalloc(n)           PyMem_Malloc(n)
  #define PyMem_RawRealloc(p, n)       PyMem_Realloc(p, n)
  #define PyMem_RawFree(p)             PyMem_Free(p)
#endif
#if CYTHON_COMPILING_IN_PYSTON
  #define __Pyx_PyCode_HasFreeVars(co)  PyCode_HasFreeVars(co)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x03060000
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#elif PY_VERSION_HEX >= 0x03000000
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_Current
#endif
#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
#include "pythread.h"
#define Py_tss_NEEDS_INIT 0
typedef int Py_tss_t;
static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  *key = PyThread_create_key();
  return 0;
}
static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  *key = Py_tss_NEEDS_INIT;
  return key;
}
static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  PyObject_Free(key);
}
static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  return *key != Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  PyThread_delete_key(*key);
  *key = Py_tss_NEEDS_INIT;
}
static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  return PyThread_set_key_value(*key, value);
}
static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  return PyThread_get_key_value(*key);
}
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStr(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
#else
#define __Pyx_PyDict_GetItemStr(dict, name)  PyDict_GetItem(dict, name)
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #if defined(PyUnicode_IS_READY)
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #else
  #define __Pyx_PyUnicode_READY(op)       (0)
  #endif
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, ch)
  #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  #endif
  #else
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #endif
#else
  #define CYTHON_PEP393_ENABLED 0
  #define PyUnicode_1BYTE_KIND  1
  #define PyUnicode_2BYTE_KIND  2
  #define PyUnicode_4BYTE_KIND  4
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
#endif
#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  #define PyObject_ASCII(o)            PyObject_Repr(o)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#ifndef PyObject_Unicode
  #define PyObject_Unicode             PyObject_Str
#endif
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
#else
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  #ifndef PyUnicode_InternFromString
    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  #endif
#endif
#if PY_VERSION_HEX < 0x030200A4
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsHash_t
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   __Pyx_PyIndex_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
#if CYTHON_USE_ASYNC_SLOTS
  #if PY_VERSION_HEX >= 0x030500B1
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
    #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  #else
    #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  #endif
#else
  #define __Pyx_PyType_AsAsync(obj) NULL
#endif
#ifndef __Pyx_PyAsyncMethodsStruct
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
    } __Pyx_PyAsyncMethodsStruct;
#endif

#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
  #if !defined(_USE_MATH_DEFINES)
    #define _USE_MATH_DEFINES
  #endif
#endif
#include <math.h>
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#define __PYX_MARK_ERR_POS(f_index, lineno) \
    { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__libs__network
#define __PYX_HAVE_API__libs__network
/* Early includes */
#include <string.h>
#include <stdio.h>
#include "numpy/arrayobject.h"
#include "numpy/ndarrayobject.h"
#include "numpy/ndarraytypes.h"
#include "numpy/arrayscalars.h"
#include "numpy/ufuncobject.h"

    /* NumPy API declarations from "numpy/__init__.pxd" */
    
#include "pythread.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
#define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
#define __Pyx_PyObject_AsWritableString(s)    ((char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return (size_t)(u_end - u - 1);
}
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#if CYTHON_ASSUME_SAFE_MACROS
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    const char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    if (strcmp(default_encoding_c, "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (!ascii_chars_u) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
        Py_DECREF(ascii_chars_u);
        Py_DECREF(ascii_chars_b);
    }
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (!sys) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    Py_DECREF(sys);
    if (!default_encoding) goto bad;
    default_encoding_c = PyBytes_AsString(default_encoding);
    if (!default_encoding_c) goto bad;
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }

static PyObject *__pyx_m = NULL;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_cython_runtime = NULL;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;

/* Header.proto */
#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif


static const char *__pyx_f[] = {
  "network.pyx",
  "networkconv.pyx",
  "stringsource",
  "networkdependencyconv.pyx",
  "__init__.pxd",
  "type.pxd",
  "bool.pxd",
  "complex.pxd",
};
/* BufferFormatStructs.proto */
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
  const char* name;
  struct __Pyx_StructField_* fields;
  size_t size;
  size_t arraysize[8];
  int ndim;
  char typegroup;
  char is_unsigned;
  int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
  __Pyx_TypeInfo* type;
  const char* name;
  size_t offset;
} __Pyx_StructField;
typedef struct {
  __Pyx_StructField* field;
  size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
  __Pyx_StructField root;
  __Pyx_BufFmt_StackElem* head;
  size_t fmt_offset;
  size_t new_count, enc_count;
  size_t struct_alignment;
  int is_complex;
  char enc_type;
  char new_packmode;
  char enc_packmode;
  char is_valid_array;
} __Pyx_BufFmt_Context;


/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":689
 * # in Cython to enable them only on the right systems.
 * 
 * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 */
typedef npy_int8 __pyx_t_5numpy_int8_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":690
 * 
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t
 */
typedef npy_int16 __pyx_t_5numpy_int16_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":691
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int64      int64_t
 * #ctypedef npy_int96      int96_t
 */
typedef npy_int32 __pyx_t_5numpy_int32_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":692
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_int96      int96_t
 * #ctypedef npy_int128     int128_t
 */
typedef npy_int64 __pyx_t_5numpy_int64_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":696
 * #ctypedef npy_int128     int128_t
 * 
 * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 */
typedef npy_uint8 __pyx_t_5numpy_uint8_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":697
 * 
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t
 */
typedef npy_uint16 __pyx_t_5numpy_uint16_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":698
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint64     uint64_t
 * #ctypedef npy_uint96     uint96_t
 */
typedef npy_uint32 __pyx_t_5numpy_uint32_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":699
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_uint96     uint96_t
 * #ctypedef npy_uint128    uint128_t
 */
typedef npy_uint64 __pyx_t_5numpy_uint64_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":703
 * #ctypedef npy_uint128    uint128_t
 * 
 * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_float64    float64_t
 * #ctypedef npy_float80    float80_t
 */
typedef npy_float32 __pyx_t_5numpy_float32_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":704
 * 
 * ctypedef npy_float32    float32_t
 * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_float80    float80_t
 * #ctypedef npy_float128   float128_t
 */
typedef npy_float64 __pyx_t_5numpy_float64_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":713
 * # The int types are mapped a bit surprising --
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t
 */
typedef npy_long __pyx_t_5numpy_int_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":714
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   longlong_t
 * 
 */
typedef npy_longlong __pyx_t_5numpy_long_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":715
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_ulong      uint_t
 */
typedef npy_longlong __pyx_t_5numpy_longlong_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":717
 * ctypedef npy_longlong   longlong_t
 * 
 * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t
 */
typedef npy_ulong __pyx_t_5numpy_uint_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":718
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":719
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_intp       intp_t
 */
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":721
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":722
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":724
 * ctypedef npy_uintp      uintp_t
 * 
 * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t
 */
typedef npy_double __pyx_t_5numpy_float_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":725
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":726
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cfloat      cfloat_t
 */
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;

/* "libs/network.pyx":20
 * 
 * #ctypedef float FLOAT_t
 * ctypedef np.float_t FLOAT_t             # <<<<<<<<<<<<<<
 * #ctypedef int INT_t
 * ctypedef np.int_t INT_t
 */
typedef __pyx_t_5numpy_float_t __pyx_t_4libs_7network_FLOAT_t;

/* "libs/network.pyx":22
 * ctypedef np.float_t FLOAT_t
 * #ctypedef int INT_t
 * ctypedef np.int_t INT_t             # <<<<<<<<<<<<<<
 * ctypedef np.double_t DOUBLE_t
 * 
 */
typedef __pyx_t_5numpy_int_t __pyx_t_4libs_7network_INT_t;

/* "libs/network.pyx":23
 * #ctypedef int INT_t
 * ctypedef np.int_t INT_t
 * ctypedef np.double_t DOUBLE_t             # <<<<<<<<<<<<<<
 * 
 * # ----------------------------------------------------------------------
 */
typedef __pyx_t_5numpy_double_t __pyx_t_4libs_7network_DOUBLE_t;
/* Declarations.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

/* Declarations.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);


/*--- Type declarations ---*/
struct __pyx_obj_4libs_7network_Network;
struct __pyx_obj_4libs_7network_ConvolutionalNetwork;
struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork;
struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new;
struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr;
struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train;
struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr;
struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate;
struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr;
struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new;
struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr;
struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train;
struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":728
 * ctypedef npy_longdouble longdouble_t
 * 
 * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t
 */
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":729
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":730
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cdouble     complex_t
 */
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":732
 * ctypedef npy_clongdouble clongdouble_t
 * 
 * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 */
typedef npy_cdouble __pyx_t_5numpy_complex_t;
struct __pyx_opt_args_4libs_7network_logsumexp;
struct __pyx_opt_args_4libs_7network_hardtanh;

/* "libs/network.pyx":28
 * # Math functions
 * 
 * cdef logsumexp(np.ndarray a, axis=None):             # <<<<<<<<<<<<<<
 *     """Compute the log of the sum of exponentials of input elements.
 *     like: scipy.misc.logsumexp
 */
struct __pyx_opt_args_4libs_7network_logsumexp {
  int __pyx_n;
  PyObject *axis;
};

/* "libs/network.pyx":53
 *     return np.log(np.sum(np.exp(a - a_max), axis=0)) + a_max
 * 
 * cdef hardtanh(np.ndarray weights, inplace=False):             # <<<<<<<<<<<<<<
 *     """
 *     Hard hyperbolic tangent.
 */
struct __pyx_opt_args_4libs_7network_hardtanh {
  int __pyx_n;
  PyObject *inplace;
};

/* "libs/network.pyx":79
 * # ----------------------------------------------------------------------
 * 
 * cdef class Network:             # <<<<<<<<<<<<<<
 * 
 *     # sizes and learning rates
 */
struct __pyx_obj_4libs_7network_Network {
  PyObject_HEAD
  int word_window_size;
  int input_size;
  int hidden_size;
  int output_size;
  float learning_rate;
  float learning_rate_features;
  float decay_factor;
  PyBoolObject *use_learning_rate_decay;
  int features_per_token;
  PyArrayObject *sentence_lookup;
  PyArrayObject *padding_left;
  PyArrayObject *padding_right;
  PyArrayObject *pre_padding;
  PyArrayObject *pos_padding;
  PyArrayObject *hidden_weights;
  PyArrayObject *output_weights;
  PyArrayObject *hidden_bias;
  PyArrayObject *output_bias;
  PyArrayObject *input_values;
  PyArrayObject *hidden_values;
  PyArrayObject *layer2_values;
  PyObject *feature_tables;
  float learning_rate_trans;
  PyArrayObject *transitions;
  float answer_score;
  PyArrayObject *net_gradients;
  PyArrayObject *trans_gradients;
  PyArrayObject *input_sent_values;
  PyArrayObject *hidden_sent_values;
  PyArrayObject *layer2_sent_values;
  float error;
  float accuracy;
  float float_errors;
  float sentence_accuracy;
  int num_tokens;
  int skips;
  PyObject *network_filename;
  PyObject *network_text_filename;
  PyObject *validation_sentences;
  PyObject *validation_tags;
};


/* "networkconv.pyx":11
 * cimport numpy as np
 * 
 * cdef class ConvolutionalNetwork(Network):             # <<<<<<<<<<<<<<
 * 
 *     # transition and distance feature tables
 */
struct __pyx_obj_4libs_7network_ConvolutionalNetwork {
  struct __pyx_obj_4libs_7network_Network __pyx_base;
  struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork *__pyx_vtab;
  PyArrayObject *target_dist_table;
  PyArrayObject *pred_dist_table;
  PyArrayObject *target_dist_weights;
  PyArrayObject *pred_dist_weights;
  int target_dist_offset;
  int pred_dist_offset;
  PyArrayObject *target_dist_lookup;
  PyArrayObject *pred_dist_lookup;
  PyArrayObject *target_convolution_lookup;
  PyArrayObject *pred_convolution_lookup;
  PyArrayObject *target_dist_deltas;
  PyArrayObject *pred_dist_deltas;
  int hidden2_size;
  PyArrayObject *hidden2_weights;
  PyArrayObject *hidden2_bias;
  PyArrayObject *hidden2_values;
  PyArrayObject *hidden2_before_activation;
  PyArrayObject *hidden_before_activation;
  PyArrayObject *convolution_lookup;
  PyArrayObject *max_indices;
  int num_targets;
  PyBoolObject *only_classify;
  int half_window;
  PyArrayObject *hidden_gradients;
  PyArrayObject *hidden2_gradients;
  PyArrayObject *input_deltas;
  int num_sentences;
  PyObject *validation_predicates;
  PyObject *validation_arguments;
};


/* "networkdependencyconv.pyx":11
 * cimport numpy as np
 * 
 * cdef class ConvolutionalDependencyNetwork(ConvolutionalNetwork):             # <<<<<<<<<<<<<<
 * 
 *     # the weights of all possible dependency among tokens
 */
struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork {
  struct __pyx_obj_4libs_7network_ConvolutionalNetwork __pyx_base;
  PyArrayObject *dependency_weights;
  PyObject *validation_heads;
};


/* "libs/network.pyx":127
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, int word_window, int hidden_size,             # <<<<<<<<<<<<<<
 *                  int output_size):
 *         """
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new {
  PyObject_HEAD
  PyObject *__pyx_v_feature_tables;
};


/* "libs/network.pyx":133
 *         """
 *         # sum the number of features in all tables
 *         cdef int input_size = sum(table.shape[1] for table in feature_tables)             # <<<<<<<<<<<<<<
 *         input_size *= word_window
 * 
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *__pyx_outer_scope;
  PyObject *__pyx_v_table;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "libs/network.pyx":595
 *             self.learning_rate_trans *= factor
 * 
 *     def train(self, list sentences, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0):
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train {
  PyObject_HEAD
  PyObject *__pyx_v_sentences;
};


/* "libs/network.pyx":617
 *         last_accuracy = 0
 *         last_error = np.Infinity
 *         self.num_tokens = sum(len(sent) for sent in sentences)             # <<<<<<<<<<<<<<
 * 
 *         if self.validation_sentences is None:
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *__pyx_outer_scope;
  PyObject *__pyx_v_sent;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};


/* "libs/network.pyx":693
 *                 self.float_errors += 1
 * 
 *     def _validate(self):             # <<<<<<<<<<<<<<
 *         """Perform validation on validation data and estimate accuracy"""
 *         hits = 0
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate {
  PyObject_HEAD
  struct __pyx_obj_4libs_7network_Network *__pyx_v_self;
};


/* "libs/network.pyx":702
 * 
 *         # self.num_tokens stores number of tokens in training sentences
 *         num_tokens = sum(len(sent) for sent in self.validation_sentences)             # <<<<<<<<<<<<<<
 *         self.accuracy = float(hits) / num_tokens
 * 
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *__pyx_outer_scope;
  PyObject *__pyx_v_sent;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};


/* "networkconv.pyx":52
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, target_dist_table, pred_dist_table,             # <<<<<<<<<<<<<<
 *                    int word_window, int hidden1_size, int hidden2_size, int output_size):
 *         """Creates a new convolutional neural network."""
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new {
  PyObject_HEAD
  PyObject *__pyx_v_feature_tables;
};


/* "networkconv.pyx":56
 *         """Creates a new convolutional neural network."""
 *         # sum the number of features in all tables except for distance
 *         cdef int input_size = sum(table.shape[1] for table in feature_tables)             # <<<<<<<<<<<<<<
 *         input_size *= word_window
 * 
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *__pyx_outer_scope;
  PyObject *__pyx_v_table;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "networkconv.pyx":275
 *         self.validation_arguments = validation_arguments
 * 
 *     def train(self, list sentences, list predicates, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0, list arguments=None):
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train {
  PyObject_HEAD
  PyObject *__pyx_v_sentences;
};


/* "networkconv.pyx":288
 *         """
 *         self.num_sentences = len(sentences)
 *         self.num_tokens = sum(len(sent) for sent in sentences)             # <<<<<<<<<<<<<<
 *         self.only_classify = arguments is not None
 * 
 */
struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr {
  PyObject_HEAD
  struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *__pyx_outer_scope;
  PyObject *__pyx_v_sent;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
};



/* "networkconv.pyx":11
 * cimport numpy as np
 * 
 * cdef class ConvolutionalNetwork(Network):             # <<<<<<<<<<<<<<
 * 
 *     # transition and distance feature tables
 */

struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork {
  PyArrayObject *(*argument_distances)(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *, PyObject *, PyObject *);
};
static struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork *__pyx_vtabptr_4libs_7network_ConvolutionalNetwork;


/* "networkdependencyconv.pyx":11
 * cimport numpy as np
 * 
 * cdef class ConvolutionalDependencyNetwork(ConvolutionalNetwork):             # <<<<<<<<<<<<<<
 * 
 *     # the weights of all possible dependency among tokens
 */

struct __pyx_vtabstruct_4libs_7network_ConvolutionalDependencyNetwork {
  struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork __pyx_base;
};
static struct __pyx_vtabstruct_4libs_7network_ConvolutionalDependencyNetwork *__pyx_vtabptr_4libs_7network_ConvolutionalDependencyNetwork;

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyObjectGetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* PyThreadStateGet.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#define __Pyx_PyErr_Occurred()  __pyx_tstate->curexc_type
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* Profile.proto */
#ifndef CYTHON_PROFILE
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
  #define CYTHON_PROFILE 0
#else
  #define CYTHON_PROFILE 1
#endif
#endif
#ifndef CYTHON_TRACE_NOGIL
  #define CYTHON_TRACE_NOGIL 0
#else
  #if CYTHON_TRACE_NOGIL && !defined(CYTHON_TRACE)
    #define CYTHON_TRACE 1
  #endif
#endif
#ifndef CYTHON_TRACE
  #define CYTHON_TRACE 0
#endif
#if CYTHON_TRACE
  #undef CYTHON_PROFILE_REUSE_FRAME
#endif
#ifndef CYTHON_PROFILE_REUSE_FRAME
  #define CYTHON_PROFILE_REUSE_FRAME 0
#endif
#if CYTHON_PROFILE || CYTHON_TRACE
  #include "compile.h"
  #include "frameobject.h"
  #include "traceback.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
  #if CYTHON_PROFILE_REUSE_FRAME
    #define CYTHON_FRAME_MODIFIER static
    #define CYTHON_FRAME_DEL(frame)
  #else
    #define CYTHON_FRAME_MODIFIER
    #define CYTHON_FRAME_DEL(frame) Py_CLEAR(frame)
  #endif
  #define __Pyx_TraceDeclarations\
      static PyCodeObject *__pyx_frame_code = NULL;\
      CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;\
      int __Pyx_use_tracing = 0;
  #define __Pyx_TraceFrameInit(codeobj)\
      if (codeobj) __pyx_frame_code = (PyCodeObject*) codeobj;
#if PY_VERSION_HEX >= 0x030b00a2
  #define __Pyx_IsTracing(tstate, check_tracing, check_funcs)\
     (unlikely((tstate)->cframe->use_tracing) &&\
         (!(check_tracing) || !(tstate)->tracing) &&\
         (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc)))
  #define __Pyx_EnterTracing(tstate) PyThreadState_EnterTracing(tstate)
  #define __Pyx_LeaveTracing(tstate) PyThreadState_LeaveTracing(tstate)
#elif PY_VERSION_HEX >= 0x030a00b1
  #define __Pyx_IsTracing(tstate, check_tracing, check_funcs)\
     (unlikely((tstate)->cframe->use_tracing) &&\
         (!(check_tracing) || !(tstate)->tracing) &&\
         (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc)))
  #define __Pyx_EnterTracing(tstate)\
      do { tstate->tracing++; tstate->cframe->use_tracing = 0; } while (0)
  #define __Pyx_LeaveTracing(tstate)\
      do {\
          tstate->tracing--;\
          tstate->cframe->use_tracing = ((CYTHON_TRACE && tstate->c_tracefunc != NULL)\
                                 || tstate->c_profilefunc != NULL);\
      } while (0)
#else
  #define __Pyx_IsTracing(tstate, check_tracing, check_funcs)\
     (unlikely((tstate)->use_tracing) &&\
         (!(check_tracing) || !(tstate)->tracing) &&\
         (!(check_funcs) || (tstate)->c_profilefunc || (CYTHON_TRACE && (tstate)->c_tracefunc)))
  #define __Pyx_EnterTracing(tstate)\
      do { tstate->tracing++; tstate->use_tracing = 0; } while (0)
  #define __Pyx_LeaveTracing(tstate)\
      do {\
          tstate->tracing--;\
          tstate->use_tracing = ((CYTHON_TRACE && tstate->c_tracefunc != NULL)\
                                         || tstate->c_profilefunc != NULL);\
      } while (0)
#endif
  #ifdef WITH_THREAD
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  if (nogil) {\
      if (CYTHON_TRACE_NOGIL) {\
          PyThreadState *tstate;\
          PyGILState_STATE state = PyGILState_Ensure();\
          tstate = __Pyx_PyThreadState_Current;\
          if (__Pyx_IsTracing(tstate, 1, 1)) {\
              __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          }\
          PyGILState_Release(state);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  } else {\
      PyThreadState* tstate = PyThreadState_GET();\
      if (__Pyx_IsTracing(tstate, 1, 1)) {\
          __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  }
  #else
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)\
  {   PyThreadState* tstate = PyThreadState_GET();\
      if (__Pyx_IsTracing(tstate, 1, 1)) {\
          __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, tstate, funcname, srcfile, firstlineno);\
          if (unlikely(__Pyx_use_tracing < 0)) goto_error;\
      }\
  }
  #endif
  #define __Pyx_TraceException()\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (__Pyx_IsTracing(tstate, 0, 1)) {\
          __Pyx_EnterTracing(tstate);\
          PyObject *exc_info = __Pyx_GetExceptionTuple(tstate);\
          if (exc_info) {\
              if (CYTHON_TRACE && tstate->c_tracefunc)\
                  tstate->c_tracefunc(\
                      tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
              tstate->c_profilefunc(\
                  tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);\
              Py_DECREF(exc_info);\
          }\
          __Pyx_LeaveTracing(tstate);\
      }\
  }
  static void __Pyx_call_return_trace_func(PyThreadState *tstate, PyFrameObject *frame, PyObject *result) {
      PyObject *type, *value, *traceback;
      __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
      __Pyx_EnterTracing(tstate);
      if (CYTHON_TRACE && tstate->c_tracefunc)
          tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_RETURN, result);
      if (tstate->c_profilefunc)
          tstate->c_profilefunc(tstate->c_profileobj, frame, PyTrace_RETURN, result);
      CYTHON_FRAME_DEL(frame);
      __Pyx_LeaveTracing(tstate);
      __Pyx_ErrRestoreInState(tstate, type, value, traceback);
  }
  #ifdef WITH_THREAD
  #define __Pyx_TraceReturn(result, nogil)\
  if (likely(!__Pyx_use_tracing)); else {\
      if (nogil) {\
          if (CYTHON_TRACE_NOGIL) {\
              PyThreadState *tstate;\
              PyGILState_STATE state = PyGILState_Ensure();\
              tstate = __Pyx_PyThreadState_Current;\
              if (__Pyx_IsTracing(tstate, 0, 0)) {\
                  __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
              }\
              PyGILState_Release(state);\
          }\
      } else {\
          PyThreadState* tstate = __Pyx_PyThreadState_Current;\
          if (__Pyx_IsTracing(tstate, 0, 0)) {\
              __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
          }\
      }\
  }
  #else
  #define __Pyx_TraceReturn(result, nogil)\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (__Pyx_IsTracing(tstate, 0, 0)) {\
          __Pyx_call_return_trace_func(tstate, __pyx_frame, (PyObject*)result);\
      }\
  }
  #endif
  static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno);
  static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, PyThreadState* tstate, const char *funcname, const char *srcfile, int firstlineno);
#else
  #define __Pyx_TraceDeclarations
  #define __Pyx_TraceFrameInit(codeobj)
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno, nogil, goto_error)   if ((1)); else goto_error;
  #define __Pyx_TraceException()
  #define __Pyx_TraceReturn(result, nogil)
#endif
#if CYTHON_TRACE
  static int __Pyx_call_line_trace_func(PyThreadState *tstate, PyFrameObject *frame, int lineno) {
      int ret;
      PyObject *type, *value, *traceback;
      __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
      __Pyx_PyFrame_SetLineNumber(frame, lineno);
      __Pyx_EnterTracing(tstate);
      ret = tstate->c_tracefunc(tstate->c_traceobj, frame, PyTrace_LINE, NULL);
      __Pyx_LeaveTracing(tstate);
      if (likely(!ret)) {
          __Pyx_ErrRestoreInState(tstate, type, value, traceback);
      } else {
          Py_XDECREF(type);
          Py_XDECREF(value);
          Py_XDECREF(traceback);
      }
      return ret;
  }
  #ifdef WITH_THREAD
  #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  if (likely(!__Pyx_use_tracing)); else {\
      if (nogil) {\
          if (CYTHON_TRACE_NOGIL) {\
              int ret = 0;\
              PyThreadState *tstate;\
              PyGILState_STATE state = PyGILState_Ensure();\
              tstate = __Pyx_PyThreadState_Current;\
              if (__Pyx_IsTracing(tstate, 0, 0) && tstate->c_tracefunc && __pyx_frame->f_trace) {\
                  ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
              }\
              PyGILState_Release(state);\
              if (unlikely(ret)) goto_error;\
          }\
      } else {\
          PyThreadState* tstate = __Pyx_PyThreadState_Current;\
          if (__Pyx_IsTracing(tstate, 0, 0) && tstate->c_tracefunc && __pyx_frame->f_trace) {\
              int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
              if (unlikely(ret)) goto_error;\
          }\
      }\
  }
  #else
  #define __Pyx_TraceLine(lineno, nogil, goto_error)\
  if (likely(!__Pyx_use_tracing)); else {\
      PyThreadState* tstate = __Pyx_PyThreadState_Current;\
      if (__Pyx_IsTracing(tstate, 0, 0) && tstate->c_tracefunc && __pyx_frame->f_trace) {\
          int ret = __Pyx_call_line_trace_func(tstate, __pyx_frame, lineno);\
          if (unlikely(ret)) goto_error;\
      }\
  }
  #endif
#else
  #define __Pyx_TraceLine(lineno, nogil, goto_error)   if ((1)); else goto_error;
#endif

/* PyFunctionFastCall.proto */
#if CYTHON_FAST_PYCALL
#define __Pyx_PyFunction_FastCall(func, args, nargs)\
    __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
#else
#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
#endif
#define __Pyx_BUILD_ASSERT_EXPR(cond)\
    (sizeof(char [1 - 2*!(cond)]) - 1)
#ifndef Py_MEMBER_SIZE
#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
#endif
#if CYTHON_FAST_PYCALL
  static size_t __pyx_pyframe_localsplus_offset = 0;
  #include "frameobject.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
  #define __Pxy_PyFrame_Initialize_Offsets()\
    ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
     (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  #define __Pyx_PyFrame_GetLocalsplus(frame)\
    (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
#endif // CYTHON_FAST_PYCALL
#endif

/* PyObjectCall.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyObjectCallMethO.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectCallNoArg.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
#else
#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
#endif

/* PyCFunctionFastCall.proto */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
#else
#define __Pyx_PyCFunction_FastCall(func, args, nargs)  (assert(0), NULL)
#endif

/* PyObjectCallOneArg.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* ExtTypeTest.proto */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);

/* PyDictVersioning.proto */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __pyx_dict_cached_value;\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
#define __Pyx_GetModuleGlobalNameUncached(var, name)  {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
}
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyObjectCall2Args.proto */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* IsLittleEndian.proto */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);

/* BufferFormatCheck.proto */
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type);

/* BufferGetAndValidate.proto */
#define __Pyx_GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack)\
    ((obj == Py_None || obj == NULL) ?\
    (__Pyx_ZeroBuffer(buf), 0) :\
    __Pyx__GetBufferAndValidate(buf, obj, dtype, flags, nd, cast, stack))
static int  __Pyx__GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
    __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static void __Pyx_ZeroBuffer(Py_buffer* buf);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static Py_ssize_t __Pyx_minusones[] = { -1, -1, -1, -1, -1, -1, -1, -1 };
static Py_ssize_t __Pyx_zeros[] = { 0, 0, 0, 0, 0, 0, 0, 0 };

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* RaiseDoubleKeywords.proto */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywords.proto */
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
    const char* function_name);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

/* PyFloatBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_TrueDivideCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyFloat_TrueDivideCObj(op1, op2, floatval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
#endif

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* GCCDiagnostics.proto */
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

/* BuildPyUnicode.proto */
static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
                                                int prepend_sign, char padding_char);

/* IncludeStringH.proto */
#include <string.h>

/* CIntToPyUnicode.proto */
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_From_int(int value, Py_ssize_t width, char padding_char, char format_char);

/* PyObjectFormatAndDecref.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);

/* JoinPyUnicode.proto */
static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
                                      Py_UCS4 max_char);

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* DivInt[long].proto */
static CYTHON_INLINE long __Pyx_div_long(long, long);

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* SetItemInt.proto */
#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* BufferFallbackError.proto */
static void __Pyx_RaiseBufferFallbackError(void);

/* PyIntCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* PyFloatBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_AddCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyFloat_AddCObj(op1, op2, floatval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_AddCObj(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* PyObjectFormat.proto */
#if CYTHON_USE_UNICODE_WRITER
static PyObject* __Pyx_PyObject_Format(PyObject* s, PyObject* f);
#else
#define __Pyx_PyObject_Format(s, f) PyObject_Format(s, f)
#endif

/* GetTopmostException.proto */
#if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyErrExceptionMatches.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* BufferIndexError.proto */
static void __Pyx_RaiseBufferIndexError(int axis);

#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
/* DictGetItem.proto */
#if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* GetAttr.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* CIntToPyUnicode.proto */
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_From_long(long value, Py_ssize_t width, char padding_char, char format_char);

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_TrueDivideObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
#endif

/* PyIntBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyInt_FloorDivideObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceFloorDivide(op1, op2) : PyNumber_FloorDivide(op1, op2))
#endif

/* IterNext.proto */
#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);

/* None.proto */
static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

/* RaiseException.proto */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* PyIntCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* pyobject_as_double.proto */
static double __Pyx__PyObject_AsDouble(PyObject* obj);
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyObject_AsDouble(obj)\
(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\
 likely(PyInt_CheckExact(obj)) ?\
 PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#else
#define __Pyx_PyObject_AsDouble(obj)\
((likely(PyFloat_CheckExact(obj))) ?\
 PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif

/* pyfrozenset_new.proto */
static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);

/* PySetContains.proto */
static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq);

/* UnpackUnboundCMethod.proto */
typedef struct {
    PyObject *type;
    PyObject **method_name;
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;

/* CallUnboundCMethod1.proto */
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* Import.proto */
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* HasAttr.proto */
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);

/* WriteUnraisableException.proto */
static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback, int nogil);

/* PyObject_GenericGetAttrNoDict.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
#endif

/* PyObject_GenericGetAttr.proto */
#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif

/* PyObjectGetAttrStrNoError.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);

/* SetVTable.proto */
static int __Pyx_SetVtable(PyObject *dict, void *vtable);

/* TypeImport.proto */
#ifndef __PYX_HAVE_RT_ImportType_proto
#define __PYX_HAVE_RT_ImportType_proto
enum __Pyx_ImportType_CheckSize {
   __Pyx_ImportType_CheckSize_Error = 0,
   __Pyx_ImportType_CheckSize_Warn = 1,
   __Pyx_ImportType_CheckSize_Ignore = 2
};
static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
#endif

/* ClassMethod.proto */
#include "descrobject.h"
static CYTHON_UNUSED PyObject* __Pyx_Method_ClassMethod(PyObject *method);

/* GetNameInClass.proto */
#define __Pyx_GetNameInClass(var, nmspace, name)  (var) = __Pyx__GetNameInClass(nmspace, name)
static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name);

/* CLineInTraceback.proto */
#ifdef CYTHON_CLINE_IN_TRACEBACK
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#else
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#endif

/* CodeObjectCache.proto */
typedef struct {
    PyCodeObject* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* BufferStructDeclare.proto */
typedef struct {
  Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
  size_t refcount;
  Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
  __Pyx_Buffer *rcbuffer;
  char *data;
  __Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;

#if PY_MAJOR_VERSION < 3
    static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
    static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
    #define __Pyx_GetBuffer PyObject_GetBuffer
    #define __Pyx_ReleaseBuffer PyBuffer_Release
#endif


/* RealImag.proto */
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(__cplusplus) && CYTHON_CCOMPLEX\
        && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq_float(a, b)   ((a)==(b))
    #define __Pyx_c_sum_float(a, b)  ((a)+(b))
    #define __Pyx_c_diff_float(a, b) ((a)-(b))
    #define __Pyx_c_prod_float(a, b) ((a)*(b))
    #define __Pyx_c_quot_float(a, b) ((a)/(b))
    #define __Pyx_c_neg_float(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero_float(z) ((z)==(float)0)
    #define __Pyx_c_conj_float(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs_float(z)     (::std::abs(z))
        #define __Pyx_c_pow_float(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero_float(z) ((z)==0)
    #define __Pyx_c_conj_float(z)    (conjf(z))
    #if 1
        #define __Pyx_c_abs_float(z)     (cabsf(z))
        #define __Pyx_c_pow_float(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

/* Arithmetic.proto */
#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq_double(a, b)   ((a)==(b))
    #define __Pyx_c_sum_double(a, b)  ((a)+(b))
    #define __Pyx_c_diff_double(a, b) ((a)-(b))
    #define __Pyx_c_prod_double(a, b) ((a)*(b))
    #define __Pyx_c_quot_double(a, b) ((a)/(b))
    #define __Pyx_c_neg_double(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
    #define __Pyx_c_conj_double(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs_double(z)     (::std::abs(z))
        #define __Pyx_c_pow_double(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero_double(z) ((z)==0)
    #define __Pyx_c_conj_double(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs_double(z)     (cabs(z))
        #define __Pyx_c_pow_double(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_long(npy_long value);

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value);

/* CIntFromPy.proto */
static CYTHON_INLINE Py_intptr_t __Pyx_PyInt_As_Py_intptr_t(PyObject *);

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
#endif
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)

/* FetchCommonType.proto */
static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyObjectGetMethod.proto */
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

/* PyObjectCallMethod1.proto */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* CoroutineBase.proto */
typedef PyObject *(*__pyx_coroutine_body_t)(PyObject *, PyThreadState *, PyObject *);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_ExcInfoStruct  _PyErr_StackItem
#else
typedef struct {
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
} __Pyx_ExcInfoStruct;
#endif
typedef struct {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    __Pyx_ExcInfoStruct gi_exc_state;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    PyObject *gi_name;
    PyObject *gi_qualname;
    PyObject *gi_modulename;
    PyObject *gi_code;
    PyObject *gi_frame;
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
static int __Pyx_Coroutine_clear(PyObject *self);
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Coroutine_Close(PyObject *self);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_Coroutine_SwapException(self)
#define __Pyx_Coroutine_ResetAndClearException(self)  __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
#else
#define __Pyx_Coroutine_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
    (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
    }
#endif
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);

/* PatchModuleWithCoroutine.proto */
static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code);

/* PatchGeneratorABC.proto */
static int __Pyx_patch_abc(void);

/* Generator.proto */
#define __Pyx_Generator_USED
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(void);

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(void);

/* InitStrings.proto */
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);

static PyArrayObject *__pyx_f_4libs_7network_20ConvolutionalNetwork_argument_distances(CYTHON_UNUSED struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_positions, PyObject *__pyx_v_argument); /* proto*/

/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'cpython.version' */

/* Module declarations from 'cpython.exc' */

/* Module declarations from 'cpython.module' */

/* Module declarations from 'cpython.mem' */

/* Module declarations from 'cpython.tuple' */

/* Module declarations from 'cpython.list' */

/* Module declarations from 'cpython.sequence' */

/* Module declarations from 'cpython.mapping' */

/* Module declarations from 'cpython.iterator' */

/* Module declarations from 'cpython.number' */

/* Module declarations from 'cpython.int' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.bool' */
static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;

/* Module declarations from 'cpython.long' */

/* Module declarations from 'cpython.float' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.complex' */
static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;

/* Module declarations from 'cpython.string' */

/* Module declarations from 'cpython.unicode' */

/* Module declarations from 'cpython.dict' */

/* Module declarations from 'cpython.instance' */

/* Module declarations from 'cpython.function' */

/* Module declarations from 'cpython.method' */

/* Module declarations from 'cpython.weakref' */

/* Module declarations from 'cpython.getargs' */

/* Module declarations from 'cpython.pythread' */

/* Module declarations from 'cpython.pystate' */

/* Module declarations from 'cpython.cobject' */

/* Module declarations from 'cpython.oldbuffer' */

/* Module declarations from 'cpython.set' */

/* Module declarations from 'cpython.bytes' */

/* Module declarations from 'cpython.pycapsule' */

/* Module declarations from 'cpython' */

/* Module declarations from 'cpython.object' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'numpy' */

/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_generic = 0;
static PyTypeObject *__pyx_ptype_5numpy_number = 0;
static PyTypeObject *__pyx_ptype_5numpy_integer = 0;
static PyTypeObject *__pyx_ptype_5numpy_signedinteger = 0;
static PyTypeObject *__pyx_ptype_5numpy_unsignedinteger = 0;
static PyTypeObject *__pyx_ptype_5numpy_inexact = 0;
static PyTypeObject *__pyx_ptype_5numpy_floating = 0;
static PyTypeObject *__pyx_ptype_5numpy_complexfloating = 0;
static PyTypeObject *__pyx_ptype_5numpy_flexible = 0;
static PyTypeObject *__pyx_ptype_5numpy_character = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;

/* Module declarations from 'cython' */

/* Module declarations from 'libs.network' */
static PyTypeObject *__pyx_ptype_4libs_7network_Network = 0;
static PyTypeObject *__pyx_ptype_4libs_7network_ConvolutionalNetwork = 0;
static PyTypeObject *__pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct__create_new = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_1_genexpr = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_2_train = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_3_genexpr = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_4__validate = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_5_genexpr = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_6_create_new = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_7_genexpr = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_8_train = 0;
static PyTypeObject *__pyx_ptype_4libs_7network___pyx_scope_struct_9_genexpr = 0;
static PyObject *__pyx_f_4libs_7network_logsumexp(PyArrayObject *, struct __pyx_opt_args_4libs_7network_logsumexp *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4libs_7network_hardtanh(PyArrayObject *, struct __pyx_opt_args_4libs_7network_hardtanh *__pyx_optional_args); /*proto*/
static PyObject *__pyx_f_4libs_7network_hardtanhd(PyArrayObject *); /*proto*/
static PyObject *__pyx_f_4libs_7network___pyx_unpickle_Network__set_state(struct __pyx_obj_4libs_7network_Network *, PyObject *); /*proto*/
static PyObject *__pyx_f_4libs_7network___pyx_unpickle_ConvolutionalNetwork__set_state(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *, PyObject *); /*proto*/
static PyObject *__pyx_f_4libs_7network___pyx_unpickle_ConvolutionalDependencyNetwork__set_state(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *, PyObject *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t = { "FLOAT_t", NULL, sizeof(__pyx_t_4libs_7network_FLOAT_t), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_4libs_7network_DOUBLE_t = { "DOUBLE_t", NULL, sizeof(__pyx_t_4libs_7network_DOUBLE_t), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t = { "INT_t", NULL, sizeof(__pyx_t_4libs_7network_INT_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_4libs_7network_INT_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_4libs_7network_INT_t), 0 };
#define __Pyx_MODULE_NAME "libs.network"
extern int __pyx_module_is_main_libs__network;
int __pyx_module_is_main_libs__network = 0;

/* Implementation of 'libs.network' */
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_enumerate;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_xrange;
static PyObject *__pyx_builtin_zip;
static PyObject *__pyx_builtin_FloatingPointError;
static PyObject *__pyx_builtin_super;
static PyObject *__pyx_builtin_NotImplementedError;
static PyObject *__pyx_builtin_ImportError;
static const char __pyx_k_[] = ", ";
static const char __pyx_k_T[] = "T";
static const char __pyx_k_d[] = "d";
static const char __pyx_k_f[] = "f";
static const char __pyx_k__2[] = "\n";
static const char __pyx_k__7[] = "   ";
static const char __pyx_k_np[] = "np";
static const char __pyx_k__12[] = "    ";
static const char __pyx_k_add[] = "add";
static const char __pyx_k_dot[] = "dot";
static const char __pyx_k_exp[] = "exp";
static const char __pyx_k_log[] = "log";
static const char __pyx_k_max[] = "max";
static const char __pyx_k_new[] = "__new__";
static const char __pyx_k_sum[] = "sum";
static const char __pyx_k_zip[] = "zip";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_axis[] = "axis";
static const char __pyx_k_clip[] = "clip";
static const char __pyx_k_copy[] = "copy";
static const char __pyx_k_data[] = "data";
static const char __pyx_k_dict[] = "__dict__";
static const char __pyx_k_info[] = "info";
static const char __pyx_k_init[] = "__init__";
static const char __pyx_k_less[] = "less";
static const char __pyx_k_load[] = "load";
static const char __pyx_k_main[] = "__main__";
static const char __pyx_k_mode[] = "mode";
static const char __pyx_k_name[] = "__name__";
static const char __pyx_k_save[] = "save";
static const char __pyx_k_send[] = "send";
static const char __pyx_k_sqrt[] = "sqrt";
static const char __pyx_k_tags[] = "tags";
static const char __pyx_k_take[] = "take";
static const char __pyx_k_test[] = "__test__";
static const char __pyx_k_tile[] = "tile";
static const char __pyx_k_array[] = "array";
static const char __pyx_k_close[] = "close";
static const char __pyx_k_cycle[] = "cycle";
static const char __pyx_k_debug[] = "debug";
static const char __pyx_k_dtype[] = "dtype";
static const char __pyx_k_empty[] = "empty";
static const char __pyx_k_graph[] = "graph";
static const char __pyx_k_heads[] = "heads";
static const char __pyx_k_numpy[] = "numpy";
static const char __pyx_k_range[] = "range";
static const char __pyx_k_ravel[] = "ravel";
static const char __pyx_k_savez[] = "savez";
static const char __pyx_k_shape[] = "shape";
static const char __pyx_k_super[] = "super";
static const char __pyx_k_throw[] = "throw";
static const char __pyx_k_train[] = "train";
static const char __pyx_k_where[] = "where";
static const char __pyx_k_zeros[] = "zeros";
static const char __pyx_k_Logger[] = "Logger";
static const char __pyx_k_arange[] = "arange";
static const char __pyx_k_argmax[] = "argmax";
static const char __pyx_k_astype[] = "astype";
static const char __pyx_k_epochs[] = "epochs";
static const char __pyx_k_import[] = "__import__";
static const char __pyx_k_labels[] = "labels";
static const char __pyx_k_pickle[] = "pickle";
static const char __pyx_k_random[] = "random";
static const char __pyx_k_reduce[] = "__reduce__";
static const char __pyx_k_scores[] = "scores";
static const char __pyx_k_update[] = "update";
static const char __pyx_k_vertex[] = "vertex";
static const char __pyx_k_vstack[] = "vstack";
static const char __pyx_k_xrange[] = "xrange";
static const char __pyx_k_Network[] = "Network";
static const char __pyx_k_flatten[] = "flatten";
static const char __pyx_k_float64[] = "float64";
static const char __pyx_k_genexpr[] = "genexpr";
static const char __pyx_k_greater[] = "greater";
static const char __pyx_k_logging[] = "logging";
static const char __pyx_k_logprob[] = "logprob";
static const char __pyx_k_reshape[] = "reshape";
static const char __pyx_k_shuffle[] = "shuffle";
static const char __pyx_k_uniform[] = "uniform";
static const char __pyx_k_visited[] = "visited";
static const char __pyx_k_viterbi[] = "_viterbi";
static const char __pyx_k_Accuracy[] = "   Accuracy: ";
static const char __pyx_k_Infinity[] = "Infinity";
static const char __pyx_k_bincount[] = "bincount";
static const char __pyx_k_diagonal[] = "diagonal";
static const char __pyx_k_filename[] = "filename";
static const char __pyx_k_getstate[] = "__getstate__";
static const char __pyx_k_pyx_type[] = "__pyx_type";
static const char __pyx_k_rollaxis[] = "rollaxis";
static const char __pyx_k_sentence[] = "sentence";
static const char __pyx_k_setstate[] = "__setstate__";
static const char __pyx_k_training[] = "training";
static const char __pyx_k_validate[] = "_validate";
static const char __pyx_k_arguments[] = "arguments";
static const char __pyx_k_enumerate[] = "enumerate";
static const char __pyx_k_getLogger[] = "getLogger";
static const char __pyx_k_get_state[] = "get_state";
static const char __pyx_k_gold_head[] = "gold_head";
static const char __pyx_k_predicate[] = "predicate";
static const char __pyx_k_pyx_state[] = "__pyx_state";
static const char __pyx_k_reachable[] = "reachable";
static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
static const char __pyx_k_sentences[] = "sentences";
static const char __pyx_k_set_state[] = "set_state";
static const char __pyx_k_create_new[] = "create_new";
static const char __pyx_k_empty_like[] = "empty_like";
static const char __pyx_k_input_size[] = "input_size";
static const char __pyx_k_predicates[] = "predicates";
static const char __pyx_k_pyx_result[] = "__pyx_result";
static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static const char __pyx_k_zeros_like[] = "zeros_like";
static const char __pyx_k_ImportError[] = "ImportError";
static const char __pyx_k_Output_size[] = "\nOutput size: ";
static const char __pyx_k_PickleError[] = "PickleError";
static const char __pyx_k_Saved_model[] = "Saved model";
static const char __pyx_k_concatenate[] = "concatenate";
static const char __pyx_k_find_cycles[] = "_find_cycles";
static const char __pyx_k_hidden_bias[] = "hidden_bias";
static const char __pyx_k_hidden_size[] = "hidden_size";
static const char __pyx_k_logical_and[] = "logical_and";
static const char __pyx_k_logical_not[] = "logical_not";
static const char __pyx_k_output_bias[] = "output_bias";
static const char __pyx_k_output_size[] = "output_size";
static const char __pyx_k_pos_padding[] = "pos_padding";
static const char __pyx_k_pre_padding[] = "pre_padding";
static const char __pyx_k_train_epoch[] = "_train_epoch";
static const char __pyx_k_transitions[] = "transitions";
static const char __pyx_k_unreachable[] = "unreachable";
static const char __pyx_k_word_window[] = "word_window";
static const char __pyx_k_allow_pickle[] = "allow_pickle";
static const char __pyx_k_decay_factor[] = "decay_factor";
static const char __pyx_k_epochs_Error[] = " epochs   Error: ";
static const char __pyx_k_hidden1_bias[] = "hidden1_bias";
static const char __pyx_k_hidden1_size[] = "hidden1_size";
static const char __pyx_k_hidden2_bias[] = "hidden2_bias";
static const char __pyx_k_hidden2_size[] = "hidden2_size";
static const char __pyx_k_libs_network[] = "libs.network";
static const char __pyx_k_padding_left[] = "padding_left";
static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
static const char __pyx_k_shuffle_data[] = "_shuffle_data";
static const char __pyx_k_stringsource[] = "stringsource";
static const char __pyx_k_tag_sentence[] = "_tag_sentence";
static const char __pyx_k_allow_repeats[] = "allow_repeats";
static const char __pyx_k_backpropagate[] = "_backpropagate";
static const char __pyx_k_count_nonzero[] = "count_nonzero";
static const char __pyx_k_fill_diagonal[] = "fill_diagonal";
static const char __pyx_k_padding_right[] = "padding_right";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_Token_accuracy[] = "   Token accuracy: ";
static const char __pyx_k_adjust_weights[] = "_adjust_weights";
static const char __pyx_k_contract_cycle[] = "_contract_cycle";
static const char __pyx_k_feature_tables[] = "feature_tables";
static const char __pyx_k_hidden_weights[] = "hidden_weights";
static const char __pyx_k_load_from_file[] = "_load_from_file";
static const char __pyx_k_output_weights[] = "output_weights";
static const char __pyx_k_reset_counters[] = "_reset_counters";
static const char __pyx_k_tag_sentence_2[] = "tag_sentence";
static const char __pyx_k_adjust_features[] = "_adjust_features";
static const char __pyx_k_argument_blocks[] = "argument_blocks";
static const char __pyx_k_calculate_delta[] = "_calculate_delta";
static const char __pyx_k_hidden1_weights[] = "hidden1_weights";
static const char __pyx_k_hidden2_weights[] = "hidden2_weights";
static const char __pyx_k_load_parameters[] = "_load_parameters";
static const char __pyx_k_pred_dist_table[] = "pred_dist_table";
static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
static const char __pyx_k_validation_tags[] = "validation_tags";
static const char __pyx_k_Input_layer_size[] = "\nInput layer size: ";
static const char __pyx_k_Word_window_size[] = "\nWord window size: ";
static const char __pyx_k_desired_accuracy[] = "desired_accuracy";
static const char __pyx_k_load_from_file_2[] = "load_from_file";
static const char __pyx_k_network_filename[] = "network_filename";
static const char __pyx_k_word_window_size[] = "word_window_size";
static const char __pyx_k_Hidden_layer_size[] = "\nHidden layer size: ";
static const char __pyx_k_Sentence_accuracy[] = "   Sentence accuracy: ";
static const char __pyx_k_pre_tagging_setup[] = "_pre_tagging_setup";
static const char __pyx_k_pred_dist_weights[] = "pred_dist_weights";
static const char __pyx_k_target_dist_table[] = "target_dist_table";
static const char __pyx_k_FloatingPointError[] = "FloatingPointError";
static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
static const char __pyx_k_create_pred_lookup[] = "_create_pred_lookup";
static const char __pyx_k_generate_save_dict[] = "_generate_save_dict";
static const char __pyx_k_print_epoch_report[] = "_print_epoch_report";
static const char __pyx_k_Feature_table_sizes[] = "\nFeature table sizes: ";
static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
static const char __pyx_k_calculate_gradients[] = "_calculate_gradients";
static const char __pyx_k_set_validation_data[] = "set_validation_data";
static const char __pyx_k_target_dist_weights[] = "target_dist_weights";
static const char __pyx_k_ConvolutionalNetwork[] = "ConvolutionalNetwork";
static const char __pyx_k_calculate_all_scores[] = "_calculate_all_scores";
static const char __pyx_k_create_target_lookup[] = "_create_target_lookup";
static const char __pyx_k_find_cycle_recursive[] = "_find_cycle_recursive";
static const char __pyx_k_pyx_unpickle_Network[] = "__pyx_unpickle_Network";
static const char __pyx_k_sentence_convolution[] = "_sentence_convolution";
static const char __pyx_k_train_locals_genexpr[] = "train.<locals>.genexpr";
static const char __pyx_k_validation_arguments[] = "validation_arguments";
static const char __pyx_k_validation_sentences[] = "validation_sentences";
static const char __pyx_k_validation_predicates[] = "validation_predicates";
static const char __pyx_k_Convolution_layer_size[] = "\nConvolution layer size: ";
static const char __pyx_k_calculate_input_deltas[] = "_calculate_input_deltas";
static const char __pyx_k_create_sentence_lookup[] = "_create_sentence_lookup";
static const char __pyx_k_epochs_between_reports[] = "epochs_between_reports";
static const char __pyx_k_calculate_gradients_sll[] = "_calculate_gradients_sll";
static const char __pyx_k_decrease_learning_rates[] = "decrease_learning_rates";
static const char __pyx_k_validate_locals_genexpr[] = "_validate.<locals>.genexpr";
static const char __pyx_k_Second_hidden_layer_size[] = " \nSecond hidden layer size: ";
static const char __pyx_k_create_convolution_lookup[] = "_create_convolution_lookup";
static const char __pyx_k_create_new_locals_genexpr[] = "create_new.<locals>.genexpr";
static const char __pyx_k_find_maximum_spanning_tree[] = "_find_maximum_spanning_tree";
static const char __pyx_k_Training_for_up_to_d_epochs[] = "Training for up to %d epochs";
static const char __pyx_k_calculate_gradients_classify[] = "_calculate_gradients_classify";
static const char __pyx_k_ConvolutionalDependencyNetwork[] = "ConvolutionalDependencyNetwork";
static const char __pyx_k_pyx_unpickle_ConvolutionalDepe[] = "__pyx_unpickle_ConvolutionalDependencyNetwork";
static const char __pyx_k_pyx_unpickle_ConvolutionalNetw[] = "__pyx_unpickle_ConvolutionalNetwork";
static const char __pyx_k_A_neural_network_for_NLP_taggin[] = "\nA neural network for NLP tagging tasks.\nIt employs feature tables to store feature vectors for each token.\n";
static const char __pyx_k_Distance_table_sizes_target_and[] = "\nDistance table sizes (target and predicate): ";
static const char __pyx_k_corrections_skipped_Learning_ra[] = " corrections skipped   Learning rate: ";
static const char __pyx_k_corrections_skipped_learning_ra[] = " corrections skipped   learning rate: ";
static const char __pyx_k_numpy_core_multiarray_failed_to[] = "numpy.core.multiarray failed to import";
static const char __pyx_k_tag_sentence_labeled_dependency[] = "_tag_sentence_labeled_dependency";
static const char __pyx_k_tag_sentence_unlabeled_dependen[] = "_tag_sentence_unlabeled_dependency";
static const char __pyx_k_Confidence_measure_not_implement[] = "Confidence measure not implemented for argument classifying";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0[] = "Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))";
static const char __pyx_k_numpy_core_umath_failed_to_impor[] = "numpy.core.umath failed to import";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_2[] = "Incompatible checksums (0x%x vs (0x8e85e02, 0x2f64fba, 0x8d42e09) = (accuracy, answer_score, convolution_lookup, decay_factor, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_predicates, validation_sentences, validation_tags, word_window_size))";
static const char __pyx_k_Incompatible_checksums_0x_x_vs_0_3[] = "Incompatible checksums (0x%x vs (0x1a87293, 0xca52c1e, 0x8b21fc2) = (accuracy, answer_score, convolution_lookup, decay_factor, dependency_weights, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_heads, validation_predicates, validation_sentences, validation_tags, word_window_size))";
static PyObject *__pyx_kp_u_;
static PyObject *__pyx_kp_u_Accuracy;
static PyObject *__pyx_kp_u_Confidence_measure_not_implement;
static PyObject *__pyx_kp_u_Convolution_layer_size;
static PyObject *__pyx_n_s_ConvolutionalDependencyNetwork;
static PyObject *__pyx_n_s_ConvolutionalNetwork;
static PyObject *__pyx_kp_u_Distance_table_sizes_target_and;
static PyObject *__pyx_kp_u_Feature_table_sizes;
static PyObject *__pyx_n_s_FloatingPointError;
static PyObject *__pyx_kp_u_Hidden_layer_size;
static PyObject *__pyx_n_s_ImportError;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2;
static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3;
static PyObject *__pyx_n_s_Infinity;
static PyObject *__pyx_kp_u_Input_layer_size;
static PyObject *__pyx_n_u_Logger;
static PyObject *__pyx_n_s_Network;
static PyObject *__pyx_n_s_NotImplementedError;
static PyObject *__pyx_kp_u_Output_size;
static PyObject *__pyx_n_s_PickleError;
static PyObject *__pyx_kp_u_Saved_model;
static PyObject *__pyx_kp_u_Second_hidden_layer_size;
static PyObject *__pyx_kp_u_Sentence_accuracy;
static PyObject *__pyx_n_s_T;
static PyObject *__pyx_kp_u_Token_accuracy;
static PyObject *__pyx_kp_u_Training_for_up_to_d_epochs;
static PyObject *__pyx_kp_u_Word_window_size;
static PyObject *__pyx_kp_u__12;
static PyObject *__pyx_kp_u__2;
static PyObject *__pyx_kp_u__7;
static PyObject *__pyx_n_s_add;
static PyObject *__pyx_n_s_adjust_features;
static PyObject *__pyx_n_s_adjust_weights;
static PyObject *__pyx_n_s_allow_pickle;
static PyObject *__pyx_n_s_allow_repeats;
static PyObject *__pyx_n_s_arange;
static PyObject *__pyx_n_s_argmax;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_argument_blocks;
static PyObject *__pyx_n_s_arguments;
static PyObject *__pyx_n_s_array;
static PyObject *__pyx_n_s_astype;
static PyObject *__pyx_n_s_axis;
static PyObject *__pyx_n_s_backpropagate;
static PyObject *__pyx_n_s_bincount;
static PyObject *__pyx_n_s_calculate_all_scores;
static PyObject *__pyx_n_s_calculate_delta;
static PyObject *__pyx_n_s_calculate_gradients;
static PyObject *__pyx_n_s_calculate_gradients_classify;
static PyObject *__pyx_n_s_calculate_gradients_sll;
static PyObject *__pyx_n_s_calculate_input_deltas;
static PyObject *__pyx_n_s_cline_in_traceback;
static PyObject *__pyx_n_s_clip;
static PyObject *__pyx_n_u_clip;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_concatenate;
static PyObject *__pyx_n_s_contract_cycle;
static PyObject *__pyx_n_s_copy;
static PyObject *__pyx_kp_u_corrections_skipped_Learning_ra;
static PyObject *__pyx_kp_u_corrections_skipped_learning_ra;
static PyObject *__pyx_n_s_count_nonzero;
static PyObject *__pyx_n_s_create_convolution_lookup;
static PyObject *__pyx_n_s_create_new;
static PyObject *__pyx_n_s_create_new_locals_genexpr;
static PyObject *__pyx_n_s_create_pred_lookup;
static PyObject *__pyx_n_s_create_sentence_lookup;
static PyObject *__pyx_n_s_create_target_lookup;
static PyObject *__pyx_n_s_cycle;
static PyObject *__pyx_n_u_d;
static PyObject *__pyx_n_s_data;
static PyObject *__pyx_n_s_debug;
static PyObject *__pyx_n_s_decay_factor;
static PyObject *__pyx_n_s_decrease_learning_rates;
static PyObject *__pyx_n_s_desired_accuracy;
static PyObject *__pyx_n_s_diagonal;
static PyObject *__pyx_n_s_dict;
static PyObject *__pyx_n_s_dot;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_empty;
static PyObject *__pyx_n_s_empty_like;
static PyObject *__pyx_n_s_enumerate;
static PyObject *__pyx_n_s_epochs;
static PyObject *__pyx_kp_u_epochs_Error;
static PyObject *__pyx_n_s_epochs_between_reports;
static PyObject *__pyx_n_s_exp;
static PyObject *__pyx_n_u_f;
static PyObject *__pyx_n_s_feature_tables;
static PyObject *__pyx_n_u_feature_tables;
static PyObject *__pyx_n_s_filename;
static PyObject *__pyx_n_s_fill_diagonal;
static PyObject *__pyx_n_s_find_cycle_recursive;
static PyObject *__pyx_n_s_find_cycles;
static PyObject *__pyx_n_s_find_maximum_spanning_tree;
static PyObject *__pyx_n_s_flatten;
static PyObject *__pyx_n_s_float64;
static PyObject *__pyx_n_s_generate_save_dict;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_getLogger;
static PyObject *__pyx_n_s_get_state;
static PyObject *__pyx_n_s_getstate;
static PyObject *__pyx_n_s_gold_head;
static PyObject *__pyx_n_s_graph;
static PyObject *__pyx_n_s_greater;
static PyObject *__pyx_n_s_heads;
static PyObject *__pyx_n_s_hidden1_bias;
static PyObject *__pyx_n_s_hidden1_size;
static PyObject *__pyx_n_s_hidden1_weights;
static PyObject *__pyx_n_s_hidden2_bias;
static PyObject *__pyx_n_u_hidden2_bias;
static PyObject *__pyx_n_s_hidden2_size;
static PyObject *__pyx_n_u_hidden2_size;
static PyObject *__pyx_n_s_hidden2_weights;
static PyObject *__pyx_n_u_hidden2_weights;
static PyObject *__pyx_n_s_hidden_bias;
static PyObject *__pyx_n_u_hidden_bias;
static PyObject *__pyx_n_s_hidden_size;
static PyObject *__pyx_n_u_hidden_size;
static PyObject *__pyx_n_s_hidden_weights;
static PyObject *__pyx_n_u_hidden_weights;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_info;
static PyObject *__pyx_n_s_init;
static PyObject *__pyx_n_s_input_size;
static PyObject *__pyx_n_u_input_size;
static PyObject *__pyx_n_s_labels;
static PyObject *__pyx_n_s_less;
static PyObject *__pyx_n_s_libs_network;
static PyObject *__pyx_n_s_load;
static PyObject *__pyx_n_s_load_from_file;
static PyObject *__pyx_n_s_load_from_file_2;
static PyObject *__pyx_n_s_load_parameters;
static PyObject *__pyx_n_s_log;
static PyObject *__pyx_n_s_logging;
static PyObject *__pyx_n_s_logical_and;
static PyObject *__pyx_n_s_logical_not;
static PyObject *__pyx_n_s_logprob;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_max;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_name;
static PyObject *__pyx_n_s_network_filename;
static PyObject *__pyx_n_s_new;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_kp_u_numpy_core_multiarray_failed_to;
static PyObject *__pyx_kp_u_numpy_core_umath_failed_to_impor;
static PyObject *__pyx_n_s_output_bias;
static PyObject *__pyx_n_u_output_bias;
static PyObject *__pyx_n_s_output_size;
static PyObject *__pyx_n_u_output_size;
static PyObject *__pyx_n_s_output_weights;
static PyObject *__pyx_n_u_output_weights;
static PyObject *__pyx_n_s_padding_left;
static PyObject *__pyx_n_u_padding_left;
static PyObject *__pyx_n_s_padding_right;
static PyObject *__pyx_n_u_padding_right;
static PyObject *__pyx_n_s_pickle;
static PyObject *__pyx_n_s_pos_padding;
static PyObject *__pyx_n_s_pre_padding;
static PyObject *__pyx_n_s_pre_tagging_setup;
static PyObject *__pyx_n_s_pred_dist_table;
static PyObject *__pyx_n_u_pred_dist_table;
static PyObject *__pyx_n_s_pred_dist_weights;
static PyObject *__pyx_n_u_pred_dist_weights;
static PyObject *__pyx_n_s_predicate;
static PyObject *__pyx_n_s_predicates;
static PyObject *__pyx_n_s_print_epoch_report;
static PyObject *__pyx_n_s_pyx_PickleError;
static PyObject *__pyx_n_s_pyx_checksum;
static PyObject *__pyx_n_s_pyx_result;
static PyObject *__pyx_n_s_pyx_state;
static PyObject *__pyx_n_s_pyx_type;
static PyObject *__pyx_n_s_pyx_unpickle_ConvolutionalDepe;
static PyObject *__pyx_n_s_pyx_unpickle_ConvolutionalNetw;
static PyObject *__pyx_n_s_pyx_unpickle_Network;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_random;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_ravel;
static PyObject *__pyx_n_s_reachable;
static PyObject *__pyx_n_s_reduce;
static PyObject *__pyx_n_s_reduce_cython;
static PyObject *__pyx_n_s_reduce_ex;
static PyObject *__pyx_n_s_reset_counters;
static PyObject *__pyx_n_s_reshape;
static PyObject *__pyx_n_s_rollaxis;
static PyObject *__pyx_n_s_save;
static PyObject *__pyx_n_s_savez;
static PyObject *__pyx_n_s_scores;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_sentence;
static PyObject *__pyx_n_s_sentence_convolution;
static PyObject *__pyx_n_s_sentences;
static PyObject *__pyx_n_s_set_state;
static PyObject *__pyx_n_s_set_validation_data;
static PyObject *__pyx_n_s_setstate;
static PyObject *__pyx_n_s_setstate_cython;
static PyObject *__pyx_n_s_shape;
static PyObject *__pyx_n_s_shuffle;
static PyObject *__pyx_n_s_shuffle_data;
static PyObject *__pyx_n_s_sqrt;
static PyObject *__pyx_kp_s_stringsource;
static PyObject *__pyx_n_s_sum;
static PyObject *__pyx_n_s_super;
static PyObject *__pyx_n_s_tag_sentence;
static PyObject *__pyx_n_s_tag_sentence_2;
static PyObject *__pyx_n_s_tag_sentence_labeled_dependency;
static PyObject *__pyx_n_s_tag_sentence_unlabeled_dependen;
static PyObject *__pyx_n_s_tags;
static PyObject *__pyx_n_s_take;
static PyObject *__pyx_n_s_target_dist_table;
static PyObject *__pyx_n_u_target_dist_table;
static PyObject *__pyx_n_s_target_dist_weights;
static PyObject *__pyx_n_u_target_dist_weights;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_tile;
static PyObject *__pyx_n_s_train;
static PyObject *__pyx_n_s_train_epoch;
static PyObject *__pyx_n_s_train_locals_genexpr;
static PyObject *__pyx_n_s_training;
static PyObject *__pyx_n_s_transitions;
static PyObject *__pyx_n_u_transitions;
static PyObject *__pyx_n_s_uniform;
static PyObject *__pyx_n_s_unreachable;
static PyObject *__pyx_n_s_update;
static PyObject *__pyx_n_s_validate;
static PyObject *__pyx_n_s_validate_locals_genexpr;
static PyObject *__pyx_n_s_validation_arguments;
static PyObject *__pyx_n_s_validation_predicates;
static PyObject *__pyx_n_s_validation_sentences;
static PyObject *__pyx_n_s_validation_tags;
static PyObject *__pyx_n_s_vertex;
static PyObject *__pyx_n_s_visited;
static PyObject *__pyx_n_s_viterbi;
static PyObject *__pyx_n_s_vstack;
static PyObject *__pyx_n_s_where;
static PyObject *__pyx_n_s_word_window;
static PyObject *__pyx_n_s_word_window_size;
static PyObject *__pyx_n_u_word_window_size;
static PyObject *__pyx_n_s_xrange;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_n_s_zeros_like;
static PyObject *__pyx_n_s_zip;
static PyObject *__pyx_pf_4libs_7network_7Network_10create_new_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_create_new(CYTHON_UNUSED PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_feature_tables, int __pyx_v_word_window, int __pyx_v_hidden_size, int __pyx_v_output_size); /* proto */
static int __pyx_pf_4libs_7network_7Network_2__init__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_word_window, PyObject *__pyx_v_input_size, PyObject *__pyx_v_hidden_size, PyObject *__pyx_v_output_size, PyObject *__pyx_v_hidden_weights, PyObject *__pyx_v_hidden_bias, PyObject *__pyx_v_output_weights, PyObject *__pyx_v_output_bias, PyObject *__pyx_v_transitions); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_4description(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_6_create_sentence_lookup(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_sentence); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_12padding_left___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_12padding_left_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_padding_left); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_13padding_right___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_13padding_right_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_padding_right); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_8tag_sentence(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_sentence); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_10_tag_sentence(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyObject *__pyx_v_tags); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_12_calculate_delta(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_scores); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_14_calculate_gradients_sll(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_tags, PyObject *__pyx_v_scores); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_16_calculate_gradients_wll(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_tags, PyObject *__pyx_v_scores); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_18_viterbi(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_scores); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_20set_validation_data(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_validation_sentences, PyObject *__pyx_v_validation_tags); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_22set_learning_rate_decay(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, float __pyx_v_decay_factor); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_24decrease_learning_rates(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_epoch); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_5train_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_26train(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_tags, int __pyx_v_epochs, int __pyx_v_epochs_between_reports, float __pyx_v_desired_accuracy); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_28_print_epoch_report(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, int __pyx_v_num); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_30_train_epoch(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_tags); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_9_validate_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_32_validate(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_34_backpropagate(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_sentence); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_36_load_parameters(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_38save(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_40load_from_file(CYTHON_UNUSED PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_filename); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_16word_window_size___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_10input_size___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_11hidden_size___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_11output_size___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_13learning_rate___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_13learning_rate_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_22learning_rate_features___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_22learning_rate_features_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_12decay_factor___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_12decay_factor_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_23use_learning_rate_decay___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_23use_learning_rate_decay_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_7Network_23use_learning_rate_decay_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_18features_per_token___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_11pre_padding___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_11pre_padding_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_7Network_11pre_padding_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_11pos_padding___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_11pos_padding_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_7Network_11pos_padding_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_14hidden_weights___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_14output_weights___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_11hidden_bias___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_11output_bias___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_12input_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_13hidden_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_13layer2_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_14feature_tables___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_14feature_tables_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_7Network_14feature_tables_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_19learning_rate_trans___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_19learning_rate_trans_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_11transitions___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_11transitions_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_7Network_11transitions_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_12answer_score___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_13net_gradients___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_15trans_gradients___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_17input_sent_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_18hidden_sent_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_18layer2_sent_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_16network_filename___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_16network_filename_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_7Network_16network_filename_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_21network_text_filename___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_7Network_21network_text_filename_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_7Network_21network_text_filename_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_42__reduce_cython__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_7Network_44__setstate_cython__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_10create_new_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_create_new(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_feature_tables, PyObject *__pyx_v_target_dist_table, PyObject *__pyx_v_pred_dist_table, int __pyx_v_word_window, int __pyx_v_hidden1_size, int __pyx_v_hidden2_size, int __pyx_v_output_size); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_2description(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_4__init__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_word_window, PyObject *__pyx_v_input_size, PyObject *__pyx_v_hidden1_size, PyObject *__pyx_v_hidden2_size, PyObject *__pyx_v_output_size, PyObject *__pyx_v_hidden1_weights, PyObject *__pyx_v_hidden1_bias, PyObject *__pyx_v_target_dist_weights, PyObject *__pyx_v_pred_dist_weights, PyObject *__pyx_v_hidden2_weights, PyObject *__pyx_v_hidden2_bias, PyObject *__pyx_v_output_weights, PyObject *__pyx_v_output_bias); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_6_generate_save_dict(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_8save(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_10_load_from_file(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_data, PyObject *__pyx_v_filename); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_12load_from_file(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_filename); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_14_load_parameters(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_16set_validation_data(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_validation_sentences, PyObject *__pyx_v_validation_predicates, PyObject *__pyx_v_validation_tags, PyObject *__pyx_v_validation_arguments); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_5train_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_18train(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_predicates, PyObject *__pyx_v_tags, int __pyx_v_epochs, int __pyx_v_epochs_between_reports, float __pyx_v_desired_accuracy, PyObject *__pyx_v_arguments); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_20_reset_counters(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_22_shuffle_data(CYTHON_UNUSED struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_predicates, PyObject *__pyx_v_tags, PyObject *__pyx_v_arguments); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_24_train_epoch(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_predicates, PyObject *__pyx_v_tags, PyObject *__pyx_v_arguments); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_26tag_sentence(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_predicates, PyObject *__pyx_v_arguments, PyBoolObject *__pyx_v_logprob, PyBoolObject *__pyx_v_allow_repeats); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_28_sentence_convolution(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentence, PyObject *__pyx_v_predicate, PyObject *__pyx_v_argument_blocks, PyObject *__pyx_v_training); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_30_pre_tagging_setup(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyBoolObject *__pyx_v_training); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_32_tag_sentence(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_predicates, PyObject *__pyx_v_tags, PyObject *__pyx_v_argument_blocks, PyBoolObject *__pyx_v_allow_repeats, PyBoolObject *__pyx_v_logprob); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_34_validate(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_36_calculate_gradients(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_tags, PyObject *__pyx_v_scores); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_38_calculate_gradients_classify(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_tags, PyObject *__pyx_v_scores); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_40_backpropagate(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_42_adjust_weights(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_predicate, PyObject *__pyx_v_arguments); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_44_calculate_input_deltas(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, int __pyx_v_predicate, PyObject *__pyx_v_arguments); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_46_adjust_features(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentence, CYTHON_UNUSED PyObject *__pyx_v_predicate); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_48_viterbi(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_scores, PyBoolObject *__pyx_v_allow_repeats); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_50_create_target_lookup(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_52_create_pred_lookup(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_54_create_convolution_lookup(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentence, PyObject *__pyx_v_training); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table_2__set__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table_4__del__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_2__set__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_4__del__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_19target_dist_weights___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_17pred_dist_weights___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_offset___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_offset___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_lookup___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_lookup___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_25target_convolution_lookup___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_23pred_convolution_lookup___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_deltas___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_deltas___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_12hidden2_size___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_15hidden2_weights___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_12hidden2_bias___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_14hidden2_values___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_25hidden2_before_activation___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_24hidden_before_activation___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_11max_indices___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_56__reduce_cython__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_58__setstate_cython__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_save(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_2load_from_file(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_filename); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_4train(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_heads, int __pyx_v_epochs, int __pyx_v_epochs_between_reports, float __pyx_v_desired_accuracy, PyObject *__pyx_v_labels); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_6set_validation_data(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_heads, PyObject *__pyx_v_labels); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_8_tag_sentence(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_sentence, CYTHON_UNUSED PyObject *__pyx_v_predicates, PyObject *__pyx_v_heads, PyObject *__pyx_v_labels); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_10_tag_sentence_unlabeled_dependency(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_heads); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_12_tag_sentence_labeled_dependency(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_heads, PyArrayObject *__pyx_v_labels); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_14_calculate_gradients(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_gold_head, PyObject *__pyx_v_scores); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_16_validate(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_18_average_error(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_20_print_epoch_report(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, int __pyx_v_num); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_22tag_sentence(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_heads); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_24_find_cycles(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_graph); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_26_find_cycle_recursive(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_graph, int __pyx_v_vertex, PyObject *__pyx_v_visited, PyObject *__pyx_v_reachable, PyObject *__pyx_v_unreachable); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_28_contract_cycle(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_heads, PyObject *__pyx_v_cycle); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_30_find_maximum_spanning_tree(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_18dependency_weights___get__(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_32__reduce_cython__(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_34__setstate_cython__(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4libs_7network___pyx_unpickle_Network(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4libs_7network_2__pyx_unpickle_ConvolutionalNetwork(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_pf_4libs_7network_4__pyx_unpickle_ConvolutionalDependencyNetwork(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
static PyObject *__pyx_tp_new_4libs_7network_Network(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network_ConvolutionalNetwork(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network_ConvolutionalDependencyNetwork(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct__create_new(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_2_train(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_3_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_4__validate(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_5_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_6_create_new(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_7_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_8_train(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_9_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static __Pyx_CachedCFunction __pyx_umethod_PySet_Type_update = {0, &__pyx_n_s_update, 0, 0, 0};
static PyObject *__pyx_float_1_0;
static PyObject *__pyx_float_0_01;
static PyObject *__pyx_float_2_38;
static PyObject *__pyx_float_neg_1_0;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_27816595;
static PyObject *__pyx_int_49696698;
static PyObject *__pyx_int_119830996;
static PyObject *__pyx_int_145891266;
static PyObject *__pyx_int_148123145;
static PyObject *__pyx_int_149446146;
static PyObject *__pyx_int_202246394;
static PyObject *__pyx_int_212151326;
static PyObject *__pyx_int_220499725;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_neg_2;
static PyObject *__pyx_int_neg_1000;
static PyObject *__pyx_slice__3;
static PyObject *__pyx_slice__4;
static PyObject *__pyx_slice__5;
static PyObject *__pyx_slice__9;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_slice__11;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_codeobj__13;
static PyObject *__pyx_codeobj__15;
static PyObject *__pyx_codeobj__17;
/* Late includes */

/* "libs/network.pyx":28
 * # Math functions
 * 
 * cdef logsumexp(np.ndarray a, axis=None):             # <<<<<<<<<<<<<<
 *     """Compute the log of the sum of exponentials of input elements.
 *     like: scipy.misc.logsumexp
 */

static PyObject *__pyx_f_4libs_7network_logsumexp(PyArrayObject *__pyx_v_a, struct __pyx_opt_args_4libs_7network_logsumexp *__pyx_optional_args) {
  PyObject *__pyx_v_axis = ((PyObject *)Py_None);
  PyObject *__pyx_v_a_max = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("logsumexp", 0);
  __Pyx_TraceCall("logsumexp", __pyx_f[0], 28, 0, __PYX_ERR(0, 28, __pyx_L1_error));
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_axis = __pyx_optional_args->axis;
    }
  }
  __Pyx_INCREF((PyObject *)__pyx_v_a);

  /* "libs/network.pyx":46
 *         more stable way.
 *     """
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *     else:
 */
  __pyx_t_1 = (__pyx_v_axis == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "libs/network.pyx":47
 *     """
 *     if axis is None:
 *         a = a.ravel()             # <<<<<<<<<<<<<<
 *     else:
 *         a = np.rollaxis(a, axis)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_ravel); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 47, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "libs/network.pyx":46
 *         more stable way.
 *     """
 *     if axis is None:             # <<<<<<<<<<<<<<
 *         a = a.ravel()
 *     else:
 */
    goto __pyx_L3;
  }

  /* "libs/network.pyx":49
 *         a = a.ravel()
 *     else:
 *         a = np.rollaxis(a, axis)             # <<<<<<<<<<<<<<
 *     a_max = a.max(axis=0)
 *     return np.log(np.sum(np.exp(a - a_max), axis=0)) + a_max
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_rollaxis); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 49, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_a), __pyx_v_axis};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_a), __pyx_v_axis};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_a));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_a));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_a));
      __Pyx_INCREF(__pyx_v_axis);
      __Pyx_GIVEREF(__pyx_v_axis);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_axis);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 49, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_a, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "libs/network.pyx":50
 *     else:
 *         a = np.rollaxis(a, axis)
 *     a_max = a.max(axis=0)             # <<<<<<<<<<<<<<
 *     return np.log(np.sum(np.exp(a - a_max), axis=0)) + a_max
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_a), __pyx_n_s_max); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_a_max = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "libs/network.pyx":51
 *         a = np.rollaxis(a, axis)
 *     a_max = a.max(axis=0)
 *     return np.log(np.sum(np.exp(a - a_max), axis=0)) + a_max             # <<<<<<<<<<<<<<
 * 
 * cdef hardtanh(np.ndarray weights, inplace=False):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_log); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_exp); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Subtract(((PyObject *)__pyx_v_a), __pyx_v_a_max); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  __pyx_t_5 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 51, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_7 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_7, __pyx_v_a_max); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "libs/network.pyx":28
 * # Math functions
 * 
 * cdef logsumexp(np.ndarray a, axis=None):             # <<<<<<<<<<<<<<
 *     """Compute the log of the sum of exponentials of input elements.
 *     like: scipy.misc.logsumexp
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libs.network.logsumexp", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a_max);
  __Pyx_XDECREF((PyObject *)__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":53
 *     return np.log(np.sum(np.exp(a - a_max), axis=0)) + a_max
 * 
 * cdef hardtanh(np.ndarray weights, inplace=False):             # <<<<<<<<<<<<<<
 *     """
 *     Hard hyperbolic tangent.
 */

static PyObject *__pyx_f_4libs_7network_hardtanh(PyArrayObject *__pyx_v_weights, struct __pyx_opt_args_4libs_7network_hardtanh *__pyx_optional_args) {
  PyObject *__pyx_v_inplace = ((PyObject *)Py_False);
  PyObject *__pyx_v_out = NULL;
  PyObject *__pyx_v_inds_greater = NULL;
  PyObject *__pyx_v_inds_lesser = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("hardtanh", 0);
  __Pyx_TraceCall("hardtanh", __pyx_f[0], 53, 0, __PYX_ERR(0, 53, __pyx_L1_error));
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_inplace = __pyx_optional_args->inplace;
    }
  }

  /* "libs/network.pyx":58
 *     If inplace is True, modifies the input weights, which will be faster.
 *     """
 *     if inplace:             # <<<<<<<<<<<<<<
 *         out = weights
 *     else:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_inplace); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 58, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "libs/network.pyx":59
 *     """
 *     if inplace:
 *         out = weights             # <<<<<<<<<<<<<<
 *     else:
 *         out = np.copy(weights)
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_weights));
    __pyx_v_out = ((PyObject *)__pyx_v_weights);

    /* "libs/network.pyx":58
 *     If inplace is True, modifies the input weights, which will be faster.
 *     """
 *     if inplace:             # <<<<<<<<<<<<<<
 *         out = weights
 *     else:
 */
    goto __pyx_L3;
  }

  /* "libs/network.pyx":61
 *         out = weights
 *     else:
 *         out = np.copy(weights)             # <<<<<<<<<<<<<<
 *     inds_greater = weights > 1
 *     inds_lesser = weights < -1
 */
  /*else*/ {
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, ((PyObject *)__pyx_v_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_weights));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_out = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "libs/network.pyx":62
 *     else:
 *         out = np.copy(weights)
 *     inds_greater = weights > 1             # <<<<<<<<<<<<<<
 *     inds_lesser = weights < -1
 *     out[inds_greater] = 1
 */
  __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_weights), __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
  __pyx_v_inds_greater = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libs/network.pyx":63
 *         out = np.copy(weights)
 *     inds_greater = weights > 1
 *     inds_lesser = weights < -1             # <<<<<<<<<<<<<<
 *     out[inds_greater] = 1
 *     out[inds_lesser] = -1
 */
  __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_weights), __pyx_int_neg_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
  __pyx_v_inds_lesser = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libs/network.pyx":64
 *     inds_greater = weights > 1
 *     inds_lesser = weights < -1
 *     out[inds_greater] = 1             # <<<<<<<<<<<<<<
 *     out[inds_lesser] = -1
 * 
 */
  if (unlikely(PyObject_SetItem(__pyx_v_out, __pyx_v_inds_greater, __pyx_int_1) < 0)) __PYX_ERR(0, 64, __pyx_L1_error)

  /* "libs/network.pyx":65
 *     inds_lesser = weights < -1
 *     out[inds_greater] = 1
 *     out[inds_lesser] = -1             # <<<<<<<<<<<<<<
 * 
 *     return out
 */
  if (unlikely(PyObject_SetItem(__pyx_v_out, __pyx_v_inds_lesser, __pyx_int_neg_1) < 0)) __PYX_ERR(0, 65, __pyx_L1_error)

  /* "libs/network.pyx":67
 *     out[inds_lesser] = -1
 * 
 *     return out             # <<<<<<<<<<<<<<
 * 
 * cdef hardtanhd(np.ndarray[FLOAT_t, ndim=2] weights):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  /* "libs/network.pyx":53
 *     return np.log(np.sum(np.exp(a - a_max), axis=0)) + a_max
 * 
 * cdef hardtanh(np.ndarray weights, inplace=False):             # <<<<<<<<<<<<<<
 *     """
 *     Hard hyperbolic tangent.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("libs.network.hardtanh", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_inds_greater);
  __Pyx_XDECREF(__pyx_v_inds_lesser);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":69
 *     return out
 * 
 * cdef hardtanhd(np.ndarray[FLOAT_t, ndim=2] weights):             # <<<<<<<<<<<<<<
 *     """derivative of hardtanh"""
 *     cdef np.ndarray out = np.zeros_like(weights)
 */

static PyObject *__pyx_f_4libs_7network_hardtanhd(PyArrayObject *__pyx_v_weights) {
  PyArrayObject *__pyx_v_out = 0;
  PyObject *__pyx_v_inds = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_weights;
  __Pyx_Buffer __pyx_pybuffer_weights;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("hardtanhd", 0);
  __Pyx_TraceCall("hardtanhd", __pyx_f[0], 69, 0, __PYX_ERR(0, 69, __pyx_L1_error));
  __pyx_pybuffer_weights.pybuffer.buf = NULL;
  __pyx_pybuffer_weights.refcount = 0;
  __pyx_pybuffernd_weights.data = NULL;
  __pyx_pybuffernd_weights.rcbuffer = &__pyx_pybuffer_weights;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_weights, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error)
  }
  __pyx_pybuffernd_weights.diminfo[0].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_weights.diminfo[0].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_weights.diminfo[1].strides = __pyx_pybuffernd_weights.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_weights.diminfo[1].shape = __pyx_pybuffernd_weights.rcbuffer->pybuffer.shape[1];

  /* "libs/network.pyx":71
 * cdef hardtanhd(np.ndarray[FLOAT_t, ndim=2] weights):
 *     """derivative of hardtanh"""
 *     cdef np.ndarray out = np.zeros_like(weights)             # <<<<<<<<<<<<<<
 *     inds = np.logical_and(-1.0 <= weights, weights <= 1.0)
 *     out[inds] = 1.0
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, ((PyObject *)__pyx_v_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_weights));
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 71, __pyx_L1_error)
  __pyx_v_out = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":72
 *     """derivative of hardtanh"""
 *     cdef np.ndarray out = np.zeros_like(weights)
 *     inds = np.logical_and(-1.0 <= weights, weights <= 1.0)             # <<<<<<<<<<<<<<
 *     out[inds] = 1.0
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_logical_and); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_float_neg_1_0, ((PyObject *)__pyx_v_weights), Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_weights), __pyx_float_1_0, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error)
  __pyx_t_5 = NULL;
  __pyx_t_6 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_6 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_inds = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":73
 *     cdef np.ndarray out = np.zeros_like(weights)
 *     inds = np.logical_and(-1.0 <= weights, weights <= 1.0)
 *     out[inds] = 1.0             # <<<<<<<<<<<<<<
 * 
 *     return out
 */
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_out), __pyx_v_inds, __pyx_float_1_0) < 0)) __PYX_ERR(0, 73, __pyx_L1_error)

  /* "libs/network.pyx":75
 *     out[inds] = 1.0
 * 
 *     return out             # <<<<<<<<<<<<<<
 * 
 * # ----------------------------------------------------------------------
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_out));
  __pyx_r = ((PyObject *)__pyx_v_out);
  goto __pyx_L0;

  /* "libs/network.pyx":69
 *     return out
 * 
 * cdef hardtanhd(np.ndarray[FLOAT_t, ndim=2] weights):             # <<<<<<<<<<<<<<
 *     """derivative of hardtanh"""
 *     cdef np.ndarray out = np.zeros_like(weights)
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.hardtanhd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_weights.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_inds);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":127
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, int word_window, int hidden_size,             # <<<<<<<<<<<<<<
 *                  int output_size):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_1create_new(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_create_new[] = "Network.create_new(type cls, feature_tables, int word_window, int hidden_size, int output_size)\n\n        Creates a new neural network.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_1create_new(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_feature_tables = 0;
  int __pyx_v_word_window;
  int __pyx_v_hidden_size;
  int __pyx_v_output_size;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_new (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_feature_tables,&__pyx_n_s_word_window,&__pyx_n_s_hidden_size,&__pyx_n_s_output_size,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_feature_tables)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_word_window)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 4, 4, 1); __PYX_ERR(0, 127, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 4, 4, 2); __PYX_ERR(0, 127, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 4, 4, 3); __PYX_ERR(0, 127, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_new") < 0)) __PYX_ERR(0, 127, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_feature_tables = values[0];
    __pyx_v_word_window = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_word_window == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error)
    __pyx_v_hidden_size = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_hidden_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 127, __pyx_L3_error)
    __pyx_v_output_size = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_output_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 128, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_new", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 127, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network.create_new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_7Network_create_new(((PyTypeObject*)__pyx_v_cls), __pyx_v_feature_tables, __pyx_v_word_window, __pyx_v_hidden_size, __pyx_v_output_size);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4libs_7network_7Network_10create_new_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "libs/network.pyx":133
 *         """
 *         # sum the number of features in all tables
 *         cdef int input_size = sum(table.shape[1] for table in feature_tables)             # <<<<<<<<<<<<<<
 *         input_size *= word_window
 * 
 */

static PyObject *__pyx_pf_4libs_7network_7Network_10create_new_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *)__pyx_tp_new_4libs_7network___pyx_scope_struct_1_genexpr(__pyx_ptype_4libs_7network___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 133, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4libs_7network_7Network_10create_new_2generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_create_new_locals_genexpr, __pyx_n_s_libs_network); if (unlikely(!gen)) __PYX_ERR(0, 133, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.create_new.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4libs_7network_7Network_10create_new_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 133, 0, __PYX_ERR(0, 133, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 133, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables)) { __Pyx_RaiseClosureNameError("feature_tables"); __PYX_ERR(0, 133, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 133, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 133, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 133, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_table);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_table, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 133, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 133, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":127
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, int word_window, int hidden_size,             # <<<<<<<<<<<<<<
 *                  int output_size):
 *         """
 */

static PyObject *__pyx_pf_4libs_7network_7Network_create_new(CYTHON_UNUSED PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_feature_tables, int __pyx_v_word_window, int __pyx_v_hidden_size, int __pyx_v_output_size) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *__pyx_cur_scope;
  int __pyx_v_input_size;
  PyObject *__pyx_v_high = NULL;
  PyObject *__pyx_v_hidden_weights = NULL;
  PyObject *__pyx_v_hidden_bias = NULL;
  PyObject *__pyx_v_output_weights = NULL;
  PyObject *__pyx_v_output_bias = NULL;
  PyObject *__pyx_v_transitions = NULL;
  struct __pyx_obj_4libs_7network_Network *__pyx_v_net = NULL;
  PyObject *__pyx_gb_4libs_7network_7Network_10create_new_2generator = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_new", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *)__pyx_tp_new_4libs_7network___pyx_scope_struct__create_new(__pyx_ptype_4libs_7network___pyx_scope_struct__create_new, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 127, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("create_new", __pyx_f[0], 127, 0, __PYX_ERR(0, 127, __pyx_L1_error));
  __pyx_cur_scope->__pyx_v_feature_tables = __pyx_v_feature_tables;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_feature_tables);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_feature_tables);

  /* "libs/network.pyx":133
 *         """
 *         # sum the number of features in all tables
 *         cdef int input_size = sum(table.shape[1] for table in feature_tables)             # <<<<<<<<<<<<<<
 *         input_size *= word_window
 * 
 */
  __pyx_t_1 = __pyx_pf_4libs_7network_7Network_10create_new_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 133, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_input_size = __pyx_t_3;

  /* "libs/network.pyx":134
 *         # sum the number of features in all tables
 *         cdef int input_size = sum(table.shape[1] for table in feature_tables)
 *         input_size *= word_window             # <<<<<<<<<<<<<<
 * 
 *         # creates the weight matrices
 */
  __pyx_v_input_size = (__pyx_v_input_size * __pyx_v_word_window);

  /* "libs/network.pyx":145
 *         # interval = 3.46 / fanin ^ 1/4
 *         #high = 1.732 / np.power(input_size, 0.25) # SENNA: 0.416
 *         high = 2.38 / np.sqrt(input_size) # [Bottou-88]             # <<<<<<<<<<<<<<
 *         #high = 0.1              # Fonseca
 *         hidden_weights = np.random.uniform(-high, high, (hidden_size, input_size))
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_input_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_2_38, __pyx_t_2, 2.38, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_high = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "libs/network.pyx":147
 *         high = 2.38 / np.sqrt(input_size) # [Bottou-88]
 *         #high = 0.1              # Fonseca
 *         hidden_weights = np.random.uniform(-high, high, (hidden_size, input_size))             # <<<<<<<<<<<<<<
 *         hidden_bias = np.random.uniform(-high, high, (hidden_size))
 *         #high = 1.732 / np.power(hidden_size, 0.25) # SENNA
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uniform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_hidden_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_input_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 147, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_v_high, __pyx_t_7};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_v_high, __pyx_t_7};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_3, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_3, __pyx_t_7);
    __pyx_t_1 = 0;
    __pyx_t_7 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_hidden_weights = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "libs/network.pyx":148
 *         #high = 0.1              # Fonseca
 *         hidden_weights = np.random.uniform(-high, high, (hidden_size, input_size))
 *         hidden_bias = np.random.uniform(-high, high, (hidden_size))             # <<<<<<<<<<<<<<
 *         #high = 1.732 / np.power(hidden_size, 0.25) # SENNA
 *         high = 2.38 / np.sqrt(hidden_size) # [Bottou-88]
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_uniform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_hidden_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 148, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_5, __pyx_v_high, __pyx_t_7};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_5, __pyx_v_high, __pyx_t_7};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_3, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_3, __pyx_t_7);
    __pyx_t_5 = 0;
    __pyx_t_7 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_hidden_bias = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "libs/network.pyx":150
 *         hidden_bias = np.random.uniform(-high, high, (hidden_size))
 *         #high = 1.732 / np.power(hidden_size, 0.25) # SENNA
 *         high = 2.38 / np.sqrt(hidden_size) # [Bottou-88]             # <<<<<<<<<<<<<<
 *         #high = 0.1              # Fonseca
 *         output_weights = np.random.uniform(-high, high, (output_size, hidden_size))
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_hidden_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_2_38, __pyx_t_4, 2.38, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF_SET(__pyx_v_high, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "libs/network.pyx":152
 *         high = 2.38 / np.sqrt(hidden_size) # [Bottou-88]
 *         #high = 0.1              # Fonseca
 *         output_weights = np.random.uniform(-high, high, (output_size, hidden_size))             # <<<<<<<<<<<<<<
 *         output_bias = np.random.uniform(-high, high, (output_size))
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uniform); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_hidden_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
  __pyx_t_7 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_2, __pyx_v_high, __pyx_t_1};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_5, __pyx_t_2, __pyx_v_high, __pyx_t_1};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_3, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_3, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_output_weights = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libs/network.pyx":153
 *         #high = 0.1              # Fonseca
 *         output_weights = np.random.uniform(-high, high, (output_size, hidden_size))
 *         output_bias = np.random.uniform(-high, high, (output_size))             # <<<<<<<<<<<<<<
 * 
 *         high = 1.0
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uniform); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_t_7, __pyx_v_high, __pyx_t_1};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 153, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_t_7, __pyx_v_high, __pyx_t_1};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 153, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_3, __pyx_t_7);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_3, __pyx_t_1);
    __pyx_t_7 = 0;
    __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_output_bias = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libs/network.pyx":155
 *         output_bias = np.random.uniform(-high, high, (output_size))
 * 
 *         high = 1.0             # <<<<<<<<<<<<<<
 *         # +1 is due for the initial transition
 *         transitions = np.random.uniform(-high, high, (output_size + 1, output_size))
 */
  __Pyx_INCREF(__pyx_float_1_0);
  __Pyx_DECREF_SET(__pyx_v_high, __pyx_float_1_0);

  /* "libs/network.pyx":157
 *         high = 1.0
 *         # +1 is due for the initial transition
 *         transitions = np.random.uniform(-high, high, (output_size + 1, output_size))             # <<<<<<<<<<<<<<
 * 
 *         net = Network(word_window, input_size, hidden_size, output_size,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_uniform); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_output_size + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_5, __pyx_v_high, __pyx_t_2};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_5, __pyx_v_high, __pyx_t_2};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_3, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_3, __pyx_t_2);
    __pyx_t_5 = 0;
    __pyx_t_2 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_transitions = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libs/network.pyx":159
 *         transitions = np.random.uniform(-high, high, (output_size + 1, output_size))
 * 
 *         net = Network(word_window, input_size, hidden_size, output_size,             # <<<<<<<<<<<<<<
 *                       hidden_weights, hidden_bias, output_weights, output_bias,
 *                       transitions)
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_word_window); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_input_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_hidden_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "libs/network.pyx":161
 *         net = Network(word_window, input_size, hidden_size, output_size,
 *                       hidden_weights, hidden_bias, output_weights, output_bias,
 *                       transitions)             # <<<<<<<<<<<<<<
 *         net.feature_tables = feature_tables
 * 
 */
  __pyx_t_5 = PyTuple_New(9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_hidden_weights);
  __Pyx_GIVEREF(__pyx_v_hidden_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_hidden_weights);
  __Pyx_INCREF(__pyx_v_hidden_bias);
  __Pyx_GIVEREF(__pyx_v_hidden_bias);
  PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_v_hidden_bias);
  __Pyx_INCREF(__pyx_v_output_weights);
  __Pyx_GIVEREF(__pyx_v_output_weights);
  PyTuple_SET_ITEM(__pyx_t_5, 6, __pyx_v_output_weights);
  __Pyx_INCREF(__pyx_v_output_bias);
  __Pyx_GIVEREF(__pyx_v_output_bias);
  PyTuple_SET_ITEM(__pyx_t_5, 7, __pyx_v_output_bias);
  __Pyx_INCREF(__pyx_v_transitions);
  __Pyx_GIVEREF(__pyx_v_transitions);
  PyTuple_SET_ITEM(__pyx_t_5, 8, __pyx_v_transitions);
  __pyx_t_6 = 0;
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;

  /* "libs/network.pyx":159
 *         transitions = np.random.uniform(-high, high, (output_size + 1, output_size))
 * 
 *         net = Network(word_window, input_size, hidden_size, output_size,             # <<<<<<<<<<<<<<
 *                       hidden_weights, hidden_bias, output_weights, output_bias,
 *                       transitions)
 */
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4libs_7network_Network), __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_net = ((struct __pyx_obj_4libs_7network_Network *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":162
 *                       hidden_weights, hidden_bias, output_weights, output_bias,
 *                       transitions)
 *         net.feature_tables = feature_tables             # <<<<<<<<<<<<<<
 * 
 *         return net
 */
  if (!(likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_feature_tables))||((__pyx_cur_scope->__pyx_v_feature_tables) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_cur_scope->__pyx_v_feature_tables)->tp_name), 0))) __PYX_ERR(0, 162, __pyx_L1_error)
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_feature_tables;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_net->feature_tables);
  __Pyx_DECREF(__pyx_v_net->feature_tables);
  __pyx_v_net->feature_tables = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":164
 *         net.feature_tables = feature_tables
 * 
 *         return net             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, word_window, input_size, hidden_size, output_size,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_net));
  __pyx_r = ((PyObject *)__pyx_v_net);
  goto __pyx_L0;

  /* "libs/network.pyx":127
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, int word_window, int hidden_size,             # <<<<<<<<<<<<<<
 *                  int output_size):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.Network.create_new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_high);
  __Pyx_XDECREF(__pyx_v_hidden_weights);
  __Pyx_XDECREF(__pyx_v_hidden_bias);
  __Pyx_XDECREF(__pyx_v_output_weights);
  __Pyx_XDECREF(__pyx_v_output_bias);
  __Pyx_XDECREF(__pyx_v_transitions);
  __Pyx_XDECREF((PyObject *)__pyx_v_net);
  __Pyx_XDECREF(__pyx_gb_4libs_7network_7Network_10create_new_2generator);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":166
 *         return net
 * 
 *     def __init__(self, word_window, input_size, hidden_size, output_size,             # <<<<<<<<<<<<<<
 *                  hidden_weights, hidden_bias, output_weights, output_bias,
 *                  transitions=None):
 */

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_2__init__[] = "\n        This function isn't expected to be directly called.\n        Instead, use the classmethods load_from_file or \n        create_new.\n        \n        :param transitions: transition weights. If None uses\n            Window Level Likelihood instead of Sentence Level Likelihood.\n        ";
#if CYTHON_UPDATE_DESCRIPTOR_DOC
struct wrapperbase __pyx_wrapperbase_4libs_7network_7Network_2__init__;
#endif
static int __pyx_pw_4libs_7network_7Network_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_word_window = 0;
  PyObject *__pyx_v_input_size = 0;
  PyObject *__pyx_v_hidden_size = 0;
  PyObject *__pyx_v_output_size = 0;
  PyObject *__pyx_v_hidden_weights = 0;
  PyObject *__pyx_v_hidden_bias = 0;
  PyObject *__pyx_v_output_weights = 0;
  PyObject *__pyx_v_output_bias = 0;
  PyObject *__pyx_v_transitions = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_word_window,&__pyx_n_s_input_size,&__pyx_n_s_hidden_size,&__pyx_n_s_output_size,&__pyx_n_s_hidden_weights,&__pyx_n_s_hidden_bias,&__pyx_n_s_output_weights,&__pyx_n_s_output_bias,&__pyx_n_s_transitions,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};

    /* "libs/network.pyx":168
 *     def __init__(self, word_window, input_size, hidden_size, output_size,
 *                  hidden_weights, hidden_bias, output_weights, output_bias,
 *                  transitions=None):             # <<<<<<<<<<<<<<
 *         """
 *         This function isn't expected to be directly called.
 */
    values[8] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_word_window)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 9, 1); __PYX_ERR(0, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 9, 2); __PYX_ERR(0, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 9, 3); __PYX_ERR(0, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 9, 4); __PYX_ERR(0, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden_bias)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 9, 5); __PYX_ERR(0, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 9, 6); __PYX_ERR(0, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_bias)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 9, 7); __PYX_ERR(0, 166, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_transitions);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 166, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_word_window = values[0];
    __pyx_v_input_size = values[1];
    __pyx_v_hidden_size = values[2];
    __pyx_v_output_size = values[3];
    __pyx_v_hidden_weights = values[4];
    __pyx_v_hidden_bias = values[5];
    __pyx_v_output_weights = values[6];
    __pyx_v_output_bias = values[7];
    __pyx_v_transitions = values[8];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 8, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 166, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_7Network_2__init__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), __pyx_v_word_window, __pyx_v_input_size, __pyx_v_hidden_size, __pyx_v_output_size, __pyx_v_hidden_weights, __pyx_v_hidden_bias, __pyx_v_output_weights, __pyx_v_output_bias, __pyx_v_transitions);

  /* "libs/network.pyx":166
 *         return net
 * 
 *     def __init__(self, word_window, input_size, hidden_size, output_size,             # <<<<<<<<<<<<<<
 *                  hidden_weights, hidden_bias, output_weights, output_bias,
 *                  transitions=None):
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_2__init__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_word_window, PyObject *__pyx_v_input_size, PyObject *__pyx_v_hidden_size, PyObject *__pyx_v_output_size, PyObject *__pyx_v_hidden_weights, PyObject *__pyx_v_hidden_bias, PyObject *__pyx_v_output_weights, PyObject *__pyx_v_output_bias, PyObject *__pyx_v_transitions) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 166, 0, __PYX_ERR(0, 166, __pyx_L1_error));

  /* "libs/network.pyx":177
 *             Window Level Likelihood instead of Sentence Level Likelihood.
 *         """
 *         self.learning_rate = 0             # <<<<<<<<<<<<<<
 *         self.learning_rate_features = 0
 * 
 */
  __pyx_v_self->learning_rate = 0.0;

  /* "libs/network.pyx":178
 *         """
 *         self.learning_rate = 0
 *         self.learning_rate_features = 0             # <<<<<<<<<<<<<<
 * 
 *         self.word_window_size = word_window
 */
  __pyx_v_self->learning_rate_features = 0.0;

  /* "libs/network.pyx":180
 *         self.learning_rate_features = 0
 * 
 *         self.word_window_size = word_window             # <<<<<<<<<<<<<<
 *         self.input_size = input_size
 *         self.hidden_size = hidden_size
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_word_window); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 180, __pyx_L1_error)
  __pyx_v_self->word_window_size = __pyx_t_1;

  /* "libs/network.pyx":181
 * 
 *         self.word_window_size = word_window
 *         self.input_size = input_size             # <<<<<<<<<<<<<<
 *         self.hidden_size = hidden_size
 *         self.output_size = output_size
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_input_size); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 181, __pyx_L1_error)
  __pyx_v_self->input_size = __pyx_t_1;

  /* "libs/network.pyx":182
 *         self.word_window_size = word_window
 *         self.input_size = input_size
 *         self.hidden_size = hidden_size             # <<<<<<<<<<<<<<
 *         self.output_size = output_size
 *         self.features_per_token = input_size / word_window
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_hidden_size); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error)
  __pyx_v_self->hidden_size = __pyx_t_1;

  /* "libs/network.pyx":183
 *         self.input_size = input_size
 *         self.hidden_size = hidden_size
 *         self.output_size = output_size             # <<<<<<<<<<<<<<
 *         self.features_per_token = input_size / word_window
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_output_size); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L1_error)
  __pyx_v_self->output_size = __pyx_t_1;

  /* "libs/network.pyx":184
 *         self.hidden_size = hidden_size
 *         self.output_size = output_size
 *         self.features_per_token = input_size / word_window             # <<<<<<<<<<<<<<
 * 
 *         # A_i_j score for jumping from tag i to j
 */
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_v_input_size, __pyx_v_word_window); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->features_per_token = __pyx_t_1;

  /* "libs/network.pyx":188
 *         # A_i_j score for jumping from tag i to j
 *         # A_0_i = transitions[-1]
 *         self.transitions = transitions             # <<<<<<<<<<<<<<
 * 
 *         self.hidden_weights = hidden_weights
 */
  if (!(likely(((__pyx_v_transitions) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_transitions, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 188, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_transitions;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->transitions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->transitions));
  __pyx_v_self->transitions = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":190
 *         self.transitions = transitions
 * 
 *         self.hidden_weights = hidden_weights             # <<<<<<<<<<<<<<
 *         self.hidden_bias = hidden_bias
 *         self.output_weights = output_weights
 */
  if (!(likely(((__pyx_v_hidden_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hidden_weights, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 190, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_hidden_weights;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->hidden_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_weights));
  __pyx_v_self->hidden_weights = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":191
 * 
 *         self.hidden_weights = hidden_weights
 *         self.hidden_bias = hidden_bias             # <<<<<<<<<<<<<<
 *         self.output_weights = output_weights
 *         self.output_bias = output_bias
 */
  if (!(likely(((__pyx_v_hidden_bias) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hidden_bias, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 191, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_hidden_bias;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->hidden_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_bias));
  __pyx_v_self->hidden_bias = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":192
 *         self.hidden_weights = hidden_weights
 *         self.hidden_bias = hidden_bias
 *         self.output_weights = output_weights             # <<<<<<<<<<<<<<
 *         self.output_bias = output_bias
 * 
 */
  if (!(likely(((__pyx_v_output_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_output_weights, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 192, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_output_weights;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->output_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->output_weights));
  __pyx_v_self->output_weights = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":193
 *         self.hidden_bias = hidden_bias
 *         self.output_weights = output_weights
 *         self.output_bias = output_bias             # <<<<<<<<<<<<<<
 * 
 *         self.validation_sentences = None
 */
  if (!(likely(((__pyx_v_output_bias) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_output_bias, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 193, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_output_bias;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->output_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->output_bias));
  __pyx_v_self->output_bias = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":195
 *         self.output_bias = output_bias
 * 
 *         self.validation_sentences = None             # <<<<<<<<<<<<<<
 *         self.validation_tags = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->validation_sentences);
  __Pyx_DECREF(__pyx_v_self->validation_sentences);
  __pyx_v_self->validation_sentences = ((PyObject*)Py_None);

  /* "libs/network.pyx":196
 * 
 *         self.validation_sentences = None
 *         self.validation_tags = None             # <<<<<<<<<<<<<<
 * 
 *         self.use_learning_rate_decay = False
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->validation_tags);
  __Pyx_DECREF(__pyx_v_self->validation_tags);
  __pyx_v_self->validation_tags = ((PyObject*)Py_None);

  /* "libs/network.pyx":198
 *         self.validation_tags = None
 * 
 *         self.use_learning_rate_decay = False             # <<<<<<<<<<<<<<
 * 
 *     def description(self):
 */
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  __Pyx_GOTREF(__pyx_v_self->use_learning_rate_decay);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->use_learning_rate_decay));
  __pyx_v_self->use_learning_rate_decay = ((PyBoolObject *)Py_False);

  /* "libs/network.pyx":166
 *         return net
 * 
 *     def __init__(self, word_window, input_size, hidden_size, output_size,             # <<<<<<<<<<<<<<
 *                  hidden_weights, hidden_bias, output_weights, output_bias,
 *                  transitions=None):
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libs.network.Network.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":200
 *         self.use_learning_rate_decay = False
 * 
 *     def description(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns a textual description of the network.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_5description(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_7Network_4description[] = "Network.description(self)\n\n        Returns a textual description of the network.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_5description(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("description (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_4description(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_4description(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_v_table_dims = NULL;
  PyObject *__pyx_v_desc = NULL;
  PyObject *__pyx_8genexpr1__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_UCS4 __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("description", 0);
  __Pyx_TraceCall("description", __pyx_f[0], 200, 0, __PYX_ERR(0, 200, __pyx_L1_error));

  /* "libs/network.pyx":204
 *         Returns a textual description of the network.
 *         """
 *         table_dims = [str(t.shape[1]) for t in self.feature_tables]             # <<<<<<<<<<<<<<
 *         table_dims =  ', '.join(table_dims)
 * 
 */
  { /* enter inner scope */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__pyx_v_self->feature_tables == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(0, 204, __pyx_L5_error)
    }
    __pyx_t_2 = __pyx_v_self->feature_tables; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    for (;;) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 204, __pyx_L5_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_t, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 204, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_t); __pyx_8genexpr1__pyx_v_t = 0;
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_t); __pyx_8genexpr1__pyx_v_t = 0;
    goto __pyx_L1_error;
    __pyx_L8_exit_scope:;
  } /* exit inner scope */
  __pyx_v_table_dims = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":205
 *         """
 *         table_dims = [str(t.shape[1]) for t in self.feature_tables]
 *         table_dims =  ', '.join(table_dims)             # <<<<<<<<<<<<<<
 * 
 *         desc = """
 */
  __pyx_t_1 = PyUnicode_Join(__pyx_kp_u_, __pyx_v_table_dims); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_table_dims, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":207
 *         table_dims =  ', '.join(table_dims)
 * 
 *         desc = """             # <<<<<<<<<<<<<<
 * Word window size: %d
 * Feature table sizes: %s
 */
  __pyx_t_1 = PyTuple_New(11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_6 = 127;
  __Pyx_INCREF(__pyx_kp_u_Word_window_size);
  __pyx_t_3 += 19;
  __Pyx_GIVEREF(__pyx_kp_u_Word_window_size);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Word_window_size);

  /* "libs/network.pyx":213
 * Hidden layer size: %d
 * Output size: %d
 * """ % (self.word_window_size, table_dims, self.input_size, self.hidden_size, self.output_size)             # <<<<<<<<<<<<<<
 * 
 *         return desc
 */
  __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_self->word_window_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_kp_u_Feature_table_sizes);
  __pyx_t_3 += 22;
  __Pyx_GIVEREF(__pyx_kp_u_Feature_table_sizes);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Feature_table_sizes);
  __pyx_t_2 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_table_dims), __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_6;
  __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_kp_u_Input_layer_size);
  __pyx_t_3 += 19;
  __Pyx_GIVEREF(__pyx_kp_u_Input_layer_size);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_Input_layer_size);
  __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_self->input_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_kp_u_Hidden_layer_size);
  __pyx_t_3 += 20;
  __Pyx_GIVEREF(__pyx_kp_u_Hidden_layer_size);
  PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_kp_u_Hidden_layer_size);
  __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_self->hidden_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 7, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_kp_u_Output_size);
  __pyx_t_3 += 14;
  __Pyx_GIVEREF(__pyx_kp_u_Output_size);
  PyTuple_SET_ITEM(__pyx_t_1, 8, __pyx_kp_u_Output_size);
  __pyx_t_2 = __Pyx_PyUnicode_From_int(__pyx_v_self->output_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 9, __pyx_t_2);
  __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_kp_u__2);
  __pyx_t_3 += 1;
  __Pyx_GIVEREF(__pyx_kp_u__2);
  PyTuple_SET_ITEM(__pyx_t_1, 10, __pyx_kp_u__2);

  /* "libs/network.pyx":207
 *         table_dims =  ', '.join(table_dims)
 * 
 *         desc = """             # <<<<<<<<<<<<<<
 * Word window size: %d
 * Feature table sizes: %s
 */
  __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_1, 11, __pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_desc = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":215
 * """ % (self.word_window_size, table_dims, self.input_size, self.hidden_size, self.output_size)
 * 
 *         return desc             # <<<<<<<<<<<<<<
 * 
 *     def _create_sentence_lookup(self, np.ndarray sentence):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_desc);
  __pyx_r = __pyx_v_desc;
  goto __pyx_L0;

  /* "libs/network.pyx":200
 *         self.use_learning_rate_decay = False
 * 
 *     def description(self):             # <<<<<<<<<<<<<<
 *         """
 *         Returns a textual description of the network.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("libs.network.Network.description", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_table_dims);
  __Pyx_XDECREF(__pyx_v_desc);
  __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":217
 *         return desc
 * 
 *     def _create_sentence_lookup(self, np.ndarray sentence):             # <<<<<<<<<<<<<<
 *         """
 *         Create a lookup matrix with the embeddings values for all tokens in a sentence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_7_create_sentence_lookup(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence); /*proto*/
static char __pyx_doc_4libs_7network_7Network_6_create_sentence_lookup[] = "Network._create_sentence_lookup(self, ndarray sentence)\n\n        Create a lookup matrix with the embeddings values for all tokens in a sentence.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_7_create_sentence_lookup(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_sentence_lookup (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(0, 217, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_6_create_sentence_lookup(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyArrayObject *)__pyx_v_sentence));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_6_create_sentence_lookup(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_sentence) {
  PyArrayObject *__pyx_v_padded_sentence = 0;
  PyObject *__pyx_v_ind_from = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_table = NULL;
  PyObject *__pyx_v_num_dims = NULL;
  PyObject *__pyx_v_ind_to = NULL;
  PyObject *__pyx_v_token_indices = NULL;
  PyObject *__pyx_v_embeddings = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_sentence_lookup", 0);
  __Pyx_TraceCall("_create_sentence_lookup", __pyx_f[0], 217, 0, __PYX_ERR(0, 217, __pyx_L1_error));

  /* "libs/network.pyx":222
 *         """
 *         #print (sentence)
 *         cdef np.ndarray padded_sentence = np.concatenate((self.pre_padding,             # <<<<<<<<<<<<<<
 *                                                           sentence,
 *                                                           self.pos_padding))
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libs/network.pyx":224
 *         cdef np.ndarray padded_sentence = np.concatenate((self.pre_padding,
 *                                                           sentence,
 *                                                           self.pos_padding))             # <<<<<<<<<<<<<<
 * 
 *         # make sure it works on 32 bit python installations
 */
  __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pre_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pre_padding));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->pre_padding));
  __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_sentence));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pos_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pos_padding));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_self->pos_padding));
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "libs/network.pyx":222
 *         """
 *         #print (sentence)
 *         cdef np.ndarray padded_sentence = np.concatenate((self.pre_padding,             # <<<<<<<<<<<<<<
 *                                                           sentence,
 *                                                           self.pos_padding))
 */
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 222, __pyx_L1_error)
  __pyx_v_padded_sentence = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":227
 * 
 *         # make sure it works on 32 bit python installations
 *         padded_sentence = padded_sentence.astype(int)             # <<<<<<<<<<<<<<
 *         #padded_sentence = padded_sentence.astype(np.int64)
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_padded_sentence), __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, ((PyObject *)(&PyInt_Type))) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)(&PyInt_Type)));
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 227, __pyx_L1_error)
  __Pyx_DECREF_SET(__pyx_v_padded_sentence, ((PyArrayObject *)__pyx_t_1));
  __pyx_t_1 = 0;

  /* "libs/network.pyx":230
 *         #padded_sentence = padded_sentence.astype(np.int64)
 * 
 *         self.sentence_lookup = np.empty((len(padded_sentence), self.features_per_token))             # <<<<<<<<<<<<<<
 *         ind_from = 0
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_padded_sentence)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 230, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->features_per_token); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->sentence_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->sentence_lookup));
  __pyx_v_self->sentence_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":231
 * 
 *         self.sentence_lookup = np.empty((len(padded_sentence), self.features_per_token))
 *         ind_from = 0             # <<<<<<<<<<<<<<
 * 
 *         for i, table in enumerate(self.feature_tables):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_ind_from = __pyx_int_0;

  /* "libs/network.pyx":233
 *         ind_from = 0
 * 
 *         for i, table in enumerate(self.feature_tables):             # <<<<<<<<<<<<<<
 *             num_dims = table.shape[1]
 *             ind_to = ind_from + num_dims
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  __pyx_t_2 = __pyx_v_self->feature_tables; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 233, __pyx_L1_error)
    #else
    __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_XDECREF_SET(__pyx_v_table, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 233, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "libs/network.pyx":234
 * 
 *         for i, table in enumerate(self.feature_tables):
 *             num_dims = table.shape[1]             # <<<<<<<<<<<<<<
 *             ind_to = ind_from + num_dims
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_6, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_num_dims, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "libs/network.pyx":235
 *         for i, table in enumerate(self.feature_tables):
 *             num_dims = table.shape[1]
 *             ind_to = ind_from + num_dims             # <<<<<<<<<<<<<<
 * 
 *             token_indices = padded_sentence[:, i]
 */
    __pyx_t_4 = PyNumber_Add(__pyx_v_ind_from, __pyx_v_num_dims); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_ind_to, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "libs/network.pyx":237
 *             ind_to = ind_from + num_dims
 * 
 *             token_indices = padded_sentence[:, i]             # <<<<<<<<<<<<<<
 *             embeddings = table.take(token_indices, axis=0)
 *             self.sentence_lookup[:, ind_from:ind_to] = embeddings
 */
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_slice__3);
    __Pyx_GIVEREF(__pyx_slice__3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__3);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_i);
    __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_padded_sentence), __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 237, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_token_indices, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "libs/network.pyx":238
 * 
 *             token_indices = padded_sentence[:, i]
 *             embeddings = table.take(token_indices, axis=0)             # <<<<<<<<<<<<<<
 *             self.sentence_lookup[:, ind_from:ind_to] = embeddings
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_table, __pyx_n_s_take); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_token_indices);
    __Pyx_GIVEREF(__pyx_v_token_indices);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_token_indices);
    __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 238, __pyx_L1_error)
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 238, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_embeddings, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "libs/network.pyx":239
 *             token_indices = padded_sentence[:, i]
 *             embeddings = table.take(token_indices, axis=0)
 *             self.sentence_lookup[:, ind_from:ind_to] = embeddings             # <<<<<<<<<<<<<<
 * 
 *             ind_from = ind_to
 */
    __pyx_t_7 = PySlice_New(__pyx_v_ind_from, __pyx_v_ind_to, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 239, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 239, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_slice__3);
    __Pyx_GIVEREF(__pyx_slice__3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_slice__3);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7);
    __pyx_t_7 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->sentence_lookup), __pyx_t_3, __pyx_v_embeddings) < 0)) __PYX_ERR(0, 239, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libs/network.pyx":241
 *             self.sentence_lookup[:, ind_from:ind_to] = embeddings
 * 
 *             ind_from = ind_to             # <<<<<<<<<<<<<<
 * 
 *     property padding_left:
 */
    __Pyx_INCREF(__pyx_v_ind_to);
    __Pyx_DECREF_SET(__pyx_v_ind_from, __pyx_v_ind_to);

    /* "libs/network.pyx":233
 *         ind_from = 0
 * 
 *         for i, table in enumerate(self.feature_tables):             # <<<<<<<<<<<<<<
 *             num_dims = table.shape[1]
 *             ind_to = ind_from + num_dims
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":217
 *         return desc
 * 
 *     def _create_sentence_lookup(self, np.ndarray sentence):             # <<<<<<<<<<<<<<
 *         """
 *         Create a lookup matrix with the embeddings values for all tokens in a sentence.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.Network._create_sentence_lookup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_padded_sentence);
  __Pyx_XDECREF(__pyx_v_ind_from);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_table);
  __Pyx_XDECREF(__pyx_v_num_dims);
  __Pyx_XDECREF(__pyx_v_ind_to);
  __Pyx_XDECREF(__pyx_v_token_indices);
  __Pyx_XDECREF(__pyx_v_embeddings);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":248
 *         of the sentence.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.padding_left
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_12padding_left_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_12padding_left_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_12padding_left___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_12padding_left___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 248, 0, __PYX_ERR(0, 248, __pyx_L1_error));

  /* "libs/network.pyx":249
 *         """
 *         def __get__(self):
 *             return self.padding_left             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, np.ndarray padding_left):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->padding_left));
  __pyx_r = ((PyObject *)__pyx_v_self->padding_left);
  goto __pyx_L0;

  /* "libs/network.pyx":248
 *         of the sentence.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.padding_left
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.padding_left.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":251
 *             return self.padding_left
 * 
 *         def __set__(self, np.ndarray padding_left):             # <<<<<<<<<<<<<<
 *             self.padding_left = padding_left
 *             self.pre_padding = np.array((self.word_window_size // 2) * [padding_left])
 */

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_12padding_left_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_padding_left); /*proto*/
static int __pyx_pw_4libs_7network_7Network_12padding_left_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_padding_left) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_padding_left), __pyx_ptype_5numpy_ndarray, 1, "padding_left", 0))) __PYX_ERR(0, 251, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_12padding_left_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyArrayObject *)__pyx_v_padding_left));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_12padding_left_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_padding_left) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 251, 0, __PYX_ERR(0, 251, __pyx_L1_error));

  /* "libs/network.pyx":252
 * 
 *         def __set__(self, np.ndarray padding_left):
 *             self.padding_left = padding_left             # <<<<<<<<<<<<<<
 *             self.pre_padding = np.array((self.word_window_size // 2) * [padding_left])
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_padding_left));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_padding_left));
  __Pyx_GOTREF(__pyx_v_self->padding_left);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->padding_left));
  __pyx_v_self->padding_left = __pyx_v_padding_left;

  /* "libs/network.pyx":253
 *         def __set__(self, np.ndarray padding_left):
 *             self.padding_left = padding_left
 *             self.pre_padding = np.array((self.word_window_size // 2) * [padding_left])             # <<<<<<<<<<<<<<
 * 
 *     property padding_right:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long(__Pyx_div_long(__pyx_v_self->word_window_size, 2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_padding_left));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_padding_left));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_padding_left));
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pre_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pre_padding));
  __pyx_v_self->pre_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":251
 *             return self.padding_left
 * 
 *         def __set__(self, np.ndarray padding_left):             # <<<<<<<<<<<<<<
 *             self.padding_left = padding_left
 *             self.pre_padding = np.array((self.word_window_size // 2) * [padding_left])
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("libs.network.Network.padding_left.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":260
 *         of the sentence.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.padding_right
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_13padding_right_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_13padding_right_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_13padding_right___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_13padding_right___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 260, 0, __PYX_ERR(0, 260, __pyx_L1_error));

  /* "libs/network.pyx":261
 *         """
 *         def __get__(self):
 *             return self.padding_right             # <<<<<<<<<<<<<<
 * 
 *         def __set__(self, np.ndarray padding_right):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->padding_right));
  __pyx_r = ((PyObject *)__pyx_v_self->padding_right);
  goto __pyx_L0;

  /* "libs/network.pyx":260
 *         of the sentence.
 *         """
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.padding_right
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.padding_right.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":263
 *             return self.padding_right
 * 
 *         def __set__(self, np.ndarray padding_right):             # <<<<<<<<<<<<<<
 *             self.padding_right = padding_right
 *             self.pos_padding = np.array((self.word_window_size // 2) * [padding_right])
 */

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_13padding_right_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_padding_right); /*proto*/
static int __pyx_pw_4libs_7network_7Network_13padding_right_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_padding_right) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_padding_right), __pyx_ptype_5numpy_ndarray, 1, "padding_right", 0))) __PYX_ERR(0, 263, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_13padding_right_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyArrayObject *)__pyx_v_padding_right));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_13padding_right_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_padding_right) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 263, 0, __PYX_ERR(0, 263, __pyx_L1_error));

  /* "libs/network.pyx":264
 * 
 *         def __set__(self, np.ndarray padding_right):
 *             self.padding_right = padding_right             # <<<<<<<<<<<<<<
 *             self.pos_padding = np.array((self.word_window_size // 2) * [padding_right])
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_padding_right));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_padding_right));
  __Pyx_GOTREF(__pyx_v_self->padding_right);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->padding_right));
  __pyx_v_self->padding_right = __pyx_v_padding_right;

  /* "libs/network.pyx":265
 *         def __set__(self, np.ndarray padding_right):
 *             self.padding_right = padding_right
 *             self.pos_padding = np.array((self.word_window_size // 2) * [padding_right])             # <<<<<<<<<<<<<<
 * 
 *     def tag_sentence(self, np.ndarray sentence):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long(__Pyx_div_long(__pyx_v_self->word_window_size, 2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_padding_right));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_padding_right));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_padding_right));
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 265, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pos_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pos_padding));
  __pyx_v_self->pos_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":263
 *             return self.padding_right
 * 
 *         def __set__(self, np.ndarray padding_right):             # <<<<<<<<<<<<<<
 *             self.padding_right = padding_right
 *             self.pos_padding = np.array((self.word_window_size // 2) * [padding_right])
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("libs.network.Network.padding_right.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":267
 *             self.pos_padding = np.array((self.word_window_size // 2) * [padding_right])
 * 
 *     def tag_sentence(self, np.ndarray sentence):             # <<<<<<<<<<<<<<
 *         """
 *         Runs the network for each element in the sentence and returns
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_9tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence); /*proto*/
static char __pyx_doc_4libs_7network_7Network_8tag_sentence[] = "Network.tag_sentence(self, ndarray sentence)\n\n        Runs the network for each element in the sentence and returns \n        the sequence of tags.\n        \n        :param sentence: a 2-dim numpy array, where each item encodes a token.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_9tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tag_sentence (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(0, 267, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_8tag_sentence(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyArrayObject *)__pyx_v_sentence));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_8tag_sentence(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_sentence) {
  PyObject *__pyx_v_scores = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tag_sentence", 0);
  __Pyx_TraceCall("tag_sentence", __pyx_f[0], 267, 0, __PYX_ERR(0, 267, __pyx_L1_error));

  /* "libs/network.pyx":274
 *         :param sentence: a 2-dim numpy array, where each item encodes a token.
 *         """
 *         scores = self._tag_sentence(sentence)             # <<<<<<<<<<<<<<
 *         # computes full score, combining ftheta and A (if SLL)
 *         return self._viterbi(scores)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_sentence)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_sentence));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_scores = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":276
 *         scores = self._tag_sentence(sentence)
 *         # computes full score, combining ftheta and A (if SLL)
 *         return self._viterbi(scores)             # <<<<<<<<<<<<<<
 * 
 *     def _tag_sentence(self, np.ndarray sentence, tags=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_viterbi); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_scores) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_scores);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "libs/network.pyx":267
 *             self.pos_padding = np.array((self.word_window_size // 2) * [padding_right])
 * 
 *     def tag_sentence(self, np.ndarray sentence):             # <<<<<<<<<<<<<<
 *         """
 *         Runs the network for each element in the sentence and returns
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libs.network.Network.tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_scores);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":278
 *         return self._viterbi(scores)
 * 
 *     def _tag_sentence(self, np.ndarray sentence, tags=None):             # <<<<<<<<<<<<<<
 *         """
 *         Runs the network for each element in the sentence and returns
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_11_tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_10_tag_sentence[] = "Network._tag_sentence(self, ndarray sentence, tags=None)\n\n        Runs the network for each element in the sentence and returns \n        the sequence of tags.\n        \n        :param sentence: a 2-dim numpy array, where each item encodes a token.\n        :param tags: the correct tags (needed when training)\n        :return: a (len(sentence), output_size) array with the scores for all tokens\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_11_tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_sentence = 0;
  PyObject *__pyx_v_tags = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_tag_sentence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_tags,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_tag_sentence") < 0)) __PYX_ERR(0, 278, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = ((PyArrayObject *)values[0]);
    __pyx_v_tags = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_tag_sentence", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 278, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network._tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(0, 278, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_10_tag_sentence(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), __pyx_v_sentence, __pyx_v_tags);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_10_tag_sentence(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyObject *__pyx_v_tags) {
  PyArrayObject *__pyx_v_input_data = 0;
  PyArrayObject *__pyx_v_scores = 0;
  PyObject *__pyx_v_training = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_output = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  struct __pyx_opt_args_4libs_7network_hardtanh __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_tag_sentence", 0);
  __Pyx_TraceCall("_tag_sentence", __pyx_f[0], 278, 0, __PYX_ERR(0, 278, __pyx_L1_error));

  /* "libs/network.pyx":290
 *         cdef np.ndarray input_data
 *         # scores[t, i] = ftheta_i,t = score for i-th tag, t-th word
 *         cdef np.ndarray scores = np.empty((len(sentence), self.output_size))             # <<<<<<<<<<<<<<
 * 
 *         training = tags is not None
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 290, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->output_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 290, __pyx_L1_error)
  __pyx_v_scores = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":292
 *         cdef np.ndarray scores = np.empty((len(sentence), self.output_size))
 * 
 *         training = tags is not None             # <<<<<<<<<<<<<<
 *         if training:
 *             self.input_sent_values = np.empty((len(sentence), self.input_size))
 */
  __pyx_t_7 = (__pyx_v_tags != Py_None);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_training = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":293
 * 
 *         training = tags is not None
 *         if training:             # <<<<<<<<<<<<<<
 *             self.input_sent_values = np.empty((len(sentence), self.input_size))
 *             # layer2_values at each token in the correct path
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 293, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "libs/network.pyx":294
 *         training = tags is not None
 *         if training:
 *             self.input_sent_values = np.empty((len(sentence), self.input_size))             # <<<<<<<<<<<<<<
 *             # layer2_values at each token in the correct path
 *             self.layer2_sent_values = np.empty((len(sentence), self.hidden_size))
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 294, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->input_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
    __pyx_t_3 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 294, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->input_sent_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->input_sent_values));
    __pyx_v_self->input_sent_values = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "libs/network.pyx":296
 *             self.input_sent_values = np.empty((len(sentence), self.input_size))
 *             # layer2_values at each token in the correct path
 *             self.layer2_sent_values = np.empty((len(sentence), self.hidden_size))             # <<<<<<<<<<<<<<
 *             # hidden_values at each token in the correct path
 *             self.hidden_sent_values = np.empty((len(sentence), self.hidden_size))
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 296, __pyx_L1_error)
    __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->hidden_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
    __pyx_t_6 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 296, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->layer2_sent_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->layer2_sent_values));
    __pyx_v_self->layer2_sent_values = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "libs/network.pyx":298
 *             self.layer2_sent_values = np.empty((len(sentence), self.hidden_size))
 *             # hidden_values at each token in the correct path
 *             self.hidden_sent_values = np.empty((len(sentence), self.hidden_size))             # <<<<<<<<<<<<<<
 * 
 *         self._create_sentence_lookup(sentence)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 298, __pyx_L1_error)
    __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->hidden_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
    __pyx_t_2 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->hidden_sent_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_sent_values));
    __pyx_v_self->hidden_sent_values = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "libs/network.pyx":293
 * 
 *         training = tags is not None
 *         if training:             # <<<<<<<<<<<<<<
 *             self.input_sent_values = np.empty((len(sentence), self.input_size))
 *             # layer2_values at each token in the correct path
 */
  }

  /* "libs/network.pyx":300
 *             self.hidden_sent_values = np.empty((len(sentence), self.hidden_size))
 * 
 *         self._create_sentence_lookup(sentence)             # <<<<<<<<<<<<<<
 * 
 *         # run through all windows in the sentence
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_sentence_lookup); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_6, ((PyObject *)__pyx_v_sentence)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_sentence));
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":303
 * 
 *         # run through all windows in the sentence
 *         for i in range(len(sentence)):             # <<<<<<<<<<<<<<
 *             input_data = self.sentence_lookup[i:i + self.word_window_size].flatten()
 * 
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 303, __pyx_L1_error)
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 303, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 303, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 303, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_8(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 303, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "libs/network.pyx":304
 *         # run through all windows in the sentence
 *         for i in range(len(sentence)):
 *             input_data = self.sentence_lookup[i:i + self.word_window_size].flatten()             # <<<<<<<<<<<<<<
 * 
 *             # (hidden_size, input_size) . input_size = hidden_size
 */
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_self->word_window_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyNumber_Add(__pyx_v_i, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->sentence_lookup), 0, 0, &__pyx_v_i, &__pyx_t_5, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_flatten); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 304, __pyx_L1_error)
    __Pyx_XDECREF_SET(__pyx_v_input_data, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "libs/network.pyx":307
 * 
 *             # (hidden_size, input_size) . input_size = hidden_size
 *             self.layer2_values = self.hidden_weights.dot(input_data) + self.hidden_bias             # <<<<<<<<<<<<<<
 *             self.hidden_values = hardtanh(self.layer2_values, inplace=not training)
 *             output = self.output_weights.dot(self.hidden_values) + self.output_bias
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hidden_weights), __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, ((PyObject *)__pyx_v_input_data)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_input_data));
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Add(__pyx_t_3, ((PyObject *)__pyx_v_self->hidden_bias)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 307, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->layer2_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->layer2_values));
    __pyx_v_self->layer2_values = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;

    /* "libs/network.pyx":308
 *             # (hidden_size, input_size) . input_size = hidden_size
 *             self.layer2_values = self.hidden_weights.dot(input_data) + self.hidden_bias
 *             self.hidden_values = hardtanh(self.layer2_values, inplace=not training)             # <<<<<<<<<<<<<<
 *             output = self.output_weights.dot(self.hidden_values) + self.output_bias
 *             scores[i] = output
 */
    __pyx_t_5 = ((PyObject *)__pyx_v_self->layer2_values);
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 308, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyBool_FromLong((!__pyx_t_7)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9.__pyx_n = 1;
    __pyx_t_9.inplace = __pyx_t_3;
    __pyx_t_6 = __pyx_f_4libs_7network_hardtanh(((PyArrayObject *)__pyx_t_5), &__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 308, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->hidden_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_values));
    __pyx_v_self->hidden_values = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "libs/network.pyx":309
 *             self.layer2_values = self.hidden_weights.dot(input_data) + self.hidden_bias
 *             self.hidden_values = hardtanh(self.layer2_values, inplace=not training)
 *             output = self.output_weights.dot(self.hidden_values) + self.output_bias             # <<<<<<<<<<<<<<
 *             scores[i] = output
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->output_weights), __pyx_n_s_dot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_6 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, ((PyObject *)__pyx_v_self->hidden_values)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self->hidden_values));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_v_self->output_bias)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 309, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_output, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "libs/network.pyx":310
 *             self.hidden_values = hardtanh(self.layer2_values, inplace=not training)
 *             output = self.output_weights.dot(self.hidden_values) + self.output_bias
 *             scores[i] = output             # <<<<<<<<<<<<<<
 * 
 *             if training:
 */
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_scores), __pyx_v_i, __pyx_v_output) < 0)) __PYX_ERR(0, 310, __pyx_L1_error)

    /* "libs/network.pyx":312
 *             scores[i] = output
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.input_sent_values[i] = input_data
 *                 self.layer2_sent_values[i] = self.layer2_values
 */
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 312, __pyx_L1_error)
    if (__pyx_t_7) {

      /* "libs/network.pyx":313
 * 
 *             if training:
 *                 self.input_sent_values[i] = input_data             # <<<<<<<<<<<<<<
 *                 self.layer2_sent_values[i] = self.layer2_values
 *                 self.hidden_sent_values[i] = self.hidden_values
 */
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->input_sent_values), __pyx_v_i, ((PyObject *)__pyx_v_input_data)) < 0)) __PYX_ERR(0, 313, __pyx_L1_error)

      /* "libs/network.pyx":314
 *             if training:
 *                 self.input_sent_values[i] = input_data
 *                 self.layer2_sent_values[i] = self.layer2_values             # <<<<<<<<<<<<<<
 *                 self.hidden_sent_values[i] = self.hidden_values
 * 
 */
      __pyx_t_3 = ((PyObject *)__pyx_v_self->layer2_values);
      __Pyx_INCREF(__pyx_t_3);
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->layer2_sent_values), __pyx_v_i, __pyx_t_3) < 0)) __PYX_ERR(0, 314, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "libs/network.pyx":315
 *                 self.input_sent_values[i] = input_data
 *                 self.layer2_sent_values[i] = self.layer2_values
 *                 self.hidden_sent_values[i] = self.hidden_values             # <<<<<<<<<<<<<<
 * 
 *         if training:
 */
      __pyx_t_3 = ((PyObject *)__pyx_v_self->hidden_values);
      __Pyx_INCREF(__pyx_t_3);
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->hidden_sent_values), __pyx_v_i, __pyx_t_3) < 0)) __PYX_ERR(0, 315, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "libs/network.pyx":312
 *             scores[i] = output
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.input_sent_values[i] = input_data
 *                 self.layer2_sent_values[i] = self.layer2_values
 */
    }

    /* "libs/network.pyx":303
 * 
 *         # run through all windows in the sentence
 *         for i in range(len(sentence)):             # <<<<<<<<<<<<<<
 *             input_data = self.sentence_lookup[i:i + self.word_window_size].flatten()
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":317
 *                 self.hidden_sent_values[i] = self.hidden_values
 * 
 *         if training:             # <<<<<<<<<<<<<<
 *             if self._calculate_gradients_sll(tags, scores):
 *                 self._backpropagate(sentence)
 */
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 317, __pyx_L1_error)
  if (__pyx_t_7) {

    /* "libs/network.pyx":318
 * 
 *         if training:
 *             if self._calculate_gradients_sll(tags, scores):             # <<<<<<<<<<<<<<
 *                 self._backpropagate(sentence)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_gradients_sll); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 318, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_tags, ((PyObject *)__pyx_v_scores)};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_tags, ((PyObject *)__pyx_v_scores)};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_tags);
      __Pyx_GIVEREF(__pyx_v_tags);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_10, __pyx_v_tags);
      __Pyx_INCREF(((PyObject *)__pyx_v_scores));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_scores));
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_10, ((PyObject *)__pyx_v_scores));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 318, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_7) {

      /* "libs/network.pyx":319
 *         if training:
 *             if self._calculate_gradients_sll(tags, scores):
 *                 self._backpropagate(sentence)             # <<<<<<<<<<<<<<
 * 
 *         return scores
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_backpropagate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, ((PyObject *)__pyx_v_sentence)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_sentence));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "libs/network.pyx":318
 * 
 *         if training:
 *             if self._calculate_gradients_sll(tags, scores):             # <<<<<<<<<<<<<<
 *                 self._backpropagate(sentence)
 * 
 */
    }

    /* "libs/network.pyx":317
 *                 self.hidden_sent_values[i] = self.hidden_values
 * 
 *         if training:             # <<<<<<<<<<<<<<
 *             if self._calculate_gradients_sll(tags, scores):
 *                 self._backpropagate(sentence)
 */
  }

  /* "libs/network.pyx":321
 *                 self._backpropagate(sentence)
 * 
 *         return scores             # <<<<<<<<<<<<<<
 * 
 *     def _calculate_delta(self, scores):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_scores));
  __pyx_r = ((PyObject *)__pyx_v_scores);
  goto __pyx_L0;

  /* "libs/network.pyx":278
 *         return self._viterbi(scores)
 * 
 *     def _tag_sentence(self, np.ndarray sentence, tags=None):             # <<<<<<<<<<<<<<
 *         """
 *         Runs the network for each element in the sentence and returns
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libs.network.Network._tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_input_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_scores);
  __Pyx_XDECREF(__pyx_v_training);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_output);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":323
 *         return scores
 * 
 *     def _calculate_delta(self, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates a matrix with the scores for all possible paths at all given
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_13_calculate_delta(PyObject *__pyx_v_self, PyObject *__pyx_v_scores); /*proto*/
static char __pyx_doc_4libs_7network_7Network_12_calculate_delta[] = "Network._calculate_delta(self, scores)\n\n        Calculates a matrix with the scores for all possible paths at all given\n        points (tokens).\n        In the returned matrix, delta[i][j] means the sum of all scores \n        ending in token i with tag j (delta_i(j) in eq. 14 in the paper)\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_13_calculate_delta(PyObject *__pyx_v_self, PyObject *__pyx_v_scores) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_delta (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_12_calculate_delta(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_scores));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_12_calculate_delta(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_scores) {
  PyObject *__pyx_v_delta = NULL;
  PyObject *__pyx_v_transitions = NULL;
  PyObject *__pyx_v_token = NULL;
  PyObject *__pyx_v_logadd = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  struct __pyx_opt_args_4libs_7network_logsumexp __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculate_delta", 0);
  __Pyx_TraceCall("_calculate_delta", __pyx_f[0], 323, 0, __PYX_ERR(0, 323, __pyx_L1_error));

  /* "libs/network.pyx":334
 *         # (use long double because taking exp's leads to very very big numbers)
 *         # scores[t][k] = ftheta_k,t
 *         delta = scores             # <<<<<<<<<<<<<<
 * 
 *         # transitions[-1] represents initial transition, A_0,i in paper (mispelled as A_i,0)
 */
  __Pyx_INCREF(__pyx_v_scores);
  __pyx_v_delta = __pyx_v_scores;

  /* "libs/network.pyx":338
 *         # transitions[-1] represents initial transition, A_0,i in paper (mispelled as A_i,0)
 *         # delta_0(k) = ftheta_k,0 + A_0,i
 *         delta[0] += self.transitions[-1]             # <<<<<<<<<<<<<<
 * 
 *         # logadd for the remaining tokens
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_delta, __pyx_t_1, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->transitions), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(__Pyx_SetItemInt(__pyx_v_delta, __pyx_t_1, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "libs/network.pyx":343
 *         # delta_t(k) = ftheta_k,t + logadd_i(delta_t-1(i) + A_i,k)
 *         #            = ftheta_k,t + log(Sum_i(exp(delta_t-1(i) + A_i,k)))
 *         transitions = self.transitions[:-1].T # A_k,i             # <<<<<<<<<<<<<<
 * 
 *         for token in xrange(1, len(delta)):
 */
  __pyx_t_4 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->transitions), 0, -1L, NULL, NULL, &__pyx_slice__4, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_T); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_transitions = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libs/network.pyx":345
 *         transitions = self.transitions[:-1].T # A_k,i
 * 
 *         for token in xrange(1, len(delta)):             # <<<<<<<<<<<<<<
 *             # sum by rows
 *             logadd = logsumexp(delta[token - 1] + transitions, 1)
 */
  __pyx_t_1 = PyObject_Length(__pyx_v_delta); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 345, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_xrange, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_1 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 345, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 345, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 345, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 345, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 345, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 345, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_token, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "libs/network.pyx":347
 *         for token in xrange(1, len(delta)):
 *             # sum by rows
 *             logadd = logsumexp(delta[token - 1] + transitions, 1)             # <<<<<<<<<<<<<<
 *             delta[token] += logadd
 * 
 */
    __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_v_token, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_delta, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_v_transitions); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 347, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 347, __pyx_L1_error)
    __pyx_t_6.__pyx_n = 1;
    __pyx_t_6.axis = __pyx_int_1;
    __pyx_t_2 = __pyx_f_4libs_7network_logsumexp(((PyArrayObject *)__pyx_t_3), &__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_logadd, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "libs/network.pyx":348
 *             # sum by rows
 *             logadd = logsumexp(delta[token - 1] + transitions, 1)
 *             delta[token] += logadd             # <<<<<<<<<<<<<<
 * 
 *         return delta
 */
    __Pyx_INCREF(__pyx_v_token);
    __pyx_t_2 = __pyx_v_token;
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_delta, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_logadd); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 348, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_delta, __pyx_t_2, __pyx_t_7) < 0)) __PYX_ERR(0, 348, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "libs/network.pyx":345
 *         transitions = self.transitions[:-1].T # A_k,i
 * 
 *         for token in xrange(1, len(delta)):             # <<<<<<<<<<<<<<
 *             # sum by rows
 *             logadd = logsumexp(delta[token - 1] + transitions, 1)
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "libs/network.pyx":350
 *             delta[token] += logadd
 * 
 *         return delta             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_delta);
  __pyx_r = __pyx_v_delta;
  goto __pyx_L0;

  /* "libs/network.pyx":323
 *         return scores
 * 
 *     def _calculate_delta(self, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates a matrix with the scores for all possible paths at all given
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.Network._calculate_delta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_delta);
  __Pyx_XDECREF(__pyx_v_transitions);
  __Pyx_XDECREF(__pyx_v_token);
  __Pyx_XDECREF(__pyx_v_logadd);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":353
 * 
 *     @cython.boundscheck(False)
 *     def _calculate_gradients_sll(self, tags, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the output and transition deltas for each token, using Sentence Level Likelihood.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_15_calculate_gradients_sll(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_14_calculate_gradients_sll[] = "Network._calculate_gradients_sll(self, tags, scores)\n\n        Calculates the output and transition deltas for each token, using Sentence Level Likelihood.\n        The aim is to minimize the cost:\n        C(theta,A) = logadd(scores for all possible paths) - score(correct path)\n        \n        :returns: if True, normal gradient calculation was performed.\n            If False, the error was too low and weight correction should be\n            skipped.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_15_calculate_gradients_sll(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tags = 0;
  PyObject *__pyx_v_scores = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_gradients_sll (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tags,&__pyx_n_s_scores,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_scores)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_calculate_gradients_sll", 1, 2, 2, 1); __PYX_ERR(0, 353, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_calculate_gradients_sll") < 0)) __PYX_ERR(0, 353, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_tags = values[0];
    __pyx_v_scores = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_calculate_gradients_sll", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 353, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network._calculate_gradients_sll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_7Network_14_calculate_gradients_sll(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), __pyx_v_tags, __pyx_v_scores);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_14_calculate_gradients_sll(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_tags, PyObject *__pyx_v_scores) {
  PyArrayObject *__pyx_v_delta = 0;
  PyArrayObject *__pyx_v_delta_softmax = 0;
  PyObject *__pyx_v_correct_path_score = NULL;
  PyObject *__pyx_v_last_tag = NULL;
  PyObject *__pyx_v_tag = NULL;
  PyObject *__pyx_v_net_scores = NULL;
  PyObject *__pyx_v_trans = NULL;
  PyObject *__pyx_v_error = NULL;
  PyObject *__pyx_v_sumlogadd = NULL;
  PyObject *__pyx_v_transitions_t = NULL;
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_v_path_scores = NULL;
  PyObject *__pyx_v_log_sum_scores = NULL;
  PyObject *__pyx_v_grad_times_softmax = NULL;
  PyObject *__pyx_v_token = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_delta;
  __Pyx_Buffer __pyx_pybuffer_delta;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_delta_softmax;
  __Pyx_Buffer __pyx_pybuffer_delta_softmax;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  int __pyx_t_9;
  PyArrayObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  float __pyx_t_18;
  struct __pyx_opt_args_4libs_7network_logsumexp __pyx_t_19;
  PyArrayObject *__pyx_t_20 = NULL;
  PyArrayObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  int __pyx_t_23;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculate_gradients_sll", 0);
  __Pyx_TraceCall("_calculate_gradients_sll", __pyx_f[0], 353, 0, __PYX_ERR(0, 353, __pyx_L1_error));
  __pyx_pybuffer_delta.pybuffer.buf = NULL;
  __pyx_pybuffer_delta.refcount = 0;
  __pyx_pybuffernd_delta.data = NULL;
  __pyx_pybuffernd_delta.rcbuffer = &__pyx_pybuffer_delta;
  __pyx_pybuffer_delta_softmax.pybuffer.buf = NULL;
  __pyx_pybuffer_delta_softmax.refcount = 0;
  __pyx_pybuffernd_delta_softmax.data = NULL;
  __pyx_pybuffernd_delta_softmax.rcbuffer = &__pyx_pybuffer_delta_softmax;

  /* "libs/network.pyx":368
 *         # ftheta_i,t = network output for i-th tag, at t-th word
 *         # s = Sum_i(A_tags[i-1],tags[i] + ftheta_i,i), i < len(sentence)   (12)
 *         correct_path_score = 0             # <<<<<<<<<<<<<<
 *         last_tag = self.output_size
 *         for tag, net_scores in zip(tags[:-2], scores[:-2]):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_correct_path_score = __pyx_int_0;

  /* "libs/network.pyx":369
 *         # s = Sum_i(A_tags[i-1],tags[i] + ftheta_i,i), i < len(sentence)   (12)
 *         correct_path_score = 0
 *         last_tag = self.output_size             # <<<<<<<<<<<<<<
 *         for tag, net_scores in zip(tags[:-2], scores[:-2]):
 *             #print(tags, last_tag, tag, self.transitions)
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->output_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_last_tag = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":370
 *         correct_path_score = 0
 *         last_tag = self.output_size
 *         for tag, net_scores in zip(tags[:-2], scores[:-2]):             # <<<<<<<<<<<<<<
 *             #print(tags, last_tag, tag, self.transitions)
 *             trans = 0 if self.transitions is None else self.transitions[last_tag, tag]
 */
  __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_tags, 0, -2L, NULL, NULL, &__pyx_slice__5, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_scores, 0, -2L, NULL, NULL, &__pyx_slice__5, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 370, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 370, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 370, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 370, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 370, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 370, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 370, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_tag, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_net_scores, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "libs/network.pyx":372
 *         for tag, net_scores in zip(tags[:-2], scores[:-2]):
 *             #print(tags, last_tag, tag, self.transitions)
 *             trans = 0 if self.transitions is None else self.transitions[last_tag, tag]             # <<<<<<<<<<<<<<
 *             #print ('trans:',trans)
 *             #print ('net:',tag, net_scores[tag])
 */
    __pyx_t_9 = (((PyObject *)__pyx_v_self->transitions) == Py_None);
    if ((__pyx_t_9 != 0)) {
      __Pyx_INCREF(__pyx_int_0);
      __pyx_t_2 = __pyx_int_0;
    } else {
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 372, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_last_tag);
      __Pyx_GIVEREF(__pyx_v_last_tag);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_last_tag);
      __Pyx_INCREF(__pyx_v_tag);
      __Pyx_GIVEREF(__pyx_v_tag);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_tag);
      __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->transitions), __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 372, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_2 = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __Pyx_XDECREF_SET(__pyx_v_trans, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "libs/network.pyx":376
 *             #print ('net:',tag, net_scores[tag])
 *             #print
 *             correct_path_score += trans + net_scores[tag]             # <<<<<<<<<<<<<<
 *             last_tag = tag
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_net_scores, __pyx_v_tag); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Add(__pyx_v_trans, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_correct_path_score, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 376, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_correct_path_score, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "libs/network.pyx":377
 *             #print
 *             correct_path_score += trans + net_scores[tag]
 *             last_tag = tag             # <<<<<<<<<<<<<<
 * 
 *         # delta[t] = delta_t in equation (14)
 */
    __Pyx_INCREF(__pyx_v_tag);
    __Pyx_DECREF_SET(__pyx_v_last_tag, __pyx_v_tag);

    /* "libs/network.pyx":370
 *         correct_path_score = 0
 *         last_tag = self.output_size
 *         for tag, net_scores in zip(tags[:-2], scores[:-2]):             # <<<<<<<<<<<<<<
 *             #print(tags, last_tag, tag, self.transitions)
 *             trans = 0 if self.transitions is None else self.transitions[last_tag, tag]
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "libs/network.pyx":380
 * 
 *         # delta[t] = delta_t in equation (14)
 *         delta = self._calculate_delta(scores)             # <<<<<<<<<<<<<<
 *         # logadd_i(delta_T(i)) = log(Sum_i(exp(delta_T(i))))
 *         # Sentence-level Log-Likelihood (SLL)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_delta); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_scores) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_scores);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 380, __pyx_L1_error)
  __pyx_t_10 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_delta.rcbuffer->pybuffer);
    __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_delta.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_DOUBLE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_11 < 0)) {
      PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_delta.rcbuffer->pybuffer, (PyObject*)__pyx_v_delta, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_DOUBLE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      }
      __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0;
    }
    __pyx_pybuffernd_delta.diminfo[0].strides = __pyx_pybuffernd_delta.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_delta.diminfo[0].shape = __pyx_pybuffernd_delta.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_delta.diminfo[1].strides = __pyx_pybuffernd_delta.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_delta.diminfo[1].shape = __pyx_pybuffernd_delta.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 380, __pyx_L1_error)
  }
  __pyx_t_10 = 0;
  __pyx_v_delta = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":386
 *         #print ': ', np.log(np.sum(np.exp(delta[-1])))
 *         #print '> ', correct_path_score
 *         error = np.log(np.sum(np.exp(delta[-1]))) - correct_path_score             # <<<<<<<<<<<<<<
 *         #print error
 *         #error = logsumexp(delta[-1]) - correct_path_score
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_sum); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_exp); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = __Pyx_GetItemInt(((PyObject *)__pyx_v_delta), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_17 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16);
    if (likely(__pyx_t_17)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
      __Pyx_INCREF(__pyx_t_17);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_16, function);
    }
  }
  __pyx_t_6 = (__pyx_t_17) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_17, __pyx_t_15) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __pyx_t_16 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_2 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_16, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(__pyx_t_3, __pyx_v_correct_path_score); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_error = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":389
 *         #print error
 *         #error = logsumexp(delta[-1]) - correct_path_score
 *         self.error += error             # <<<<<<<<<<<<<<
 * 
 *         # if the error is too low, don't bother training (saves time and avoids
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_v_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_18 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_18 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 389, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->error = __pyx_t_18;

  /* "libs/network.pyx":397
 *         # error 0.22 -> 80%
 *         # error 0.1  -> 90%
 *         if error <= 0.01:             # <<<<<<<<<<<<<<
 *             self.skips += 1
 *             return False
 */
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_error, __pyx_float_0_01, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 397, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_9) {

    /* "libs/network.pyx":398
 *         # error 0.1  -> 90%
 *         if error <= 0.01:
 *             self.skips += 1             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_v_self->skips = (__pyx_v_self->skips + 1);

    /* "libs/network.pyx":399
 *         if error <= 0.01:
 *             self.skips += 1
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         # initialize gradients
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "libs/network.pyx":397
 *         # error 0.22 -> 80%
 *         # error 0.1  -> 90%
 *         if error <= 0.01:             # <<<<<<<<<<<<<<
 *             self.skips += 1
 *             return False
 */
  }

  /* "libs/network.pyx":403
 *         # initialize gradients
 *         # dC / dftheta
 *         self.net_gradients = np.zeros((len(tags), self.output_size))             # <<<<<<<<<<<<<<
 *         # dC / dA
 *         #self.trans_gradients = np.zeros_like(self.transitions, float)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = PyObject_Length(__pyx_v_tags); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 403, __pyx_L1_error)
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->output_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 403, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->net_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->net_gradients));
  __pyx_v_self->net_gradients = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":406
 *         # dC / dA
 *         #self.trans_gradients = np.zeros_like(self.transitions, float)
 *         self.trans_gradients = np.zeros_like(self.transitions, np.float64)             # <<<<<<<<<<<<<<
 * 
 *         # things get nasty from here
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_self->transitions), __pyx_t_7};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, ((PyObject *)__pyx_v_self->transitions), __pyx_t_7};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self->transitions));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->transitions));
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_11, ((PyObject *)__pyx_v_self->transitions));
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_11, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->trans_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->trans_gradients));
  __pyx_v_self->trans_gradients = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":418
 *         # delta_T(i) - logsumexp(delta_T(k))
 *         # dC_logadd / ddelta_T(i) = e(delta_T(i) - logsumexp(delta_T(k)))
 *         sumlogadd = logsumexp(delta[-1])             # <<<<<<<<<<<<<<
 *         # negative gradients
 *         self.net_gradients[-1] = -np.exp(delta[-1] - sumlogadd)
 */
  __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_delta), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 418, __pyx_L1_error)
  __pyx_t_6 = __pyx_f_4libs_7network_logsumexp(((PyArrayObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_sumlogadd = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "libs/network.pyx":420
 *         sumlogadd = logsumexp(delta[-1])
 *         # negative gradients
 *         self.net_gradients[-1] = -np.exp(delta[-1] - sumlogadd)             # <<<<<<<<<<<<<<
 * 
 *         transitions_t = 0 if self.transitions is None else self.transitions[:-1].T
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_exp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_delta), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyNumber_Subtract(__pyx_t_3, __pyx_v_sumlogadd); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_6 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Negative(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_self->net_gradients), -1L, __pyx_t_1, long, 1, __Pyx_PyInt_From_long, 0, 1, 0) < 0)) __PYX_ERR(0, 420, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":422
 *         self.net_gradients[-1] = -np.exp(delta[-1] - sumlogadd)
 * 
 *         transitions_t = 0 if self.transitions is None else self.transitions[:-1].T             # <<<<<<<<<<<<<<
 * 
 *         # delta[i][j]: sum of scores of all path that assign tag j to ith-token
 */
  __pyx_t_9 = (((PyObject *)__pyx_v_self->transitions) == Py_None);
  if ((__pyx_t_9 != 0)) {
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->transitions), 0, -1L, NULL, NULL, &__pyx_slice__4, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_T); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 422, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_1 = __pyx_t_7;
    __pyx_t_7 = 0;
  }
  __pyx_v_transitions_t = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":427
 * 
 *         # now compute the gradients for the other tokens, from last to first
 *         for t in range(len(scores) - 2, -1, -1):             # <<<<<<<<<<<<<<
 * 
 *             # sum the scores for all paths ending with each tag i at token t
 */
  __pyx_t_4 = PyObject_Length(__pyx_v_scores); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 427, __pyx_L1_error)
  __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_4 - 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_neg_1);
  __Pyx_INCREF(__pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_neg_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
    __pyx_t_7 = __pyx_t_1; __Pyx_INCREF(__pyx_t_7); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 427, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 427, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_7))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 427, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 427, __pyx_L1_error)
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        #endif
      }
    } else {
      __pyx_t_1 = __pyx_t_5(__pyx_t_7);
      if (unlikely(!__pyx_t_1)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 427, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "libs/network.pyx":433
 *             # Obtained by transposing twice
 *             # [delta_t-1(i)+A_j,i]T
 *             path_scores = (delta[t] + transitions_t).T             # <<<<<<<<<<<<<<
 * 
 *             # normalize over all possible tag paths using a softmax,
 */
    __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_delta), __pyx_v_t); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_v_transitions_t); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 433, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_path_scores, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "libs/network.pyx":438
 *             # computed using log.
 *             # the log of the sums of exps, summed by column
 *             log_sum_scores = logsumexp(path_scores, 0)             # <<<<<<<<<<<<<<
 * 
 *             # softmax is the division of an exponential by the sum of all exponentials
 */
    if (!(likely(((__pyx_v_path_scores) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_path_scores, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 438, __pyx_L1_error)
    __pyx_t_19.__pyx_n = 1;
    __pyx_t_19.axis = __pyx_int_0;
    __pyx_t_1 = __pyx_f_4libs_7network_logsumexp(((PyArrayObject *)__pyx_v_path_scores), &__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_log_sum_scores, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "libs/network.pyx":443
 *             # (yields a probability)
 *             # e(delta_t-1(i)+A_i,j) / Sum_k e(delta_t-1(k)+A_k,j)
 *             delta_softmax = np.exp(path_scores - log_sum_scores)             # <<<<<<<<<<<<<<
 * 
 *             # multiply each value in the softmax by the gradient at the next tag
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 443, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_exp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 443, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Subtract(__pyx_v_path_scores, __pyx_v_log_sum_scores); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 443, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 443, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 443, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer);
      __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_DOUBLE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_11 < 0)) {
        PyErr_Fetch(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer, (PyObject*)__pyx_v_delta_softmax, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_DOUBLE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_14, __pyx_t_13, __pyx_t_12);
        }
        __pyx_t_14 = __pyx_t_13 = __pyx_t_12 = 0;
      }
      __pyx_pybuffernd_delta_softmax.diminfo[0].strides = __pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_delta_softmax.diminfo[0].shape = __pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_delta_softmax.diminfo[1].strides = __pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_delta_softmax.diminfo[1].shape = __pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 443, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __Pyx_XDECREF_SET(__pyx_v_delta_softmax, ((PyArrayObject *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "libs/network.pyx":448
 *             # dC_logadd / ddelta_t(i) * delta_softmax
 *             # Attardi: negative since net_gradients[t + 1] already negative
 *             grad_times_softmax = self.net_gradients[t + 1] * delta_softmax             # <<<<<<<<<<<<<<
 *             # dC / dA_i,j
 *             self.trans_gradients[:-1, :] += grad_times_softmax
 */
    __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_t, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->net_gradients), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_3, ((PyObject *)__pyx_v_delta_softmax)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_grad_times_softmax, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "libs/network.pyx":450
 *             grad_times_softmax = self.net_gradients[t + 1] * delta_softmax
 *             # dC / dA_i,j
 *             self.trans_gradients[:-1, :] += grad_times_softmax             # <<<<<<<<<<<<<<
 * 
 *             # sum all transition gradients by row to find the network gradients
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self->trans_gradients));
    __pyx_t_21 = __pyx_v_self->trans_gradients;
    __Pyx_INCREF(__pyx_tuple__6);
    __pyx_t_22 = __pyx_tuple__6;
    __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_t_21), __pyx_t_22); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_v_grad_times_softmax); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_t_21), __pyx_t_22, __pyx_t_3) < 0)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_21)); __pyx_t_21 = 0;

    /* "libs/network.pyx":455
 *             # Sum_j(dC_logadd / ddelta_t(j) * delta_softmax)
 *             # Attardi: negative since grad_times_softmax already negative
 *             self.net_gradients[t] = np.sum(grad_times_softmax, 1)             # <<<<<<<<<<<<<<
 * 
 *         # find the gradients for the starting transition
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sum); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_grad_times_softmax, __pyx_int_1};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_grad_times_softmax, __pyx_int_1};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 455, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(__pyx_v_grad_times_softmax);
      __Pyx_GIVEREF(__pyx_v_grad_times_softmax);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_11, __pyx_v_grad_times_softmax);
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_11, __pyx_int_1);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->net_gradients), __pyx_v_t, __pyx_t_3) < 0)) __PYX_ERR(0, 455, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libs/network.pyx":427
 * 
 *         # now compute the gradients for the other tokens, from last to first
 *         for t in range(len(scores) - 2, -1, -1):             # <<<<<<<<<<<<<<
 * 
 *             # sum the scores for all paths ending with each tag i at token t
 */
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "libs/network.pyx":459
 *         # find the gradients for the starting transition
 *         # there is only one possibility to come from, which is the sentence start
 *         self.trans_gradients[-1] = self.net_gradients[0]             # <<<<<<<<<<<<<<
 * 
 *         # now, add +1 to the correct path
 */
  __pyx_t_7 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->net_gradients), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 459, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_self->trans_gradients), -1L, __pyx_t_7, long, 1, __Pyx_PyInt_From_long, 0, 1, 0) < 0)) __PYX_ERR(0, 459, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "libs/network.pyx":462
 * 
 *         # now, add +1 to the correct path
 *         last_tag = self.output_size             # <<<<<<<<<<<<<<
 *         for token, tag in enumerate(tags):
 *             self.net_gradients[token][tag] += 1 # negative gradient
 */
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->output_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF_SET(__pyx_v_last_tag, __pyx_t_7);
  __pyx_t_7 = 0;

  /* "libs/network.pyx":463
 *         # now, add +1 to the correct path
 *         last_tag = self.output_size
 *         for token, tag in enumerate(tags):             # <<<<<<<<<<<<<<
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             if self.transitions is not None:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_7 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_tags)) || PyTuple_CheckExact(__pyx_v_tags)) {
    __pyx_t_3 = __pyx_v_tags; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_tags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 463, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 463, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 463, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 463, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 463, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 463, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_5(__pyx_t_3);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 463, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_tag, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_XDECREF_SET(__pyx_v_token, __pyx_t_7);
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_7, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 463, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7);
    __pyx_t_7 = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "libs/network.pyx":464
 *         last_tag = self.output_size
 *         for token, tag in enumerate(tags):
 *             self.net_gradients[token][tag] += 1 # negative gradient             # <<<<<<<<<<<<<<
 *             if self.transitions is not None:
 *                 self.trans_gradients[last_tag][tag] += 1 # negative gradient
 */
    __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->net_gradients), __pyx_v_token); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_v_tag);
    __pyx_t_2 = __pyx_v_tag;
    __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_16 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_2, __pyx_t_16) < 0)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libs/network.pyx":465
 *         for token, tag in enumerate(tags):
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             if self.transitions is not None:             # <<<<<<<<<<<<<<
 *                 self.trans_gradients[last_tag][tag] += 1 # negative gradient
 *             last_tag = tag
 */
    __pyx_t_9 = (((PyObject *)__pyx_v_self->transitions) != Py_None);
    __pyx_t_23 = (__pyx_t_9 != 0);
    if (__pyx_t_23) {

      /* "libs/network.pyx":466
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             if self.transitions is not None:
 *                 self.trans_gradients[last_tag][tag] += 1 # negative gradient             # <<<<<<<<<<<<<<
 *             last_tag = tag
 * 
 */
      __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->trans_gradients), __pyx_v_last_tag); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_tag);
      __pyx_t_2 = __pyx_v_tag;
      __pyx_t_16 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_16, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      if (unlikely(PyObject_SetItem(__pyx_t_6, __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(0, 466, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "libs/network.pyx":465
 *         for token, tag in enumerate(tags):
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             if self.transitions is not None:             # <<<<<<<<<<<<<<
 *                 self.trans_gradients[last_tag][tag] += 1 # negative gradient
 *             last_tag = tag
 */
    }

    /* "libs/network.pyx":467
 *             if self.transitions is not None:
 *                 self.trans_gradients[last_tag][tag] += 1 # negative gradient
 *             last_tag = tag             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
    __Pyx_INCREF(__pyx_v_tag);
    __Pyx_DECREF_SET(__pyx_v_last_tag, __pyx_v_tag);

    /* "libs/network.pyx":463
 *         # now, add +1 to the correct path
 *         last_tag = self.output_size
 *         for token, tag in enumerate(tags):             # <<<<<<<<<<<<<<
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             if self.transitions is not None:
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "libs/network.pyx":469
 *             last_tag = tag
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  /* "libs/network.pyx":353
 * 
 *     @cython.boundscheck(False)
 *     def _calculate_gradients_sll(self, tags, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the output and transition deltas for each token, using Sentence Level Likelihood.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(((PyObject *)__pyx_t_21));
  __Pyx_XDECREF(__pyx_t_22);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_delta.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.Network._calculate_gradients_sll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_delta.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_delta_softmax.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_delta);
  __Pyx_XDECREF((PyObject *)__pyx_v_delta_softmax);
  __Pyx_XDECREF(__pyx_v_correct_path_score);
  __Pyx_XDECREF(__pyx_v_last_tag);
  __Pyx_XDECREF(__pyx_v_tag);
  __Pyx_XDECREF(__pyx_v_net_scores);
  __Pyx_XDECREF(__pyx_v_trans);
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_XDECREF(__pyx_v_sumlogadd);
  __Pyx_XDECREF(__pyx_v_transitions_t);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_path_scores);
  __Pyx_XDECREF(__pyx_v_log_sum_scores);
  __Pyx_XDECREF(__pyx_v_grad_times_softmax);
  __Pyx_XDECREF(__pyx_v_token);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":472
 * 
 *     @cython.boundscheck(False)
 *     def _calculate_gradients_wll(self, tags, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the output for each token, using Word Level Likelihood.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_17_calculate_gradients_wll(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_16_calculate_gradients_wll[] = "Network._calculate_gradients_wll(self, tags, scores)\n\n        Calculates the output for each token, using Word Level Likelihood.\n        The aim is to minimize the word-level log-likelihood:\n        C(ftheta) = logadd_j(ftheta_j) - ftheta_y,\n        where y is the sequence of correct tags\n        \n        :returns: if True, normal gradient calculation was performed.\n            If False, the error was too low and weight correction should be\n            skipped.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_17_calculate_gradients_wll(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tags = 0;
  PyObject *__pyx_v_scores = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_gradients_wll (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tags,&__pyx_n_s_scores,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_scores)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_calculate_gradients_wll", 1, 2, 2, 1); __PYX_ERR(0, 472, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_calculate_gradients_wll") < 0)) __PYX_ERR(0, 472, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_tags = values[0];
    __pyx_v_scores = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_calculate_gradients_wll", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 472, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network._calculate_gradients_wll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_7Network_16_calculate_gradients_wll(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), __pyx_v_tags, __pyx_v_scores);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_16_calculate_gradients_wll(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_tags, PyObject *__pyx_v_scores) {
  PyObject *__pyx_v_exponentials = NULL;
  PyObject *__pyx_v_correct_path_score = NULL;
  PyObject *__pyx_v_token = NULL;
  PyObject *__pyx_v_tag = NULL;
  PyObject *__pyx_v_net_scores = NULL;
  PyObject *__pyx_v_error = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  float __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculate_gradients_wll", 0);
  __Pyx_TraceCall("_calculate_gradients_wll", __pyx_f[0], 472, 0, __PYX_ERR(0, 472, __pyx_L1_error));

  /* "libs/network.pyx":485
 *         # compute the negative gradient with respect to ftheta
 *         # dC / dftheta_i = e(ftheta_i)/Sum_k(e(ftheta_k))
 *         exponentials = np.exp(scores)             # <<<<<<<<<<<<<<
 *         # FIXME: use logsumexp
 *         # ((len(sentence), self.output_size))
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_exp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_scores) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_scores);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 485, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_exponentials = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":488
 *         # FIXME: use logsumexp
 *         # ((len(sentence), self.output_size))
 *         self.net_gradients = -(exponentials.T / exponentials.sum(1)).T             # <<<<<<<<<<<<<<
 * 
 *         # correct path and its gradient
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_exponentials, __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_exponentials, __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_int_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_int_1);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_T); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Negative(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 488, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->net_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->net_gradients));
  __pyx_v_self->net_gradients = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":491
 * 
 *         # correct path and its gradient
 *         correct_path_score = 0             # <<<<<<<<<<<<<<
 *         token = 0
 *         for tag, net_scores in zip(tags, scores):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_correct_path_score = __pyx_int_0;

  /* "libs/network.pyx":492
 *         # correct path and its gradient
 *         correct_path_score = 0
 *         token = 0             # <<<<<<<<<<<<<<
 *         for tag, net_scores in zip(tags, scores):
 *             self.net_gradients[token][tag] += 1 # negative gradient
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_token = __pyx_int_0;

  /* "libs/network.pyx":493
 *         correct_path_score = 0
 *         token = 0
 *         for tag, net_scores in zip(tags, scores):             # <<<<<<<<<<<<<<
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             token += 1
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_tags);
  __Pyx_GIVEREF(__pyx_v_tags);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_tags);
  __Pyx_INCREF(__pyx_v_scores);
  __Pyx_GIVEREF(__pyx_v_scores);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_scores);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 493, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 493, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 493, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 493, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 493, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 493, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 493, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 493, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 493, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 493, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 493, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 493, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      index = 1; __pyx_t_4 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 493, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 493, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_tag, __pyx_t_1);
    __pyx_t_1 = 0;
    __Pyx_XDECREF_SET(__pyx_v_net_scores, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "libs/network.pyx":494
 *         token = 0
 *         for tag, net_scores in zip(tags, scores):
 *             self.net_gradients[token][tag] += 1 # negative gradient             # <<<<<<<<<<<<<<
 *             token += 1
 *             correct_path_score += net_scores[tag]
 */
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->net_gradients), __pyx_v_token); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_tag);
    __pyx_t_4 = __pyx_v_tag;
    __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 494, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(PyObject_SetItem(__pyx_t_3, __pyx_t_4, __pyx_t_7) < 0)) __PYX_ERR(0, 494, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libs/network.pyx":495
 *         for tag, net_scores in zip(tags, scores):
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             token += 1             # <<<<<<<<<<<<<<
 *             correct_path_score += net_scores[tag]
 * 
 */
    __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_token, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_token, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "libs/network.pyx":496
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             token += 1
 *             correct_path_score += net_scores[tag]             # <<<<<<<<<<<<<<
 * 
 *         # C(ftheta) = logadd_j(ftheta_j) - score(correct path)
 */
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_net_scores, __pyx_v_tag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_correct_path_score, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF_SET(__pyx_v_correct_path_score, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "libs/network.pyx":493
 *         correct_path_score = 0
 *         token = 0
 *         for tag, net_scores in zip(tags, scores):             # <<<<<<<<<<<<<<
 *             self.net_gradients[token][tag] += 1 # negative gradient
 *             token += 1
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libs/network.pyx":500
 *         # C(ftheta) = logadd_j(ftheta_j) - score(correct path)
 *         #error = np.log(np.sum(np.exp(scores))) - correct_path_score
 *         error = logsumexp(scores) - correct_path_score             # <<<<<<<<<<<<<<
 *         # approximate
 *         #error = np.max(scores) - correct_path_score
 */
  if (!(likely(((__pyx_v_scores) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_scores, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 500, __pyx_L1_error)
  __pyx_t_2 = __pyx_f_4libs_7network_logsumexp(((PyArrayObject *)__pyx_v_scores), NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyNumber_Subtract(__pyx_t_2, __pyx_v_correct_path_score); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 500, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_error = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "libs/network.pyx":503
 *         # approximate
 *         #error = np.max(scores) - correct_path_score
 *         self.error += error             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_v_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 503, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 503, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->error = __pyx_t_9;

  /* "libs/network.pyx":505
 *         self.error += error
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  /* "libs/network.pyx":472
 * 
 *     @cython.boundscheck(False)
 *     def _calculate_gradients_wll(self, tags, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the output for each token, using Word Level Likelihood.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.Network._calculate_gradients_wll", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_exponentials);
  __Pyx_XDECREF(__pyx_v_correct_path_score);
  __Pyx_XDECREF(__pyx_v_token);
  __Pyx_XDECREF(__pyx_v_tag);
  __Pyx_XDECREF(__pyx_v_net_scores);
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":508
 * 
 *     @cython.boundscheck(False)
 *     def _viterbi(self, np.ndarray[FLOAT_t, ndim=2] scores):             # <<<<<<<<<<<<<<
 *         """
 *         Performs a Viterbi search over the scores for each tag using
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_19_viterbi(PyObject *__pyx_v_self, PyObject *__pyx_v_scores); /*proto*/
static char __pyx_doc_4libs_7network_7Network_18_viterbi[] = "Network._viterbi(self, ndarray scores)\n\n        Performs a Viterbi search over the scores for each tag using\n        the transitions matrix. If a matrix wasn't supplied, \n        it will return the tags with the highest scores individually.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_19_viterbi(PyObject *__pyx_v_self, PyObject *__pyx_v_scores) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_viterbi (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_scores), __pyx_ptype_5numpy_ndarray, 1, "scores", 0))) __PYX_ERR(0, 508, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_18_viterbi(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyArrayObject *)__pyx_v_scores));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_18_viterbi(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyArrayObject *__pyx_v_scores) {
  PyObject *__pyx_v_path_scores = NULL;
  PyObject *__pyx_v_path_backtrack = NULL;
  PyObject *__pyx_v_output_range = NULL;
  PyObject *__pyx_v_transitions = NULL;
  int __pyx_v_i;
  PyObject *__pyx_v_prev_score_and_trans = NULL;
  PyObject *__pyx_v_answer = NULL;
  PyObject *__pyx_v_previous_tag = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_scores;
  __Pyx_Buffer __pyx_pybuffer_scores;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  long __pyx_t_11;
  float __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_viterbi", 0);
  __Pyx_TraceCall("_viterbi", __pyx_f[0], 508, 0, __PYX_ERR(0, 508, __pyx_L1_error));
  __pyx_pybuffer_scores.pybuffer.buf = NULL;
  __pyx_pybuffer_scores.refcount = 0;
  __pyx_pybuffernd_scores.data = NULL;
  __pyx_pybuffernd_scores.rcbuffer = &__pyx_pybuffer_scores;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_scores.rcbuffer->pybuffer, (PyObject*)__pyx_v_scores, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 508, __pyx_L1_error)
  }
  __pyx_pybuffernd_scores.diminfo[0].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_scores.diminfo[0].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_scores.diminfo[1].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_scores.diminfo[1].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[1];

  /* "libs/network.pyx":515
 *         """
 *         # pretty straightforward
 *         if self.transitions is None or len(scores) == 1:             # <<<<<<<<<<<<<<
 *             return scores.argmax(1)
 * 
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_self->transitions) == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_scores)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 515, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_4 == 1) != 0);
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "libs/network.pyx":516
 *         # pretty straightforward
 *         if self.transitions is None or len(scores) == 1:
 *             return scores.argmax(1)             # <<<<<<<<<<<<<<
 * 
 *         path_scores = np.empty_like(scores)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_scores), __pyx_n_s_argmax); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_int_1) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_int_1);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L0;

    /* "libs/network.pyx":515
 *         """
 *         # pretty straightforward
 *         if self.transitions is None or len(scores) == 1:             # <<<<<<<<<<<<<<
 *             return scores.argmax(1)
 * 
 */
  }

  /* "libs/network.pyx":518
 *             return scores.argmax(1)
 * 
 *         path_scores = np.empty_like(scores)             # <<<<<<<<<<<<<<
 *         #path_backtrack = np.empty_like(scores, np.int64)
 *         path_backtrack = np.empty_like(scores, int)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty_like); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_5 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_6, ((PyObject *)__pyx_v_scores)) : __Pyx_PyObject_CallOneArg(__pyx_t_7, ((PyObject *)__pyx_v_scores));
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_path_scores = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "libs/network.pyx":520
 *         path_scores = np.empty_like(scores)
 *         #path_backtrack = np.empty_like(scores, np.int64)
 *         path_backtrack = np.empty_like(scores, int)             # <<<<<<<<<<<<<<
 * 
 *         # now the actual Viterbi algorithm
 */
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 520, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_empty_like); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 520, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_scores), ((PyObject *)(&PyInt_Type))};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 520, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_scores), ((PyObject *)(&PyInt_Type))};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 520, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else
  #endif
  {
    __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 520, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_scores));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_scores));
    PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, ((PyObject *)__pyx_v_scores));
    __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
    PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, ((PyObject *)(&PyInt_Type)));
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 520, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_path_backtrack = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "libs/network.pyx":525
 *         # first, get the scores for each tag at token 0
 *         # the last row of the transitions table has the scores for the first tag
 *         path_scores[0] = scores[0] + self.transitions[-1]             # <<<<<<<<<<<<<<
 * 
 *         output_range = np.arange(self.output_size) # outside loop. Attardi
 */
  __pyx_t_5 = __Pyx_GetItemInt(((PyObject *)__pyx_v_scores), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->transitions), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = PyNumber_Add(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(__Pyx_SetItemInt(__pyx_v_path_scores, 0, __pyx_t_9, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 525, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

  /* "libs/network.pyx":527
 *         path_scores[0] = scores[0] + self.transitions[-1]
 * 
 *         output_range = np.arange(self.output_size) # outside loop. Attardi             # <<<<<<<<<<<<<<
 *         transitions = self.transitions[:-1]        # idem
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_self->output_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_9 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_output_range = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "libs/network.pyx":528
 * 
 *         output_range = np.arange(self.output_size) # outside loop. Attardi
 *         transitions = self.transitions[:-1]        # idem             # <<<<<<<<<<<<<<
 * 
 *         cdef int i
 */
  __pyx_t_9 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->transitions), 0, -1L, NULL, NULL, &__pyx_slice__4, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_v_transitions = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "libs/network.pyx":531
 * 
 *         cdef int i
 *         for i in xrange(1, len(scores)):             # <<<<<<<<<<<<<<
 * 
 *             # each line contains the score until each tag t plus the transition to each other tag t'
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_scores)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 531, __pyx_L1_error)
  __pyx_t_10 = __pyx_t_4;
  for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_10; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "libs/network.pyx":534
 * 
 *             # each line contains the score until each tag t plus the transition to each other tag t'
 *             prev_score_and_trans = (path_scores[i - 1] + transitions.T).T             # <<<<<<<<<<<<<<
 * 
 *             # find the previous tag that yielded the max score
 */
    __pyx_t_11 = (__pyx_v_i - 1);
    __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_path_scores, __pyx_t_11, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_transitions, __pyx_n_s_T); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyNumber_Add(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_T); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_prev_score_and_trans, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "libs/network.pyx":537
 * 
 *             # find the previous tag that yielded the max score
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)             # <<<<<<<<<<<<<<
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],
 *                                                   output_range] + scores[i]
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_prev_score_and_trans, __pyx_n_s_argmax); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 537, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_5 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_9, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_int_0);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 537, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(__Pyx_SetItemInt(__pyx_v_path_backtrack, __pyx_v_i, __pyx_t_5, int, 1, __Pyx_PyInt_From_int, 0, 1, 0) < 0)) __PYX_ERR(0, 537, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "libs/network.pyx":538
 *             # find the previous tag that yielded the max score
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],             # <<<<<<<<<<<<<<
 *                                                   output_range] + scores[i]
 * 
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_path_backtrack, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);

    /* "libs/network.pyx":539
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],
 *                                                   output_range] + scores[i]             # <<<<<<<<<<<<<<
 * 
 *         # now find the maximum score for the last token and follow the backtrack
 */
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 538, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_output_range);
    __Pyx_GIVEREF(__pyx_v_output_range);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_output_range);
    __pyx_t_5 = 0;

    /* "libs/network.pyx":538
 *             # find the previous tag that yielded the max score
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],             # <<<<<<<<<<<<<<
 *                                                   output_range] + scores[i]
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_prev_score_and_trans, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libs/network.pyx":539
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],
 *                                                   output_range] + scores[i]             # <<<<<<<<<<<<<<
 * 
 *         # now find the maximum score for the last token and follow the backtrack
 */
    __pyx_t_6 = __Pyx_GetItemInt(((PyObject *)__pyx_v_scores), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 539, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyNumber_Add(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 539, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "libs/network.pyx":538
 *             # find the previous tag that yielded the max score
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],             # <<<<<<<<<<<<<<
 *                                                   output_range] + scores[i]
 * 
 */
    if (unlikely(__Pyx_SetItemInt(__pyx_v_path_scores, __pyx_v_i, __pyx_t_9, int, 1, __Pyx_PyInt_From_int, 0, 1, 0) < 0)) __PYX_ERR(0, 538, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  }

  /* "libs/network.pyx":543
 *         # now find the maximum score for the last token and follow the backtrack
 *         #answer = np.empty(len(scores), dtype=np.int64)
 *         answer = np.empty(len(scores), dtype=int)             # <<<<<<<<<<<<<<
 *         answer[-1] = path_scores[-1].argmax()
 *         self.answer_score = path_scores[-1][answer[-1]]
 */
  __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_scores)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 543, __pyx_L1_error)
  __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 543, __pyx_L1_error)
  __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_answer = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "libs/network.pyx":544
 *         #answer = np.empty(len(scores), dtype=np.int64)
 *         answer = np.empty(len(scores), dtype=int)
 *         answer[-1] = path_scores[-1].argmax()             # <<<<<<<<<<<<<<
 *         self.answer_score = path_scores[-1][answer[-1]]
 *         previous_tag = path_backtrack[-1][answer[-1]]
 */
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_path_scores, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_argmax); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(__Pyx_SetItemInt(__pyx_v_answer, -1L, __pyx_t_7, long, 1, __Pyx_PyInt_From_long, 0, 1, 0) < 0)) __PYX_ERR(0, 544, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "libs/network.pyx":545
 *         answer = np.empty(len(scores), dtype=int)
 *         answer[-1] = path_scores[-1].argmax()
 *         self.answer_score = path_scores[-1][answer[-1]]             # <<<<<<<<<<<<<<
 *         previous_tag = path_backtrack[-1][answer[-1]]
 * 
 */
  __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_path_scores, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_answer, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_self->answer_score = __pyx_t_12;

  /* "libs/network.pyx":546
 *         answer[-1] = path_scores[-1].argmax()
 *         self.answer_score = path_scores[-1][answer[-1]]
 *         previous_tag = path_backtrack[-1][answer[-1]]             # <<<<<<<<<<<<<<
 * 
 *         for i in range(len(scores) - 2, 0, -1):
 */
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_path_backtrack, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_answer, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_previous_tag = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "libs/network.pyx":548
 *         previous_tag = path_backtrack[-1][answer[-1]]
 * 
 *         for i in range(len(scores) - 2, 0, -1):             # <<<<<<<<<<<<<<
 *             answer[i] = previous_tag
 *             previous_tag = path_backtrack[i][previous_tag]
 */
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_scores)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 548, __pyx_L1_error)
  for (__pyx_t_8 = (__pyx_t_4 - 2); __pyx_t_8 > 0; __pyx_t_8-=1) {
    __pyx_v_i = __pyx_t_8;

    /* "libs/network.pyx":549
 * 
 *         for i in range(len(scores) - 2, 0, -1):
 *             answer[i] = previous_tag             # <<<<<<<<<<<<<<
 *             previous_tag = path_backtrack[i][previous_tag]
 * 
 */
    if (unlikely(__Pyx_SetItemInt(__pyx_v_answer, __pyx_v_i, __pyx_v_previous_tag, int, 1, __Pyx_PyInt_From_int, 0, 1, 0) < 0)) __PYX_ERR(0, 549, __pyx_L1_error)

    /* "libs/network.pyx":550
 *         for i in range(len(scores) - 2, 0, -1):
 *             answer[i] = previous_tag
 *             previous_tag = path_backtrack[i][previous_tag]             # <<<<<<<<<<<<<<
 * 
 *         answer[0] = previous_tag
 */
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_path_backtrack, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_v_previous_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_previous_tag, __pyx_t_5);
    __pyx_t_5 = 0;
  }

  /* "libs/network.pyx":552
 *             previous_tag = path_backtrack[i][previous_tag]
 * 
 *         answer[0] = previous_tag             # <<<<<<<<<<<<<<
 *         return answer
 * 
 */
  if (unlikely(__Pyx_SetItemInt(__pyx_v_answer, 0, __pyx_v_previous_tag, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 552, __pyx_L1_error)

  /* "libs/network.pyx":553
 * 
 *         answer[0] = previous_tag
 *         return answer             # <<<<<<<<<<<<<<
 * 
 *     def set_validation_data(self, list validation_sentences=None,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_answer);
  __pyx_r = __pyx_v_answer;
  goto __pyx_L0;

  /* "libs/network.pyx":508
 * 
 *     @cython.boundscheck(False)
 *     def _viterbi(self, np.ndarray[FLOAT_t, ndim=2] scores):             # <<<<<<<<<<<<<<
 *         """
 *         Performs a Viterbi search over the scores for each tag using
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.Network._viterbi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_path_scores);
  __Pyx_XDECREF(__pyx_v_path_backtrack);
  __Pyx_XDECREF(__pyx_v_output_range);
  __Pyx_XDECREF(__pyx_v_transitions);
  __Pyx_XDECREF(__pyx_v_prev_score_and_trans);
  __Pyx_XDECREF(__pyx_v_answer);
  __Pyx_XDECREF(__pyx_v_previous_tag);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":555
 *         return answer
 * 
 *     def set_validation_data(self, list validation_sentences=None,             # <<<<<<<<<<<<<<
 *                             list validation_tags=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_21set_validation_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_20set_validation_data[] = "Network.set_validation_data(self, list validation_sentences=None, list validation_tags=None)\n\n        Sets the data to be used during validation. If this function is not\n        called before training, the training data is used to measure performance.\n        \n        :param validation_sentences: sentences to be used in validation.\n        :param validation_tags: tags for the validation sentences.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_21set_validation_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_validation_sentences = 0;
  PyObject *__pyx_v_validation_tags = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_validation_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_validation_sentences,&__pyx_n_s_validation_tags,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject*)Py_None);

    /* "libs/network.pyx":556
 * 
 *     def set_validation_data(self, list validation_sentences=None,
 *                             list validation_tags=None):             # <<<<<<<<<<<<<<
 *         """
 *         Sets the data to be used during validation. If this function is not
 */
    values[1] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_validation_sentences);
          if (value) { values[0] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_validation_tags);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_validation_data") < 0)) __PYX_ERR(0, 555, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_validation_sentences = ((PyObject*)values[0]);
    __pyx_v_validation_tags = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_validation_data", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 555, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network.set_validation_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_validation_sentences), (&PyList_Type), 1, "validation_sentences", 1))) __PYX_ERR(0, 555, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_validation_tags), (&PyList_Type), 1, "validation_tags", 1))) __PYX_ERR(0, 556, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_20set_validation_data(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), __pyx_v_validation_sentences, __pyx_v_validation_tags);

  /* "libs/network.pyx":555
 *         return answer
 * 
 *     def set_validation_data(self, list validation_sentences=None,             # <<<<<<<<<<<<<<
 *                             list validation_tags=None):
 *         """
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_20set_validation_data(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_validation_sentences, PyObject *__pyx_v_validation_tags) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_validation_data", 0);
  __Pyx_TraceCall("set_validation_data", __pyx_f[0], 555, 0, __PYX_ERR(0, 555, __pyx_L1_error));

  /* "libs/network.pyx":564
 *         :param validation_tags: tags for the validation sentences.
 *         """
 *         self.validation_sentences = validation_sentences             # <<<<<<<<<<<<<<
 *         self.validation_tags = validation_tags
 * 
 */
  __Pyx_INCREF(__pyx_v_validation_sentences);
  __Pyx_GIVEREF(__pyx_v_validation_sentences);
  __Pyx_GOTREF(__pyx_v_self->validation_sentences);
  __Pyx_DECREF(__pyx_v_self->validation_sentences);
  __pyx_v_self->validation_sentences = __pyx_v_validation_sentences;

  /* "libs/network.pyx":565
 *         """
 *         self.validation_sentences = validation_sentences
 *         self.validation_tags = validation_tags             # <<<<<<<<<<<<<<
 * 
 *     def set_learning_rate_decay(self, float decay_factor=1.0):
 */
  __Pyx_INCREF(__pyx_v_validation_tags);
  __Pyx_GIVEREF(__pyx_v_validation_tags);
  __Pyx_GOTREF(__pyx_v_self->validation_tags);
  __Pyx_DECREF(__pyx_v_self->validation_tags);
  __pyx_v_self->validation_tags = __pyx_v_validation_tags;

  /* "libs/network.pyx":555
 *         return answer
 * 
 *     def set_validation_data(self, list validation_sentences=None,             # <<<<<<<<<<<<<<
 *                             list validation_tags=None):
 *         """
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.set_validation_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":567
 *         self.validation_tags = validation_tags
 * 
 *     def set_learning_rate_decay(self, float decay_factor=1.0):             # <<<<<<<<<<<<<<
 *         """
 *         Sets the network to use learning rate decay.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_23set_learning_rate_decay(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_22set_learning_rate_decay[] = "Network.set_learning_rate_decay(self, float decay_factor=1.0)\n\n        Sets the network to use learning rate decay. \n        \n        The learning rate at each iteration t is determined as:\n        initial_rate / (1 + t * decay_factor)\n        \n        with t starting from 0\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_23set_learning_rate_decay(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_decay_factor;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_learning_rate_decay (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_decay_factor,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_decay_factor);
          if (value) { values[0] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_learning_rate_decay") < 0)) __PYX_ERR(0, 567, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    if (values[0]) {
      __pyx_v_decay_factor = __pyx_PyFloat_AsFloat(values[0]); if (unlikely((__pyx_v_decay_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 567, __pyx_L3_error)
    } else {
      __pyx_v_decay_factor = ((float)1.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_learning_rate_decay", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 567, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network.set_learning_rate_decay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_7Network_22set_learning_rate_decay(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), __pyx_v_decay_factor);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_22set_learning_rate_decay(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, float __pyx_v_decay_factor) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_learning_rate_decay", 0);
  __Pyx_TraceCall("set_learning_rate_decay", __pyx_f[0], 567, 0, __PYX_ERR(0, 567, __pyx_L1_error));

  /* "libs/network.pyx":576
 *         with t starting from 0
 *         """
 *         self.use_learning_rate_decay = True             # <<<<<<<<<<<<<<
 *         self.decay_factor = decay_factor
 * 
 */
  __Pyx_INCREF(Py_True);
  __Pyx_GIVEREF(Py_True);
  __Pyx_GOTREF(__pyx_v_self->use_learning_rate_decay);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->use_learning_rate_decay));
  __pyx_v_self->use_learning_rate_decay = ((PyBoolObject *)Py_True);

  /* "libs/network.pyx":577
 *         """
 *         self.use_learning_rate_decay = True
 *         self.decay_factor = decay_factor             # <<<<<<<<<<<<<<
 * 
 *     def decrease_learning_rates(self, epoch):
 */
  __pyx_v_self->decay_factor = __pyx_v_decay_factor;

  /* "libs/network.pyx":567
 *         self.validation_tags = validation_tags
 * 
 *     def set_learning_rate_decay(self, float decay_factor=1.0):             # <<<<<<<<<<<<<<
 *         """
 *         Sets the network to use learning rate decay.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.set_learning_rate_decay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":579
 *         self.decay_factor = decay_factor
 * 
 *     def decrease_learning_rates(self, epoch):             # <<<<<<<<<<<<<<
 *         """
 *         Apply the learning rate decay, if the network was configured to use it.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_25decrease_learning_rates(PyObject *__pyx_v_self, PyObject *__pyx_v_epoch); /*proto*/
static char __pyx_doc_4libs_7network_7Network_24decrease_learning_rates[] = "Network.decrease_learning_rates(self, epoch)\n\n        Apply the learning rate decay, if the network was configured to use it.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_25decrease_learning_rates(PyObject *__pyx_v_self, PyObject *__pyx_v_epoch) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("decrease_learning_rates (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_24decrease_learning_rates(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_epoch));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_24decrease_learning_rates(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_epoch) {
  PyObject *__pyx_v_factor = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  float __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decrease_learning_rates", 0);
  __Pyx_TraceCall("decrease_learning_rates", __pyx_f[0], 579, 0, __PYX_ERR(0, 579, __pyx_L1_error));

  /* "libs/network.pyx":583
 *         Apply the learning rate decay, if the network was configured to use it.
 *         """
 *         if not self.use_learning_rate_decay or epoch == 0:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->use_learning_rate_decay)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 583, __pyx_L1_error)
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_v_epoch, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 583, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_1 = __pyx_t_3;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "libs/network.pyx":584
 *         """
 *         if not self.use_learning_rate_decay or epoch == 0:
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # multiplying the last rate by this adjustment is equivalent to
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "libs/network.pyx":583
 *         Apply the learning rate decay, if the network was configured to use it.
 *         """
 *         if not self.use_learning_rate_decay or epoch == 0:             # <<<<<<<<<<<<<<
 *             return
 * 
 */
  }

  /* "libs/network.pyx":589
 *         # initial_rate / (1 + t * decay_factor)
 *         # and we don't need to store the initial rates
 *         factor = (1.0 + (epoch - 1) * self.decay_factor) / (1 + epoch * self.decay_factor)             # <<<<<<<<<<<<<<
 *         self.learning_rate *= factor
 *         self.learning_rate_features *= factor
 */
  __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_epoch, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_self->decay_factor); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyNumber_Multiply(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyFloat_AddCObj(__pyx_float_1_0, __pyx_t_6, 1.0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->decay_factor); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyNumber_Multiply(__pyx_v_epoch, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_AddCObj(__pyx_int_1, __pyx_t_4, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_factor = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "libs/network.pyx":590
 *         # and we don't need to store the initial rates
 *         factor = (1.0 + (epoch - 1) * self.decay_factor) / (1 + epoch * self.decay_factor)
 *         self.learning_rate *= factor             # <<<<<<<<<<<<<<
 *         self.learning_rate_features *= factor
 *         if self.transitions is not None:
 */
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->learning_rate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 590, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_t_4, __pyx_v_factor); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 590, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 590, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_self->learning_rate = __pyx_t_7;

  /* "libs/network.pyx":591
 *         factor = (1.0 + (epoch - 1) * self.decay_factor) / (1 + epoch * self.decay_factor)
 *         self.learning_rate *= factor
 *         self.learning_rate_features *= factor             # <<<<<<<<<<<<<<
 *         if self.transitions is not None:
 *             self.learning_rate_trans *= factor
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->learning_rate_features); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyNumber_InPlaceMultiply(__pyx_t_6, __pyx_v_factor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 591, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_self->learning_rate_features = __pyx_t_7;

  /* "libs/network.pyx":592
 *         self.learning_rate *= factor
 *         self.learning_rate_features *= factor
 *         if self.transitions is not None:             # <<<<<<<<<<<<<<
 *             self.learning_rate_trans *= factor
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->transitions) != Py_None);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "libs/network.pyx":593
 *         self.learning_rate_features *= factor
 *         if self.transitions is not None:
 *             self.learning_rate_trans *= factor             # <<<<<<<<<<<<<<
 * 
 *     def train(self, list sentences, list tags,
 */
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->learning_rate_trans); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_t_4, __pyx_v_factor); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_self->learning_rate_trans = __pyx_t_7;

    /* "libs/network.pyx":592
 *         self.learning_rate *= factor
 *         self.learning_rate_features *= factor
 *         if self.transitions is not None:             # <<<<<<<<<<<<<<
 *             self.learning_rate_trans *= factor
 * 
 */
  }

  /* "libs/network.pyx":579
 *         self.decay_factor = decay_factor
 * 
 *     def decrease_learning_rates(self, epoch):             # <<<<<<<<<<<<<<
 *         """
 *         Apply the learning rate decay, if the network was configured to use it.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libs.network.Network.decrease_learning_rates", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_factor);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":595
 *             self.learning_rate_trans *= factor
 * 
 *     def train(self, list sentences, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_27train(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_26train[] = "Network.train(self, list sentences, list tags, int epochs, int epochs_between_reports=0, float desired_accuracy=0)\n\n        Trains the network to tag sentences.\n        \n        :param sentences: a list of 2-dim numpy arrays, where each item \n            encodes a sentence. Each item in a sentence has the \n            indices to its features.\n        :param tags: a list of 1-dim numpy arrays, where each item has\n            the tags of the sentences.\n        :param epochs: number of training epochs\n        :param epochs_between_reports: number of epochs to wait between\n            reports about the training performance. 0 means no reports.\n        :param desired_accuracy: training stops if the desired accuracy\n            is reached. Ignored if 0.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_27train(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentences = 0;
  PyObject *__pyx_v_tags = 0;
  int __pyx_v_epochs;
  int __pyx_v_epochs_between_reports;
  float __pyx_v_desired_accuracy;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("train (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentences,&__pyx_n_s_tags,&__pyx_n_s_epochs,&__pyx_n_s_epochs_between_reports,&__pyx_n_s_desired_accuracy,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentences)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("train", 0, 3, 5, 1); __PYX_ERR(0, 595, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_epochs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("train", 0, 3, 5, 2); __PYX_ERR(0, 595, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_epochs_between_reports);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desired_accuracy);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "train") < 0)) __PYX_ERR(0, 595, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentences = ((PyObject*)values[0]);
    __pyx_v_tags = ((PyObject*)values[1]);
    __pyx_v_epochs = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_epochs == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 596, __pyx_L3_error)
    if (values[3]) {
      __pyx_v_epochs_between_reports = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_epochs_between_reports == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 596, __pyx_L3_error)
    } else {
      __pyx_v_epochs_between_reports = ((int)0);
    }
    if (values[4]) {
      __pyx_v_desired_accuracy = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_desired_accuracy == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 597, __pyx_L3_error)
    } else {
      __pyx_v_desired_accuracy = ((float)0.0);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("train", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 595, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network.train", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentences), (&PyList_Type), 1, "sentences", 1))) __PYX_ERR(0, 595, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tags), (&PyList_Type), 1, "tags", 1))) __PYX_ERR(0, 595, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_26train(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), __pyx_v_sentences, __pyx_v_tags, __pyx_v_epochs, __pyx_v_epochs_between_reports, __pyx_v_desired_accuracy);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4libs_7network_7Network_5train_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "libs/network.pyx":617
 *         last_accuracy = 0
 *         last_error = np.Infinity
 *         self.num_tokens = sum(len(sent) for sent in sentences)             # <<<<<<<<<<<<<<
 * 
 *         if self.validation_sentences is None:
 */

static PyObject *__pyx_pf_4libs_7network_7Network_5train_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *)__pyx_tp_new_4libs_7network___pyx_scope_struct_3_genexpr(__pyx_ptype_4libs_7network___pyx_scope_struct_3_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 617, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4libs_7network_7Network_5train_2generator1, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_train_locals_genexpr, __pyx_n_s_libs_network); if (unlikely(!gen)) __PYX_ERR(0, 617, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.train.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4libs_7network_7Network_5train_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 617, 0, __PYX_ERR(0, 617, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 617, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_sentences)) { __Pyx_RaiseClosureNameError("sentences"); __PYX_ERR(0, 617, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_sentences == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 617, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_sentences; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 617, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sent);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sent, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_4 = PyObject_Length(__pyx_cur_scope->__pyx_v_sent); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 617, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 617, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":595
 *             self.learning_rate_trans *= factor
 * 
 *     def train(self, list sentences, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0):
 */

static PyObject *__pyx_pf_4libs_7network_7Network_26train(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_tags, int __pyx_v_epochs, int __pyx_v_epochs_between_reports, float __pyx_v_desired_accuracy) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *__pyx_cur_scope;
  PyObject *__pyx_v_logger = NULL;
  double __pyx_v_top_accuracy;
  double __pyx_v_last_accuracy;
  PyObject *__pyx_v_last_error = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_gb_4libs_7network_7Network_5train_2generator1 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  float __pyx_t_11;
  float __pyx_t_12;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("train", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *)__pyx_tp_new_4libs_7network___pyx_scope_struct_2_train(__pyx_ptype_4libs_7network___pyx_scope_struct_2_train, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 595, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("train", __pyx_f[0], 595, 0, __PYX_ERR(0, 595, __pyx_L1_error));
  __pyx_cur_scope->__pyx_v_sentences = __pyx_v_sentences;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sentences);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sentences);

  /* "libs/network.pyx":612
 *             is reached. Ignored if 0.
 *         """
 *         logger = logging.getLogger("Logger")             # <<<<<<<<<<<<<<
 *         logger.info("Training for up to %d epochs" % epochs)
 *         top_accuracy = 0
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_n_u_Logger) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_n_u_Logger);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 612, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_logger = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":613
 *         """
 *         logger = logging.getLogger("Logger")
 *         logger.info("Training for up to %d epochs" % epochs)             # <<<<<<<<<<<<<<
 *         top_accuracy = 0
 *         last_accuracy = 0
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_logger, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_epochs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyUnicode_Format(__pyx_kp_u_Training_for_up_to_d_epochs, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 613, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":614
 *         logger = logging.getLogger("Logger")
 *         logger.info("Training for up to %d epochs" % epochs)
 *         top_accuracy = 0             # <<<<<<<<<<<<<<
 *         last_accuracy = 0
 *         last_error = np.Infinity
 */
  __pyx_v_top_accuracy = 0.0;

  /* "libs/network.pyx":615
 *         logger.info("Training for up to %d epochs" % epochs)
 *         top_accuracy = 0
 *         last_accuracy = 0             # <<<<<<<<<<<<<<
 *         last_error = np.Infinity
 *         self.num_tokens = sum(len(sent) for sent in sentences)
 */
  __pyx_v_last_accuracy = 0.0;

  /* "libs/network.pyx":616
 *         top_accuracy = 0
 *         last_accuracy = 0
 *         last_error = np.Infinity             # <<<<<<<<<<<<<<
 *         self.num_tokens = sum(len(sent) for sent in sentences)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 616, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Infinity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 616, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_last_error = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "libs/network.pyx":617
 *         last_accuracy = 0
 *         last_error = np.Infinity
 *         self.num_tokens = sum(len(sent) for sent in sentences)             # <<<<<<<<<<<<<<
 * 
 *         if self.validation_sentences is None:
 */
  __pyx_t_3 = __pyx_pf_4libs_7network_7Network_5train_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 617, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->num_tokens = __pyx_t_5;

  /* "libs/network.pyx":619
 *         self.num_tokens = sum(len(sent) for sent in sentences)
 * 
 *         if self.validation_sentences is None:             # <<<<<<<<<<<<<<
 *             self.validation_sentences = sentences
 *             self.validation_tags = tags
 */
  __pyx_t_6 = (__pyx_v_self->validation_sentences == ((PyObject*)Py_None));
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "libs/network.pyx":620
 * 
 *         if self.validation_sentences is None:
 *             self.validation_sentences = sentences             # <<<<<<<<<<<<<<
 *             self.validation_tags = tags
 * 
 */
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sentences);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sentences);
    __Pyx_GOTREF(__pyx_v_self->validation_sentences);
    __Pyx_DECREF(__pyx_v_self->validation_sentences);
    __pyx_v_self->validation_sentences = __pyx_cur_scope->__pyx_v_sentences;

    /* "libs/network.pyx":621
 *         if self.validation_sentences is None:
 *             self.validation_sentences = sentences
 *             self.validation_tags = tags             # <<<<<<<<<<<<<<
 * 
 *         for i in range(epochs):
 */
    __Pyx_INCREF(__pyx_v_tags);
    __Pyx_GIVEREF(__pyx_v_tags);
    __Pyx_GOTREF(__pyx_v_self->validation_tags);
    __Pyx_DECREF(__pyx_v_self->validation_tags);
    __pyx_v_self->validation_tags = __pyx_v_tags;

    /* "libs/network.pyx":619
 *         self.num_tokens = sum(len(sent) for sent in sentences)
 * 
 *         if self.validation_sentences is None:             # <<<<<<<<<<<<<<
 *             self.validation_sentences = sentences
 *             self.validation_tags = tags
 */
  }

  /* "libs/network.pyx":623
 *             self.validation_tags = tags
 * 
 *         for i in range(epochs):             # <<<<<<<<<<<<<<
 *             self.decrease_learning_rates(i)
 *             self._train_epoch(sentences, tags)
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_epochs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 623, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 623, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 623, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 623, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 623, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_9(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 623, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "libs/network.pyx":624
 * 
 *         for i in range(epochs):
 *             self.decrease_learning_rates(i)             # <<<<<<<<<<<<<<
 *             self._train_epoch(sentences, tags)
 *             self._validate()
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_decrease_learning_rates); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_v_i) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_i);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libs/network.pyx":625
 *         for i in range(epochs):
 *             self.decrease_learning_rates(i)
 *             self._train_epoch(sentences, tags)             # <<<<<<<<<<<<<<
 *             self._validate()
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_train_epoch); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 625, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_sentences, __pyx_v_tags};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_sentences, __pyx_v_tags};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_2) {
        __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); __pyx_t_2 = NULL;
      }
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sentences);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sentences);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_cur_scope->__pyx_v_sentences);
      __Pyx_INCREF(__pyx_v_tags);
      __Pyx_GIVEREF(__pyx_v_tags);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_v_tags);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libs/network.pyx":626
 *             self.decrease_learning_rates(i)
 *             self._train_epoch(sentences, tags)
 *             self._validate()             # <<<<<<<<<<<<<<
 * 
 *             # normalize error
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_validate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 626, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 626, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "libs/network.pyx":629
 * 
 *             # normalize error
 *             self.error = self.error / self.num_tokens if self.num_tokens else np.Infinity             # <<<<<<<<<<<<<<
 * 
 *             # Attardi: save model
 */
    if ((__pyx_v_self->num_tokens != 0)) {
      if (unlikely(__pyx_v_self->num_tokens == 0)) {
        PyErr_SetString(PyExc_ZeroDivisionError, "float division");
        __PYX_ERR(0, 629, __pyx_L1_error)
      }
      __pyx_t_11 = (__pyx_v_self->error / ((float)__pyx_v_self->num_tokens));
    } else {
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 629, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Infinity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 629, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_12 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 629, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_11 = __pyx_t_12;
    }
    __pyx_v_self->error = __pyx_t_11;

    /* "libs/network.pyx":632
 * 
 *             # Attardi: save model
 *             if self.accuracy > top_accuracy:             # <<<<<<<<<<<<<<
 *                 top_accuracy = self.accuracy
 *                 self.save()
 */
    __pyx_t_7 = ((__pyx_v_self->accuracy > __pyx_v_top_accuracy) != 0);
    if (__pyx_t_7) {

      /* "libs/network.pyx":633
 *             # Attardi: save model
 *             if self.accuracy > top_accuracy:
 *                 top_accuracy = self.accuracy             # <<<<<<<<<<<<<<
 *                 self.save()
 *                 logger.debug("Saved model")
 */
      __pyx_t_11 = __pyx_v_self->accuracy;
      __pyx_v_top_accuracy = __pyx_t_11;

      /* "libs/network.pyx":634
 *             if self.accuracy > top_accuracy:
 *                 top_accuracy = self.accuracy
 *                 self.save()             # <<<<<<<<<<<<<<
 *                 logger.debug("Saved model")
 *             elif self.use_learning_rate_decay:
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_save); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "libs/network.pyx":635
 *                 top_accuracy = self.accuracy
 *                 self.save()
 *                 logger.debug("Saved model")             # <<<<<<<<<<<<<<
 *             elif self.use_learning_rate_decay:
 *                 # this iteration didn't bring improvements; load the last saved model
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_logger, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 635, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_10, __pyx_kp_u_Saved_model) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_Saved_model);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 635, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "libs/network.pyx":632
 * 
 *             # Attardi: save model
 *             if self.accuracy > top_accuracy:             # <<<<<<<<<<<<<<
 *                 top_accuracy = self.accuracy
 *                 self.save()
 */
      goto __pyx_L6;
    }

    /* "libs/network.pyx":636
 *                 self.save()
 *                 logger.debug("Saved model")
 *             elif self.use_learning_rate_decay:             # <<<<<<<<<<<<<<
 *                 # this iteration didn't bring improvements; load the last saved model
 *                 # before continuing training with a lower rate
 */
    __pyx_t_7 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->use_learning_rate_decay)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 636, __pyx_L1_error)
    if (__pyx_t_7) {

      /* "libs/network.pyx":639
 *                 # this iteration didn't bring improvements; load the last saved model
 *                 # before continuing training with a lower rate
 *                 self._load_parameters()             # <<<<<<<<<<<<<<
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_load_parameters); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 639, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "libs/network.pyx":636
 *                 self.save()
 *                 logger.debug("Saved model")
 *             elif self.use_learning_rate_decay:             # <<<<<<<<<<<<<<
 *                 # this iteration didn't bring improvements; load the last saved model
 *                 # before continuing training with a lower rate
 */
    }
    __pyx_L6:;

    /* "libs/network.pyx":641
 *                 self._load_parameters()
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \             # <<<<<<<<<<<<<<
 *                 or self.accuracy >= desired_accuracy > 0 \
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 */
    __pyx_t_6 = ((__pyx_v_epochs_between_reports > 0) != 0);
    if (!__pyx_t_6) {
      goto __pyx_L9_next_or;
    } else {
    }
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_epochs_between_reports); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Remainder(__pyx_v_i, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyInt_EqObjC(__pyx_t_3, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 641, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!__pyx_t_6) {
    } else {
      __pyx_t_7 = __pyx_t_6;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_L9_next_or:;

    /* "libs/network.pyx":642
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \
 *                 or self.accuracy >= desired_accuracy > 0 \             # <<<<<<<<<<<<<<
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 * 
 */
    __pyx_t_6 = (__pyx_v_self->accuracy >= __pyx_v_desired_accuracy);
    if (__pyx_t_6) {
      __pyx_t_6 = (__pyx_v_desired_accuracy > 0.0);
    }
    __pyx_t_13 = (__pyx_t_6 != 0);
    if (!__pyx_t_13) {
    } else {
      __pyx_t_7 = __pyx_t_13;
      goto __pyx_L8_bool_binop_done;
    }

    /* "libs/network.pyx":643
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \
 *                 or self.accuracy >= desired_accuracy > 0 \
 *                 or (self.accuracy < last_accuracy and self.error > last_error):             # <<<<<<<<<<<<<<
 * 
 *                 self._print_epoch_report(i + 1)
 */
    __pyx_t_13 = ((__pyx_v_self->accuracy < __pyx_v_last_accuracy) != 0);
    if (__pyx_t_13) {
    } else {
      __pyx_t_7 = __pyx_t_13;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_v_last_error, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = __pyx_t_13;
    __pyx_L8_bool_binop_done:;

    /* "libs/network.pyx":641
 *                 self._load_parameters()
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \             # <<<<<<<<<<<<<<
 *                 or self.accuracy >= desired_accuracy > 0 \
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 */
    if (__pyx_t_7) {

      /* "libs/network.pyx":645
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 * 
 *                 self._print_epoch_report(i + 1)             # <<<<<<<<<<<<<<
 * 
 *                 if self.accuracy >= desired_accuracy > 0\
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_print_epoch_report); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 645, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "libs/network.pyx":647
 *                 self._print_epoch_report(i + 1)
 * 
 *                 if self.accuracy >= desired_accuracy > 0\             # <<<<<<<<<<<<<<
 *                         or (self.error > last_error and self.accuracy < last_accuracy):
 *                     break
 */
      __pyx_t_13 = (__pyx_v_self->accuracy >= __pyx_v_desired_accuracy);
      if (__pyx_t_13) {
        __pyx_t_13 = (__pyx_v_desired_accuracy > 0.0);
      }
      __pyx_t_6 = (__pyx_t_13 != 0);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_7 = __pyx_t_6;
        goto __pyx_L14_bool_binop_done;
      }

      /* "libs/network.pyx":648
 * 
 *                 if self.accuracy >= desired_accuracy > 0\
 *                         or (self.error > last_error and self.accuracy < last_accuracy):             # <<<<<<<<<<<<<<
 *                     break
 * 
 */
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 648, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_last_error, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 648, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 648, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
      } else {
        __pyx_t_7 = __pyx_t_6;
        goto __pyx_L14_bool_binop_done;
      }
      __pyx_t_6 = ((__pyx_v_self->accuracy < __pyx_v_last_accuracy) != 0);
      __pyx_t_7 = __pyx_t_6;
      __pyx_L14_bool_binop_done:;

      /* "libs/network.pyx":647
 *                 self._print_epoch_report(i + 1)
 * 
 *                 if self.accuracy >= desired_accuracy > 0\             # <<<<<<<<<<<<<<
 *                         or (self.error > last_error and self.accuracy < last_accuracy):
 *                     break
 */
      if (__pyx_t_7) {

        /* "libs/network.pyx":649
 *                 if self.accuracy >= desired_accuracy > 0\
 *                         or (self.error > last_error and self.accuracy < last_accuracy):
 *                     break             # <<<<<<<<<<<<<<
 * 
 *             last_accuracy = self.accuracy
 */
        goto __pyx_L5_break;

        /* "libs/network.pyx":647
 *                 self._print_epoch_report(i + 1)
 * 
 *                 if self.accuracy >= desired_accuracy > 0\             # <<<<<<<<<<<<<<
 *                         or (self.error > last_error and self.accuracy < last_accuracy):
 *                     break
 */
      }

      /* "libs/network.pyx":641
 *                 self._load_parameters()
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \             # <<<<<<<<<<<<<<
 *                 or self.accuracy >= desired_accuracy > 0 \
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 */
    }

    /* "libs/network.pyx":651
 *                     break
 * 
 *             last_accuracy = self.accuracy             # <<<<<<<<<<<<<<
 *             last_error = self.error
 * 
 */
    __pyx_t_11 = __pyx_v_self->accuracy;
    __pyx_v_last_accuracy = __pyx_t_11;

    /* "libs/network.pyx":652
 * 
 *             last_accuracy = self.accuracy
 *             last_error = self.error             # <<<<<<<<<<<<<<
 * 
 *         self.num_tokens = 0
 */
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 652, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_last_error, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "libs/network.pyx":623
 *             self.validation_tags = tags
 * 
 *         for i in range(epochs):             # <<<<<<<<<<<<<<
 *             self.decrease_learning_rates(i)
 *             self._train_epoch(sentences, tags)
 */
  }
  __pyx_L5_break:;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":654
 *             last_error = self.error
 * 
 *         self.num_tokens = 0             # <<<<<<<<<<<<<<
 * 
 *     def _print_epoch_report(self, int num):
 */
  __pyx_v_self->num_tokens = 0;

  /* "libs/network.pyx":595
 *             self.learning_rate_trans *= factor
 * 
 *     def train(self, list sentences, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libs.network.Network.train", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_logger);
  __Pyx_XDECREF(__pyx_v_last_error);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_gb_4libs_7network_7Network_5train_2generator1);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":656
 *         self.num_tokens = 0
 * 
 *     def _print_epoch_report(self, int num):             # <<<<<<<<<<<<<<
 *         """
 *         Reports the status of the network in the given training
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_29_print_epoch_report(PyObject *__pyx_v_self, PyObject *__pyx_arg_num); /*proto*/
static char __pyx_doc_4libs_7network_7Network_28_print_epoch_report[] = "Network._print_epoch_report(self, int num)\n\n        Reports the status of the network in the given training\n        epoch, including error and accuracy.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_29_print_epoch_report(PyObject *__pyx_v_self, PyObject *__pyx_arg_num) {
  int __pyx_v_num;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_print_epoch_report (wrapper)", 0);
  assert(__pyx_arg_num); {
    __pyx_v_num = __Pyx_PyInt_As_int(__pyx_arg_num); if (unlikely((__pyx_v_num == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 656, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network._print_epoch_report", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_7Network_28_print_epoch_report(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((int)__pyx_v_num));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_28_print_epoch_report(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, int __pyx_v_num) {
  PyObject *__pyx_v_logger = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_UCS4 __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_print_epoch_report", 0);
  __Pyx_TraceCall("_print_epoch_report", __pyx_f[0], 656, 0, __PYX_ERR(0, 656, __pyx_L1_error));

  /* "libs/network.pyx":661
 *         epoch, including error and accuracy.
 *         """
 *         logger = logging.getLogger("Logger")             # <<<<<<<<<<<<<<
 *         logger.info("%d epochs   Error: %f   Accuracy: %f   " \
 *             "%d corrections skipped   " \
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_n_u_Logger) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_n_u_Logger);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_logger = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":662
 *         """
 *         logger = logging.getLogger("Logger")
 *         logger.info("%d epochs   Error: %f   Accuracy: %f   " \             # <<<<<<<<<<<<<<
 *             "%d corrections skipped   " \
 *             "learning rate: %f" % (num,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_logger, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_5 = 127;

  /* "libs/network.pyx":664
 *         logger.info("%d epochs   Error: %f   Accuracy: %f   " \
 *             "%d corrections skipped   " \
 *             "learning rate: %f" % (num,             # <<<<<<<<<<<<<<
 *                                    self.error,
 *                                    self.accuracy,
 */
  __pyx_t_6 = __Pyx_PyUnicode_From_int(__pyx_v_num, 0, ' ', 'd'); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_kp_u_epochs_Error);
  __pyx_t_4 += 17;
  __Pyx_GIVEREF(__pyx_kp_u_epochs_Error);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_kp_u_epochs_Error);

  /* "libs/network.pyx":665
 *             "%d corrections skipped   " \
 *             "learning rate: %f" % (num,
 *                                    self.error,             # <<<<<<<<<<<<<<
 *                                    self.accuracy,
 *                                    self.skips,
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_Format(__pyx_t_6, __pyx_n_u_f); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 665, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_5;
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_7);
  __pyx_t_7 = 0;
  __Pyx_INCREF(__pyx_kp_u_Accuracy);
  __pyx_t_4 += 13;
  __Pyx_GIVEREF(__pyx_kp_u_Accuracy);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_kp_u_Accuracy);

  /* "libs/network.pyx":666
 *             "learning rate: %f" % (num,
 *                                    self.error,
 *                                    self.accuracy,             # <<<<<<<<<<<<<<
 *                                    self.skips,
 *                                    self.learning_rate))
 */
  __pyx_t_7 = PyFloat_FromDouble(__pyx_v_self->accuracy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_Format(__pyx_t_7, __pyx_n_u_f); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 666, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5;
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_kp_u__7);
  __pyx_t_4 += 3;
  __Pyx_GIVEREF(__pyx_kp_u__7);
  PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_kp_u__7);

  /* "libs/network.pyx":667
 *                                    self.error,
 *                                    self.accuracy,
 *                                    self.skips,             # <<<<<<<<<<<<<<
 *                                    self.learning_rate))
 * 
 */
  __pyx_t_6 = __Pyx_PyUnicode_From_int(__pyx_v_self->skips, 0, ' ', 'd'); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 667, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_kp_u_corrections_skipped_learning_ra);
  __pyx_t_4 += 38;
  __Pyx_GIVEREF(__pyx_kp_u_corrections_skipped_learning_ra);
  PyTuple_SET_ITEM(__pyx_t_2, 7, __pyx_kp_u_corrections_skipped_learning_ra);

  /* "libs/network.pyx":668
 *                                    self.accuracy,
 *                                    self.skips,
 *                                    self.learning_rate))             # <<<<<<<<<<<<<<
 * 
 *     def _train_epoch(self, list sentences, list tags):
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->learning_rate); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 668, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_Format(__pyx_t_6, __pyx_n_u_f); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 668, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_5;
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_2, 8, __pyx_t_7);
  __pyx_t_7 = 0;

  /* "libs/network.pyx":662
 *         """
 *         logger = logging.getLogger("Logger")
 *         logger.info("%d epochs   Error: %f   Accuracy: %f   " \             # <<<<<<<<<<<<<<
 *             "%d corrections skipped   " \
 *             "learning rate: %f" % (num,
 */
  __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_2, 9, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":656
 *         self.num_tokens = 0
 * 
 *     def _print_epoch_report(self, int num):             # <<<<<<<<<<<<<<
 *         """
 *         Reports the status of the network in the given training
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.Network._print_epoch_report", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_logger);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":670
 *                                    self.learning_rate))
 * 
 *     def _train_epoch(self, list sentences, list tags):             # <<<<<<<<<<<<<<
 *         """
 *         Trains for one epoch with all examples.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_31_train_epoch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_7Network_30_train_epoch[] = "Network._train_epoch(self, list sentences, list tags)\n\n        Trains for one epoch with all examples.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_31_train_epoch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentences = 0;
  PyObject *__pyx_v_tags = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_train_epoch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentences,&__pyx_n_s_tags,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentences)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_train_epoch", 1, 2, 2, 1); __PYX_ERR(0, 670, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_train_epoch") < 0)) __PYX_ERR(0, 670, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sentences = ((PyObject*)values[0]);
    __pyx_v_tags = ((PyObject*)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_train_epoch", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 670, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.Network._train_epoch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentences), (&PyList_Type), 1, "sentences", 1))) __PYX_ERR(0, 670, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tags), (&PyList_Type), 1, "tags", 1))) __PYX_ERR(0, 670, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_7Network_30_train_epoch(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), __pyx_v_sentences, __pyx_v_tags);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_30_train_epoch(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_tags) {
  PyObject *__pyx_v_random_state = NULL;
  PyObject *__pyx_v_sent = NULL;
  PyObject *__pyx_v_sent_tags = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_train_epoch", 0);
  __Pyx_TraceCall("_train_epoch", __pyx_f[0], 670, 0, __PYX_ERR(0, 670, __pyx_L1_error));

  /* "libs/network.pyx":674
 *         Trains for one epoch with all examples.
 *         """
 *         self.error = 0             # <<<<<<<<<<<<<<
 *         self.skips = 0
 *         self.float_errors = 0
 */
  __pyx_v_self->error = 0.0;

  /* "libs/network.pyx":675
 *         """
 *         self.error = 0
 *         self.skips = 0             # <<<<<<<<<<<<<<
 *         self.float_errors = 0
 * 
 */
  __pyx_v_self->skips = 0;

  /* "libs/network.pyx":676
 *         self.error = 0
 *         self.skips = 0
 *         self.float_errors = 0             # <<<<<<<<<<<<<<
 * 
 *         # shuffle data
 */
  __pyx_v_self->float_errors = 0.0;

  /* "libs/network.pyx":681
 *         # get the random number generator state in order to shuffle
 *         # sentences and their tags in the same order
 *         random_state = np.random.get_state()             # <<<<<<<<<<<<<<
 *         np.random.shuffle(sentences)
 *         np.random.set_state(random_state)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_random_state = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":682
 *         # sentences and their tags in the same order
 *         random_state = np.random.get_state()
 *         np.random.shuffle(sentences)             # <<<<<<<<<<<<<<
 *         np.random.set_state(random_state)
 *         np.random.shuffle(tags)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_sentences) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_sentences);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":683
 *         random_state = np.random.get_state()
 *         np.random.shuffle(sentences)
 *         np.random.set_state(random_state)             # <<<<<<<<<<<<<<
 *         np.random.shuffle(tags)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_set_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_random_state) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_random_state);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 683, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":684
 *         np.random.shuffle(sentences)
 *         np.random.set_state(random_state)
 *         np.random.shuffle(tags)             # <<<<<<<<<<<<<<
 * 
 *         for sent, sent_tags in zip(sentences, tags):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_tags) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_tags);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":686
 *         np.random.shuffle(tags)
 * 
 *         for sent, sent_tags in zip(sentences, tags):             # <<<<<<<<<<<<<<
 *             try:
 *                 self._tag_sentence(sent, sent_tags)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_sentences);
  __Pyx_GIVEREF(__pyx_v_sentences);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sentences);
  __Pyx_INCREF(__pyx_v_tags);
  __Pyx_GIVEREF(__pyx_v_tags);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_tags);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 686, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 686, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 686, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(0, 686, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 686, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 686, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 686, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 686, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 686, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 686, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 686, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 686, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_sent, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_sent_tags, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "libs/network.pyx":687
 * 
 *         for sent, sent_tags in zip(sentences, tags):
 *             try:             # <<<<<<<<<<<<<<
 *                 self._tag_sentence(sent, sent_tags)
 *             except FloatingPointError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      /*try:*/ {

        /* "libs/network.pyx":688
 *         for sent, sent_tags in zip(sentences, tags):
 *             try:
 *                 self._tag_sentence(sent, sent_tags)             # <<<<<<<<<<<<<<
 *             except FloatingPointError:
 *                 # just ignore the sentence in case of an overflow
 */
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 688, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = NULL;
        __pyx_t_12 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_6, function);
            __pyx_t_12 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_sent, __pyx_v_sent_tags};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 688, __pyx_L7_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_sent, __pyx_v_sent_tags};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_12, 2+__pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 688, __pyx_L7_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(2+__pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 688, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__pyx_t_3) {
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
          }
          __Pyx_INCREF(__pyx_v_sent);
          __Pyx_GIVEREF(__pyx_v_sent);
          PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_12, __pyx_v_sent);
          __Pyx_INCREF(__pyx_v_sent_tags);
          __Pyx_GIVEREF(__pyx_v_sent_tags);
          PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_12, __pyx_v_sent_tags);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 688, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "libs/network.pyx":687
 * 
 *         for sent, sent_tags in zip(sentences, tags):
 *             try:             # <<<<<<<<<<<<<<
 *                 self._tag_sentence(sent, sent_tags)
 *             except FloatingPointError:
 */
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L14_try_end;
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "libs/network.pyx":689
 *             try:
 *                 self._tag_sentence(sent, sent_tags)
 *             except FloatingPointError:             # <<<<<<<<<<<<<<
 *                 # just ignore the sentence in case of an overflow
 *                 self.float_errors += 1
 */
      __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_FloatingPointError);
      if (__pyx_t_12) {
        __Pyx_AddTraceback("libs.network.Network._train_epoch", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 689, __pyx_L9_except_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_t_7);

        /* "libs/network.pyx":691
 *             except FloatingPointError:
 *                 # just ignore the sentence in case of an overflow
 *                 self.float_errors += 1             # <<<<<<<<<<<<<<
 * 
 *     def _validate(self):
 */
        __pyx_v_self->float_errors = (__pyx_v_self->float_errors + 1.0);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L8_exception_handled;
      }
      goto __pyx_L9_except_error;
      __pyx_L9_except_error:;

      /* "libs/network.pyx":687
 * 
 *         for sent, sent_tags in zip(sentences, tags):
 *             try:             # <<<<<<<<<<<<<<
 *                 self._tag_sentence(sent, sent_tags)
 *             except FloatingPointError:
 */
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      goto __pyx_L1_error;
      __pyx_L8_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      __pyx_L14_try_end:;
    }

    /* "libs/network.pyx":686
 *         np.random.shuffle(tags)
 * 
 *         for sent, sent_tags in zip(sentences, tags):             # <<<<<<<<<<<<<<
 *             try:
 *                 self._tag_sentence(sent, sent_tags)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":670
 *                                    self.learning_rate))
 * 
 *     def _train_epoch(self, list sentences, list tags):             # <<<<<<<<<<<<<<
 *         """
 *         Trains for one epoch with all examples.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.Network._train_epoch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_random_state);
  __Pyx_XDECREF(__pyx_v_sent);
  __Pyx_XDECREF(__pyx_v_sent_tags);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":693
 *                 self.float_errors += 1
 * 
 *     def _validate(self):             # <<<<<<<<<<<<<<
 *         """Perform validation on validation data and estimate accuracy"""
 *         hits = 0
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_33_validate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_7Network_32_validate[] = "Network._validate(self)\nPerform validation on validation data and estimate accuracy";
static PyObject *__pyx_pw_4libs_7network_7Network_33_validate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_validate (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_32_validate(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4libs_7network_7Network_9_validate_2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "libs/network.pyx":702
 * 
 *         # self.num_tokens stores number of tokens in training sentences
 *         num_tokens = sum(len(sent) for sent in self.validation_sentences)             # <<<<<<<<<<<<<<
 *         self.accuracy = float(hits) / num_tokens
 * 
 */

static PyObject *__pyx_pf_4libs_7network_7Network_9_validate_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *)__pyx_tp_new_4libs_7network___pyx_scope_struct_5_genexpr(__pyx_ptype_4libs_7network___pyx_scope_struct_5_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 702, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4libs_7network_7Network_9_validate_2generator2, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_validate_locals_genexpr, __pyx_n_s_libs_network); if (unlikely(!gen)) __PYX_ERR(0, 702, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network._validate.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4libs_7network_7Network_9_validate_2generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 702, 0, __PYX_ERR(0, 702, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 702, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 702, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->validation_sentences == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(0, 702, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self->validation_sentences; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 702, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sent);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sent, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_4 = PyObject_Length(__pyx_cur_scope->__pyx_v_sent); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 702, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 702, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":693
 *                 self.float_errors += 1
 * 
 *     def _validate(self):             # <<<<<<<<<<<<<<
 *         """Perform validation on validation data and estimate accuracy"""
 *         hits = 0
 */

static PyObject *__pyx_pf_4libs_7network_7Network_32_validate(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *__pyx_cur_scope;
  PyObject *__pyx_v_hits = NULL;
  PyObject *__pyx_v_sent = NULL;
  PyObject *__pyx_v_gold_tags = NULL;
  PyObject *__pyx_v_answer = NULL;
  PyObject *__pyx_v_num_tokens = NULL;
  PyObject *__pyx_gb_4libs_7network_7Network_9_validate_2generator2 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  float __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_validate", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *)__pyx_tp_new_4libs_7network___pyx_scope_struct_4__validate(__pyx_ptype_4libs_7network___pyx_scope_struct_4__validate, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 693, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("_validate", __pyx_f[0], 693, 0, __PYX_ERR(0, 693, __pyx_L1_error));
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);

  /* "libs/network.pyx":695
 *     def _validate(self):
 *         """Perform validation on validation data and estimate accuracy"""
 *         hits = 0             # <<<<<<<<<<<<<<
 * 
 *         for sent, gold_tags in zip(self.validation_sentences, self.validation_tags):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_hits = __pyx_int_0;

  /* "libs/network.pyx":697
 *         hits = 0
 * 
 *         for sent, gold_tags in zip(self.validation_sentences, self.validation_tags):             # <<<<<<<<<<<<<<
 *             answer = self.tag_sentence(sent)
 *             hits += np.count_nonzero(answer == gold_tags)
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->validation_sentences);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self->validation_sentences);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_self->validation_sentences);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->validation_tags);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self->validation_tags);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_self->validation_tags);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
  } else {
    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 697, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_4)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 697, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 697, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 697, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 697, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 697, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 697, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 697, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 697, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 697, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L6_unpacking_done;
      __pyx_L5_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 697, __pyx_L1_error)
      __pyx_L6_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_sent, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_gold_tags, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "libs/network.pyx":698
 * 
 *         for sent, gold_tags in zip(self.validation_sentences, self.validation_tags):
 *             answer = self.tag_sentence(sent)             # <<<<<<<<<<<<<<
 *             hits += np.count_nonzero(answer == gold_tags)
 * 
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_tag_sentence_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 698, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_v_sent) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_sent);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 698, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_answer, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "libs/network.pyx":699
 *         for sent, gold_tags in zip(self.validation_sentences, self.validation_tags):
 *             answer = self.tag_sentence(sent)
 *             hits += np.count_nonzero(answer == gold_tags)             # <<<<<<<<<<<<<<
 * 
 *         # self.num_tokens stores number of tokens in training sentences
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_count_nonzero); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_RichCompare(__pyx_v_answer, __pyx_v_gold_tags, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 699, __pyx_L1_error)
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_hits, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 699, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_hits, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "libs/network.pyx":697
 *         hits = 0
 * 
 *         for sent, gold_tags in zip(self.validation_sentences, self.validation_tags):             # <<<<<<<<<<<<<<
 *             answer = self.tag_sentence(sent)
 *             hits += np.count_nonzero(answer == gold_tags)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":702
 * 
 *         # self.num_tokens stores number of tokens in training sentences
 *         num_tokens = sum(len(sent) for sent in self.validation_sentences)             # <<<<<<<<<<<<<<
 *         self.accuracy = float(hits) / num_tokens
 * 
 */
  __pyx_t_1 = __pyx_pf_4libs_7network_7Network_9_validate_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 702, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_num_tokens = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "libs/network.pyx":703
 *         # self.num_tokens stores number of tokens in training sentences
 *         num_tokens = sum(len(sent) for sent in self.validation_sentences)
 *         self.accuracy = float(hits) / num_tokens             # <<<<<<<<<<<<<<
 * 
 *     def _backpropagate(self, sentence):
 */
  __pyx_t_5 = __Pyx_PyNumber_Float(__pyx_v_hits); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_v_num_tokens); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 703, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 703, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_cur_scope->__pyx_v_self->accuracy = __pyx_t_9;

  /* "libs/network.pyx":693
 *                 self.float_errors += 1
 * 
 *     def _validate(self):             # <<<<<<<<<<<<<<
 *         """Perform validation on validation data and estimate accuracy"""
 *         hits = 0
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.Network._validate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_hits);
  __Pyx_XDECREF(__pyx_v_sent);
  __Pyx_XDECREF(__pyx_v_gold_tags);
  __Pyx_XDECREF(__pyx_v_answer);
  __Pyx_XDECREF(__pyx_v_num_tokens);
  __Pyx_XDECREF(__pyx_gb_4libs_7network_7Network_9_validate_2generator2);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":705
 *         self.accuracy = float(hits) / num_tokens
 * 
 *     def _backpropagate(self, sentence):             # <<<<<<<<<<<<<<
 *         """
 *         Backpropagate the gradients of the cost.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_35_backpropagate(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence); /*proto*/
static char __pyx_doc_4libs_7network_7Network_34_backpropagate[] = "Network._backpropagate(self, sentence)\n\n        Backpropagate the gradients of the cost.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_35_backpropagate(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_backpropagate (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_34_backpropagate(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_sentence));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_34_backpropagate(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_sentence) {
  PyArrayObject *__pyx_v_output_deltas = 0;
  PyObject *__pyx_v_output_bias_deltas = NULL;
  PyObject *__pyx_v_dCdf_3 = NULL;
  PyObject *__pyx_v_dCdf_2 = NULL;
  PyArrayObject *__pyx_v_hidden_deltas = 0;
  PyObject *__pyx_v_hidden_bias_deltas = NULL;
  PyArrayObject *__pyx_v_input_gradients = 0;
  PyArrayObject *__pyx_v_input_deltas = 0;
  PyObject *__pyx_v_padded_sentence = NULL;
  PyArrayObject *__pyx_v_features = 0;
  PyArrayObject *__pyx_v_table = 0;
  int __pyx_v_start;
  int __pyx_v_end;
  int __pyx_v_t;
  int __pyx_v_i;
  PyObject *__pyx_v_w_deltas = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_features;
  __Pyx_Buffer __pyx_pybuffer_features;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_hidden_deltas;
  __Pyx_Buffer __pyx_pybuffer_hidden_deltas;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_input_deltas;
  __Pyx_Buffer __pyx_pybuffer_input_deltas;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_input_gradients;
  __Pyx_Buffer __pyx_pybuffer_input_gradients;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_output_deltas;
  __Pyx_Buffer __pyx_pybuffer_output_deltas;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_table;
  __Pyx_Buffer __pyx_pybuffer_table;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyArrayObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  PyArrayObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  Py_ssize_t __pyx_t_15;
  PyObject *(*__pyx_t_16)(PyObject *);
  PyArrayObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  Py_ssize_t __pyx_t_19;
  PyArrayObject *__pyx_t_20 = NULL;
  int __pyx_t_21;
  Py_ssize_t __pyx_t_22;
  __pyx_t_4libs_7network_INT_t __pyx_t_23;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  int __pyx_t_26;
  int __pyx_t_27;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_backpropagate", 0);
  __Pyx_TraceCall("_backpropagate", __pyx_f[0], 705, 0, __PYX_ERR(0, 705, __pyx_L1_error));
  __pyx_pybuffer_output_deltas.pybuffer.buf = NULL;
  __pyx_pybuffer_output_deltas.refcount = 0;
  __pyx_pybuffernd_output_deltas.data = NULL;
  __pyx_pybuffernd_output_deltas.rcbuffer = &__pyx_pybuffer_output_deltas;
  __pyx_pybuffer_hidden_deltas.pybuffer.buf = NULL;
  __pyx_pybuffer_hidden_deltas.refcount = 0;
  __pyx_pybuffernd_hidden_deltas.data = NULL;
  __pyx_pybuffernd_hidden_deltas.rcbuffer = &__pyx_pybuffer_hidden_deltas;
  __pyx_pybuffer_input_gradients.pybuffer.buf = NULL;
  __pyx_pybuffer_input_gradients.refcount = 0;
  __pyx_pybuffernd_input_gradients.data = NULL;
  __pyx_pybuffernd_input_gradients.rcbuffer = &__pyx_pybuffer_input_gradients;
  __pyx_pybuffer_input_deltas.pybuffer.buf = NULL;
  __pyx_pybuffer_input_deltas.refcount = 0;
  __pyx_pybuffernd_input_deltas.data = NULL;
  __pyx_pybuffernd_input_deltas.rcbuffer = &__pyx_pybuffer_input_deltas;
  __pyx_pybuffer_features.pybuffer.buf = NULL;
  __pyx_pybuffer_features.refcount = 0;
  __pyx_pybuffernd_features.data = NULL;
  __pyx_pybuffernd_features.rcbuffer = &__pyx_pybuffer_features;
  __pyx_pybuffer_table.pybuffer.buf = NULL;
  __pyx_pybuffer_table.refcount = 0;
  __pyx_pybuffernd_table.data = NULL;
  __pyx_pybuffernd_table.rcbuffer = &__pyx_pybuffer_table;

  /* "libs/network.pyx":725
 *         # (len, output_size).T (len, hidden_size) = (output_size, hidden_size)
 *         cdef np.ndarray[FLOAT_t, ndim=2] output_deltas
 *         output_deltas = self.net_gradients.T.dot(self.hidden_sent_values)             # <<<<<<<<<<<<<<
 * 
 *         # dC / db_4 = dC / df_4					(22)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->net_gradients), __pyx_n_s_T); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, ((PyObject *)__pyx_v_self->hidden_sent_values)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self->hidden_sent_values));
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 725, __pyx_L1_error)
  __pyx_t_4 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output_deltas.rcbuffer->pybuffer);
    __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_5 < 0)) {
      PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_output_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_v_output_deltas, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      }
      __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
    }
    __pyx_pybuffernd_output_deltas.diminfo[0].strides = __pyx_pybuffernd_output_deltas.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_output_deltas.diminfo[0].shape = __pyx_pybuffernd_output_deltas.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_output_deltas.diminfo[1].strides = __pyx_pybuffernd_output_deltas.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_output_deltas.diminfo[1].shape = __pyx_pybuffernd_output_deltas.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 725, __pyx_L1_error)
  }
  __pyx_t_4 = 0;
  __pyx_v_output_deltas = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":730
 *         # (output_size) += ((len(sentence), output_size))
 *         # sum by column, i.e. all changes through the sentence
 *         output_bias_deltas = self.net_gradients.sum(0)             # <<<<<<<<<<<<<<
 * 
 *         # dC / df_3 = M_2.T dC / df_4				(23)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->net_gradients), __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_int_0);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 730, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_output_bias_deltas = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":734
 *         # dC / df_3 = M_2.T dC / df_4				(23)
 *         #  (len, output_size) (output_size, hidden_size) = (len, hidden_size)
 *         dCdf_3 = self.net_gradients.dot(self.output_weights)             # <<<<<<<<<<<<<<
 * 
 *         # layer 3: HardTanh layer
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->net_gradients), __pyx_n_s_dot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, ((PyObject *)__pyx_v_self->output_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_self->output_weights));
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 734, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_dCdf_3 = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":742
 *         # (len, hidden_size) (len, hidden_size)
 *         # FIXME: this goes quickly to 0.
 *         dCdf_2 = hardtanhd(self.layer2_sent_values) * dCdf_3             # <<<<<<<<<<<<<<
 * 
 *         # df_2 / df_1 = M_1
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_self->layer2_sent_values);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = __pyx_f_4libs_7network_hardtanhd(((PyArrayObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_3, __pyx_v_dCdf_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 742, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_dCdf_2 = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":750
 *         cdef np.ndarray[FLOAT_t, ndim=2] hidden_deltas
 *         # (len, hidden_size).T (len, input_size) = (hidden_size, input_size)
 *         hidden_deltas = dCdf_2.T.dot(self.input_sent_values)             # <<<<<<<<<<<<<<
 * 
 *         # dC / db_2 = dC / df_2					(22)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dCdf_2, __pyx_n_s_T); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dot); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_self->input_sent_values)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self->input_sent_values));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 750, __pyx_L1_error)
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer);
    __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_5 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_v_hidden_deltas, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
      }
      __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
    }
    __pyx_pybuffernd_hidden_deltas.diminfo[0].strides = __pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_hidden_deltas.diminfo[0].shape = __pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_hidden_deltas.diminfo[1].strides = __pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_hidden_deltas.diminfo[1].shape = __pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 750, __pyx_L1_error)
  }
  __pyx_t_9 = 0;
  __pyx_v_hidden_deltas = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":754
 *         # dC / db_2 = dC / df_2					(22)
 *         # sum by column contribution by each token
 *         hidden_bias_deltas = dCdf_2.sum(0)             # <<<<<<<<<<<<<<
 * 
 *         # dC / df_1 = M_1.T dC / df_2
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dCdf_2, __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_int_0);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_hidden_bias_deltas = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":759
 *         cdef np.ndarray[FLOAT_t, ndim=2] input_gradients
 *         # (len, hidden_size) (hidden_size, input_size) = (len, input_size)
 *         input_gradients = dCdf_2.dot(self.hidden_weights)             # <<<<<<<<<<<<<<
 * 
 *         """
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_dCdf_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_self->hidden_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self->hidden_weights));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 759, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 759, __pyx_L1_error)
  __pyx_t_10 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer);
    __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_5 < 0)) {
      PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_v_input_gradients, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      }
      __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
    }
    __pyx_pybuffernd_input_gradients.diminfo[0].strides = __pyx_pybuffernd_input_gradients.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input_gradients.diminfo[0].shape = __pyx_pybuffernd_input_gradients.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_input_gradients.diminfo[1].strides = __pyx_pybuffernd_input_gradients.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_input_gradients.diminfo[1].shape = __pyx_pybuffernd_input_gradients.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 759, __pyx_L1_error)
  }
  __pyx_t_10 = 0;
  __pyx_v_input_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":764
 *         Adjust the weights.
 *         """
 *         self.output_weights += output_deltas * self.learning_rate             # <<<<<<<<<<<<<<
 *         self.output_bias += output_bias_deltas * self.learning_rate
 *         self.hidden_weights += hidden_deltas * self.learning_rate
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->learning_rate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(((PyObject *)__pyx_v_output_deltas), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->output_weights), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 764, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->output_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->output_weights));
  __pyx_v_self->output_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":765
 *         """
 *         self.output_weights += output_deltas * self.learning_rate
 *         self.output_bias += output_bias_deltas * self.learning_rate             # <<<<<<<<<<<<<<
 *         self.hidden_weights += hidden_deltas * self.learning_rate
 *         self.hidden_bias += hidden_bias_deltas * self.learning_rate
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->learning_rate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 765, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_output_bias_deltas, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 765, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->output_bias), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 765, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 765, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->output_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->output_bias));
  __pyx_v_self->output_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":766
 *         self.output_weights += output_deltas * self.learning_rate
 *         self.output_bias += output_bias_deltas * self.learning_rate
 *         self.hidden_weights += hidden_deltas * self.learning_rate             # <<<<<<<<<<<<<<
 *         self.hidden_bias += hidden_bias_deltas * self.learning_rate
 * 
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->learning_rate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(((PyObject *)__pyx_v_hidden_deltas), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->hidden_weights), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 766, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->hidden_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_weights));
  __pyx_v_self->hidden_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":767
 *         self.output_bias += output_bias_deltas * self.learning_rate
 *         self.hidden_weights += hidden_deltas * self.learning_rate
 *         self.hidden_bias += hidden_bias_deltas * self.learning_rate             # <<<<<<<<<<<<<<
 * 
 *         """
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->learning_rate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(__pyx_v_hidden_bias_deltas, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->hidden_bias), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 767, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->hidden_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_bias));
  __pyx_v_self->hidden_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":778
 *         cdef np.ndarray[FLOAT_t, ndim=2] input_deltas
 *         # (len, input_size)
 *         input_deltas = input_gradients * self.learning_rate_features             # <<<<<<<<<<<<<<
 * 
 *         padded_sentence = np.concatenate((self.pre_padding,
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->learning_rate_features); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 778, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(((PyObject *)__pyx_v_input_gradients), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 778, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 778, __pyx_L1_error)
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_deltas.rcbuffer->pybuffer);
    __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_5 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_v_input_deltas, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
      }
      __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
    }
    __pyx_pybuffernd_input_deltas.diminfo[0].strides = __pyx_pybuffernd_input_deltas.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input_deltas.diminfo[0].shape = __pyx_pybuffernd_input_deltas.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_input_deltas.diminfo[1].strides = __pyx_pybuffernd_input_deltas.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_input_deltas.diminfo[1].shape = __pyx_pybuffernd_input_deltas.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 778, __pyx_L1_error)
  }
  __pyx_t_11 = 0;
  __pyx_v_input_deltas = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "libs/network.pyx":780
 *         input_deltas = input_gradients * self.learning_rate_features
 * 
 *         padded_sentence = np.concatenate((self.pre_padding,             # <<<<<<<<<<<<<<
 *                                           sentence,
 *                                           self.pos_padding))
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":782
 *         padded_sentence = np.concatenate((self.pre_padding,
 *                                           sentence,
 *                                           self.pos_padding))             # <<<<<<<<<<<<<<
 * 
 *         cdef np.ndarray[INT_t, ndim=1] features
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pre_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pre_padding));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->pre_padding));
  __Pyx_INCREF(__pyx_v_sentence);
  __Pyx_GIVEREF(__pyx_v_sentence);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_sentence);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pos_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pos_padding));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_self->pos_padding));
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_12, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 780, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_padded_sentence = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "libs/network.pyx":789
 *         cdef int i, j
 * 
 *         for i, w_deltas in enumerate(input_deltas):             # <<<<<<<<<<<<<<
 *             # for each window (w_deltas: 300, features: 5)
 *             # this tracks where the deltas for the next table begins
 */
  __pyx_t_5 = 0;
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_input_deltas))) || PyTuple_CheckExact(((PyObject *)__pyx_v_input_deltas))) {
    __pyx_t_2 = ((PyObject *)__pyx_v_input_deltas); __Pyx_INCREF(__pyx_t_2); __pyx_t_13 = 0;
    __pyx_t_14 = NULL;
  } else {
    __pyx_t_13 = -1; __pyx_t_2 = PyObject_GetIter(((PyObject *)__pyx_v_input_deltas)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_14 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 789, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_14)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_13); __Pyx_INCREF(__pyx_t_3); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 789, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 789, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_13); __Pyx_INCREF(__pyx_t_3); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(0, 789, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 789, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_14(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(0, 789, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_w_deltas, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_v_i = __pyx_t_5;
    __pyx_t_5 = (__pyx_t_5 + 1);

    /* "libs/network.pyx":792
 *             # for each window (w_deltas: 300, features: 5)
 *             # this tracks where the deltas for the next table begins
 *             start = 0             # <<<<<<<<<<<<<<
 *             for features in padded_sentence[i:i+self.word_window_size]:
 *                 # select the columns for each feature_tables (t: 3)
 */
    __pyx_v_start = 0;

    /* "libs/network.pyx":793
 *             # this tracks where the deltas for the next table begins
 *             start = 0
 *             for features in padded_sentence[i:i+self.word_window_size]:             # <<<<<<<<<<<<<<
 *                 # select the columns for each feature_tables (t: 3)
 *                 for t, table in enumerate(self.feature_tables):
 */
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_padded_sentence, __pyx_v_i, (__pyx_v_i + __pyx_v_self->word_window_size), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 793, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
      __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_15 = 0;
      __pyx_t_16 = NULL;
    } else {
      __pyx_t_15 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 793, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_16 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 793, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    for (;;) {
      if (likely(!__pyx_t_16)) {
        if (likely(PyList_CheckExact(__pyx_t_1))) {
          if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 793, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 793, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        } else {
          if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_15); __Pyx_INCREF(__pyx_t_3); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(0, 793, __pyx_L1_error)
          #else
          __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 793, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          #endif
        }
      } else {
        __pyx_t_3 = __pyx_t_16(__pyx_t_1);
        if (unlikely(!__pyx_t_3)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(0, 793, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_3);
      }
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 793, __pyx_L1_error)
      __pyx_t_17 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer);
        __pyx_t_18 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_18 < 0)) {
          PyErr_Fetch(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_features.rcbuffer->pybuffer, (PyObject*)__pyx_v_features, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_6, __pyx_t_7, __pyx_t_8);
          }
          __pyx_t_6 = __pyx_t_7 = __pyx_t_8 = 0;
        }
        __pyx_pybuffernd_features.diminfo[0].strides = __pyx_pybuffernd_features.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_features.diminfo[0].shape = __pyx_pybuffernd_features.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 793, __pyx_L1_error)
      }
      __pyx_t_17 = 0;
      __Pyx_XDECREF_SET(__pyx_v_features, ((PyArrayObject *)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "libs/network.pyx":795
 *             for features in padded_sentence[i:i+self.word_window_size]:
 *                 # select the columns for each feature_tables (t: 3)
 *                 for t, table in enumerate(self.feature_tables):             # <<<<<<<<<<<<<<
 *                     end = start + table.shape[1]
 *                     table[features[t]] += w_deltas[start:end]
 */
      __pyx_t_18 = 0;
      __pyx_t_3 = __pyx_v_self->feature_tables; __Pyx_INCREF(__pyx_t_3); __pyx_t_19 = 0;
      for (;;) {
        if (__pyx_t_19 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_12 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_19); __Pyx_INCREF(__pyx_t_12); __pyx_t_19++; if (unlikely(0 < 0)) __PYX_ERR(0, 795, __pyx_L1_error)
        #else
        __pyx_t_12 = PySequence_ITEM(__pyx_t_3, __pyx_t_19); __pyx_t_19++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 795, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        #endif
        if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 795, __pyx_L1_error)
        __pyx_t_20 = ((PyArrayObject *)__pyx_t_12);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_table.rcbuffer->pybuffer);
          __pyx_t_21 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_table.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_21 < 0)) {
            PyErr_Fetch(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_table.rcbuffer->pybuffer, (PyObject*)__pyx_v_table, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_8, __pyx_t_7, __pyx_t_6);
            }
            __pyx_t_8 = __pyx_t_7 = __pyx_t_6 = 0;
          }
          __pyx_pybuffernd_table.diminfo[0].strides = __pyx_pybuffernd_table.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_table.diminfo[0].shape = __pyx_pybuffernd_table.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_table.diminfo[1].strides = __pyx_pybuffernd_table.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_table.diminfo[1].shape = __pyx_pybuffernd_table.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_21 < 0)) __PYX_ERR(0, 795, __pyx_L1_error)
        }
        __pyx_t_20 = 0;
        __Pyx_XDECREF_SET(__pyx_v_table, ((PyArrayObject *)__pyx_t_12));
        __pyx_t_12 = 0;
        __pyx_v_t = __pyx_t_18;
        __pyx_t_18 = (__pyx_t_18 + 1);

        /* "libs/network.pyx":796
 *                 # select the columns for each feature_tables (t: 3)
 *                 for t, table in enumerate(self.feature_tables):
 *                     end = start + table.shape[1]             # <<<<<<<<<<<<<<
 *                     table[features[t]] += w_deltas[start:end]
 *                     start = end
 */
        __pyx_v_end = (__pyx_v_start + (__pyx_v_table->dimensions[1]));

        /* "libs/network.pyx":797
 *                 for t, table in enumerate(self.feature_tables):
 *                     end = start + table.shape[1]
 *                     table[features[t]] += w_deltas[start:end]             # <<<<<<<<<<<<<<
 *                     start = end
 * 
 */
        __pyx_t_22 = __pyx_v_t;
        __pyx_t_21 = -1;
        if (__pyx_t_22 < 0) {
          __pyx_t_22 += __pyx_pybuffernd_features.diminfo[0].shape;
          if (unlikely(__pyx_t_22 < 0)) __pyx_t_21 = 0;
        } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_features.diminfo[0].shape)) __pyx_t_21 = 0;
        if (unlikely(__pyx_t_21 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_21);
          __PYX_ERR(0, 797, __pyx_L1_error)
        }
        __pyx_t_23 = (*__Pyx_BufPtrStrided1d(__pyx_t_4libs_7network_INT_t *, __pyx_pybuffernd_features.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_features.diminfo[0].strides));
        __pyx_t_12 = __Pyx_GetItemInt(((PyObject *)__pyx_v_table), __pyx_t_23, __pyx_t_4libs_7network_INT_t, 1, __Pyx_PyInt_From_npy_long, 0, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 797, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_24 = __Pyx_PyObject_GetSlice(__pyx_v_w_deltas, __pyx_v_start, __pyx_v_end, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 797, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_25 = PyNumber_InPlaceAdd(__pyx_t_12, __pyx_t_24); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 797, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_25);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_table), __pyx_t_23, __pyx_t_25, __pyx_t_4libs_7network_INT_t, 1, __Pyx_PyInt_From_npy_long, 0, 1, 1) < 0)) __PYX_ERR(0, 797, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

        /* "libs/network.pyx":798
 *                     end = start + table.shape[1]
 *                     table[features[t]] += w_deltas[start:end]
 *                     start = end             # <<<<<<<<<<<<<<
 * 
 *         # Adjusts the transition scores table with the calculated gradients.
 */
        __pyx_v_start = __pyx_v_end;

        /* "libs/network.pyx":795
 *             for features in padded_sentence[i:i+self.word_window_size]:
 *                 # select the columns for each feature_tables (t: 3)
 *                 for t, table in enumerate(self.feature_tables):             # <<<<<<<<<<<<<<
 *                     end = start + table.shape[1]
 *                     table[features[t]] += w_deltas[start:end]
 */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "libs/network.pyx":793
 *             # this tracks where the deltas for the next table begins
 *             start = 0
 *             for features in padded_sentence[i:i+self.word_window_size]:             # <<<<<<<<<<<<<<
 *                 # select the columns for each feature_tables (t: 3)
 *                 for t, table in enumerate(self.feature_tables):
 */
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "libs/network.pyx":789
 *         cdef int i, j
 * 
 *         for i, w_deltas in enumerate(input_deltas):             # <<<<<<<<<<<<<<
 *             # for each window (w_deltas: 300, features: 5)
 *             # this tracks where the deltas for the next table begins
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "libs/network.pyx":801
 * 
 *         # Adjusts the transition scores table with the calculated gradients.
 *         if self.transitions is not None:             # <<<<<<<<<<<<<<
 *             self.transitions += self.trans_gradients * self.learning_rate_trans
 * 
 */
  __pyx_t_26 = (((PyObject *)__pyx_v_self->transitions) != Py_None);
  __pyx_t_27 = (__pyx_t_26 != 0);
  if (__pyx_t_27) {

    /* "libs/network.pyx":802
 *         # Adjusts the transition scores table with the calculated gradients.
 *         if self.transitions is not None:
 *             self.transitions += self.trans_gradients * self.learning_rate_trans             # <<<<<<<<<<<<<<
 * 
 *     def _load_parameters(self):
 */
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->learning_rate_trans); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_self->trans_gradients), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->transitions), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 802, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->transitions);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->transitions));
    __pyx_v_self->transitions = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "libs/network.pyx":801
 * 
 *         # Adjusts the transition scores table with the calculated gradients.
 *         if self.transitions is not None:             # <<<<<<<<<<<<<<
 *             self.transitions += self.trans_gradients * self.learning_rate_trans
 * 
 */
  }

  /* "libs/network.pyx":705
 *         self.accuracy = float(hits) / num_tokens
 * 
 *     def _backpropagate(self, sentence):             # <<<<<<<<<<<<<<
 *         """
 *         Backpropagate the gradients of the cost.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_deltas.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output_deltas.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_table.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.Network._backpropagate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_features.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_hidden_deltas.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_deltas.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_output_deltas.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_table.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_output_deltas);
  __Pyx_XDECREF(__pyx_v_output_bias_deltas);
  __Pyx_XDECREF(__pyx_v_dCdf_3);
  __Pyx_XDECREF(__pyx_v_dCdf_2);
  __Pyx_XDECREF((PyObject *)__pyx_v_hidden_deltas);
  __Pyx_XDECREF(__pyx_v_hidden_bias_deltas);
  __Pyx_XDECREF((PyObject *)__pyx_v_input_gradients);
  __Pyx_XDECREF((PyObject *)__pyx_v_input_deltas);
  __Pyx_XDECREF(__pyx_v_padded_sentence);
  __Pyx_XDECREF((PyObject *)__pyx_v_features);
  __Pyx_XDECREF((PyObject *)__pyx_v_table);
  __Pyx_XDECREF(__pyx_v_w_deltas);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":804
 *             self.transitions += self.trans_gradients * self.learning_rate_trans
 * 
 *     def _load_parameters(self):             # <<<<<<<<<<<<<<
 *         """
 *         Loads weights, feature tables and transition tables previously saved.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_37_load_parameters(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_7Network_36_load_parameters[] = "Network._load_parameters(self)\n\n        Loads weights, feature tables and transition tables previously saved.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_37_load_parameters(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_load_parameters (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_36_load_parameters(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_36_load_parameters(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_load_parameters", 0);
  __Pyx_TraceCall("_load_parameters", __pyx_f[0], 804, 0, __PYX_ERR(0, 804, __pyx_L1_error));

  /* "libs/network.pyx":808
 *         Loads weights, feature tables and transition tables previously saved.
 *         """
 *         data = np.load(self.network_filename)             # <<<<<<<<<<<<<<
 *         self.hidden_weights = data['hidden_weights']
 *         self.hidden_bias = data['hidden_bias']
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 808, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_load); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 808, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_self->network_filename) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->network_filename);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 808, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":809
 *         """
 *         data = np.load(self.network_filename)
 *         self.hidden_weights = data['hidden_weights']             # <<<<<<<<<<<<<<
 *         self.hidden_bias = data['hidden_bias']
 *         self.output_weights = data['output_weights']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 809, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 809, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->hidden_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_weights));
  __pyx_v_self->hidden_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":810
 *         data = np.load(self.network_filename)
 *         self.hidden_weights = data['hidden_weights']
 *         self.hidden_bias = data['hidden_bias']             # <<<<<<<<<<<<<<
 *         self.output_weights = data['output_weights']
 *         self.output_bias = data['output_bias']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->hidden_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_bias));
  __pyx_v_self->hidden_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":811
 *         self.hidden_weights = data['hidden_weights']
 *         self.hidden_bias = data['hidden_bias']
 *         self.output_weights = data['output_weights']             # <<<<<<<<<<<<<<
 *         self.output_bias = data['output_bias']
 *         self.feature_tables = list(data['feature_tables'])
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 811, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->output_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->output_weights));
  __pyx_v_self->output_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":812
 *         self.hidden_bias = data['hidden_bias']
 *         self.output_weights = data['output_weights']
 *         self.output_bias = data['output_bias']             # <<<<<<<<<<<<<<
 *         self.feature_tables = list(data['feature_tables'])
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 812, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->output_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->output_bias));
  __pyx_v_self->output_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "libs/network.pyx":813
 *         self.output_weights = data['output_weights']
 *         self.output_bias = data['output_bias']
 *         self.feature_tables = list(data['feature_tables'])             # <<<<<<<<<<<<<<
 * 
 *         # check if transitions isn't None (numpy saves everything as an array)
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_feature_tables); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->feature_tables);
  __Pyx_DECREF(__pyx_v_self->feature_tables);
  __pyx_v_self->feature_tables = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":816
 * 
 *         # check if transitions isn't None (numpy saves everything as an array)
 *         if data['transitions'].shape != ():             # <<<<<<<<<<<<<<
 *             self.transitions = data['transitions']
 *         else:
 */
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_transitions); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_empty_tuple, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "libs/network.pyx":817
 *         # check if transitions isn't None (numpy saves everything as an array)
 *         if data['transitions'].shape != ():
 *             self.transitions = data['transitions']             # <<<<<<<<<<<<<<
 *         else:
 *             self.transitions = None
 */
    __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_transitions); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 817, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 817, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->transitions);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->transitions));
    __pyx_v_self->transitions = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "libs/network.pyx":816
 * 
 *         # check if transitions isn't None (numpy saves everything as an array)
 *         if data['transitions'].shape != ():             # <<<<<<<<<<<<<<
 *             self.transitions = data['transitions']
 *         else:
 */
    goto __pyx_L3;
  }

  /* "libs/network.pyx":819
 *             self.transitions = data['transitions']
 *         else:
 *             self.transitions = None             # <<<<<<<<<<<<<<
 * 
 *     def save(self):
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->transitions);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->transitions));
    __pyx_v_self->transitions = ((PyArrayObject *)Py_None);
  }
  __pyx_L3:;

  /* "libs/network.pyx":804
 *             self.transitions += self.trans_gradients * self.learning_rate_trans
 * 
 *     def _load_parameters(self):             # <<<<<<<<<<<<<<
 *         """
 *         Loads weights, feature tables and transition tables previously saved.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libs.network.Network._load_parameters", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":821
 *             self.transitions = None
 * 
 *     def save(self):             # <<<<<<<<<<<<<<
 *         """
 *         Saves the neural network to a file.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_39save(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_7Network_38save[] = "Network.save(self)\n\n        Saves the neural network to a file.\n        It will save the weights, biases, sizes, padding, \n        and feature tables.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_39save(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("save (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_38save(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_38save(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("save", 0);
  __Pyx_TraceCall("save", __pyx_f[0], 821, 0, __PYX_ERR(0, 821, __pyx_L1_error));

  /* "libs/network.pyx":827
 *         and feature tables.
 *         """
 *         np.savez(self.network_filename, hidden_weights=self.hidden_weights,             # <<<<<<<<<<<<<<
 *                  output_weights=self.output_weights,
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_savez); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->network_filename);
  __Pyx_GIVEREF(__pyx_v_self->network_filename);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->network_filename);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_hidden_weights, ((PyObject *)__pyx_v_self->hidden_weights)) < 0) __PYX_ERR(0, 827, __pyx_L1_error)

  /* "libs/network.pyx":828
 *         """
 *         np.savez(self.network_filename, hidden_weights=self.hidden_weights,
 *                  output_weights=self.output_weights,             # <<<<<<<<<<<<<<
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 *                  word_window_size=self.word_window_size,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_output_weights, ((PyObject *)__pyx_v_self->output_weights)) < 0) __PYX_ERR(0, 827, __pyx_L1_error)

  /* "libs/network.pyx":829
 *         np.savez(self.network_filename, hidden_weights=self.hidden_weights,
 *                  output_weights=self.output_weights,
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,             # <<<<<<<<<<<<<<
 *                  word_window_size=self.word_window_size,
 *                  input_size=self.input_size, hidden_size=self.hidden_size,
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_hidden_bias, ((PyObject *)__pyx_v_self->hidden_bias)) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_output_bias, ((PyObject *)__pyx_v_self->output_bias)) < 0) __PYX_ERR(0, 827, __pyx_L1_error)

  /* "libs/network.pyx":830
 *                  output_weights=self.output_weights,
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 *                  word_window_size=self.word_window_size,             # <<<<<<<<<<<<<<
 *                  input_size=self.input_size, hidden_size=self.hidden_size,
 *                  output_size=self.output_size, padding_left=self.padding_left,
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->word_window_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 830, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_word_window_size, __pyx_t_4) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "libs/network.pyx":831
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 *                  word_window_size=self.word_window_size,
 *                  input_size=self.input_size, hidden_size=self.hidden_size,             # <<<<<<<<<<<<<<
 *                  output_size=self.output_size, padding_left=self.padding_left,
 *                  padding_right=self.padding_right, transitions=self.transitions,
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->input_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_input_size, __pyx_t_4) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->hidden_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_hidden_size, __pyx_t_4) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "libs/network.pyx":832
 *                  word_window_size=self.word_window_size,
 *                  input_size=self.input_size, hidden_size=self.hidden_size,
 *                  output_size=self.output_size, padding_left=self.padding_left,             # <<<<<<<<<<<<<<
 *                  padding_right=self.padding_right, transitions=self.transitions,
 *                  feature_tables=self.feature_tables)
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->output_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_output_size, __pyx_t_4) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_padding_left, ((PyObject *)__pyx_v_self->padding_left)) < 0) __PYX_ERR(0, 827, __pyx_L1_error)

  /* "libs/network.pyx":833
 *                  input_size=self.input_size, hidden_size=self.hidden_size,
 *                  output_size=self.output_size, padding_left=self.padding_left,
 *                  padding_right=self.padding_right, transitions=self.transitions,             # <<<<<<<<<<<<<<
 *                  feature_tables=self.feature_tables)
 * 
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_padding_right, ((PyObject *)__pyx_v_self->padding_right)) < 0) __PYX_ERR(0, 827, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_transitions, ((PyObject *)__pyx_v_self->transitions)) < 0) __PYX_ERR(0, 827, __pyx_L1_error)

  /* "libs/network.pyx":834
 *                  output_size=self.output_size, padding_left=self.padding_left,
 *                  padding_right=self.padding_right, transitions=self.transitions,
 *                  feature_tables=self.feature_tables)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_feature_tables, __pyx_v_self->feature_tables) < 0) __PYX_ERR(0, 827, __pyx_L1_error)

  /* "libs/network.pyx":827
 *         and feature tables.
 *         """
 *         np.savez(self.network_filename, hidden_weights=self.hidden_weights,             # <<<<<<<<<<<<<<
 *                  output_weights=self.output_weights,
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 */
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 827, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "libs/network.pyx":821
 *             self.transitions = None
 * 
 *     def save(self):             # <<<<<<<<<<<<<<
 *         """
 *         Saves the neural network to a file.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("libs.network.Network.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":838
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_41load_from_file(PyObject *__pyx_v_cls, PyObject *__pyx_v_filename); /*proto*/
static char __pyx_doc_4libs_7network_7Network_40load_from_file[] = "Network.load_from_file(type cls, filename)\n\n        Loads the neural network from a file.\n        It will load weights, biases, sizes, padding, \n        and feature tables.\n        ";
static PyObject *__pyx_pw_4libs_7network_7Network_41load_from_file(PyObject *__pyx_v_cls, PyObject *__pyx_v_filename) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load_from_file (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_40load_from_file(((PyTypeObject*)__pyx_v_cls), ((PyObject *)__pyx_v_filename));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_40load_from_file(CYTHON_UNUSED PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_hidden_weights = NULL;
  PyObject *__pyx_v_hidden_bias = NULL;
  PyObject *__pyx_v_output_weights = NULL;
  PyObject *__pyx_v_output_bias = NULL;
  PyObject *__pyx_v_word_window_size = NULL;
  PyObject *__pyx_v_input_size = NULL;
  PyObject *__pyx_v_hidden_size = NULL;
  PyObject *__pyx_v_output_size = NULL;
  PyObject *__pyx_v_transitions = NULL;
  struct __pyx_obj_4libs_7network_Network *__pyx_v_nn = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load_from_file", 0);
  __Pyx_TraceCall("load_from_file", __pyx_f[0], 838, 0, __PYX_ERR(0, 838, __pyx_L1_error));

  /* "libs/network.pyx":844
 *         and feature tables.
 *         """
 *         data = np.load(filename)             # <<<<<<<<<<<<<<
 *         #print filename
 *         # cython classes don't have the __dict__ attribute
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_load); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_filename) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_filename);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 844, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":848
 *         # cython classes don't have the __dict__ attribute
 *         # so we can't do an elegant self.__dict__.update(data)
 *         hidden_weights = data['hidden_weights']             # <<<<<<<<<<<<<<
 *         hidden_bias = data['hidden_bias']
 *         output_weights = data['output_weights']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 848, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden_weights = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":849
 *         # so we can't do an elegant self.__dict__.update(data)
 *         hidden_weights = data['hidden_weights']
 *         hidden_bias = data['hidden_bias']             # <<<<<<<<<<<<<<
 *         output_weights = data['output_weights']
 *         output_bias = data['output_bias']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 849, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden_bias = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":850
 *         hidden_weights = data['hidden_weights']
 *         hidden_bias = data['hidden_bias']
 *         output_weights = data['output_weights']             # <<<<<<<<<<<<<<
 *         output_bias = data['output_bias']
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_output_weights = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":851
 *         hidden_bias = data['hidden_bias']
 *         output_weights = data['output_weights']
 *         output_bias = data['output_bias']             # <<<<<<<<<<<<<<
 * 
 *         word_window_size = data['word_window_size']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_output_bias = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":853
 *         output_bias = data['output_bias']
 * 
 *         word_window_size = data['word_window_size']             # <<<<<<<<<<<<<<
 *         input_size = data['input_size']
 *         hidden_size = data['hidden_size']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_word_window_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_word_window_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":854
 * 
 *         word_window_size = data['word_window_size']
 *         input_size = data['input_size']             # <<<<<<<<<<<<<<
 *         hidden_size = data['hidden_size']
 *         output_size = data['output_size']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_input_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 854, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_input_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":855
 *         word_window_size = data['word_window_size']
 *         input_size = data['input_size']
 *         hidden_size = data['hidden_size']             # <<<<<<<<<<<<<<
 *         output_size = data['output_size']
 *         if 'transitions' in data:
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":856
 *         input_size = data['input_size']
 *         hidden_size = data['hidden_size']
 *         output_size = data['output_size']             # <<<<<<<<<<<<<<
 *         if 'transitions' in data:
 *             transitions = data['transitions']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 856, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_output_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "libs/network.pyx":857
 *         hidden_size = data['hidden_size']
 *         output_size = data['output_size']
 *         if 'transitions' in data:             # <<<<<<<<<<<<<<
 *             transitions = data['transitions']
 *         else:
 */
  __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_transitions, __pyx_v_data, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 857, __pyx_L1_error)
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "libs/network.pyx":858
 *         output_size = data['output_size']
 *         if 'transitions' in data:
 *             transitions = data['transitions']             # <<<<<<<<<<<<<<
 *         else:
 *             transitions = None
 */
    __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_transitions); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 858, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_transitions = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "libs/network.pyx":857
 *         hidden_size = data['hidden_size']
 *         output_size = data['output_size']
 *         if 'transitions' in data:             # <<<<<<<<<<<<<<
 *             transitions = data['transitions']
 *         else:
 */
    goto __pyx_L3;
  }

  /* "libs/network.pyx":860
 *             transitions = data['transitions']
 *         else:
 *             transitions = None             # <<<<<<<<<<<<<<
 * 
 *         nn = Network(word_window_size, input_size, hidden_size, output_size,
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __pyx_v_transitions = Py_None;
  }
  __pyx_L3:;

  /* "libs/network.pyx":862
 *             transitions = None
 * 
 *         nn = Network(word_window_size, input_size, hidden_size, output_size,             # <<<<<<<<<<<<<<
 *                      hidden_weights, hidden_bias, output_weights, output_bias,
 *                      transitions)
 */
  __pyx_t_1 = PyTuple_New(9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_word_window_size);
  __Pyx_GIVEREF(__pyx_v_word_window_size);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_word_window_size);
  __Pyx_INCREF(__pyx_v_input_size);
  __Pyx_GIVEREF(__pyx_v_input_size);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_input_size);
  __Pyx_INCREF(__pyx_v_hidden_size);
  __Pyx_GIVEREF(__pyx_v_hidden_size);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_hidden_size);
  __Pyx_INCREF(__pyx_v_output_size);
  __Pyx_GIVEREF(__pyx_v_output_size);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_output_size);
  __Pyx_INCREF(__pyx_v_hidden_weights);
  __Pyx_GIVEREF(__pyx_v_hidden_weights);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_v_hidden_weights);
  __Pyx_INCREF(__pyx_v_hidden_bias);
  __Pyx_GIVEREF(__pyx_v_hidden_bias);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_v_hidden_bias);
  __Pyx_INCREF(__pyx_v_output_weights);
  __Pyx_GIVEREF(__pyx_v_output_weights);
  PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_v_output_weights);
  __Pyx_INCREF(__pyx_v_output_bias);
  __Pyx_GIVEREF(__pyx_v_output_bias);
  PyTuple_SET_ITEM(__pyx_t_1, 7, __pyx_v_output_bias);
  __Pyx_INCREF(__pyx_v_transitions);
  __Pyx_GIVEREF(__pyx_v_transitions);
  PyTuple_SET_ITEM(__pyx_t_1, 8, __pyx_v_transitions);
  __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_4libs_7network_Network), __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 862, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_nn = ((struct __pyx_obj_4libs_7network_Network *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":866
 *                      transitions)
 * 
 *         nn.padding_left = data['padding_left']             # <<<<<<<<<<<<<<
 *         nn.padding_right = data['padding_right']
 *         nn.pre_padding = np.array((nn.word_window_size // 2) * [nn.padding_left])
 */
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_padding_left); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 866, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 866, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_nn->padding_left);
  __Pyx_DECREF(((PyObject *)__pyx_v_nn->padding_left));
  __pyx_v_nn->padding_left = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":867
 * 
 *         nn.padding_left = data['padding_left']
 *         nn.padding_right = data['padding_right']             # <<<<<<<<<<<<<<
 *         nn.pre_padding = np.array((nn.word_window_size // 2) * [nn.padding_left])
 *         nn.pos_padding = np.array((nn.word_window_size // 2) * [nn.padding_right])
 */
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_padding_right); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 867, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 867, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_nn->padding_right);
  __Pyx_DECREF(((PyObject *)__pyx_v_nn->padding_right));
  __pyx_v_nn->padding_right = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":868
 *         nn.padding_left = data['padding_left']
 *         nn.padding_right = data['padding_right']
 *         nn.pre_padding = np.array((nn.word_window_size // 2) * [nn.padding_left])             # <<<<<<<<<<<<<<
 *         nn.pos_padding = np.array((nn.word_window_size // 2) * [nn.padding_right])
 *         nn.feature_tables = list(data['feature_tables'])
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_long(__Pyx_div_long(__pyx_v_nn->word_window_size, 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_nn->padding_left));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_nn->padding_left));
  PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_nn->padding_left));
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 868, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_nn->pre_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v_nn->pre_padding));
  __pyx_v_nn->pre_padding = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":869
 *         nn.padding_right = data['padding_right']
 *         nn.pre_padding = np.array((nn.word_window_size // 2) * [nn.padding_left])
 *         nn.pos_padding = np.array((nn.word_window_size // 2) * [nn.padding_right])             # <<<<<<<<<<<<<<
 *         nn.feature_tables = list(data['feature_tables'])
 *         nn.network_filename = filename
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_long(__Pyx_div_long(__pyx_v_nn->word_window_size, 2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_nn->padding_right));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_nn->padding_right));
  PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_nn->padding_right));
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_6, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 869, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_nn->pos_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v_nn->pos_padding));
  __pyx_v_nn->pos_padding = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "libs/network.pyx":870
 *         nn.pre_padding = np.array((nn.word_window_size // 2) * [nn.padding_left])
 *         nn.pos_padding = np.array((nn.word_window_size // 2) * [nn.padding_right])
 *         nn.feature_tables = list(data['feature_tables'])             # <<<<<<<<<<<<<<
 *         nn.network_filename = filename
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_feature_tables); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 870, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_nn->feature_tables);
  __Pyx_DECREF(__pyx_v_nn->feature_tables);
  __pyx_v_nn->feature_tables = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "libs/network.pyx":871
 *         nn.pos_padding = np.array((nn.word_window_size // 2) * [nn.padding_right])
 *         nn.feature_tables = list(data['feature_tables'])
 *         nn.network_filename = filename             # <<<<<<<<<<<<<<
 * 
 *         return nn
 */
  if (!(likely(PyUnicode_CheckExact(__pyx_v_filename))||((__pyx_v_filename) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_filename)->tp_name), 0))) __PYX_ERR(0, 871, __pyx_L1_error)
  __pyx_t_7 = __pyx_v_filename;
  __Pyx_INCREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_nn->network_filename);
  __Pyx_DECREF(__pyx_v_nn->network_filename);
  __pyx_v_nn->network_filename = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "libs/network.pyx":873
 *         nn.network_filename = filename
 * 
 *         return nn             # <<<<<<<<<<<<<<
 * 
 * # include the files for other networks
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_nn));
  __pyx_r = ((PyObject *)__pyx_v_nn);
  goto __pyx_L0;

  /* "libs/network.pyx":838
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.Network.load_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_hidden_weights);
  __Pyx_XDECREF(__pyx_v_hidden_bias);
  __Pyx_XDECREF(__pyx_v_output_weights);
  __Pyx_XDECREF(__pyx_v_output_bias);
  __Pyx_XDECREF(__pyx_v_word_window_size);
  __Pyx_XDECREF(__pyx_v_input_size);
  __Pyx_XDECREF(__pyx_v_hidden_size);
  __Pyx_XDECREF(__pyx_v_output_size);
  __Pyx_XDECREF(__pyx_v_transitions);
  __Pyx_XDECREF((PyObject *)__pyx_v_nn);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":82
 * 
 *     # sizes and learning rates
 *     cdef readonly int word_window_size, input_size, hidden_size, output_size             # <<<<<<<<<<<<<<
 *     cdef public float learning_rate, learning_rate_features
 *     cdef public float decay_factor
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_16word_window_size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_16word_window_size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_16word_window_size___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_16word_window_size___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 82, 0, __PYX_ERR(0, 82, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->word_window_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.word_window_size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_10input_size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_10input_size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_10input_size___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_10input_size___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 82, 0, __PYX_ERR(0, 82, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->input_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.input_size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_11hidden_size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_11hidden_size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11hidden_size___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_11hidden_size___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 82, 0, __PYX_ERR(0, 82, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->hidden_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.hidden_size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_11output_size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_11output_size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11output_size___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_11output_size___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 82, 0, __PYX_ERR(0, 82, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->output_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.output_size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":83
 *     # sizes and learning rates
 *     cdef readonly int word_window_size, input_size, hidden_size, output_size
 *     cdef public float learning_rate, learning_rate_features             # <<<<<<<<<<<<<<
 *     cdef public float decay_factor
 *     cdef public bool use_learning_rate_decay
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_13learning_rate_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_13learning_rate_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_13learning_rate___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_13learning_rate___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 83, 0, __PYX_ERR(0, 83, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->learning_rate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.learning_rate.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_13learning_rate_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_13learning_rate_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_13learning_rate_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_13learning_rate_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 83, 0, __PYX_ERR(0, 83, __pyx_L1_error));
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_value); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 83, __pyx_L1_error)
  __pyx_v_self->learning_rate = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.learning_rate.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_22learning_rate_features_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_22learning_rate_features_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_22learning_rate_features___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_22learning_rate_features___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 83, 0, __PYX_ERR(0, 83, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->learning_rate_features); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.learning_rate_features.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_22learning_rate_features_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_22learning_rate_features_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_22learning_rate_features_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_22learning_rate_features_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 83, 0, __PYX_ERR(0, 83, __pyx_L1_error));
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_value); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 83, __pyx_L1_error)
  __pyx_v_self->learning_rate_features = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.learning_rate_features.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":84
 *     cdef readonly int word_window_size, input_size, hidden_size, output_size
 *     cdef public float learning_rate, learning_rate_features
 *     cdef public float decay_factor             # <<<<<<<<<<<<<<
 *     cdef public bool use_learning_rate_decay
 *     cdef readonly int features_per_token
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_12decay_factor_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_12decay_factor_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_12decay_factor___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_12decay_factor___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 84, 0, __PYX_ERR(0, 84, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->decay_factor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.decay_factor.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_12decay_factor_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_12decay_factor_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_12decay_factor_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_12decay_factor_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 84, 0, __PYX_ERR(0, 84, __pyx_L1_error));
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_value); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error)
  __pyx_v_self->decay_factor = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.decay_factor.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":85
 *     cdef public float learning_rate, learning_rate_features
 *     cdef public float decay_factor
 *     cdef public bool use_learning_rate_decay             # <<<<<<<<<<<<<<
 *     cdef readonly int features_per_token
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_23use_learning_rate_decay___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_23use_learning_rate_decay___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 85, 0, __PYX_ERR(0, 85, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->use_learning_rate_decay));
  __pyx_r = ((PyObject *)__pyx_v_self->use_learning_rate_decay);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.use_learning_rate_decay.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_23use_learning_rate_decay_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_23use_learning_rate_decay_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 85, 0, __PYX_ERR(0, 85, __pyx_L1_error));
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(0, 85, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->use_learning_rate_decay);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->use_learning_rate_decay));
  __pyx_v_self->use_learning_rate_decay = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.use_learning_rate_decay.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_23use_learning_rate_decay_4__del__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_23use_learning_rate_decay_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 85, 0, __PYX_ERR(0, 85, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->use_learning_rate_decay);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->use_learning_rate_decay));
  __pyx_v_self->use_learning_rate_decay = ((PyBoolObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.use_learning_rate_decay.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":86
 *     cdef public float decay_factor
 *     cdef public bool use_learning_rate_decay
 *     cdef readonly int features_per_token             # <<<<<<<<<<<<<<
 * 
 *     # lookup for fast access to all the token embeddings in a sentence
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_18features_per_token_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_18features_per_token_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_18features_per_token___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_18features_per_token___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 86, 0, __PYX_ERR(0, 86, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->features_per_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.features_per_token.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":93
 *     # padding stuff
 *     cdef np.ndarray padding_left, padding_right
 *     cdef public np.ndarray pre_padding, pos_padding             # <<<<<<<<<<<<<<
 * 
 *     # weights, biases, calculated values
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_11pre_padding_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_11pre_padding_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11pre_padding___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_11pre_padding___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 93, 0, __PYX_ERR(0, 93, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pre_padding));
  __pyx_r = ((PyObject *)__pyx_v_self->pre_padding);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.pre_padding.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_11pre_padding_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_11pre_padding_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11pre_padding_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_11pre_padding_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 93, 0, __PYX_ERR(0, 93, __pyx_L1_error));
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 93, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pre_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pre_padding));
  __pyx_v_self->pre_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.pre_padding.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_11pre_padding_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_7Network_11pre_padding_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11pre_padding_4__del__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_11pre_padding_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 93, 0, __PYX_ERR(0, 93, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->pre_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pre_padding));
  __pyx_v_self->pre_padding = ((PyArrayObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.pre_padding.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_11pos_padding_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_11pos_padding_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11pos_padding___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_11pos_padding___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 93, 0, __PYX_ERR(0, 93, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pos_padding));
  __pyx_r = ((PyObject *)__pyx_v_self->pos_padding);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.pos_padding.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_11pos_padding_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_11pos_padding_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11pos_padding_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_11pos_padding_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 93, 0, __PYX_ERR(0, 93, __pyx_L1_error));
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 93, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pos_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pos_padding));
  __pyx_v_self->pos_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.pos_padding.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_11pos_padding_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_7Network_11pos_padding_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11pos_padding_4__del__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_11pos_padding_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 93, 0, __PYX_ERR(0, 93, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->pos_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pos_padding));
  __pyx_v_self->pos_padding = ((PyArrayObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.pos_padding.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":96
 * 
 *     # weights, biases, calculated values
 *     cdef readonly np.ndarray hidden_weights, output_weights             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray hidden_bias, output_bias
 *     cdef readonly np.ndarray input_values, hidden_values, layer2_values
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_14hidden_weights_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_14hidden_weights_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_14hidden_weights___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_14hidden_weights___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 96, 0, __PYX_ERR(0, 96, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_weights));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden_weights);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.hidden_weights.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_14output_weights_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_14output_weights_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_14output_weights___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_14output_weights___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 96, 0, __PYX_ERR(0, 96, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->output_weights));
  __pyx_r = ((PyObject *)__pyx_v_self->output_weights);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.output_weights.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":97
 *     # weights, biases, calculated values
 *     cdef readonly np.ndarray hidden_weights, output_weights
 *     cdef readonly np.ndarray hidden_bias, output_bias             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray input_values, hidden_values, layer2_values
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_11hidden_bias_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_11hidden_bias_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11hidden_bias___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_11hidden_bias___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 97, 0, __PYX_ERR(0, 97, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_bias));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden_bias);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.hidden_bias.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_11output_bias_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_11output_bias_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11output_bias___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_11output_bias___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 97, 0, __PYX_ERR(0, 97, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->output_bias));
  __pyx_r = ((PyObject *)__pyx_v_self->output_bias);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.output_bias.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":98
 *     cdef readonly np.ndarray hidden_weights, output_weights
 *     cdef readonly np.ndarray hidden_bias, output_bias
 *     cdef readonly np.ndarray input_values, hidden_values, layer2_values             # <<<<<<<<<<<<<<
 * 
 *     # feature tables
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_12input_values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_12input_values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_12input_values___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_12input_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 98, 0, __PYX_ERR(0, 98, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->input_values));
  __pyx_r = ((PyObject *)__pyx_v_self->input_values);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.input_values.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_13hidden_values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_13hidden_values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_13hidden_values___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_13hidden_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 98, 0, __PYX_ERR(0, 98, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_values));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden_values);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.hidden_values.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_13layer2_values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_13layer2_values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_13layer2_values___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_13layer2_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 98, 0, __PYX_ERR(0, 98, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->layer2_values));
  __pyx_r = ((PyObject *)__pyx_v_self->layer2_values);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.layer2_values.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":101
 * 
 *     # feature tables
 *     cdef public list feature_tables             # <<<<<<<<<<<<<<
 * 
 *     # transitions
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_14feature_tables_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_14feature_tables_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_14feature_tables___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_14feature_tables___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 101, 0, __PYX_ERR(0, 101, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->feature_tables);
  __pyx_r = __pyx_v_self->feature_tables;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.feature_tables.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_14feature_tables_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_14feature_tables_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_14feature_tables_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_14feature_tables_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 101, 0, __PYX_ERR(0, 101, __pyx_L1_error));
  if (!(likely(PyList_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 101, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->feature_tables);
  __Pyx_DECREF(__pyx_v_self->feature_tables);
  __pyx_v_self->feature_tables = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.feature_tables.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_14feature_tables_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_7Network_14feature_tables_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_14feature_tables_4__del__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_14feature_tables_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 101, 0, __PYX_ERR(0, 101, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->feature_tables);
  __Pyx_DECREF(__pyx_v_self->feature_tables);
  __pyx_v_self->feature_tables = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.feature_tables.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":104
 * 
 *     # transitions
 *     cdef public float learning_rate_trans             # <<<<<<<<<<<<<<
 *     cdef public np.ndarray transitions
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_19learning_rate_trans_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_19learning_rate_trans_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_19learning_rate_trans___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_19learning_rate_trans___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 104, 0, __PYX_ERR(0, 104, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->learning_rate_trans); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.learning_rate_trans.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_19learning_rate_trans_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_19learning_rate_trans_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_19learning_rate_trans_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_19learning_rate_trans_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 104, 0, __PYX_ERR(0, 104, __pyx_L1_error));
  __pyx_t_1 = __pyx_PyFloat_AsFloat(__pyx_v_value); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) __PYX_ERR(0, 104, __pyx_L1_error)
  __pyx_v_self->learning_rate_trans = __pyx_t_1;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.learning_rate_trans.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":105
 *     # transitions
 *     cdef public float learning_rate_trans
 *     cdef public np.ndarray transitions             # <<<<<<<<<<<<<<
 * 
 *     # the score for a given path
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_11transitions_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_11transitions_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11transitions___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_11transitions___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 105, 0, __PYX_ERR(0, 105, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->transitions));
  __pyx_r = ((PyObject *)__pyx_v_self->transitions);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.transitions.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_11transitions_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_11transitions_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11transitions_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_11transitions_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 105, 0, __PYX_ERR(0, 105, __pyx_L1_error));
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 105, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->transitions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->transitions));
  __pyx_v_self->transitions = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.transitions.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_11transitions_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_7Network_11transitions_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_11transitions_4__del__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_11transitions_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 105, 0, __PYX_ERR(0, 105, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->transitions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->transitions));
  __pyx_v_self->transitions = ((PyArrayObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.transitions.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":108
 * 
 *     # the score for a given path
 *     cdef readonly float answer_score             # <<<<<<<<<<<<<<
 * 
 *     # gradients
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_12answer_score_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_12answer_score_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_12answer_score___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_12answer_score___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 108, 0, __PYX_ERR(0, 108, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->answer_score); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.answer_score.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":111
 * 
 *     # gradients
 *     cdef readonly np.ndarray net_gradients, trans_gradients             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray input_sent_values, hidden_sent_values, layer2_sent_values
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_13net_gradients_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_13net_gradients_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_13net_gradients___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_13net_gradients___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 111, 0, __PYX_ERR(0, 111, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->net_gradients));
  __pyx_r = ((PyObject *)__pyx_v_self->net_gradients);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.net_gradients.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_15trans_gradients_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_15trans_gradients_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_15trans_gradients___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_15trans_gradients___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 111, 0, __PYX_ERR(0, 111, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->trans_gradients));
  __pyx_r = ((PyObject *)__pyx_v_self->trans_gradients);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.trans_gradients.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":112
 *     # gradients
 *     cdef readonly np.ndarray net_gradients, trans_gradients
 *     cdef readonly np.ndarray input_sent_values, hidden_sent_values, layer2_sent_values             # <<<<<<<<<<<<<<
 * 
 *     # data for statistics during training.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_17input_sent_values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_17input_sent_values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_17input_sent_values___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_17input_sent_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 112, 0, __PYX_ERR(0, 112, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->input_sent_values));
  __pyx_r = ((PyObject *)__pyx_v_self->input_sent_values);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.input_sent_values.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_18hidden_sent_values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_18hidden_sent_values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_18hidden_sent_values___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_18hidden_sent_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 112, 0, __PYX_ERR(0, 112, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_sent_values));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden_sent_values);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.hidden_sent_values.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_18layer2_sent_values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_18layer2_sent_values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_18layer2_sent_values___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_18layer2_sent_values___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 112, 0, __PYX_ERR(0, 112, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->layer2_sent_values));
  __pyx_r = ((PyObject *)__pyx_v_self->layer2_sent_values);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.layer2_sent_values.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":119
 * 
 *     # file where the network is saved
 *     cdef public str network_filename             # <<<<<<<<<<<<<<
 *     cdef public str network_text_filename
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_16network_filename_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_16network_filename_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_16network_filename___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_16network_filename___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 119, 0, __PYX_ERR(0, 119, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->network_filename);
  __pyx_r = __pyx_v_self->network_filename;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.network_filename.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_16network_filename_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_16network_filename_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_16network_filename_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_16network_filename_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 119, 0, __PYX_ERR(0, 119, __pyx_L1_error));
  if (!(likely(PyUnicode_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 119, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->network_filename);
  __Pyx_DECREF(__pyx_v_self->network_filename);
  __pyx_v_self->network_filename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.network_filename.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_16network_filename_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_7Network_16network_filename_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_16network_filename_4__del__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_16network_filename_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 119, 0, __PYX_ERR(0, 119, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->network_filename);
  __Pyx_DECREF(__pyx_v_self->network_filename);
  __pyx_v_self->network_filename = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.network_filename.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "libs/network.pyx":120
 *     # file where the network is saved
 *     cdef public str network_filename
 *     cdef public str network_text_filename             # <<<<<<<<<<<<<<
 * 
 *     # validation
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_21network_text_filename_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_7Network_21network_text_filename_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_21network_text_filename___get__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_21network_text_filename___get__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[0], 120, 0, __PYX_ERR(0, 120, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->network_text_filename);
  __pyx_r = __pyx_v_self->network_text_filename;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.network_text_filename.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_21network_text_filename_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_7Network_21network_text_filename_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_21network_text_filename_2__set__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_21network_text_filename_2__set__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[0], 120, 0, __PYX_ERR(0, 120, __pyx_L1_error));
  if (!(likely(PyUnicode_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 120, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->network_text_filename);
  __Pyx_DECREF(__pyx_v_self->network_text_filename);
  __pyx_v_self->network_text_filename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.network_text_filename.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_7Network_21network_text_filename_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_7Network_21network_text_filename_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_21network_text_filename_4__del__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_7Network_21network_text_filename_4__del__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[0], 120, 0, __PYX_ERR(0, 120, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->network_text_filename);
  __Pyx_DECREF(__pyx_v_self->network_text_filename);
  __pyx_v_self->network_text_filename = ((PyObject*)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.Network.network_text_filename.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_43__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_7Network_42__reduce_cython__[] = "Network.__reduce_cython__(self)";
static PyObject *__pyx_pw_4libs_7network_7Network_43__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_42__reduce_cython__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_42__reduce_cython__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.accuracy, self.answer_score, self.decay_factor, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.hidden_bias, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.net_gradients, self.network_filename, self.network_text_filename, self.num_tokens, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.sentence_accuracy, self.sentence_lookup, self.skips, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_sentences, self.validation_tags, self.word_window_size)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->accuracy); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->answer_score); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->decay_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->error); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->features_per_token); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->float_errors); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->hidden_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->input_size); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_self->learning_rate); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = PyFloat_FromDouble(__pyx_v_self->learning_rate_features); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_self->learning_rate_trans); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_self->num_tokens); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_self->output_size); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = PyFloat_FromDouble(__pyx_v_self->sentence_accuracy); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_self->skips); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_self->word_window_size); if (unlikely(!__pyx_t_16)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_17 = PyTuple_New(40); if (unlikely(!__pyx_t_17)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_17, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_17, 3, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->feature_tables);
  __Pyx_GIVEREF(__pyx_v_self->feature_tables);
  PyTuple_SET_ITEM(__pyx_t_17, 4, __pyx_v_self->feature_tables);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_17, 5, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_17, 6, __pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_bias));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden_bias));
  PyTuple_SET_ITEM(__pyx_t_17, 7, ((PyObject *)__pyx_v_self->hidden_bias));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden_sent_values));
  PyTuple_SET_ITEM(__pyx_t_17, 8, ((PyObject *)__pyx_v_self->hidden_sent_values));
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_17, 9, __pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden_values));
  PyTuple_SET_ITEM(__pyx_t_17, 10, ((PyObject *)__pyx_v_self->hidden_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden_weights));
  PyTuple_SET_ITEM(__pyx_t_17, 11, ((PyObject *)__pyx_v_self->hidden_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->input_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->input_sent_values));
  PyTuple_SET_ITEM(__pyx_t_17, 12, ((PyObject *)__pyx_v_self->input_sent_values));
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_17, 13, __pyx_t_8);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->input_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->input_values));
  PyTuple_SET_ITEM(__pyx_t_17, 14, ((PyObject *)__pyx_v_self->input_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->layer2_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->layer2_sent_values));
  PyTuple_SET_ITEM(__pyx_t_17, 15, ((PyObject *)__pyx_v_self->layer2_sent_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->layer2_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->layer2_values));
  PyTuple_SET_ITEM(__pyx_t_17, 16, ((PyObject *)__pyx_v_self->layer2_values));
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_17, 17, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_17, 18, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_17, 19, __pyx_t_11);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->net_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->net_gradients));
  PyTuple_SET_ITEM(__pyx_t_17, 20, ((PyObject *)__pyx_v_self->net_gradients));
  __Pyx_INCREF(__pyx_v_self->network_filename);
  __Pyx_GIVEREF(__pyx_v_self->network_filename);
  PyTuple_SET_ITEM(__pyx_t_17, 21, __pyx_v_self->network_filename);
  __Pyx_INCREF(__pyx_v_self->network_text_filename);
  __Pyx_GIVEREF(__pyx_v_self->network_text_filename);
  PyTuple_SET_ITEM(__pyx_t_17, 22, __pyx_v_self->network_text_filename);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_17, 23, __pyx_t_12);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->output_bias));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->output_bias));
  PyTuple_SET_ITEM(__pyx_t_17, 24, ((PyObject *)__pyx_v_self->output_bias));
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_17, 25, __pyx_t_13);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->output_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->output_weights));
  PyTuple_SET_ITEM(__pyx_t_17, 26, ((PyObject *)__pyx_v_self->output_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->padding_left));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->padding_left));
  PyTuple_SET_ITEM(__pyx_t_17, 27, ((PyObject *)__pyx_v_self->padding_left));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->padding_right));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->padding_right));
  PyTuple_SET_ITEM(__pyx_t_17, 28, ((PyObject *)__pyx_v_self->padding_right));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pos_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pos_padding));
  PyTuple_SET_ITEM(__pyx_t_17, 29, ((PyObject *)__pyx_v_self->pos_padding));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pre_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pre_padding));
  PyTuple_SET_ITEM(__pyx_t_17, 30, ((PyObject *)__pyx_v_self->pre_padding));
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_17, 31, __pyx_t_14);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->sentence_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->sentence_lookup));
  PyTuple_SET_ITEM(__pyx_t_17, 32, ((PyObject *)__pyx_v_self->sentence_lookup));
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_17, 33, __pyx_t_15);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->trans_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->trans_gradients));
  PyTuple_SET_ITEM(__pyx_t_17, 34, ((PyObject *)__pyx_v_self->trans_gradients));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->transitions));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->transitions));
  PyTuple_SET_ITEM(__pyx_t_17, 35, ((PyObject *)__pyx_v_self->transitions));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->use_learning_rate_decay));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->use_learning_rate_decay));
  PyTuple_SET_ITEM(__pyx_t_17, 36, ((PyObject *)__pyx_v_self->use_learning_rate_decay));
  __Pyx_INCREF(__pyx_v_self->validation_sentences);
  __Pyx_GIVEREF(__pyx_v_self->validation_sentences);
  PyTuple_SET_ITEM(__pyx_t_17, 37, __pyx_v_self->validation_sentences);
  __Pyx_INCREF(__pyx_v_self->validation_tags);
  __Pyx_GIVEREF(__pyx_v_self->validation_tags);
  PyTuple_SET_ITEM(__pyx_t_17, 38, __pyx_v_self->validation_tags);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_17, 39, __pyx_t_16);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_t_16 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_17);
  __pyx_t_17 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.accuracy, self.answer_score, self.decay_factor, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.hidden_bias, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.net_gradients, self.network_filename, self.network_text_filename, self.num_tokens, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.sentence_accuracy, self.sentence_lookup, self.skips, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_17 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_17)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_v__dict = __pyx_t_17;
  __pyx_t_17 = 0;

  /* "(tree fragment)":7
 *     state = (self.accuracy, self.answer_score, self.decay_factor, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.hidden_bias, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.net_gradients, self.network_filename, self.network_text_filename, self.num_tokens, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.sentence_accuracy, self.sentence_lookup, self.skips, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_18 = (__pyx_v__dict != Py_None);
  __pyx_t_19 = (__pyx_t_18 != 0);
  if (__pyx_t_19) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_17 = PyTuple_New(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_v__dict);
    __pyx_t_16 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_17); if (unlikely(!__pyx_t_16)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_16));
    __pyx_t_16 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.feature_tables is not None or self.hidden_bias is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.sentence_lookup is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_sentences is not None or self.validation_tags is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.accuracy, self.answer_score, self.decay_factor, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.hidden_bias, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.net_gradients, self.network_filename, self.network_text_filename, self.num_tokens, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.sentence_accuracy, self.sentence_lookup, self.skips, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.feature_tables is not None or self.hidden_bias is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.sentence_lookup is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_sentences is not None or self.validation_tags is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, None), state
 */
  /*else*/ {
    __pyx_t_18 = (__pyx_v_self->feature_tables != ((PyObject*)Py_None));
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->hidden_bias) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->hidden_sent_values) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->hidden_values) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->hidden_weights) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->input_sent_values) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->input_values) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->layer2_sent_values) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->layer2_values) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->net_gradients) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->network_filename != ((PyObject*)Py_None));
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (__pyx_v_self->network_text_filename != ((PyObject*)Py_None));
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->output_bias) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->output_weights) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->padding_left) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->padding_right) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->pos_padding) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->pre_padding) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->sentence_lookup) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->trans_gradients) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (((PyObject *)__pyx_v_self->transitions) != Py_None);
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (((PyObject *)__pyx_v_self->use_learning_rate_decay) != Py_None);
    __pyx_t_18 = (__pyx_t_20 != 0);
    if (!__pyx_t_18) {
    } else {
      __pyx_t_19 = __pyx_t_18;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_18 = (__pyx_v_self->validation_sentences != ((PyObject*)Py_None));
    __pyx_t_20 = (__pyx_t_18 != 0);
    if (!__pyx_t_20) {
    } else {
      __pyx_t_19 = __pyx_t_20;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_20 = (__pyx_v_self->validation_tags != ((PyObject*)Py_None));
    __pyx_t_18 = (__pyx_t_20 != 0);
    __pyx_t_19 = __pyx_t_18;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_19;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.feature_tables is not None or self.hidden_bias is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.sentence_lookup is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, None), state
 *     else:
 */
  __pyx_t_19 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_19) {

    /* "(tree fragment)":13
 *         use_setstate = self.feature_tables is not None or self.hidden_bias is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.sentence_lookup is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_pyx_unpickle_Network); if (unlikely(!__pyx_t_16)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_17 = PyTuple_New(3); if (unlikely(!__pyx_t_17)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_17, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_202246394);
    __Pyx_GIVEREF(__pyx_int_202246394);
    PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_int_202246394);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_17, 2, Py_None);
    __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_16);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_16);
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_17);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_v_state);
    __pyx_t_16 = 0;
    __pyx_t_17 = 0;
    __pyx_r = __pyx_t_15;
    __pyx_t_15 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.feature_tables is not None or self.hidden_bias is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.sentence_lookup is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, None), state
 *     else:
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Network__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_pyx_unpickle_Network); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_17 = PyTuple_New(3); if (unlikely(!__pyx_t_17)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_17, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_202246394);
    __Pyx_GIVEREF(__pyx_int_202246394);
    PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_int_202246394);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_17, 2, __pyx_v_state);
    __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_17);
    __pyx_t_15 = 0;
    __pyx_t_17 = 0;
    __pyx_r = __pyx_t_16;
    __pyx_t_16 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("libs.network.Network.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Network__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_7Network_45__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4libs_7network_7Network_44__setstate_cython__[] = "Network.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4libs_7network_7Network_45__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_7Network_44__setstate_cython__(((struct __pyx_obj_4libs_7network_Network *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_7Network_44__setstate_cython__(struct __pyx_obj_4libs_7network_Network *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));

  /* "(tree fragment)":17
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_Network__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4libs_7network___pyx_unpickle_Network__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_Network, (type(self), 0xc0e08fa, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_Network__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.Network.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":52
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, target_dist_table, pred_dist_table,             # <<<<<<<<<<<<<<
 *                    int word_window, int hidden1_size, int hidden2_size, int output_size):
 *         """Creates a new convolutional neural network."""
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_1create_new(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_create_new[] = "ConvolutionalNetwork.create_new(type cls, feature_tables, target_dist_table, pred_dist_table, int word_window, int hidden1_size, int hidden2_size, int output_size)\nCreates a new convolutional neural network.";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_1create_new(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_feature_tables = 0;
  PyObject *__pyx_v_target_dist_table = 0;
  PyObject *__pyx_v_pred_dist_table = 0;
  int __pyx_v_word_window;
  int __pyx_v_hidden1_size;
  int __pyx_v_hidden2_size;
  int __pyx_v_output_size;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_new (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_feature_tables,&__pyx_n_s_target_dist_table,&__pyx_n_s_pred_dist_table,&__pyx_n_s_word_window,&__pyx_n_s_hidden1_size,&__pyx_n_s_hidden2_size,&__pyx_n_s_output_size,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_feature_tables)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target_dist_table)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 7, 7, 1); __PYX_ERR(1, 52, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pred_dist_table)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 7, 7, 2); __PYX_ERR(1, 52, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_word_window)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 7, 7, 3); __PYX_ERR(1, 52, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden1_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 7, 7, 4); __PYX_ERR(1, 52, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden2_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 7, 7, 5); __PYX_ERR(1, 52, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("create_new", 1, 7, 7, 6); __PYX_ERR(1, 52, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_new") < 0)) __PYX_ERR(1, 52, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
    }
    __pyx_v_feature_tables = values[0];
    __pyx_v_target_dist_table = values[1];
    __pyx_v_pred_dist_table = values[2];
    __pyx_v_word_window = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_word_window == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 53, __pyx_L3_error)
    __pyx_v_hidden1_size = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_hidden1_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 53, __pyx_L3_error)
    __pyx_v_hidden2_size = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_hidden2_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 53, __pyx_L3_error)
    __pyx_v_output_size = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_output_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 53, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_new", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 52, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.create_new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_create_new(((PyTypeObject*)__pyx_v_cls), __pyx_v_feature_tables, __pyx_v_target_dist_table, __pyx_v_pred_dist_table, __pyx_v_word_window, __pyx_v_hidden1_size, __pyx_v_hidden2_size, __pyx_v_output_size);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4libs_7network_20ConvolutionalNetwork_10create_new_2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "networkconv.pyx":56
 *         """Creates a new convolutional neural network."""
 *         # sum the number of features in all tables except for distance
 *         cdef int input_size = sum(table.shape[1] for table in feature_tables)             # <<<<<<<<<<<<<<
 *         input_size *= word_window
 * 
 */

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_10create_new_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *)__pyx_tp_new_4libs_7network___pyx_scope_struct_7_genexpr(__pyx_ptype_4libs_7network___pyx_scope_struct_7_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 56, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4libs_7network_20ConvolutionalNetwork_10create_new_2generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_create_new_locals_genexpr, __pyx_n_s_libs_network); if (unlikely(!gen)) __PYX_ERR(1, 56, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.create_new.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4libs_7network_20ConvolutionalNetwork_10create_new_2generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[1], 56, 0, __PYX_ERR(1, 56, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 56, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables)) { __Pyx_RaiseClosureNameError("feature_tables"); __PYX_ERR(1, 56, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_feature_tables); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 56, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 56, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 56, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 56, __pyx_L1_error)
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 56, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        #endif
      }
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 56, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_table);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_table, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 56, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 56, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":52
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, target_dist_table, pred_dist_table,             # <<<<<<<<<<<<<<
 *                    int word_window, int hidden1_size, int hidden2_size, int output_size):
 *         """Creates a new convolutional neural network."""
 */

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_create_new(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_feature_tables, PyObject *__pyx_v_target_dist_table, PyObject *__pyx_v_pred_dist_table, int __pyx_v_word_window, int __pyx_v_hidden1_size, int __pyx_v_hidden2_size, int __pyx_v_output_size) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *__pyx_cur_scope;
  int __pyx_v_input_size;
  PyObject *__pyx_v_dist_features_per_token = NULL;
  PyObject *__pyx_v_input_size_with_distance = NULL;
  PyObject *__pyx_v_high = NULL;
  PyObject *__pyx_v_hidden_weights = NULL;
  PyObject *__pyx_v_num_dist_features = NULL;
  PyObject *__pyx_v_target_dist_weights = NULL;
  PyObject *__pyx_v_pred_dist_weights = NULL;
  PyObject *__pyx_v_hidden_bias = NULL;
  PyObject *__pyx_v_hidden2_weights = NULL;
  PyObject *__pyx_v_hidden2_bias = NULL;
  PyObject *__pyx_v_output_dim = NULL;
  PyObject *__pyx_v_output_weights = NULL;
  PyObject *__pyx_v_output_bias = NULL;
  PyObject *__pyx_v_net = NULL;
  PyObject *__pyx_gb_4libs_7network_20ConvolutionalNetwork_10create_new_2generator3 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("create_new", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *)__pyx_tp_new_4libs_7network___pyx_scope_struct_6_create_new(__pyx_ptype_4libs_7network___pyx_scope_struct_6_create_new, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 52, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("create_new", __pyx_f[1], 52, 0, __PYX_ERR(1, 52, __pyx_L1_error));
  __pyx_cur_scope->__pyx_v_feature_tables = __pyx_v_feature_tables;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_feature_tables);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_feature_tables);

  /* "networkconv.pyx":56
 *         """Creates a new convolutional neural network."""
 *         # sum the number of features in all tables except for distance
 *         cdef int input_size = sum(table.shape[1] for table in feature_tables)             # <<<<<<<<<<<<<<
 *         input_size *= word_window
 * 
 */
  __pyx_t_1 = __pyx_pf_4libs_7network_20ConvolutionalNetwork_10create_new_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 56, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 56, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_input_size = __pyx_t_3;

  /* "networkconv.pyx":57
 *         # sum the number of features in all tables except for distance
 *         cdef int input_size = sum(table.shape[1] for table in feature_tables)
 *         input_size *= word_window             # <<<<<<<<<<<<<<
 * 
 *         dist_features_per_token = target_dist_table.shape[1] + pred_dist_table.shape[1]
 */
  __pyx_v_input_size = (__pyx_v_input_size * __pyx_v_word_window);

  /* "networkconv.pyx":59
 *         input_size *= word_window
 * 
 *         dist_features_per_token = target_dist_table.shape[1] + pred_dist_table.shape[1]             # <<<<<<<<<<<<<<
 *         input_size_with_distance = input_size + (word_window * dist_features_per_token)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_target_dist_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred_dist_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_dist_features_per_token = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "networkconv.pyx":60
 * 
 *         dist_features_per_token = target_dist_table.shape[1] + pred_dist_table.shape[1]
 *         input_size_with_distance = input_size + (word_window * dist_features_per_token)             # <<<<<<<<<<<<<<
 * 
 *         # creates the weight matrices
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_input_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_word_window); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, __pyx_v_dist_features_per_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_input_size_with_distance = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "networkconv.pyx":63
 * 
 *         # creates the weight matrices
 *         high = 2.38 / np.sqrt(input_size_with_distance) # [Bottou-88]             # <<<<<<<<<<<<<<
 *         hidden_weights = np.random.uniform(-high, high, (hidden1_size, input_size))
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_input_size_with_distance) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_input_size_with_distance);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_2_38, __pyx_t_4, 2.38, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 63, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_high = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "networkconv.pyx":64
 *         # creates the weight matrices
 *         high = 2.38 / np.sqrt(input_size_with_distance) # [Bottou-88]
 *         hidden_weights = np.random.uniform(-high, high, (hidden1_size, input_size))             # <<<<<<<<<<<<<<
 * 
 *         num_dist_features = word_window * target_dist_table.shape[1]
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uniform); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_hidden1_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_input_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 64, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_v_high, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 64, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_v_high, __pyx_t_7};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 64, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 64, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_3, __pyx_t_1);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_3, __pyx_t_7);
    __pyx_t_1 = 0;
    __pyx_t_7 = 0;
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 64, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_hidden_weights = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "networkconv.pyx":66
 *         hidden_weights = np.random.uniform(-high, high, (hidden1_size, input_size))
 * 
 *         num_dist_features = word_window * target_dist_table.shape[1]             # <<<<<<<<<<<<<<
 *         target_dist_weights = np.random.uniform(-high, high, (num_dist_features, hidden1_size))
 *         num_dist_features = word_window * pred_dist_table.shape[1]
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_word_window); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_target_dist_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Multiply(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 66, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_num_dist_features = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "networkconv.pyx":67
 * 
 *         num_dist_features = word_window * target_dist_table.shape[1]
 *         target_dist_weights = np.random.uniform(-high, high, (num_dist_features, hidden1_size))             # <<<<<<<<<<<<<<
 *         num_dist_features = word_window * pred_dist_table.shape[1]
 *         pred_dist_weights = np.random.uniform(-high, high, (num_dist_features, hidden1_size))
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uniform); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_hidden1_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 67, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_num_dist_features);
  __Pyx_GIVEREF(__pyx_v_num_dist_features);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_num_dist_features);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_2, __pyx_v_high, __pyx_t_1};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 67, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_t_2, __pyx_v_high, __pyx_t_1};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 67, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 67, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_3, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_3, __pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 67, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_target_dist_weights = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "networkconv.pyx":68
 *         num_dist_features = word_window * target_dist_table.shape[1]
 *         target_dist_weights = np.random.uniform(-high, high, (num_dist_features, hidden1_size))
 *         num_dist_features = word_window * pred_dist_table.shape[1]             # <<<<<<<<<<<<<<
 *         pred_dist_weights = np.random.uniform(-high, high, (num_dist_features, hidden1_size))
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_word_window); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_pred_dist_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 68, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_num_dist_features, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "networkconv.pyx":69
 *         target_dist_weights = np.random.uniform(-high, high, (num_dist_features, hidden1_size))
 *         num_dist_features = word_window * pred_dist_table.shape[1]
 *         pred_dist_weights = np.random.uniform(-high, high, (num_dist_features, hidden1_size))             # <<<<<<<<<<<<<<
 * 
 *         high = 2.38 / np.sqrt(hidden1_size)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uniform); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_hidden1_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_num_dist_features);
  __Pyx_GIVEREF(__pyx_v_num_dist_features);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_num_dist_features);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_4, __pyx_v_high, __pyx_t_2};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 69, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_4, __pyx_v_high, __pyx_t_2};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 69, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 69, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_3, __pyx_t_4);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_3, __pyx_t_2);
    __pyx_t_4 = 0;
    __pyx_t_2 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 69, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_pred_dist_weights = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "networkconv.pyx":71
 *         pred_dist_weights = np.random.uniform(-high, high, (num_dist_features, hidden1_size))
 * 
 *         high = 2.38 / np.sqrt(hidden1_size)             # <<<<<<<<<<<<<<
 *         hidden_bias = np.random.uniform(-high, high, hidden1_size)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_hidden1_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_2, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_2_38, __pyx_t_5, 2.38, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF_SET(__pyx_v_high, __pyx_t_7);
  __pyx_t_7 = 0;

  /* "networkconv.pyx":72
 * 
 *         high = 2.38 / np.sqrt(hidden1_size)
 *         hidden_bias = np.random.uniform(-high, high, hidden1_size)             # <<<<<<<<<<<<<<
 * 
 *         if hidden2_size > 0:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_random); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uniform); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_hidden1_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_6, __pyx_v_high, __pyx_t_2};
    __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 72, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_6, __pyx_v_high, __pyx_t_2};
    __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 72, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 72, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_3, __pyx_t_6);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_3, __pyx_t_2);
    __pyx_t_6 = 0;
    __pyx_t_2 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 72, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_hidden_bias = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "networkconv.pyx":74
 *         hidden_bias = np.random.uniform(-high, high, hidden1_size)
 * 
 *         if hidden2_size > 0:             # <<<<<<<<<<<<<<
 *             hidden2_weights = np.random.uniform(-high, high, (hidden2_size, hidden1_size))
 *             high = 2.38 / np.sqrt(hidden2_size)
 */
  __pyx_t_8 = ((__pyx_v_hidden2_size > 0) != 0);
  if (__pyx_t_8) {

    /* "networkconv.pyx":75
 * 
 *         if hidden2_size > 0:
 *             hidden2_weights = np.random.uniform(-high, high, (hidden2_size, hidden1_size))             # <<<<<<<<<<<<<<
 *             high = 2.38 / np.sqrt(hidden2_size)
 *             hidden2_bias = np.random.uniform(-high, high, hidden2_size)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_uniform); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_hidden2_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_hidden1_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    __pyx_t_3 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_3 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_v_high, __pyx_t_4};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 75, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_v_high, __pyx_t_4};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 75, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 75, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_3, __pyx_t_1);
      __Pyx_INCREF(__pyx_v_high);
      __Pyx_GIVEREF(__pyx_v_high);
      PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_3, __pyx_v_high);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_3, __pyx_t_4);
      __pyx_t_1 = 0;
      __pyx_t_4 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 75, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_hidden2_weights = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "networkconv.pyx":76
 *         if hidden2_size > 0:
 *             hidden2_weights = np.random.uniform(-high, high, (hidden2_size, hidden1_size))
 *             high = 2.38 / np.sqrt(hidden2_size)             # <<<<<<<<<<<<<<
 *             hidden2_bias = np.random.uniform(-high, high, hidden2_size)
 *             output_dim = (output_size, hidden2_size)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_hidden2_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_7 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_2_38, __pyx_t_7, 2.38, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF_SET(__pyx_v_high, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "networkconv.pyx":77
 *             hidden2_weights = np.random.uniform(-high, high, (hidden2_size, hidden1_size))
 *             high = 2.38 / np.sqrt(hidden2_size)
 *             hidden2_bias = np.random.uniform(-high, high, hidden2_size)             # <<<<<<<<<<<<<<
 *             output_dim = (output_size, hidden2_size)
 *         else:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_uniform); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_hidden2_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 77, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = NULL;
    __pyx_t_3 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_3 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_5, __pyx_v_high, __pyx_t_4};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 77, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[4] = {__pyx_t_1, __pyx_t_5, __pyx_v_high, __pyx_t_4};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 77, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_3, __pyx_t_5);
      __Pyx_INCREF(__pyx_v_high);
      __Pyx_GIVEREF(__pyx_v_high);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_3, __pyx_v_high);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_3, __pyx_t_4);
      __pyx_t_5 = 0;
      __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_hidden2_bias = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "networkconv.pyx":78
 *             high = 2.38 / np.sqrt(hidden2_size)
 *             hidden2_bias = np.random.uniform(-high, high, hidden2_size)
 *             output_dim = (output_size, hidden2_size)             # <<<<<<<<<<<<<<
 *         else:
 *             hidden2_weights = None
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_hidden2_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 78, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
    __pyx_t_2 = 0;
    __pyx_t_7 = 0;
    __pyx_v_output_dim = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "networkconv.pyx":74
 *         hidden_bias = np.random.uniform(-high, high, hidden1_size)
 * 
 *         if hidden2_size > 0:             # <<<<<<<<<<<<<<
 *             hidden2_weights = np.random.uniform(-high, high, (hidden2_size, hidden1_size))
 *             high = 2.38 / np.sqrt(hidden2_size)
 */
    goto __pyx_L3;
  }

  /* "networkconv.pyx":80
 *             output_dim = (output_size, hidden2_size)
 *         else:
 *             hidden2_weights = None             # <<<<<<<<<<<<<<
 *             hidden2_bias = None
 *             output_dim = (output_size, hidden1_size)
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __pyx_v_hidden2_weights = Py_None;

    /* "networkconv.pyx":81
 *         else:
 *             hidden2_weights = None
 *             hidden2_bias = None             # <<<<<<<<<<<<<<
 *             output_dim = (output_size, hidden1_size)
 * 
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_hidden2_bias = Py_None;

    /* "networkconv.pyx":82
 *             hidden2_weights = None
 *             hidden2_bias = None
 *             output_dim = (output_size, hidden1_size)             # <<<<<<<<<<<<<<
 * 
 *         high = 2.38 / np.sqrt(output_dim[1])
 */
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 82, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_hidden1_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 82, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 82, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_v_output_dim = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "networkconv.pyx":84
 *             output_dim = (output_size, hidden1_size)
 * 
 *         high = 2.38 / np.sqrt(output_dim[1])             # <<<<<<<<<<<<<<
 *         output_weights = np.random.uniform(-high, high, output_dim)
 *         high = 2.38 / np.sqrt(output_size)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_output_dim, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_4, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_2_38, __pyx_t_2, 2.38, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 84, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_high, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "networkconv.pyx":85
 * 
 *         high = 2.38 / np.sqrt(output_dim[1])
 *         output_weights = np.random.uniform(-high, high, output_dim)             # <<<<<<<<<<<<<<
 *         high = 2.38 / np.sqrt(output_size)
 *         output_bias = np.random.uniform(-high, high, output_size)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uniform); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 85, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_7, __pyx_v_high, __pyx_v_output_dim};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 85, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_7, __pyx_v_high, __pyx_v_output_dim};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 85, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 85, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_3, __pyx_t_7);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_INCREF(__pyx_v_output_dim);
    __Pyx_GIVEREF(__pyx_v_output_dim);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_3, __pyx_v_output_dim);
    __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 85, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_output_weights = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "networkconv.pyx":86
 *         high = 2.38 / np.sqrt(output_dim[1])
 *         output_weights = np.random.uniform(-high, high, output_dim)
 *         high = 2.38 / np.sqrt(output_size)             # <<<<<<<<<<<<<<
 *         output_bias = np.random.uniform(-high, high, output_size)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyFloat_TrueDivideCObj(__pyx_float_2_38, __pyx_t_6, 2.38, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF_SET(__pyx_v_high, __pyx_t_5);
  __pyx_t_5 = 0;

  /* "networkconv.pyx":87
 *         output_weights = np.random.uniform(-high, high, output_dim)
 *         high = 2.38 / np.sqrt(output_size)
 *         output_bias = np.random.uniform(-high, high, output_size)             # <<<<<<<<<<<<<<
 * 
 *         net = cls(word_window, input_size, hidden1_size, hidden2_size,
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uniform); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Negative(__pyx_v_high); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = NULL;
  __pyx_t_3 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_3 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_2, __pyx_v_high, __pyx_t_7};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 87, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_2, __pyx_v_high, __pyx_t_7};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_3, 3+__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 87, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(3+__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_3, __pyx_t_2);
    __Pyx_INCREF(__pyx_v_high);
    __Pyx_GIVEREF(__pyx_v_high);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_3, __pyx_v_high);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_3, __pyx_t_7);
    __pyx_t_2 = 0;
    __pyx_t_7 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_output_bias = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "networkconv.pyx":89
 *         output_bias = np.random.uniform(-high, high, output_size)
 * 
 *         net = cls(word_window, input_size, hidden1_size, hidden2_size,             # <<<<<<<<<<<<<<
 *                   output_size, hidden_weights, hidden_bias,
 *                   target_dist_weights, pred_dist_weights,
 */
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_word_window); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_input_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_hidden1_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_hidden2_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "networkconv.pyx":90
 * 
 *         net = cls(word_window, input_size, hidden1_size, hidden2_size,
 *                   output_size, hidden_weights, hidden_bias,             # <<<<<<<<<<<<<<
 *                   target_dist_weights, pred_dist_weights,
 *                   hidden2_weights, hidden2_bias,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_output_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 90, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "networkconv.pyx":89
 *         output_bias = np.random.uniform(-high, high, output_size)
 * 
 *         net = cls(word_window, input_size, hidden1_size, hidden2_size,             # <<<<<<<<<<<<<<
 *                   output_size, hidden_weights, hidden_bias,
 *                   target_dist_weights, pred_dist_weights,
 */
  __pyx_t_4 = PyTuple_New(13); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_hidden_weights);
  __Pyx_GIVEREF(__pyx_v_hidden_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_v_hidden_weights);
  __Pyx_INCREF(__pyx_v_hidden_bias);
  __Pyx_GIVEREF(__pyx_v_hidden_bias);
  PyTuple_SET_ITEM(__pyx_t_4, 6, __pyx_v_hidden_bias);
  __Pyx_INCREF(__pyx_v_target_dist_weights);
  __Pyx_GIVEREF(__pyx_v_target_dist_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 7, __pyx_v_target_dist_weights);
  __Pyx_INCREF(__pyx_v_pred_dist_weights);
  __Pyx_GIVEREF(__pyx_v_pred_dist_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 8, __pyx_v_pred_dist_weights);
  __Pyx_INCREF(__pyx_v_hidden2_weights);
  __Pyx_GIVEREF(__pyx_v_hidden2_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 9, __pyx_v_hidden2_weights);
  __Pyx_INCREF(__pyx_v_hidden2_bias);
  __Pyx_GIVEREF(__pyx_v_hidden2_bias);
  PyTuple_SET_ITEM(__pyx_t_4, 10, __pyx_v_hidden2_bias);
  __Pyx_INCREF(__pyx_v_output_weights);
  __Pyx_GIVEREF(__pyx_v_output_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 11, __pyx_v_output_weights);
  __Pyx_INCREF(__pyx_v_output_bias);
  __Pyx_GIVEREF(__pyx_v_output_bias);
  PyTuple_SET_ITEM(__pyx_t_4, 12, __pyx_v_output_bias);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_net = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "networkconv.pyx":94
 *                   hidden2_weights, hidden2_bias,
 *                   output_weights, output_bias)
 *         net.feature_tables = feature_tables             # <<<<<<<<<<<<<<
 *         net.target_dist_table = target_dist_table
 *         net.pred_dist_table = pred_dist_table
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_net, __pyx_n_s_feature_tables, __pyx_cur_scope->__pyx_v_feature_tables) < 0) __PYX_ERR(1, 94, __pyx_L1_error)

  /* "networkconv.pyx":95
 *                   output_weights, output_bias)
 *         net.feature_tables = feature_tables
 *         net.target_dist_table = target_dist_table             # <<<<<<<<<<<<<<
 *         net.pred_dist_table = pred_dist_table
 * 
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_net, __pyx_n_s_target_dist_table, __pyx_v_target_dist_table) < 0) __PYX_ERR(1, 95, __pyx_L1_error)

  /* "networkconv.pyx":96
 *         net.feature_tables = feature_tables
 *         net.target_dist_table = target_dist_table
 *         net.pred_dist_table = pred_dist_table             # <<<<<<<<<<<<<<
 * 
 *         return net
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_net, __pyx_n_s_pred_dist_table, __pyx_v_pred_dist_table) < 0) __PYX_ERR(1, 96, __pyx_L1_error)

  /* "networkconv.pyx":98
 *         net.pred_dist_table = pred_dist_table
 * 
 *         return net             # <<<<<<<<<<<<<<
 * 
 *     def description(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_net);
  __pyx_r = __pyx_v_net;
  goto __pyx_L0;

  /* "networkconv.pyx":52
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, target_dist_table, pred_dist_table,             # <<<<<<<<<<<<<<
 *                    int word_window, int hidden1_size, int hidden2_size, int output_size):
 *         """Creates a new convolutional neural network."""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.create_new", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dist_features_per_token);
  __Pyx_XDECREF(__pyx_v_input_size_with_distance);
  __Pyx_XDECREF(__pyx_v_high);
  __Pyx_XDECREF(__pyx_v_hidden_weights);
  __Pyx_XDECREF(__pyx_v_num_dist_features);
  __Pyx_XDECREF(__pyx_v_target_dist_weights);
  __Pyx_XDECREF(__pyx_v_pred_dist_weights);
  __Pyx_XDECREF(__pyx_v_hidden_bias);
  __Pyx_XDECREF(__pyx_v_hidden2_weights);
  __Pyx_XDECREF(__pyx_v_hidden2_bias);
  __Pyx_XDECREF(__pyx_v_output_dim);
  __Pyx_XDECREF(__pyx_v_output_weights);
  __Pyx_XDECREF(__pyx_v_output_bias);
  __Pyx_XDECREF(__pyx_v_net);
  __Pyx_XDECREF(__pyx_gb_4libs_7network_20ConvolutionalNetwork_10create_new_2generator3);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":100
 *         return net
 * 
 *     def description(self):             # <<<<<<<<<<<<<<
 *         """Returns a textual description of the network."""
 *         hidden2_size = 0 if self.hidden2_weights is None else self.hidden2_size
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_3description(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_2description[] = "ConvolutionalNetwork.description(self)\nReturns a textual description of the network.";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_3description(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("description (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_2description(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_2description(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  long __pyx_v_hidden2_size;
  PyObject *__pyx_v_table_dims = NULL;
  PyObject *__pyx_v_dist_table_dims = NULL;
  PyObject *__pyx_v_desc = NULL;
  PyObject *__pyx_8genexpr5__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_UCS4 __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("description", 0);
  __Pyx_TraceCall("description", __pyx_f[1], 100, 0, __PYX_ERR(1, 100, __pyx_L1_error));

  /* "networkconv.pyx":102
 *     def description(self):
 *         """Returns a textual description of the network."""
 *         hidden2_size = 0 if self.hidden2_weights is None else self.hidden2_size             # <<<<<<<<<<<<<<
 *         table_dims = [str(t.shape[1]) for t in self.feature_tables]
 *         table_dims =  ', '.join(table_dims)
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_self->hidden2_weights) == Py_None);
  if ((__pyx_t_2 != 0)) {
    __pyx_t_1 = 0;
  } else {
    __pyx_t_1 = __pyx_v_self->hidden2_size;
  }
  __pyx_v_hidden2_size = __pyx_t_1;

  /* "networkconv.pyx":103
 *         """Returns a textual description of the network."""
 *         hidden2_size = 0 if self.hidden2_weights is None else self.hidden2_size
 *         table_dims = [str(t.shape[1]) for t in self.feature_tables]             # <<<<<<<<<<<<<<
 *         table_dims =  ', '.join(table_dims)
 * 
 */
  { /* enter inner scope */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 103, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (unlikely(__pyx_v_self->__pyx_base.feature_tables == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(1, 103, __pyx_L5_error)
    }
    __pyx_t_4 = __pyx_v_self->__pyx_base.feature_tables; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    for (;;) {
      if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 103, __pyx_L5_error)
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 103, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_t, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_t, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 103, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_6, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 103, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 103, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 103, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_t); __pyx_8genexpr5__pyx_v_t = 0;
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_t); __pyx_8genexpr5__pyx_v_t = 0;
    goto __pyx_L1_error;
    __pyx_L8_exit_scope:;
  } /* exit inner scope */
  __pyx_v_table_dims = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "networkconv.pyx":104
 *         hidden2_size = 0 if self.hidden2_weights is None else self.hidden2_size
 *         table_dims = [str(t.shape[1]) for t in self.feature_tables]
 *         table_dims =  ', '.join(table_dims)             # <<<<<<<<<<<<<<
 * 
 *         dist_table_dims = '%d, %d' % (self.target_dist_table.shape[1], self.pred_dist_table.shape[1])
 */
  __pyx_t_3 = PyUnicode_Join(__pyx_kp_u_, __pyx_v_table_dims); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF_SET(__pyx_v_table_dims, __pyx_t_3);
  __pyx_t_3 = 0;

  /* "networkconv.pyx":106
 *         table_dims =  ', '.join(table_dims)
 * 
 *         dist_table_dims = '%d, %d' % (self.target_dist_table.shape[1], self.pred_dist_table.shape[1])             # <<<<<<<<<<<<<<
 * 
 *         desc = """
 */
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = 0;
  __pyx_t_8 = 127;
  __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->target_dist_table->dimensions[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_FormatAndDecref(__Pyx_PyNumber_IntOrLong(__pyx_t_4), __pyx_n_u_d); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_8;
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_kp_u_);
  __pyx_t_5 += 2;
  __Pyx_GIVEREF(__pyx_kp_u_);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u_);
  __pyx_t_6 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->pred_dist_table->dimensions[1])); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_PyObject_FormatAndDecref(__Pyx_PyNumber_IntOrLong(__pyx_t_6), __pyx_n_u_d); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_8;
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_dist_table_dims = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "networkconv.pyx":108
 *         dist_table_dims = '%d, %d' % (self.target_dist_table.shape[1], self.pred_dist_table.shape[1])
 * 
 *         desc = """             # <<<<<<<<<<<<<<
 * Word window size: %d
 * Feature table sizes: %s
 */
  __pyx_t_4 = PyTuple_New(15); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = 0;
  __pyx_t_8 = 127;
  __Pyx_INCREF(__pyx_kp_u_Word_window_size);
  __pyx_t_5 += 19;
  __Pyx_GIVEREF(__pyx_kp_u_Word_window_size);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u_Word_window_size);

  /* "networkconv.pyx":116
 * Second hidden layer size: %d
 * Output size: %d
 * """ % (self.word_window_size, table_dims, dist_table_dims, self.input_size, self.hidden_size,             # <<<<<<<<<<<<<<
 *        hidden2_size, self.output_size)
 * 
 */
  __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_self->__pyx_base.word_window_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_kp_u_Feature_table_sizes);
  __pyx_t_5 += 22;
  __Pyx_GIVEREF(__pyx_kp_u_Feature_table_sizes);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u_Feature_table_sizes);
  __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Unicode(__pyx_v_table_dims), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_8;
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_kp_u_Distance_table_sizes_target_and);
  __pyx_t_5 += 46;
  __Pyx_GIVEREF(__pyx_kp_u_Distance_table_sizes_target_and);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_kp_u_Distance_table_sizes_target_and);
  __Pyx_INCREF(__pyx_v_dist_table_dims);
  __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_dist_table_dims) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_dist_table_dims) : __pyx_t_8;
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_dist_table_dims);
  __Pyx_GIVEREF(__pyx_v_dist_table_dims);
  PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_v_dist_table_dims);
  __Pyx_INCREF(__pyx_kp_u_Input_layer_size);
  __pyx_t_5 += 19;
  __Pyx_GIVEREF(__pyx_kp_u_Input_layer_size);
  PyTuple_SET_ITEM(__pyx_t_4, 6, __pyx_kp_u_Input_layer_size);
  __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_self->__pyx_base.input_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 7, __pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_kp_u_Convolution_layer_size);
  __pyx_t_5 += 25;
  __Pyx_GIVEREF(__pyx_kp_u_Convolution_layer_size);
  PyTuple_SET_ITEM(__pyx_t_4, 8, __pyx_kp_u_Convolution_layer_size);
  __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_self->__pyx_base.hidden_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 116, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 9, __pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_kp_u_Second_hidden_layer_size);
  __pyx_t_5 += 28;
  __Pyx_GIVEREF(__pyx_kp_u_Second_hidden_layer_size);
  PyTuple_SET_ITEM(__pyx_t_4, 10, __pyx_kp_u_Second_hidden_layer_size);

  /* "networkconv.pyx":117
 * Output size: %d
 * """ % (self.word_window_size, table_dims, dist_table_dims, self.input_size, self.hidden_size,
 *        hidden2_size, self.output_size)             # <<<<<<<<<<<<<<
 * 
 *         return desc
 */
  __pyx_t_3 = __Pyx_PyUnicode_From_long(__pyx_v_hidden2_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 11, __pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_kp_u_Output_size);
  __pyx_t_5 += 14;
  __Pyx_GIVEREF(__pyx_kp_u_Output_size);
  PyTuple_SET_ITEM(__pyx_t_4, 12, __pyx_kp_u_Output_size);
  __pyx_t_3 = __Pyx_PyUnicode_From_int(__pyx_v_self->__pyx_base.output_size, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 117, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 13, __pyx_t_3);
  __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_kp_u__2);
  __pyx_t_5 += 1;
  __Pyx_GIVEREF(__pyx_kp_u__2);
  PyTuple_SET_ITEM(__pyx_t_4, 14, __pyx_kp_u__2);

  /* "networkconv.pyx":108
 *         dist_table_dims = '%d, %d' % (self.target_dist_table.shape[1], self.pred_dist_table.shape[1])
 * 
 *         desc = """             # <<<<<<<<<<<<<<
 * Word window size: %d
 * Feature table sizes: %s
 */
  __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_4, 15, __pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_desc = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "networkconv.pyx":119
 *        hidden2_size, self.output_size)
 * 
 *         return desc             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_desc);
  __pyx_r = __pyx_v_desc;
  goto __pyx_L0;

  /* "networkconv.pyx":100
 *         return net
 * 
 *     def description(self):             # <<<<<<<<<<<<<<
 *         """Returns a textual description of the network."""
 *         hidden2_size = 0 if self.hidden2_weights is None else self.hidden2_size
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.description", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_table_dims);
  __Pyx_XDECREF(__pyx_v_dist_table_dims);
  __Pyx_XDECREF(__pyx_v_desc);
  __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":122
 * 
 * 
 *     def __init__(self, word_window, input_size, hidden1_size, hidden2_size,             # <<<<<<<<<<<<<<
 *                  output_size, hidden1_weights, hidden1_bias, target_dist_weights,
 *                  pred_dist_weights, hidden2_weights, hidden2_bias,
 */

/* Python wrapper */
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_5__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_5__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_word_window = 0;
  PyObject *__pyx_v_input_size = 0;
  PyObject *__pyx_v_hidden1_size = 0;
  PyObject *__pyx_v_hidden2_size = 0;
  PyObject *__pyx_v_output_size = 0;
  PyObject *__pyx_v_hidden1_weights = 0;
  PyObject *__pyx_v_hidden1_bias = 0;
  PyObject *__pyx_v_target_dist_weights = 0;
  PyObject *__pyx_v_pred_dist_weights = 0;
  PyObject *__pyx_v_hidden2_weights = 0;
  PyObject *__pyx_v_hidden2_bias = 0;
  PyObject *__pyx_v_output_weights = 0;
  PyObject *__pyx_v_output_bias = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_word_window,&__pyx_n_s_input_size,&__pyx_n_s_hidden1_size,&__pyx_n_s_hidden2_size,&__pyx_n_s_output_size,&__pyx_n_s_hidden1_weights,&__pyx_n_s_hidden1_bias,&__pyx_n_s_target_dist_weights,&__pyx_n_s_pred_dist_weights,&__pyx_n_s_hidden2_weights,&__pyx_n_s_hidden2_bias,&__pyx_n_s_output_weights,&__pyx_n_s_output_bias,0};
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
        CYTHON_FALLTHROUGH;
        case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
        CYTHON_FALLTHROUGH;
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        CYTHON_FALLTHROUGH;
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        CYTHON_FALLTHROUGH;
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        CYTHON_FALLTHROUGH;
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        CYTHON_FALLTHROUGH;
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_word_window)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_input_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 1); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden1_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 2); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden2_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 3); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_size)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 4); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden1_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 5); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden1_bias)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 6); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  7:
        if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_target_dist_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 7); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  8:
        if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pred_dist_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 8); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  9:
        if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden2_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 9); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 10:
        if (likely((values[10] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hidden2_bias)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 10); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 11:
        if (likely((values[11] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_weights)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 11); __PYX_ERR(1, 122, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case 12:
        if (likely((values[12] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_output_bias)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, 12); __PYX_ERR(1, 122, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 122, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 13) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
    }
    __pyx_v_word_window = values[0];
    __pyx_v_input_size = values[1];
    __pyx_v_hidden1_size = values[2];
    __pyx_v_hidden2_size = values[3];
    __pyx_v_output_size = values[4];
    __pyx_v_hidden1_weights = values[5];
    __pyx_v_hidden1_bias = values[6];
    __pyx_v_target_dist_weights = values[7];
    __pyx_v_pred_dist_weights = values[8];
    __pyx_v_hidden2_weights = values[9];
    __pyx_v_hidden2_bias = values[10];
    __pyx_v_output_weights = values[11];
    __pyx_v_output_bias = values[12];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 122, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_4__init__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_word_window, __pyx_v_input_size, __pyx_v_hidden1_size, __pyx_v_hidden2_size, __pyx_v_output_size, __pyx_v_hidden1_weights, __pyx_v_hidden1_bias, __pyx_v_target_dist_weights, __pyx_v_pred_dist_weights, __pyx_v_hidden2_weights, __pyx_v_hidden2_bias, __pyx_v_output_weights, __pyx_v_output_bias);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_4__init__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_word_window, PyObject *__pyx_v_input_size, PyObject *__pyx_v_hidden1_size, PyObject *__pyx_v_hidden2_size, PyObject *__pyx_v_output_size, PyObject *__pyx_v_hidden1_weights, PyObject *__pyx_v_hidden1_bias, PyObject *__pyx_v_target_dist_weights, PyObject *__pyx_v_pred_dist_weights, PyObject *__pyx_v_hidden2_weights, PyObject *__pyx_v_hidden2_bias, PyObject *__pyx_v_output_weights, PyObject *__pyx_v_output_bias) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[1], 122, 0, __PYX_ERR(1, 122, __pyx_L1_error));

  /* "networkconv.pyx":126
 *                  pred_dist_weights, hidden2_weights, hidden2_bias,
 *                  output_weights, output_bias):
 *         super(ConvolutionalNetwork, self).__init__(word_window, input_size,             # <<<<<<<<<<<<<<
 *                                                    hidden1_size, output_size,
 *                                                    hidden1_weights, hidden1_bias,
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "networkconv.pyx":129
 *                                                    hidden1_size, output_size,
 *                                                    hidden1_weights, hidden1_bias,
 *                                                    output_weights, output_bias)             # <<<<<<<<<<<<<<
 *         self.half_window = word_window / 2
 *         self.features_per_token = self.input_size / word_window
 */
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[9] = {__pyx_t_3, __pyx_v_word_window, __pyx_v_input_size, __pyx_v_hidden1_size, __pyx_v_output_size, __pyx_v_hidden1_weights, __pyx_v_hidden1_bias, __pyx_v_output_weights, __pyx_v_output_bias};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 8+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 126, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[9] = {__pyx_t_3, __pyx_v_word_window, __pyx_v_input_size, __pyx_v_hidden1_size, __pyx_v_output_size, __pyx_v_hidden1_weights, __pyx_v_hidden1_bias, __pyx_v_output_weights, __pyx_v_output_bias};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 8+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 126, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(8+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_word_window);
    __Pyx_GIVEREF(__pyx_v_word_window);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_word_window);
    __Pyx_INCREF(__pyx_v_input_size);
    __Pyx_GIVEREF(__pyx_v_input_size);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_input_size);
    __Pyx_INCREF(__pyx_v_hidden1_size);
    __Pyx_GIVEREF(__pyx_v_hidden1_size);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_hidden1_size);
    __Pyx_INCREF(__pyx_v_output_size);
    __Pyx_GIVEREF(__pyx_v_output_size);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_output_size);
    __Pyx_INCREF(__pyx_v_hidden1_weights);
    __Pyx_GIVEREF(__pyx_v_hidden1_weights);
    PyTuple_SET_ITEM(__pyx_t_5, 4+__pyx_t_4, __pyx_v_hidden1_weights);
    __Pyx_INCREF(__pyx_v_hidden1_bias);
    __Pyx_GIVEREF(__pyx_v_hidden1_bias);
    PyTuple_SET_ITEM(__pyx_t_5, 5+__pyx_t_4, __pyx_v_hidden1_bias);
    __Pyx_INCREF(__pyx_v_output_weights);
    __Pyx_GIVEREF(__pyx_v_output_weights);
    PyTuple_SET_ITEM(__pyx_t_5, 6+__pyx_t_4, __pyx_v_output_weights);
    __Pyx_INCREF(__pyx_v_output_bias);
    __Pyx_GIVEREF(__pyx_v_output_bias);
    PyTuple_SET_ITEM(__pyx_t_5, 7+__pyx_t_4, __pyx_v_output_bias);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":130
 *                                                    hidden1_weights, hidden1_bias,
 *                                                    output_weights, output_bias)
 *         self.half_window = word_window / 2             # <<<<<<<<<<<<<<
 *         self.features_per_token = self.input_size / word_window
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_TrueDivideObjC(__pyx_v_word_window, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 130, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->half_window = __pyx_t_4;

  /* "networkconv.pyx":131
 *                                                    output_weights, output_bias)
 *         self.half_window = word_window / 2
 *         self.features_per_token = self.input_size / word_window             # <<<<<<<<<<<<<<
 * 
 *         self.transitions = None
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.input_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_v_word_window); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 131, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->__pyx_base.features_per_token = __pyx_t_4;

  /* "networkconv.pyx":133
 *         self.features_per_token = self.input_size / word_window
 * 
 *         self.transitions = None             # <<<<<<<<<<<<<<
 *         self.target_dist_lookup = None
 *         self.pred_dist_lookup = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.transitions);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.transitions));
  __pyx_v_self->__pyx_base.transitions = ((PyArrayObject *)Py_None);

  /* "networkconv.pyx":134
 * 
 *         self.transitions = None
 *         self.target_dist_lookup = None             # <<<<<<<<<<<<<<
 *         self.pred_dist_lookup = None
 *         self.target_dist_weights = target_dist_weights
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->target_dist_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->target_dist_lookup));
  __pyx_v_self->target_dist_lookup = ((PyArrayObject *)Py_None);

  /* "networkconv.pyx":135
 *         self.transitions = None
 *         self.target_dist_lookup = None
 *         self.pred_dist_lookup = None             # <<<<<<<<<<<<<<
 *         self.target_dist_weights = target_dist_weights
 *         self.pred_dist_weights = pred_dist_weights
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->pred_dist_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_dist_lookup));
  __pyx_v_self->pred_dist_lookup = ((PyArrayObject *)Py_None);

  /* "networkconv.pyx":136
 *         self.target_dist_lookup = None
 *         self.pred_dist_lookup = None
 *         self.target_dist_weights = target_dist_weights             # <<<<<<<<<<<<<<
 *         self.pred_dist_weights = pred_dist_weights
 * 
 */
  if (!(likely(((__pyx_v_target_dist_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_target_dist_weights, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 136, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_target_dist_weights;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->target_dist_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->target_dist_weights));
  __pyx_v_self->target_dist_weights = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":137
 *         self.pred_dist_lookup = None
 *         self.target_dist_weights = target_dist_weights
 *         self.pred_dist_weights = pred_dist_weights             # <<<<<<<<<<<<<<
 * 
 *         self.hidden2_size = hidden2_size
 */
  if (!(likely(((__pyx_v_pred_dist_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_pred_dist_weights, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 137, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_pred_dist_weights;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->pred_dist_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_dist_weights));
  __pyx_v_self->pred_dist_weights = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":139
 *         self.pred_dist_weights = pred_dist_weights
 * 
 *         self.hidden2_size = hidden2_size             # <<<<<<<<<<<<<<
 *         self.hidden2_weights = hidden2_weights
 *         self.hidden2_bias = hidden2_bias
 */
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_hidden2_size); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 139, __pyx_L1_error)
  __pyx_v_self->hidden2_size = __pyx_t_4;

  /* "networkconv.pyx":140
 * 
 *         self.hidden2_size = hidden2_size
 *         self.hidden2_weights = hidden2_weights             # <<<<<<<<<<<<<<
 *         self.hidden2_bias = hidden2_bias
 * 
 */
  if (!(likely(((__pyx_v_hidden2_weights) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hidden2_weights, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 140, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_hidden2_weights;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->hidden2_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_weights));
  __pyx_v_self->hidden2_weights = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":141
 *         self.hidden2_size = hidden2_size
 *         self.hidden2_weights = hidden2_weights
 *         self.hidden2_bias = hidden2_bias             # <<<<<<<<<<<<<<
 * 
 *         self.validation_predicates = None
 */
  if (!(likely(((__pyx_v_hidden2_bias) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_hidden2_bias, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 141, __pyx_L1_error)
  __pyx_t_2 = __pyx_v_hidden2_bias;
  __Pyx_INCREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->hidden2_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_bias));
  __pyx_v_self->hidden2_bias = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":143
 *         self.hidden2_bias = hidden2_bias
 * 
 *         self.validation_predicates = None             # <<<<<<<<<<<<<<
 *         self.validation_arguments = None
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->validation_predicates);
  __Pyx_DECREF(__pyx_v_self->validation_predicates);
  __pyx_v_self->validation_predicates = ((PyObject*)Py_None);

  /* "networkconv.pyx":144
 * 
 *         self.validation_predicates = None
 *         self.validation_arguments = None             # <<<<<<<<<<<<<<
 * 
 *         self.use_learning_rate_decay = False
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->validation_arguments);
  __Pyx_DECREF(__pyx_v_self->validation_arguments);
  __pyx_v_self->validation_arguments = ((PyObject*)Py_None);

  /* "networkconv.pyx":146
 *         self.validation_arguments = None
 * 
 *         self.use_learning_rate_decay = False             # <<<<<<<<<<<<<<
 * 
 *     def _generate_save_dict(self):
 */
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.use_learning_rate_decay);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.use_learning_rate_decay));
  __pyx_v_self->__pyx_base.use_learning_rate_decay = ((PyBoolObject *)Py_False);

  /* "networkconv.pyx":122
 * 
 * 
 *     def __init__(self, word_window, input_size, hidden1_size, hidden2_size,             # <<<<<<<<<<<<<<
 *                  output_size, hidden1_weights, hidden1_bias, target_dist_weights,
 *                  pred_dist_weights, hidden2_weights, hidden2_bias,
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":148
 *         self.use_learning_rate_decay = False
 * 
 *     def _generate_save_dict(self):             # <<<<<<<<<<<<<<
 *         """
 *         Generates a dictionary with all parameters saved by the model.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_7_generate_save_dict(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_6_generate_save_dict[] = "ConvolutionalNetwork._generate_save_dict(self)\n\n        Generates a dictionary with all parameters saved by the model.\n        It is directly used by the numpy savez function.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_7_generate_save_dict(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_generate_save_dict (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_6_generate_save_dict(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_6_generate_save_dict(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_generate_save_dict", 0);
  __Pyx_TraceCall("_generate_save_dict", __pyx_f[1], 148, 0, __PYX_ERR(1, 148, __pyx_L1_error));

  /* "networkconv.pyx":153
 *         It is directly used by the numpy savez function.
 *         """
 *         d = dict(hidden_weights=self.hidden_weights,             # <<<<<<<<<<<<<<
 *                  target_dist_table=self.target_dist_table,
 *                  pred_dist_table=self.pred_dist_table,
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(19); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 153, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_hidden_weights, ((PyObject *)__pyx_v_self->__pyx_base.hidden_weights)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":154
 *         """
 *         d = dict(hidden_weights=self.hidden_weights,
 *                  target_dist_table=self.target_dist_table,             # <<<<<<<<<<<<<<
 *                  pred_dist_table=self.pred_dist_table,
 *                  target_dist_weights=self.target_dist_weights,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_target_dist_table, ((PyObject *)__pyx_v_self->target_dist_table)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":155
 *         d = dict(hidden_weights=self.hidden_weights,
 *                  target_dist_table=self.target_dist_table,
 *                  pred_dist_table=self.pred_dist_table,             # <<<<<<<<<<<<<<
 *                  target_dist_weights=self.target_dist_weights,
 *                  pred_dist_weights=self.pred_dist_weights,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_pred_dist_table, ((PyObject *)__pyx_v_self->pred_dist_table)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":156
 *                  target_dist_table=self.target_dist_table,
 *                  pred_dist_table=self.pred_dist_table,
 *                  target_dist_weights=self.target_dist_weights,             # <<<<<<<<<<<<<<
 *                  pred_dist_weights=self.pred_dist_weights,
 *                  output_weights=self.output_weights,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_target_dist_weights, ((PyObject *)__pyx_v_self->target_dist_weights)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":157
 *                  pred_dist_table=self.pred_dist_table,
 *                  target_dist_weights=self.target_dist_weights,
 *                  pred_dist_weights=self.pred_dist_weights,             # <<<<<<<<<<<<<<
 *                  output_weights=self.output_weights,
 *                  transitions=self.transitions,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_pred_dist_weights, ((PyObject *)__pyx_v_self->pred_dist_weights)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":158
 *                  target_dist_weights=self.target_dist_weights,
 *                  pred_dist_weights=self.pred_dist_weights,
 *                  output_weights=self.output_weights,             # <<<<<<<<<<<<<<
 *                  transitions=self.transitions,
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_output_weights, ((PyObject *)__pyx_v_self->__pyx_base.output_weights)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":159
 *                  pred_dist_weights=self.pred_dist_weights,
 *                  output_weights=self.output_weights,
 *                  transitions=self.transitions,             # <<<<<<<<<<<<<<
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 *                  word_window_size=self.word_window_size,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_transitions, ((PyObject *)__pyx_v_self->__pyx_base.transitions)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":160
 *                  output_weights=self.output_weights,
 *                  transitions=self.transitions,
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,             # <<<<<<<<<<<<<<
 *                  word_window_size=self.word_window_size,
 *                  input_size=self.input_size, hidden_size=self.hidden_size,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_hidden_bias, ((PyObject *)__pyx_v_self->__pyx_base.hidden_bias)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_output_bias, ((PyObject *)__pyx_v_self->__pyx_base.output_bias)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":161
 *                  transitions=self.transitions,
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 *                  word_window_size=self.word_window_size,             # <<<<<<<<<<<<<<
 *                  input_size=self.input_size, hidden_size=self.hidden_size,
 *                  output_size=self.output_size, hidden2_size=self.hidden2_size,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.word_window_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_word_window_size, __pyx_t_2) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":162
 *                  hidden_bias=self.hidden_bias, output_bias=self.output_bias,
 *                  word_window_size=self.word_window_size,
 *                  input_size=self.input_size, hidden_size=self.hidden_size,             # <<<<<<<<<<<<<<
 *                  output_size=self.output_size, hidden2_size=self.hidden2_size,
 *                  hidden2_weights=self.hidden2_weights, hidden2_bias=self.hidden2_bias,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.input_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_input_size, __pyx_t_2) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_hidden_size, __pyx_t_2) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":163
 *                  word_window_size=self.word_window_size,
 *                  input_size=self.input_size, hidden_size=self.hidden_size,
 *                  output_size=self.output_size, hidden2_size=self.hidden2_size,             # <<<<<<<<<<<<<<
 *                  hidden2_weights=self.hidden2_weights, hidden2_bias=self.hidden2_bias,
 *                  padding_left=self.padding_left, padding_right=self.padding_right,
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.output_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_output_size, __pyx_t_2) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->hidden2_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_hidden2_size, __pyx_t_2) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":164
 *                  input_size=self.input_size, hidden_size=self.hidden_size,
 *                  output_size=self.output_size, hidden2_size=self.hidden2_size,
 *                  hidden2_weights=self.hidden2_weights, hidden2_bias=self.hidden2_bias,             # <<<<<<<<<<<<<<
 *                  padding_left=self.padding_left, padding_right=self.padding_right,
 *                  feature_tables=self.feature_tables)
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_hidden2_weights, ((PyObject *)__pyx_v_self->hidden2_weights)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_hidden2_bias, ((PyObject *)__pyx_v_self->hidden2_bias)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":165
 *                  output_size=self.output_size, hidden2_size=self.hidden2_size,
 *                  hidden2_weights=self.hidden2_weights, hidden2_bias=self.hidden2_bias,
 *                  padding_left=self.padding_left, padding_right=self.padding_right,             # <<<<<<<<<<<<<<
 *                  feature_tables=self.feature_tables)
 *         return d
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_padding_left, ((PyObject *)__pyx_v_self->__pyx_base.padding_left)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_padding_right, ((PyObject *)__pyx_v_self->__pyx_base.padding_right)) < 0) __PYX_ERR(1, 153, __pyx_L1_error)

  /* "networkconv.pyx":166
 *                  hidden2_weights=self.hidden2_weights, hidden2_bias=self.hidden2_bias,
 *                  padding_left=self.padding_left, padding_right=self.padding_right,
 *                  feature_tables=self.feature_tables)             # <<<<<<<<<<<<<<
 *         return d
 * 
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_feature_tables, __pyx_v_self->__pyx_base.feature_tables) < 0) __PYX_ERR(1, 153, __pyx_L1_error)
  __pyx_v_d = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":167
 *                  padding_left=self.padding_left, padding_right=self.padding_right,
 *                  feature_tables=self.feature_tables)
 *         return d             # <<<<<<<<<<<<<<
 * 
 *     def save(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_d);
  __pyx_r = __pyx_v_d;
  goto __pyx_L0;

  /* "networkconv.pyx":148
 *         self.use_learning_rate_decay = False
 * 
 *     def _generate_save_dict(self):             # <<<<<<<<<<<<<<
 *         """
 *         Generates a dictionary with all parameters saved by the model.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._generate_save_dict", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":169
 *         return d
 * 
 *     def save(self):             # <<<<<<<<<<<<<<
 *         """
 *         Saves the neural network to a file.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_9save(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_8save[] = "ConvolutionalNetwork.save(self)\n\n        Saves the neural network to a file.\n        It will save the weights, biases, sizes, padding and \n        distance tables, and other feature tables.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_9save(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("save (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_8save(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_8save(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("save", 0);
  __Pyx_TraceCall("save", __pyx_f[1], 169, 0, __PYX_ERR(1, 169, __pyx_L1_error));

  /* "networkconv.pyx":175
 *         distance tables, and other feature tables.
 *         """
 *         data = self._generate_save_dict()             # <<<<<<<<<<<<<<
 *         np.savez(self.network_filename, **data)
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_generate_save_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 175, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":176
 *         """
 *         data = self._generate_save_dict()
 *         np.savez(self.network_filename, **data)             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_savez); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.network_filename);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.network_filename);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->__pyx_base.network_filename);
  if (unlikely(__pyx_v_data == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
    __PYX_ERR(1, 176, __pyx_L1_error)
  }
  if (likely(PyDict_CheckExact(__pyx_v_data))) {
    __pyx_t_3 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_data, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 176, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "networkconv.pyx":169
 *         return d
 * 
 *     def save(self):             # <<<<<<<<<<<<<<
 *         """
 *         Saves the neural network to a file.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":179
 * 
 *     @classmethod
 *     def _load_from_file(cls, data, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Internal method for setting data read from a npz file.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_11_load_from_file(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_10_load_from_file[] = "ConvolutionalNetwork._load_from_file(type cls, data, filename)\n\n        Internal method for setting data read from a npz file.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_11_load_from_file(PyObject *__pyx_v_cls, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_data = 0;
  PyObject *__pyx_v_filename = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_load_from_file (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_filename,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filename)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_load_from_file", 1, 2, 2, 1); __PYX_ERR(1, 179, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_load_from_file") < 0)) __PYX_ERR(1, 179, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_data = values[0];
    __pyx_v_filename = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_load_from_file", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 179, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._load_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_10_load_from_file(((PyTypeObject*)__pyx_v_cls), __pyx_v_data, __pyx_v_filename);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_10_load_from_file(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_data, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_hidden_weights = NULL;
  PyObject *__pyx_v_hidden_bias = NULL;
  PyObject *__pyx_v_hidden2_weights = NULL;
  PyObject *__pyx_v_hidden2_bias = NULL;
  PyObject *__pyx_v_output_weights = NULL;
  PyObject *__pyx_v_output_bias = NULL;
  PyObject *__pyx_v_word_window_size = NULL;
  PyObject *__pyx_v_input_size = NULL;
  PyObject *__pyx_v_hidden_size = NULL;
  PyObject *__pyx_v_hidden2_size = NULL;
  PyObject *__pyx_v_output_size = NULL;
  PyObject *__pyx_v_nn = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_load_from_file", 0);
  __Pyx_TraceCall("_load_from_file", __pyx_f[1], 179, 0, __PYX_ERR(1, 179, __pyx_L1_error));

  /* "networkconv.pyx":185
 *         # cython classes don't have the __dict__ attribute
 *         # so we can't do an elegant self.__dict__.update(data)
 *         hidden_weights = data['hidden_weights']             # <<<<<<<<<<<<<<
 *         hidden_bias = data['hidden_bias']
 *         hidden2_weights = data['hidden2_weights']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 185, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden_weights = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":186
 *         # so we can't do an elegant self.__dict__.update(data)
 *         hidden_weights = data['hidden_weights']
 *         hidden_bias = data['hidden_bias']             # <<<<<<<<<<<<<<
 *         hidden2_weights = data['hidden2_weights']
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden_bias = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":187
 *         hidden_weights = data['hidden_weights']
 *         hidden_bias = data['hidden_bias']
 *         hidden2_weights = data['hidden2_weights']             # <<<<<<<<<<<<<<
 * 
 *         hidden2_bias = data['hidden2_bias']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden2_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden2_weights = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":189
 *         hidden2_weights = data['hidden2_weights']
 * 
 *         hidden2_bias = data['hidden2_bias']             # <<<<<<<<<<<<<<
 *         output_weights = data['output_weights']
 *         output_bias = data['output_bias']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden2_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden2_bias = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":190
 * 
 *         hidden2_bias = data['hidden2_bias']
 *         output_weights = data['output_weights']             # <<<<<<<<<<<<<<
 *         output_bias = data['output_bias']
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_output_weights = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":191
 *         hidden2_bias = data['hidden2_bias']
 *         output_weights = data['output_weights']
 *         output_bias = data['output_bias']             # <<<<<<<<<<<<<<
 * 
 *         word_window_size = data['word_window_size']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_output_bias = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":193
 *         output_bias = data['output_bias']
 * 
 *         word_window_size = data['word_window_size']             # <<<<<<<<<<<<<<
 *         input_size = data['input_size']
 *         hidden_size = data['hidden_size']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_word_window_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_word_window_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":194
 * 
 *         word_window_size = data['word_window_size']
 *         input_size = data['input_size']             # <<<<<<<<<<<<<<
 *         hidden_size = data['hidden_size']
 *         hidden2_size = data['hidden2_size']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_input_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_input_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":195
 *         word_window_size = data['word_window_size']
 *         input_size = data['input_size']
 *         hidden_size = data['hidden_size']             # <<<<<<<<<<<<<<
 *         hidden2_size = data['hidden2_size']
 *         output_size = data['output_size']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":196
 *         input_size = data['input_size']
 *         hidden_size = data['hidden_size']
 *         hidden2_size = data['hidden2_size']             # <<<<<<<<<<<<<<
 *         output_size = data['output_size']
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden2_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 196, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_hidden2_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":197
 *         hidden_size = data['hidden_size']
 *         hidden2_size = data['hidden2_size']
 *         output_size = data['output_size']             # <<<<<<<<<<<<<<
 * 
 *         # numpy stores None as an array containing None and with empty shape
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_output_size = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":200
 * 
 *         # numpy stores None as an array containing None and with empty shape
 *         if hidden2_weights.shape == ():             # <<<<<<<<<<<<<<
 *             hidden2_weights = None
 *             hidden2_size = 0
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_hidden2_weights, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_empty_tuple, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "networkconv.pyx":201
 *         # numpy stores None as an array containing None and with empty shape
 *         if hidden2_weights.shape == ():
 *             hidden2_weights = None             # <<<<<<<<<<<<<<
 *             hidden2_size = 0
 *             hidden2_bias = None
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF_SET(__pyx_v_hidden2_weights, Py_None);

    /* "networkconv.pyx":202
 *         if hidden2_weights.shape == ():
 *             hidden2_weights = None
 *             hidden2_size = 0             # <<<<<<<<<<<<<<
 *             hidden2_bias = None
 * 
 */
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_DECREF_SET(__pyx_v_hidden2_size, __pyx_int_0);

    /* "networkconv.pyx":203
 *             hidden2_weights = None
 *             hidden2_size = 0
 *             hidden2_bias = None             # <<<<<<<<<<<<<<
 * 
 *         nn = cls(word_window_size, input_size, hidden_size, hidden2_size,
 */
    __Pyx_INCREF(Py_None);
    __Pyx_DECREF_SET(__pyx_v_hidden2_bias, Py_None);

    /* "networkconv.pyx":200
 * 
 *         # numpy stores None as an array containing None and with empty shape
 *         if hidden2_weights.shape == ():             # <<<<<<<<<<<<<<
 *             hidden2_weights = None
 *             hidden2_size = 0
 */
  }

  /* "networkconv.pyx":207
 *         nn = cls(word_window_size, input_size, hidden_size, hidden2_size,
 *                  output_size, hidden_weights, hidden_bias,
 *                  data['target_dist_weights'], data['pred_dist_weights'],             # <<<<<<<<<<<<<<
 *                  hidden2_weights, hidden2_bias,
 *                  output_weights, output_bias)
 */
  __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_target_dist_weights); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_pred_dist_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "networkconv.pyx":205
 *             hidden2_bias = None
 * 
 *         nn = cls(word_window_size, input_size, hidden_size, hidden2_size,             # <<<<<<<<<<<<<<
 *                  output_size, hidden_weights, hidden_bias,
 *                  data['target_dist_weights'], data['pred_dist_weights'],
 */
  __pyx_t_4 = PyTuple_New(13); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_word_window_size);
  __Pyx_GIVEREF(__pyx_v_word_window_size);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_word_window_size);
  __Pyx_INCREF(__pyx_v_input_size);
  __Pyx_GIVEREF(__pyx_v_input_size);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_input_size);
  __Pyx_INCREF(__pyx_v_hidden_size);
  __Pyx_GIVEREF(__pyx_v_hidden_size);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_hidden_size);
  __Pyx_INCREF(__pyx_v_hidden2_size);
  __Pyx_GIVEREF(__pyx_v_hidden2_size);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_hidden2_size);
  __Pyx_INCREF(__pyx_v_output_size);
  __Pyx_GIVEREF(__pyx_v_output_size);
  PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_output_size);
  __Pyx_INCREF(__pyx_v_hidden_weights);
  __Pyx_GIVEREF(__pyx_v_hidden_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 5, __pyx_v_hidden_weights);
  __Pyx_INCREF(__pyx_v_hidden_bias);
  __Pyx_GIVEREF(__pyx_v_hidden_bias);
  PyTuple_SET_ITEM(__pyx_t_4, 6, __pyx_v_hidden_bias);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 7, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 8, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_hidden2_weights);
  __Pyx_GIVEREF(__pyx_v_hidden2_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 9, __pyx_v_hidden2_weights);
  __Pyx_INCREF(__pyx_v_hidden2_bias);
  __Pyx_GIVEREF(__pyx_v_hidden2_bias);
  PyTuple_SET_ITEM(__pyx_t_4, 10, __pyx_v_hidden2_bias);
  __Pyx_INCREF(__pyx_v_output_weights);
  __Pyx_GIVEREF(__pyx_v_output_weights);
  PyTuple_SET_ITEM(__pyx_t_4, 11, __pyx_v_output_weights);
  __Pyx_INCREF(__pyx_v_output_bias);
  __Pyx_GIVEREF(__pyx_v_output_bias);
  PyTuple_SET_ITEM(__pyx_t_4, 12, __pyx_v_output_bias);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_v_cls), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_nn = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":211
 *                  output_weights, output_bias)
 * 
 *         nn.target_dist_table = data['target_dist_table']             # <<<<<<<<<<<<<<
 *         nn.pred_dist_table = data['pred_dist_table']
 *         #transitions = data['transitions']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_target_dist_table); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_nn, __pyx_n_s_target_dist_table, __pyx_t_1) < 0) __PYX_ERR(1, 211, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":212
 * 
 *         nn.target_dist_table = data['target_dist_table']
 *         nn.pred_dist_table = data['pred_dist_table']             # <<<<<<<<<<<<<<
 *         #transitions = data['transitions']
 *         #nn.transitions = transitions if transitions.shape != () else None
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_pred_dist_table); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_nn, __pyx_n_s_pred_dist_table, __pyx_t_1) < 0) __PYX_ERR(1, 212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":215
 *         #transitions = data['transitions']
 *         #nn.transitions = transitions if transitions.shape != () else None
 *         nn.padding_left = data['padding_left']             # <<<<<<<<<<<<<<
 *         nn.padding_right = data['padding_right']
 *         nn.pre_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_left])
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_padding_left); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 215, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_nn, __pyx_n_s_padding_left, __pyx_t_1) < 0) __PYX_ERR(1, 215, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":216
 *         #nn.transitions = transitions if transitions.shape != () else None
 *         nn.padding_left = data['padding_left']
 *         nn.padding_right = data['padding_right']             # <<<<<<<<<<<<<<
 *         nn.pre_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_left])
 *         nn.pos_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_right])
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_padding_right); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_nn, __pyx_n_s_padding_right, __pyx_t_1) < 0) __PYX_ERR(1, 216, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":217
 *         nn.padding_left = data['padding_left']
 *         nn.padding_right = data['padding_right']
 *         nn.pre_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_left])             # <<<<<<<<<<<<<<
 *         nn.pos_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_right])
 *         nn.feature_tables = list(data['feature_tables'])
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_nn, __pyx_n_s_word_window_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_4, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_nn, __pyx_n_s_padding_left); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_nn, __pyx_n_s_pre_padding, __pyx_t_1) < 0) __PYX_ERR(1, 217, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":218
 *         nn.padding_right = data['padding_right']
 *         nn.pre_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_left])
 *         nn.pos_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_right])             # <<<<<<<<<<<<<<
 *         nn.feature_tables = list(data['feature_tables'])
 *         nn.network_filename = filename
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_nn, __pyx_n_s_word_window_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_2, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_nn, __pyx_n_s_padding_right); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Multiply(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_nn, __pyx_n_s_pos_padding, __pyx_t_1) < 0) __PYX_ERR(1, 218, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":219
 *         nn.pre_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_left])
 *         nn.pos_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_right])
 *         nn.feature_tables = list(data['feature_tables'])             # <<<<<<<<<<<<<<
 *         nn.network_filename = filename
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_feature_tables); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_nn, __pyx_n_s_feature_tables, __pyx_t_5) < 0) __PYX_ERR(1, 219, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "networkconv.pyx":220
 *         nn.pos_padding = np.array(int(nn.word_window_size // 2) * [nn.padding_right])
 *         nn.feature_tables = list(data['feature_tables'])
 *         nn.network_filename = filename             # <<<<<<<<<<<<<<
 * 
 *         return nn
 */
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_nn, __pyx_n_s_network_filename, __pyx_v_filename) < 0) __PYX_ERR(1, 220, __pyx_L1_error)

  /* "networkconv.pyx":222
 *         nn.network_filename = filename
 * 
 *         return nn             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_nn);
  __pyx_r = __pyx_v_nn;
  goto __pyx_L0;

  /* "networkconv.pyx":179
 * 
 *     @classmethod
 *     def _load_from_file(cls, data, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Internal method for setting data read from a npz file.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._load_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_hidden_weights);
  __Pyx_XDECREF(__pyx_v_hidden_bias);
  __Pyx_XDECREF(__pyx_v_hidden2_weights);
  __Pyx_XDECREF(__pyx_v_hidden2_bias);
  __Pyx_XDECREF(__pyx_v_output_weights);
  __Pyx_XDECREF(__pyx_v_output_bias);
  __Pyx_XDECREF(__pyx_v_word_window_size);
  __Pyx_XDECREF(__pyx_v_input_size);
  __Pyx_XDECREF(__pyx_v_hidden_size);
  __Pyx_XDECREF(__pyx_v_hidden2_size);
  __Pyx_XDECREF(__pyx_v_output_size);
  __Pyx_XDECREF(__pyx_v_nn);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":225
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_13load_from_file(PyObject *__pyx_v_cls, PyObject *__pyx_v_filename); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_12load_from_file[] = "ConvolutionalNetwork.load_from_file(type cls, filename)\n\n        Loads the neural network from a file.\n        It will load weights, biases, sizes, padding and \n        distance tables, and other feature tables.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_13load_from_file(PyObject *__pyx_v_cls, PyObject *__pyx_v_filename) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load_from_file (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_12load_from_file(((PyTypeObject*)__pyx_v_cls), ((PyObject *)__pyx_v_filename));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_12load_from_file(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load_from_file", 0);
  __Pyx_TraceCall("load_from_file", __pyx_f[1], 225, 0, __PYX_ERR(1, 225, __pyx_L1_error));

  /* "networkconv.pyx":231
 *         distance tables, and other feature tables.
 *         """
 *         data = np.load(filename, allow_pickle=True) #             # <<<<<<<<<<<<<<
 *         return cls._load_from_file(data, filename)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_load); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allow_pickle, Py_True) < 0) __PYX_ERR(1, 231, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 231, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_data = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "networkconv.pyx":232
 *         """
 *         data = np.load(filename, allow_pickle=True) #
 *         return cls._load_from_file(data, filename)             # <<<<<<<<<<<<<<
 * 
 *     def _load_parameters(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s_load_from_file); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 232, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_data, __pyx_v_filename};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 232, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_data, __pyx_v_filename};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 232, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_data);
    __Pyx_GIVEREF(__pyx_v_data);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_5, __pyx_v_data);
    __Pyx_INCREF(__pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_5, __pyx_v_filename);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 232, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "networkconv.pyx":225
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.load_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":234
 *         return cls._load_from_file(data, filename)
 * 
 *     def _load_parameters(self):             # <<<<<<<<<<<<<<
 *         """
 *         Loads weights, feature tables, distance tables and
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_15_load_parameters(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_14_load_parameters[] = "ConvolutionalNetwork._load_parameters(self)\n\n        Loads weights, feature tables, distance tables and \n        transition tables previously saved.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_15_load_parameters(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_load_parameters (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_14_load_parameters(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_14_load_parameters(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_load_parameters", 0);
  __Pyx_TraceCall("_load_parameters", __pyx_f[1], 234, 0, __PYX_ERR(1, 234, __pyx_L1_error));

  /* "networkconv.pyx":239
 *         transition tables previously saved.
 *         """
 *         data = np.load(self.network_filename)             # <<<<<<<<<<<<<<
 *         self.hidden_weights = data['hidden_weights']
 *         self.hidden_bias = data['hidden_bias']
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_load); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_self->__pyx_base.network_filename) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self->__pyx_base.network_filename);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 239, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":240
 *         """
 *         data = np.load(self.network_filename)
 *         self.hidden_weights = data['hidden_weights']             # <<<<<<<<<<<<<<
 *         self.hidden_bias = data['hidden_bias']
 *         self.output_weights = data['output_weights']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 240, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 240, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.hidden_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_weights));
  __pyx_v_self->__pyx_base.hidden_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":241
 *         data = np.load(self.network_filename)
 *         self.hidden_weights = data['hidden_weights']
 *         self.hidden_bias = data['hidden_bias']             # <<<<<<<<<<<<<<
 *         self.output_weights = data['output_weights']
 *         self.output_bias = data['output_bias']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 241, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 241, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.hidden_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_bias));
  __pyx_v_self->__pyx_base.hidden_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":242
 *         self.hidden_weights = data['hidden_weights']
 *         self.hidden_bias = data['hidden_bias']
 *         self.output_weights = data['output_weights']             # <<<<<<<<<<<<<<
 *         self.output_bias = data['output_bias']
 *         self.feature_tables = list(data['feature_tables'])
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_weights); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 242, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 242, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.output_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.output_weights));
  __pyx_v_self->__pyx_base.output_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":243
 *         self.hidden_bias = data['hidden_bias']
 *         self.output_weights = data['output_weights']
 *         self.output_bias = data['output_bias']             # <<<<<<<<<<<<<<
 *         self.feature_tables = list(data['feature_tables'])
 *         self.target_dist_table = data['target_dist_table']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_output_bias); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 243, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 243, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.output_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.output_bias));
  __pyx_v_self->__pyx_base.output_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":244
 *         self.output_weights = data['output_weights']
 *         self.output_bias = data['output_bias']
 *         self.feature_tables = list(data['feature_tables'])             # <<<<<<<<<<<<<<
 *         self.target_dist_table = data['target_dist_table']
 *         self.pred_dist_table = data['pred_dist_table']
 */
  __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_feature_tables); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 244, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.feature_tables);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.feature_tables);
  __pyx_v_self->__pyx_base.feature_tables = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "networkconv.pyx":245
 *         self.output_bias = data['output_bias']
 *         self.feature_tables = list(data['feature_tables'])
 *         self.target_dist_table = data['target_dist_table']             # <<<<<<<<<<<<<<
 *         self.pred_dist_table = data['pred_dist_table']
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_target_dist_table); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 245, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 245, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->target_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->target_dist_table));
  __pyx_v_self->target_dist_table = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "networkconv.pyx":246
 *         self.feature_tables = list(data['feature_tables'])
 *         self.target_dist_table = data['target_dist_table']
 *         self.pred_dist_table = data['pred_dist_table']             # <<<<<<<<<<<<<<
 * 
 *         # check if transitions isn't None (numpy saves everything as an array)
 */
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_pred_dist_table); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 246, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 246, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->pred_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_dist_table));
  __pyx_v_self->pred_dist_table = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "networkconv.pyx":249
 * 
 *         # check if transitions isn't None (numpy saves everything as an array)
 *         if data['transitions'].shape != ():             # <<<<<<<<<<<<<<
 *             self.transitions = data['transitions']
 *         else:
 */
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_transitions); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 249, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_empty_tuple, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 249, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "networkconv.pyx":250
 *         # check if transitions isn't None (numpy saves everything as an array)
 *         if data['transitions'].shape != ():
 *             self.transitions = data['transitions']             # <<<<<<<<<<<<<<
 *         else:
 *             self.transitions = None
 */
    __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_transitions); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 250, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 250, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.transitions);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.transitions));
    __pyx_v_self->__pyx_base.transitions = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":249
 * 
 *         # check if transitions isn't None (numpy saves everything as an array)
 *         if data['transitions'].shape != ():             # <<<<<<<<<<<<<<
 *             self.transitions = data['transitions']
 *         else:
 */
    goto __pyx_L3;
  }

  /* "networkconv.pyx":252
 *             self.transitions = data['transitions']
 *         else:
 *             self.transitions = None             # <<<<<<<<<<<<<<
 * 
 *         # same for second hidden layer weights
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.transitions);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.transitions));
    __pyx_v_self->__pyx_base.transitions = ((PyArrayObject *)Py_None);
  }
  __pyx_L3:;

  /* "networkconv.pyx":255
 * 
 *         # same for second hidden layer weights
 *         if data['hidden2_weights'].shape != ():             # <<<<<<<<<<<<<<
 *             self.hidden2_weights = data['hidden2_weights']
 *             self.hidden2_bias = data['hidden2_bias']
 */
  __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden2_weights); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_empty_tuple, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 255, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 255, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "networkconv.pyx":256
 *         # same for second hidden layer weights
 *         if data['hidden2_weights'].shape != ():
 *             self.hidden2_weights = data['hidden2_weights']             # <<<<<<<<<<<<<<
 *             self.hidden2_bias = data['hidden2_bias']
 *         else:
 */
    __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden2_weights); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 256, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->hidden2_weights);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_weights));
    __pyx_v_self->hidden2_weights = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":257
 *         if data['hidden2_weights'].shape != ():
 *             self.hidden2_weights = data['hidden2_weights']
 *             self.hidden2_bias = data['hidden2_bias']             # <<<<<<<<<<<<<<
 *         else:
 *             self.hidden2_weights = None
 */
    __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_hidden2_bias); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 257, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 257, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->hidden2_bias);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_bias));
    __pyx_v_self->hidden2_bias = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":255
 * 
 *         # same for second hidden layer weights
 *         if data['hidden2_weights'].shape != ():             # <<<<<<<<<<<<<<
 *             self.hidden2_weights = data['hidden2_weights']
 *             self.hidden2_bias = data['hidden2_bias']
 */
    goto __pyx_L4;
  }

  /* "networkconv.pyx":259
 *             self.hidden2_bias = data['hidden2_bias']
 *         else:
 *             self.hidden2_weights = None             # <<<<<<<<<<<<<<
 * 
 *     def set_validation_data(self, list validation_sentences,
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_self->hidden2_weights);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_weights));
    __pyx_v_self->hidden2_weights = ((PyArrayObject *)Py_None);
  }
  __pyx_L4:;

  /* "networkconv.pyx":234
 *         return cls._load_from_file(data, filename)
 * 
 *     def _load_parameters(self):             # <<<<<<<<<<<<<<
 *         """
 *         Loads weights, feature tables, distance tables and
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._load_parameters", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":261
 *             self.hidden2_weights = None
 * 
 *     def set_validation_data(self, list validation_sentences,             # <<<<<<<<<<<<<<
 *                             list validation_predicates,
 *                             list validation_tags,
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_17set_validation_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_16set_validation_data[] = "ConvolutionalNetwork.set_validation_data(self, list validation_sentences, list validation_predicates, list validation_tags, list validation_arguments=None)\n\n        Sets the data to be used in validation during training. If this function\n        is not called before training, the training data itself is used to \n        measure the model's performance.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_17set_validation_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_validation_sentences = 0;
  PyObject *__pyx_v_validation_predicates = 0;
  PyObject *__pyx_v_validation_tags = 0;
  PyObject *__pyx_v_validation_arguments = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_validation_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_validation_sentences,&__pyx_n_s_validation_predicates,&__pyx_n_s_validation_tags,&__pyx_n_s_validation_arguments,0};
    PyObject* values[4] = {0,0,0,0};

    /* "networkconv.pyx":264
 *                             list validation_predicates,
 *                             list validation_tags,
 *                             list validation_arguments=None):             # <<<<<<<<<<<<<<
 *         """
 *         Sets the data to be used in validation during training. If this function
 */
    values[3] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_validation_sentences)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_validation_predicates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_validation_data", 0, 3, 4, 1); __PYX_ERR(1, 261, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_validation_tags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_validation_data", 0, 3, 4, 2); __PYX_ERR(1, 261, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_validation_arguments);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_validation_data") < 0)) __PYX_ERR(1, 261, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_validation_sentences = ((PyObject*)values[0]);
    __pyx_v_validation_predicates = ((PyObject*)values[1]);
    __pyx_v_validation_tags = ((PyObject*)values[2]);
    __pyx_v_validation_arguments = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_validation_data", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 261, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.set_validation_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_validation_sentences), (&PyList_Type), 1, "validation_sentences", 1))) __PYX_ERR(1, 261, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_validation_predicates), (&PyList_Type), 1, "validation_predicates", 1))) __PYX_ERR(1, 262, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_validation_tags), (&PyList_Type), 1, "validation_tags", 1))) __PYX_ERR(1, 263, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_validation_arguments), (&PyList_Type), 1, "validation_arguments", 1))) __PYX_ERR(1, 264, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_16set_validation_data(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_validation_sentences, __pyx_v_validation_predicates, __pyx_v_validation_tags, __pyx_v_validation_arguments);

  /* "networkconv.pyx":261
 *             self.hidden2_weights = None
 * 
 *     def set_validation_data(self, list validation_sentences,             # <<<<<<<<<<<<<<
 *                             list validation_predicates,
 *                             list validation_tags,
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_16set_validation_data(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_validation_sentences, PyObject *__pyx_v_validation_predicates, PyObject *__pyx_v_validation_tags, PyObject *__pyx_v_validation_arguments) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_validation_data", 0);
  __Pyx_TraceCall("set_validation_data", __pyx_f[1], 261, 0, __PYX_ERR(1, 261, __pyx_L1_error));

  /* "networkconv.pyx":270
 *         measure the model's performance.
 *         """
 *         self.validation_sentences = validation_sentences             # <<<<<<<<<<<<<<
 *         self.validation_predicates = validation_predicates
 *         self.validation_tags = validation_tags
 */
  __Pyx_INCREF(__pyx_v_validation_sentences);
  __Pyx_GIVEREF(__pyx_v_validation_sentences);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.validation_sentences);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.validation_sentences);
  __pyx_v_self->__pyx_base.validation_sentences = __pyx_v_validation_sentences;

  /* "networkconv.pyx":271
 *         """
 *         self.validation_sentences = validation_sentences
 *         self.validation_predicates = validation_predicates             # <<<<<<<<<<<<<<
 *         self.validation_tags = validation_tags
 *         self.validation_arguments = validation_arguments
 */
  __Pyx_INCREF(__pyx_v_validation_predicates);
  __Pyx_GIVEREF(__pyx_v_validation_predicates);
  __Pyx_GOTREF(__pyx_v_self->validation_predicates);
  __Pyx_DECREF(__pyx_v_self->validation_predicates);
  __pyx_v_self->validation_predicates = __pyx_v_validation_predicates;

  /* "networkconv.pyx":272
 *         self.validation_sentences = validation_sentences
 *         self.validation_predicates = validation_predicates
 *         self.validation_tags = validation_tags             # <<<<<<<<<<<<<<
 *         self.validation_arguments = validation_arguments
 * 
 */
  __Pyx_INCREF(__pyx_v_validation_tags);
  __Pyx_GIVEREF(__pyx_v_validation_tags);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.validation_tags);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.validation_tags);
  __pyx_v_self->__pyx_base.validation_tags = __pyx_v_validation_tags;

  /* "networkconv.pyx":273
 *         self.validation_predicates = validation_predicates
 *         self.validation_tags = validation_tags
 *         self.validation_arguments = validation_arguments             # <<<<<<<<<<<<<<
 * 
 *     def train(self, list sentences, list predicates, list tags,
 */
  __Pyx_INCREF(__pyx_v_validation_arguments);
  __Pyx_GIVEREF(__pyx_v_validation_arguments);
  __Pyx_GOTREF(__pyx_v_self->validation_arguments);
  __Pyx_DECREF(__pyx_v_self->validation_arguments);
  __pyx_v_self->validation_arguments = __pyx_v_validation_arguments;

  /* "networkconv.pyx":261
 *             self.hidden2_weights = None
 * 
 *     def set_validation_data(self, list validation_sentences,             # <<<<<<<<<<<<<<
 *                             list validation_predicates,
 *                             list validation_tags,
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.set_validation_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":275
 *         self.validation_arguments = validation_arguments
 * 
 *     def train(self, list sentences, list predicates, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0, list arguments=None):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_19train(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_18train[] = "ConvolutionalNetwork.train(self, list sentences, list predicates, list tags, int epochs, int epochs_between_reports=0, float desired_accuracy=0, list arguments=None)\n\n        Trains the convolutional network. Refer to the basic Network\n        train method for detailed explanation.\n        \n        :param predicates: a list of 1-dim numpy array\n            indicating the indices of predicates in each sentence.\n        :param arguments: (only for argument classifying) a list of 2-dim\n            numpy arrays indicating the start and end of each argument. \n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_19train(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentences = 0;
  PyObject *__pyx_v_predicates = 0;
  PyObject *__pyx_v_tags = 0;
  int __pyx_v_epochs;
  int __pyx_v_epochs_between_reports;
  float __pyx_v_desired_accuracy;
  PyObject *__pyx_v_arguments = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("train (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentences,&__pyx_n_s_predicates,&__pyx_n_s_tags,&__pyx_n_s_epochs,&__pyx_n_s_epochs_between_reports,&__pyx_n_s_desired_accuracy,&__pyx_n_s_arguments,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};

    /* "networkconv.pyx":277
 *     def train(self, list sentences, list predicates, list tags,
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0, list arguments=None):             # <<<<<<<<<<<<<<
 *         """
 *         Trains the convolutional network. Refer to the basic Network
 */
    values[6] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentences)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("train", 0, 4, 7, 1); __PYX_ERR(1, 275, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("train", 0, 4, 7, 2); __PYX_ERR(1, 275, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_epochs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("train", 0, 4, 7, 3); __PYX_ERR(1, 275, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_epochs_between_reports);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desired_accuracy);
          if (value) { values[5] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  6:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arguments);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "train") < 0)) __PYX_ERR(1, 275, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        CYTHON_FALLTHROUGH;
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentences = ((PyObject*)values[0]);
    __pyx_v_predicates = ((PyObject*)values[1]);
    __pyx_v_tags = ((PyObject*)values[2]);
    __pyx_v_epochs = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_epochs == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 276, __pyx_L3_error)
    if (values[4]) {
      __pyx_v_epochs_between_reports = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_epochs_between_reports == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 276, __pyx_L3_error)
    } else {
      __pyx_v_epochs_between_reports = ((int)0);
    }
    if (values[5]) {
      __pyx_v_desired_accuracy = __pyx_PyFloat_AsFloat(values[5]); if (unlikely((__pyx_v_desired_accuracy == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 277, __pyx_L3_error)
    } else {
      __pyx_v_desired_accuracy = ((float)0.0);
    }
    __pyx_v_arguments = ((PyObject*)values[6]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("train", 0, 4, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 275, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.train", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentences), (&PyList_Type), 1, "sentences", 1))) __PYX_ERR(1, 275, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_predicates), (&PyList_Type), 1, "predicates", 1))) __PYX_ERR(1, 275, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tags), (&PyList_Type), 1, "tags", 1))) __PYX_ERR(1, 275, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arguments), (&PyList_Type), 1, "arguments", 1))) __PYX_ERR(1, 277, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_18train(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_epochs, __pyx_v_epochs_between_reports, __pyx_v_desired_accuracy, __pyx_v_arguments);

  /* "networkconv.pyx":275
 *         self.validation_arguments = validation_arguments
 * 
 *     def train(self, list sentences, list predicates, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0, list arguments=None):
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_4libs_7network_20ConvolutionalNetwork_5train_2generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "networkconv.pyx":288
 *         """
 *         self.num_sentences = len(sentences)
 *         self.num_tokens = sum(len(sent) for sent in sentences)             # <<<<<<<<<<<<<<
 *         self.only_classify = arguments is not None
 * 
 */

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_5train_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *)__pyx_tp_new_4libs_7network___pyx_scope_struct_9_genexpr(__pyx_ptype_4libs_7network___pyx_scope_struct_9_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 288, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_4libs_7network_20ConvolutionalNetwork_5train_2generator4, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_train_locals_genexpr, __pyx_n_s_libs_network); if (unlikely(!gen)) __PYX_ERR(1, 288, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.train.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_4libs_7network_20ConvolutionalNetwork_5train_2generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *__pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __Pyx_TraceCall("genexpr", __pyx_f[1], 288, 0, __PYX_ERR(1, 288, __pyx_L1_error));
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_TraceReturn(Py_None, 0);
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 288, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_sentences)) { __Pyx_RaiseClosureNameError("sentences"); __PYX_ERR(1, 288, __pyx_L1_error) }
  if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_sentences == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(1, 288, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_sentences; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 288, __pyx_L1_error)
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sent);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sent, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_4 = PyObject_Length(__pyx_cur_scope->__pyx_v_sent); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 288, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_TraceReturn(__pyx_r, 0);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(1, 288, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":275
 *         self.validation_arguments = validation_arguments
 * 
 *     def train(self, list sentences, list predicates, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0, list arguments=None):
 */

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_18train(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_predicates, PyObject *__pyx_v_tags, int __pyx_v_epochs, int __pyx_v_epochs_between_reports, float __pyx_v_desired_accuracy, PyObject *__pyx_v_arguments) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *__pyx_cur_scope;
  PyObject *__pyx_v_logger = NULL;
  double __pyx_v_last_accuracy;
  double __pyx_v_top_accuracy;
  PyObject *__pyx_v_last_error = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_gb_4libs_7network_20ConvolutionalNetwork_5train_2generator4 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  float __pyx_t_11;
  int __pyx_t_12;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("train", 0);
  __pyx_cur_scope = (struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *)__pyx_tp_new_4libs_7network___pyx_scope_struct_8_train(__pyx_ptype_4libs_7network___pyx_scope_struct_8_train, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(1, 275, __pyx_L1_error)
  } else {
    __Pyx_GOTREF(__pyx_cur_scope);
  }
  __Pyx_TraceCall("train", __pyx_f[1], 275, 0, __PYX_ERR(1, 275, __pyx_L1_error));
  __pyx_cur_scope->__pyx_v_sentences = __pyx_v_sentences;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sentences);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sentences);

  /* "networkconv.pyx":287
 *             numpy arrays indicating the start and end of each argument.
 *         """
 *         self.num_sentences = len(sentences)             # <<<<<<<<<<<<<<
 *         self.num_tokens = sum(len(sent) for sent in sentences)
 *         self.only_classify = arguments is not None
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_sentences;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(1, 287, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(1, 287, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->num_sentences = __pyx_t_2;

  /* "networkconv.pyx":288
 *         """
 *         self.num_sentences = len(sentences)
 *         self.num_tokens = sum(len(sent) for sent in sentences)             # <<<<<<<<<<<<<<
 *         self.only_classify = arguments is not None
 * 
 */
  __pyx_t_1 = __pyx_pf_4libs_7network_20ConvolutionalNetwork_5train_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_sum, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->__pyx_base.num_tokens = __pyx_t_4;

  /* "networkconv.pyx":289
 *         self.num_sentences = len(sentences)
 *         self.num_tokens = sum(len(sent) for sent in sentences)
 *         self.only_classify = arguments is not None             # <<<<<<<<<<<<<<
 * 
 *         logger = logging.getLogger("Logger")
 */
  __pyx_t_5 = (__pyx_v_arguments != ((PyObject*)Py_None));
  __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 289, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(1, 289, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->only_classify);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->only_classify));
  __pyx_v_self->only_classify = ((PyBoolObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "networkconv.pyx":291
 *         self.only_classify = arguments is not None
 * 
 *         logger = logging.getLogger("Logger")             # <<<<<<<<<<<<<<
 *         logger.info("Training for up to %d epochs" % epochs)
 *         last_accuracy = 0
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_logging); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_1, __pyx_n_u_Logger) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_n_u_Logger);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_logger = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "networkconv.pyx":292
 * 
 *         logger = logging.getLogger("Logger")
 *         logger.info("Training for up to %d epochs" % epochs)             # <<<<<<<<<<<<<<
 *         last_accuracy = 0
 *         top_accuracy = 0
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_logger, __pyx_n_s_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_epochs); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyUnicode_Format(__pyx_kp_u_Training_for_up_to_d_epochs, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_1, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 292, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "networkconv.pyx":293
 *         logger = logging.getLogger("Logger")
 *         logger.info("Training for up to %d epochs" % epochs)
 *         last_accuracy = 0             # <<<<<<<<<<<<<<
 *         top_accuracy = 0
 *         last_error = np.Infinity
 */
  __pyx_v_last_accuracy = 0.0;

  /* "networkconv.pyx":294
 *         logger.info("Training for up to %d epochs" % epochs)
 *         last_accuracy = 0
 *         top_accuracy = 0             # <<<<<<<<<<<<<<
 *         last_error = np.Infinity
 * 
 */
  __pyx_v_top_accuracy = 0.0;

  /* "networkconv.pyx":295
 *         last_accuracy = 0
 *         top_accuracy = 0
 *         last_error = np.Infinity             # <<<<<<<<<<<<<<
 * 
 *         if self.validation_sentences is None:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Infinity); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 295, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_last_error = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "networkconv.pyx":297
 *         last_error = np.Infinity
 * 
 *         if self.validation_sentences is None:             # <<<<<<<<<<<<<<
 *             self.set_validation_data(sentences, predicates, tags, arguments)
 * 
 */
  __pyx_t_5 = (__pyx_v_self->__pyx_base.validation_sentences == ((PyObject*)Py_None));
  __pyx_t_8 = (__pyx_t_5 != 0);
  if (__pyx_t_8) {

    /* "networkconv.pyx":298
 * 
 *         if self.validation_sentences is None:
 *             self.set_validation_data(sentences, predicates, tags, arguments)             # <<<<<<<<<<<<<<
 * 
 *         for i in xrange(epochs):
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_validation_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = NULL;
    __pyx_t_4 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_4 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_arguments};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 298, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_arguments};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 298, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sentences);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sentences);
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_4, __pyx_cur_scope->__pyx_v_sentences);
      __Pyx_INCREF(__pyx_v_predicates);
      __Pyx_GIVEREF(__pyx_v_predicates);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_4, __pyx_v_predicates);
      __Pyx_INCREF(__pyx_v_tags);
      __Pyx_GIVEREF(__pyx_v_tags);
      PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_4, __pyx_v_tags);
      __Pyx_INCREF(__pyx_v_arguments);
      __Pyx_GIVEREF(__pyx_v_arguments);
      PyTuple_SET_ITEM(__pyx_t_1, 3+__pyx_t_4, __pyx_v_arguments);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 298, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "networkconv.pyx":297
 *         last_error = np.Infinity
 * 
 *         if self.validation_sentences is None:             # <<<<<<<<<<<<<<
 *             self.set_validation_data(sentences, predicates, tags, arguments)
 * 
 */
  }

  /* "networkconv.pyx":300
 *             self.set_validation_data(sentences, predicates, tags, arguments)
 * 
 *         for i in xrange(epochs):             # <<<<<<<<<<<<<<
 *             self.decrease_learning_rates(i)
 *             self._train_epoch(sentences, predicates, tags, arguments)
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_epochs); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_xrange, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_6 = __pyx_t_3; __Pyx_INCREF(__pyx_t_6); __pyx_t_2 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 300, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 300, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 300, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(1, 300, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 300, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_9(__pyx_t_6);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 300, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":301
 * 
 *         for i in xrange(epochs):
 *             self.decrease_learning_rates(i)             # <<<<<<<<<<<<<<
 *             self._train_epoch(sentences, predicates, tags, arguments)
 *             self._validate()
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_decrease_learning_rates); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_7, __pyx_v_i) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_i);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkconv.pyx":302
 *         for i in xrange(epochs):
 *             self.decrease_learning_rates(i)
 *             self._train_epoch(sentences, predicates, tags, arguments)             # <<<<<<<<<<<<<<
 *             self._validate()
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_train_epoch); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = NULL;
    __pyx_t_4 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_4 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_arguments};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 302, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[5] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_arguments};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 302, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 302, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sentences);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sentences);
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_4, __pyx_cur_scope->__pyx_v_sentences);
      __Pyx_INCREF(__pyx_v_predicates);
      __Pyx_GIVEREF(__pyx_v_predicates);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_4, __pyx_v_predicates);
      __Pyx_INCREF(__pyx_v_tags);
      __Pyx_GIVEREF(__pyx_v_tags);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_4, __pyx_v_tags);
      __Pyx_INCREF(__pyx_v_arguments);
      __Pyx_GIVEREF(__pyx_v_arguments);
      PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_4, __pyx_v_arguments);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 302, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkconv.pyx":303
 *             self.decrease_learning_rates(i)
 *             self._train_epoch(sentences, predicates, tags, arguments)
 *             self._validate()             # <<<<<<<<<<<<<<
 * 
 *             # Attardi: save model
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_validate); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkconv.pyx":306
 * 
 *             # Attardi: save model
 *             if self.accuracy > top_accuracy:             # <<<<<<<<<<<<<<
 *                 top_accuracy = self.accuracy
 *                 self.save()
 */
    __pyx_t_8 = ((__pyx_v_self->__pyx_base.accuracy > __pyx_v_top_accuracy) != 0);
    if (__pyx_t_8) {

      /* "networkconv.pyx":307
 *             # Attardi: save model
 *             if self.accuracy > top_accuracy:
 *                 top_accuracy = self.accuracy             # <<<<<<<<<<<<<<
 *                 self.save()
 *                 logger.debug("Saved model")
 */
      __pyx_t_11 = __pyx_v_self->__pyx_base.accuracy;
      __pyx_v_top_accuracy = __pyx_t_11;

      /* "networkconv.pyx":308
 *             if self.accuracy > top_accuracy:
 *                 top_accuracy = self.accuracy
 *                 self.save()             # <<<<<<<<<<<<<<
 *                 logger.debug("Saved model")
 *             elif self.use_learning_rate_decay:
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_save); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 308, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 308, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "networkconv.pyx":309
 *                 top_accuracy = self.accuracy
 *                 self.save()
 *                 logger.debug("Saved model")             # <<<<<<<<<<<<<<
 *             elif self.use_learning_rate_decay:
 *                 # this iteration didn't bring improvements; load the last saved model
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_logger, __pyx_n_s_debug); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 309, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_10, __pyx_kp_u_Saved_model) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_kp_u_Saved_model);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 309, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "networkconv.pyx":306
 * 
 *             # Attardi: save model
 *             if self.accuracy > top_accuracy:             # <<<<<<<<<<<<<<
 *                 top_accuracy = self.accuracy
 *                 self.save()
 */
      goto __pyx_L6;
    }

    /* "networkconv.pyx":310
 *                 self.save()
 *                 logger.debug("Saved model")
 *             elif self.use_learning_rate_decay:             # <<<<<<<<<<<<<<
 *                 # this iteration didn't bring improvements; load the last saved model
 *                 # before continuing training with a lower rate
 */
    __pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->__pyx_base.use_learning_rate_decay)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 310, __pyx_L1_error)
    if (__pyx_t_8) {

      /* "networkconv.pyx":313
 *                 # this iteration didn't bring improvements; load the last saved model
 *                 # before continuing training with a lower rate
 *                 self._load_parameters()             # <<<<<<<<<<<<<<
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_load_parameters); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 313, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 313, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "networkconv.pyx":310
 *                 self.save()
 *                 logger.debug("Saved model")
 *             elif self.use_learning_rate_decay:             # <<<<<<<<<<<<<<
 *                 # this iteration didn't bring improvements; load the last saved model
 *                 # before continuing training with a lower rate
 */
    }
    __pyx_L6:;

    /* "networkconv.pyx":315
 *                 self._load_parameters()
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \             # <<<<<<<<<<<<<<
 *                 or self.accuracy >= desired_accuracy > 0 \
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 */
    __pyx_t_5 = ((__pyx_v_epochs_between_reports > 0) != 0);
    if (!__pyx_t_5) {
      goto __pyx_L9_next_or;
    } else {
    }
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_epochs_between_reports); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 315, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Remainder(__pyx_v_i, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 315, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 315, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 315, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!__pyx_t_5) {
    } else {
      __pyx_t_8 = __pyx_t_5;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_L9_next_or:;

    /* "networkconv.pyx":316
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \
 *                 or self.accuracy >= desired_accuracy > 0 \             # <<<<<<<<<<<<<<
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 * 
 */
    __pyx_t_5 = (__pyx_v_self->__pyx_base.accuracy >= __pyx_v_desired_accuracy);
    if (__pyx_t_5) {
      __pyx_t_5 = (__pyx_v_desired_accuracy > 0.0);
    }
    __pyx_t_12 = (__pyx_t_5 != 0);
    if (!__pyx_t_12) {
    } else {
      __pyx_t_8 = __pyx_t_12;
      goto __pyx_L8_bool_binop_done;
    }

    /* "networkconv.pyx":317
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \
 *                 or self.accuracy >= desired_accuracy > 0 \
 *                 or (self.accuracy < last_accuracy and self.error > last_error):             # <<<<<<<<<<<<<<
 * 
 *                 self._print_epoch_report(i + 1)
 */
    __pyx_t_12 = ((__pyx_v_self->__pyx_base.accuracy < __pyx_v_last_accuracy) != 0);
    if (__pyx_t_12) {
    } else {
      __pyx_t_8 = __pyx_t_12;
      goto __pyx_L8_bool_binop_done;
    }
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.error); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 317, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_v_last_error, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 317, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(1, 317, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = __pyx_t_12;
    __pyx_L8_bool_binop_done:;

    /* "networkconv.pyx":315
 *                 self._load_parameters()
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \             # <<<<<<<<<<<<<<
 *                 or self.accuracy >= desired_accuracy > 0 \
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 */
    if (__pyx_t_8) {

      /* "networkconv.pyx":319
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 * 
 *                 self._print_epoch_report(i + 1)             # <<<<<<<<<<<<<<
 * 
 *                 if self.accuracy >= desired_accuracy > 0\
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_print_epoch_report); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 319, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "networkconv.pyx":321
 *                 self._print_epoch_report(i + 1)
 * 
 *                 if self.accuracy >= desired_accuracy > 0\             # <<<<<<<<<<<<<<
 *                         or (self.accuracy < last_accuracy and self.error > last_error):
 *                     # accuracy is falling, the network is probably diverging
 */
      __pyx_t_12 = (__pyx_v_self->__pyx_base.accuracy >= __pyx_v_desired_accuracy);
      if (__pyx_t_12) {
        __pyx_t_12 = (__pyx_v_desired_accuracy > 0.0);
      }
      __pyx_t_5 = (__pyx_t_12 != 0);
      if (!__pyx_t_5) {
      } else {
        __pyx_t_8 = __pyx_t_5;
        goto __pyx_L14_bool_binop_done;
      }

      /* "networkconv.pyx":322
 * 
 *                 if self.accuracy >= desired_accuracy > 0\
 *                         or (self.accuracy < last_accuracy and self.error > last_error):             # <<<<<<<<<<<<<<
 *                     # accuracy is falling, the network is probably diverging
 *                     # or overfitting
 */
      __pyx_t_5 = ((__pyx_v_self->__pyx_base.accuracy < __pyx_v_last_accuracy) != 0);
      if (__pyx_t_5) {
      } else {
        __pyx_t_8 = __pyx_t_5;
        goto __pyx_L14_bool_binop_done;
      }
      __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.error); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 322, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_v_last_error, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 322, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 322, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = __pyx_t_5;
      __pyx_L14_bool_binop_done:;

      /* "networkconv.pyx":321
 *                 self._print_epoch_report(i + 1)
 * 
 *                 if self.accuracy >= desired_accuracy > 0\             # <<<<<<<<<<<<<<
 *                         or (self.accuracy < last_accuracy and self.error > last_error):
 *                     # accuracy is falling, the network is probably diverging
 */
      if (__pyx_t_8) {

        /* "networkconv.pyx":325
 *                     # accuracy is falling, the network is probably diverging
 *                     # or overfitting
 *                     break             # <<<<<<<<<<<<<<
 * 
 *             last_accuracy = self.accuracy
 */
        goto __pyx_L5_break;

        /* "networkconv.pyx":321
 *                 self._print_epoch_report(i + 1)
 * 
 *                 if self.accuracy >= desired_accuracy > 0\             # <<<<<<<<<<<<<<
 *                         or (self.accuracy < last_accuracy and self.error > last_error):
 *                     # accuracy is falling, the network is probably diverging
 */
      }

      /* "networkconv.pyx":315
 *                 self._load_parameters()
 * 
 *             if (epochs_between_reports > 0 and i % epochs_between_reports == 0) \             # <<<<<<<<<<<<<<
 *                 or self.accuracy >= desired_accuracy > 0 \
 *                 or (self.accuracy < last_accuracy and self.error > last_error):
 */
    }

    /* "networkconv.pyx":327
 *                     break
 * 
 *             last_accuracy = self.accuracy             # <<<<<<<<<<<<<<
 *             last_error = self.error
 * 
 */
    __pyx_t_11 = __pyx_v_self->__pyx_base.accuracy;
    __pyx_v_last_accuracy = __pyx_t_11;

    /* "networkconv.pyx":328
 * 
 *             last_accuracy = self.accuracy
 *             last_error = self.error             # <<<<<<<<<<<<<<
 * 
 *         self.num_sentences = 0
 */
    __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.error); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 328, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_last_error, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":300
 *             self.set_validation_data(sentences, predicates, tags, arguments)
 * 
 *         for i in xrange(epochs):             # <<<<<<<<<<<<<<
 *             self.decrease_learning_rates(i)
 *             self._train_epoch(sentences, predicates, tags, arguments)
 */
  }
  __pyx_L5_break:;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "networkconv.pyx":330
 *             last_error = self.error
 * 
 *         self.num_sentences = 0             # <<<<<<<<<<<<<<
 *         self.num_tokens = 0
 *         self._reset_counters()
 */
  __pyx_v_self->num_sentences = 0;

  /* "networkconv.pyx":331
 * 
 *         self.num_sentences = 0
 *         self.num_tokens = 0             # <<<<<<<<<<<<<<
 *         self._reset_counters()
 * 
 */
  __pyx_v_self->__pyx_base.num_tokens = 0;

  /* "networkconv.pyx":332
 *         self.num_sentences = 0
 *         self.num_tokens = 0
 *         self._reset_counters()             # <<<<<<<<<<<<<<
 * 
 *     def _reset_counters(self):
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset_counters); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_6 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 332, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "networkconv.pyx":275
 *         self.validation_arguments = validation_arguments
 * 
 *     def train(self, list sentences, list predicates, list tags,             # <<<<<<<<<<<<<<
 *               int epochs, int epochs_between_reports=0,
 *               float desired_accuracy=0, list arguments=None):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.train", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_logger);
  __Pyx_XDECREF(__pyx_v_last_error);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_gb_4libs_7network_20ConvolutionalNetwork_5train_2generator4);
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":334
 *         self._reset_counters()
 * 
 *     def _reset_counters(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reset the performance statistics counters. They are updated during
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_21_reset_counters(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_20_reset_counters[] = "ConvolutionalNetwork._reset_counters(self)\n\n        Reset the performance statistics counters. They are updated during\n        each epoch. \n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_21_reset_counters(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_reset_counters (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_20_reset_counters(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_20_reset_counters(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_reset_counters", 0);
  __Pyx_TraceCall("_reset_counters", __pyx_f[1], 334, 0, __PYX_ERR(1, 334, __pyx_L1_error));

  /* "networkconv.pyx":339
 *         each epoch.
 *         """
 *         self.error = 0             # <<<<<<<<<<<<<<
 *         self.skips = 0
 *         self.float_errors = 0
 */
  __pyx_v_self->__pyx_base.error = 0.0;

  /* "networkconv.pyx":340
 *         """
 *         self.error = 0
 *         self.skips = 0             # <<<<<<<<<<<<<<
 *         self.float_errors = 0
 * 
 */
  __pyx_v_self->__pyx_base.skips = 0;

  /* "networkconv.pyx":341
 *         self.error = 0
 *         self.skips = 0
 *         self.float_errors = 0             # <<<<<<<<<<<<<<
 * 
 *     def _shuffle_data(self, sentences, predicates, tags, arguments=None):
 */
  __pyx_v_self->__pyx_base.float_errors = 0.0;

  /* "networkconv.pyx":334
 *         self._reset_counters()
 * 
 *     def _reset_counters(self):             # <<<<<<<<<<<<<<
 *         """
 *         Reset the performance statistics counters. They are updated during
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._reset_counters", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":343
 *         self.float_errors = 0
 * 
 *     def _shuffle_data(self, sentences, predicates, tags, arguments=None):             # <<<<<<<<<<<<<<
 *         """
 *         Shuffle the given training data in place.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_23_shuffle_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_22_shuffle_data[] = "ConvolutionalNetwork._shuffle_data(self, sentences, predicates, tags, arguments=None)\n\n        Shuffle the given training data in place.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_23_shuffle_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentences = 0;
  PyObject *__pyx_v_predicates = 0;
  PyObject *__pyx_v_tags = 0;
  PyObject *__pyx_v_arguments = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_shuffle_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentences,&__pyx_n_s_predicates,&__pyx_n_s_tags,&__pyx_n_s_arguments,0};
    PyObject* values[4] = {0,0,0,0};
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentences)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_shuffle_data", 0, 3, 4, 1); __PYX_ERR(1, 343, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_shuffle_data", 0, 3, 4, 2); __PYX_ERR(1, 343, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arguments);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_shuffle_data") < 0)) __PYX_ERR(1, 343, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentences = values[0];
    __pyx_v_predicates = values[1];
    __pyx_v_tags = values[2];
    __pyx_v_arguments = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_shuffle_data", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 343, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._shuffle_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_22_shuffle_data(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_arguments);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_22_shuffle_data(CYTHON_UNUSED struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_predicates, PyObject *__pyx_v_tags, PyObject *__pyx_v_arguments) {
  PyObject *__pyx_v_random_state = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_shuffle_data", 0);
  __Pyx_TraceCall("_shuffle_data", __pyx_f[1], 343, 0, __PYX_ERR(1, 343, __pyx_L1_error));

  /* "networkconv.pyx":349
 *         # get the random number generator state in order to shuffle
 *         # sentences and their tags in the same order
 *         random_state = np.random.get_state()             # <<<<<<<<<<<<<<
 *         np.random.shuffle(sentences)
 *         np.random.set_state(random_state)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 349, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_random_state = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":350
 *         # sentences and their tags in the same order
 *         random_state = np.random.get_state()
 *         np.random.shuffle(sentences)             # <<<<<<<<<<<<<<
 *         np.random.set_state(random_state)
 *         np.random.shuffle(predicates)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_sentences) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_sentences);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":351
 *         random_state = np.random.get_state()
 *         np.random.shuffle(sentences)
 *         np.random.set_state(random_state)             # <<<<<<<<<<<<<<
 *         np.random.shuffle(predicates)
 *         np.random.set_state(random_state)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_set_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_random_state) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_random_state);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 351, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":352
 *         np.random.shuffle(sentences)
 *         np.random.set_state(random_state)
 *         np.random.shuffle(predicates)             # <<<<<<<<<<<<<<
 *         np.random.set_state(random_state)
 *         np.random.shuffle(tags)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_predicates) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_predicates);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 352, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":353
 *         np.random.set_state(random_state)
 *         np.random.shuffle(predicates)
 *         np.random.set_state(random_state)             # <<<<<<<<<<<<<<
 *         np.random.shuffle(tags)
 *         if arguments is not None:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_set_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_random_state) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_random_state);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":354
 *         np.random.shuffle(predicates)
 *         np.random.set_state(random_state)
 *         np.random.shuffle(tags)             # <<<<<<<<<<<<<<
 *         if arguments is not None:
 *             np.random.set_state(random_state)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_tags) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_tags);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 354, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":355
 *         np.random.set_state(random_state)
 *         np.random.shuffle(tags)
 *         if arguments is not None:             # <<<<<<<<<<<<<<
 *             np.random.set_state(random_state)
 *             np.random.shuffle(arguments)
 */
  __pyx_t_4 = (__pyx_v_arguments != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "networkconv.pyx":356
 *         np.random.shuffle(tags)
 *         if arguments is not None:
 *             np.random.set_state(random_state)             # <<<<<<<<<<<<<<
 *             np.random.shuffle(arguments)
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_set_state); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_random_state) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_random_state);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 356, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "networkconv.pyx":357
 *         if arguments is not None:
 *             np.random.set_state(random_state)
 *             np.random.shuffle(arguments)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_arguments) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_arguments);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 357, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "networkconv.pyx":355
 *         np.random.set_state(random_state)
 *         np.random.shuffle(tags)
 *         if arguments is not None:             # <<<<<<<<<<<<<<
 *             np.random.set_state(random_state)
 *             np.random.shuffle(arguments)
 */
  }

  /* "networkconv.pyx":343
 *         self.float_errors = 0
 * 
 *     def _shuffle_data(self, sentences, predicates, tags, arguments=None):             # <<<<<<<<<<<<<<
 *         """
 *         Shuffle the given training data in place.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._shuffle_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_random_state);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":360
 * 
 * 
 *     def _train_epoch(self, sentences, predicates, tags, arguments):             # <<<<<<<<<<<<<<
 *         """Trains for one epoch with all examples."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_25_train_epoch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_24_train_epoch[] = "ConvolutionalNetwork._train_epoch(self, sentences, predicates, tags, arguments)\nTrains for one epoch with all examples.";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_25_train_epoch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentences = 0;
  PyObject *__pyx_v_predicates = 0;
  PyObject *__pyx_v_tags = 0;
  PyObject *__pyx_v_arguments = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_train_epoch (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentences,&__pyx_n_s_predicates,&__pyx_n_s_tags,&__pyx_n_s_arguments,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentences)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_train_epoch", 1, 4, 4, 1); __PYX_ERR(1, 360, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_train_epoch", 1, 4, 4, 2); __PYX_ERR(1, 360, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arguments)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_train_epoch", 1, 4, 4, 3); __PYX_ERR(1, 360, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_train_epoch") < 0)) __PYX_ERR(1, 360, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_sentences = values[0];
    __pyx_v_predicates = values[1];
    __pyx_v_tags = values[2];
    __pyx_v_arguments = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_train_epoch", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 360, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._train_epoch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_24_train_epoch(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_arguments);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_24_train_epoch(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_predicates, PyObject *__pyx_v_tags, PyObject *__pyx_v_arguments) {
  PyObject *__pyx_v_i_args = NULL;
  PyObject *__pyx_v_sent_args = NULL;
  PyObject *__pyx_v_sent = NULL;
  PyObject *__pyx_v_sent_preds = NULL;
  PyObject *__pyx_v_sent_tags = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_train_epoch", 0);
  __Pyx_TraceCall("_train_epoch", __pyx_f[1], 360, 0, __PYX_ERR(1, 360, __pyx_L1_error));

  /* "networkconv.pyx":363
 *         """Trains for one epoch with all examples."""
 * 
 *         self._reset_counters()             # <<<<<<<<<<<<<<
 *         self._shuffle_data(sentences, predicates, tags, arguments)
 *         if arguments is not None:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset_counters); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":364
 * 
 *         self._reset_counters()
 *         self._shuffle_data(sentences, predicates, tags, arguments)             # <<<<<<<<<<<<<<
 *         if arguments is not None:
 *             i_args = iter(arguments)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shuffle_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_arguments};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 364, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_sentences, __pyx_v_predicates, __pyx_v_tags, __pyx_v_arguments};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 364, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_sentences);
    __Pyx_GIVEREF(__pyx_v_sentences);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_sentences);
    __Pyx_INCREF(__pyx_v_predicates);
    __Pyx_GIVEREF(__pyx_v_predicates);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_predicates);
    __Pyx_INCREF(__pyx_v_tags);
    __Pyx_GIVEREF(__pyx_v_tags);
    PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_tags);
    __Pyx_INCREF(__pyx_v_arguments);
    __Pyx_GIVEREF(__pyx_v_arguments);
    PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_arguments);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":365
 *         self._reset_counters()
 *         self._shuffle_data(sentences, predicates, tags, arguments)
 *         if arguments is not None:             # <<<<<<<<<<<<<<
 *             i_args = iter(arguments)
 *         else:
 */
  __pyx_t_6 = (__pyx_v_arguments != Py_None);
  __pyx_t_7 = (__pyx_t_6 != 0);
  if (__pyx_t_7) {

    /* "networkconv.pyx":366
 *         self._shuffle_data(sentences, predicates, tags, arguments)
 *         if arguments is not None:
 *             i_args = iter(arguments)             # <<<<<<<<<<<<<<
 *         else:
 *             sent_args = None
 */
    __pyx_t_1 = PyObject_GetIter(__pyx_v_arguments); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_v_i_args = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "networkconv.pyx":365
 *         self._reset_counters()
 *         self._shuffle_data(sentences, predicates, tags, arguments)
 *         if arguments is not None:             # <<<<<<<<<<<<<<
 *             i_args = iter(arguments)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "networkconv.pyx":368
 *             i_args = iter(arguments)
 *         else:
 *             sent_args = None             # <<<<<<<<<<<<<<
 * 
 *         for sent, sent_preds, sent_tags in zip(sentences, predicates, tags):
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __pyx_v_sent_args = Py_None;
  }
  __pyx_L3:;

  /* "networkconv.pyx":370
 *             sent_args = None
 * 
 *         for sent, sent_preds, sent_tags in zip(sentences, predicates, tags):             # <<<<<<<<<<<<<<
 *             if arguments is not None:
 *                 sent_args = next(i_args)
 */
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_sentences);
  __Pyx_GIVEREF(__pyx_v_sentences);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sentences);
  __Pyx_INCREF(__pyx_v_predicates);
  __Pyx_GIVEREF(__pyx_v_predicates);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_predicates);
  __Pyx_INCREF(__pyx_v_tags);
  __Pyx_GIVEREF(__pyx_v_tags);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_tags);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 370, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 370, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 370, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(1, 370, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 370, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_9(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 370, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 370, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_10 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_10);
      #else
      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_11 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
      index = 0; __pyx_t_5 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_3 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_10);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) __PYX_ERR(1, 370, __pyx_L1_error)
      __pyx_t_12 = NULL;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_12 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 370, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_sent, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_sent_preds, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_sent_tags, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "networkconv.pyx":371
 * 
 *         for sent, sent_preds, sent_tags in zip(sentences, predicates, tags):
 *             if arguments is not None:             # <<<<<<<<<<<<<<
 *                 sent_args = next(i_args)
 *                 #sent_args = i_args.next()
 */
    __pyx_t_7 = (__pyx_v_arguments != Py_None);
    __pyx_t_6 = (__pyx_t_7 != 0);
    if (__pyx_t_6) {

      /* "networkconv.pyx":372
 *         for sent, sent_preds, sent_tags in zip(sentences, predicates, tags):
 *             if arguments is not None:
 *                 sent_args = next(i_args)             # <<<<<<<<<<<<<<
 *                 #sent_args = i_args.next()
 * 
 */
      if (unlikely(!__pyx_v_i_args)) { __Pyx_RaiseUnboundLocalError("i_args"); __PYX_ERR(1, 372, __pyx_L1_error) }
      __pyx_t_2 = __Pyx_PyIter_Next(__pyx_v_i_args); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 372, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_XDECREF_SET(__pyx_v_sent_args, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "networkconv.pyx":371
 * 
 *         for sent, sent_preds, sent_tags in zip(sentences, predicates, tags):
 *             if arguments is not None:             # <<<<<<<<<<<<<<
 *                 sent_args = next(i_args)
 *                 #sent_args = i_args.next()
 */
    }

    /* "networkconv.pyx":375
 *                 #sent_args = i_args.next()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 self._tag_sentence(sent, sent_preds, sent_tags, sent_args)
 *             except FloatingPointError:
 */
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_15);
      /*try:*/ {

        /* "networkconv.pyx":376
 * 
 *             try:
 *                 self._tag_sentence(sent, sent_preds, sent_tags, sent_args)             # <<<<<<<<<<<<<<
 *             except FloatingPointError:
 *                 # just ignore the sentence in case of an overflow
 */
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 376, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (unlikely(!__pyx_v_sent_args)) { __Pyx_RaiseUnboundLocalError("sent_args"); __PYX_ERR(1, 376, __pyx_L9_error) }
        __pyx_t_3 = NULL;
        __pyx_t_4 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_10, function);
            __pyx_t_4 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_sent, __pyx_v_sent_preds, __pyx_v_sent_tags, __pyx_v_sent_args};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 376, __pyx_L9_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
          PyObject *__pyx_temp[5] = {__pyx_t_3, __pyx_v_sent, __pyx_v_sent_preds, __pyx_v_sent_tags, __pyx_v_sent_args};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_4, 4+__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 376, __pyx_L9_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(4+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 376, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_5);
          if (__pyx_t_3) {
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
          }
          __Pyx_INCREF(__pyx_v_sent);
          __Pyx_GIVEREF(__pyx_v_sent);
          PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_sent);
          __Pyx_INCREF(__pyx_v_sent_preds);
          __Pyx_GIVEREF(__pyx_v_sent_preds);
          PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_sent_preds);
          __Pyx_INCREF(__pyx_v_sent_tags);
          __Pyx_GIVEREF(__pyx_v_sent_tags);
          PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_4, __pyx_v_sent_tags);
          __Pyx_INCREF(__pyx_v_sent_args);
          __Pyx_GIVEREF(__pyx_v_sent_args);
          PyTuple_SET_ITEM(__pyx_t_5, 3+__pyx_t_4, __pyx_v_sent_args);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 376, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "networkconv.pyx":375
 *                 #sent_args = i_args.next()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 self._tag_sentence(sent, sent_preds, sent_tags, sent_args)
 *             except FloatingPointError:
 */
      }
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      goto __pyx_L16_try_end;
      __pyx_L9_error:;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "networkconv.pyx":377
 *             try:
 *                 self._tag_sentence(sent, sent_preds, sent_tags, sent_args)
 *             except FloatingPointError:             # <<<<<<<<<<<<<<
 *                 # just ignore the sentence in case of an overflow
 *                 self.float_errors += 1
 */
      __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_FloatingPointError);
      if (__pyx_t_4) {
        __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._train_epoch", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_10, &__pyx_t_5) < 0) __PYX_ERR(1, 377, __pyx_L11_except_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GOTREF(__pyx_t_5);

        /* "networkconv.pyx":379
 *             except FloatingPointError:
 *                 # just ignore the sentence in case of an overflow
 *                 self.float_errors += 1             # <<<<<<<<<<<<<<
 * 
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray predicates,
 */
        __pyx_v_self->__pyx_base.float_errors = (__pyx_v_self->__pyx_base.float_errors + 1.0);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L10_exception_handled;
      }
      goto __pyx_L11_except_error;
      __pyx_L11_except_error:;

      /* "networkconv.pyx":375
 *                 #sent_args = i_args.next()
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 self._tag_sentence(sent, sent_preds, sent_tags, sent_args)
 *             except FloatingPointError:
 */
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      goto __pyx_L1_error;
      __pyx_L10_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_XGIVEREF(__pyx_t_15);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      __pyx_L16_try_end:;
    }

    /* "networkconv.pyx":370
 *             sent_args = None
 * 
 *         for sent, sent_preds, sent_tags in zip(sentences, predicates, tags):             # <<<<<<<<<<<<<<
 *             if arguments is not None:
 *                 sent_args = next(i_args)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":360
 * 
 * 
 *     def _train_epoch(self, sentences, predicates, tags, arguments):             # <<<<<<<<<<<<<<
 *         """Trains for one epoch with all examples."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._train_epoch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i_args);
  __Pyx_XDECREF(__pyx_v_sent_args);
  __Pyx_XDECREF(__pyx_v_sent);
  __Pyx_XDECREF(__pyx_v_sent_preds);
  __Pyx_XDECREF(__pyx_v_sent_tags);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":381
 *                 self.float_errors += 1
 * 
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray predicates,             # <<<<<<<<<<<<<<
 *                      list arguments=None, bool logprob=False,
 *                      bool allow_repeats=True):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_27tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_26tag_sentence[] = "ConvolutionalNetwork.tag_sentence(self, ndarray sentence, ndarray predicates, list arguments=None, bool logprob=False, bool allow_repeats=True)\n\n        Runs the network for each element in the sentence and returns \n        the sequence of tags.\n        \n        :param sentence: a 2-dim numpy array, where each item encodes a token.\n        :param predicates: a 1-dim numpy array, indicating the position\n            of the predicates in the sentence\n        :param logprob: a boolean indicating whether to return the \n            log-probability for each answer or not.\n        :param allow_repeats: a boolean indicating whether to allow repeated\n            argument classes (only for separate argument classification).\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_27tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_sentence = 0;
  PyArrayObject *__pyx_v_predicates = 0;
  PyObject *__pyx_v_arguments = 0;
  PyBoolObject *__pyx_v_logprob = 0;
  PyBoolObject *__pyx_v_allow_repeats = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tag_sentence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_predicates,&__pyx_n_s_arguments,&__pyx_n_s_logprob,&__pyx_n_s_allow_repeats,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "networkconv.pyx":382
 * 
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray predicates,
 *                      list arguments=None, bool logprob=False,             # <<<<<<<<<<<<<<
 *                      bool allow_repeats=True):
 *         """
 */
    values[2] = ((PyObject*)Py_None);
    values[3] = (PyObject *)((PyBoolObject *)Py_False);

    /* "networkconv.pyx":383
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray predicates,
 *                      list arguments=None, bool logprob=False,
 *                      bool allow_repeats=True):             # <<<<<<<<<<<<<<
 *         """
 *         Runs the network for each element in the sentence and returns
 */
    values[4] = (PyObject *)((PyBoolObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("tag_sentence", 0, 2, 5, 1); __PYX_ERR(1, 381, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arguments);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_logprob);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allow_repeats);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tag_sentence") < 0)) __PYX_ERR(1, 381, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = ((PyArrayObject *)values[0]);
    __pyx_v_predicates = ((PyArrayObject *)values[1]);
    __pyx_v_arguments = ((PyObject*)values[2]);
    __pyx_v_logprob = ((PyBoolObject *)values[3]);
    __pyx_v_allow_repeats = ((PyBoolObject *)values[4]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tag_sentence", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 381, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(1, 381, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_predicates), __pyx_ptype_5numpy_ndarray, 1, "predicates", 0))) __PYX_ERR(1, 381, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arguments), (&PyList_Type), 1, "arguments", 1))) __PYX_ERR(1, 382, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_logprob), __pyx_ptype_7cpython_4bool_bool, 1, "logprob", 0))) __PYX_ERR(1, 382, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_allow_repeats), __pyx_ptype_7cpython_4bool_bool, 1, "allow_repeats", 0))) __PYX_ERR(1, 383, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_26tag_sentence(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_predicates, __pyx_v_arguments, __pyx_v_logprob, __pyx_v_allow_repeats);

  /* "networkconv.pyx":381
 *                 self.float_errors += 1
 * 
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray predicates,             # <<<<<<<<<<<<<<
 *                      list arguments=None, bool logprob=False,
 *                      bool allow_repeats=True):
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_26tag_sentence(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_predicates, PyObject *__pyx_v_arguments, PyBoolObject *__pyx_v_logprob, PyBoolObject *__pyx_v_allow_repeats) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tag_sentence", 0);
  __Pyx_TraceCall("tag_sentence", __pyx_f[1], 381, 0, __PYX_ERR(1, 381, __pyx_L1_error));

  /* "networkconv.pyx":396
 *             argument classes (only for separate argument classification).
 *         """
 *         self.only_classify = arguments is not None             # <<<<<<<<<<<<<<
 *         return self._tag_sentence(sentence, predicates, argument_blocks=arguments,
 *                                   logprob=logprob, allow_repeats=allow_repeats)
 */
  __pyx_t_1 = (__pyx_v_arguments != ((PyObject*)Py_None));
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_4bool_bool)))) __PYX_ERR(1, 396, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->only_classify);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->only_classify));
  __pyx_v_self->only_classify = ((PyBoolObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":397
 *         """
 *         self.only_classify = arguments is not None
 *         return self._tag_sentence(sentence, predicates, argument_blocks=arguments,             # <<<<<<<<<<<<<<
 *                                   logprob=logprob, allow_repeats=allow_repeats)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_sentence));
  __Pyx_INCREF(((PyObject *)__pyx_v_predicates));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_predicates));
  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_predicates));
  __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_argument_blocks, __pyx_v_arguments) < 0) __PYX_ERR(1, 397, __pyx_L1_error)

  /* "networkconv.pyx":398
 *         self.only_classify = arguments is not None
 *         return self._tag_sentence(sentence, predicates, argument_blocks=arguments,
 *                                   logprob=logprob, allow_repeats=allow_repeats)             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray argument_distances(self, positions, argument):
 */
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_logprob, ((PyObject *)__pyx_v_logprob)) < 0) __PYX_ERR(1, 397, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_allow_repeats, ((PyObject *)__pyx_v_allow_repeats)) < 0) __PYX_ERR(1, 397, __pyx_L1_error)

  /* "networkconv.pyx":397
 *         """
 *         self.only_classify = arguments is not None
 *         return self._tag_sentence(sentence, predicates, argument_blocks=arguments,             # <<<<<<<<<<<<<<
 *                                   logprob=logprob, allow_repeats=allow_repeats)
 * 
 */
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "networkconv.pyx":381
 *                 self.float_errors += 1
 * 
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray predicates,             # <<<<<<<<<<<<<<
 *                      list arguments=None, bool logprob=False,
 *                      bool allow_repeats=True):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":400
 *                                   logprob=logprob, allow_repeats=allow_repeats)
 * 
 *     cdef np.ndarray argument_distances(self, positions, argument):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the distance from each token in the sentence to the argument.
 */

static PyArrayObject *__pyx_f_4libs_7network_20ConvolutionalNetwork_argument_distances(CYTHON_UNUSED struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_positions, PyObject *__pyx_v_argument) {
  PyObject *__pyx_v_distances = NULL;
  PyObject *__pyx_v_lo = NULL;
  PyObject *__pyx_v_hi = NULL;
  PyArrayObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("argument_distances", 0);
  __Pyx_TraceCall("argument_distances", __pyx_f[1], 400, 0, __PYX_ERR(1, 400, __pyx_L1_error));

  /* "networkconv.pyx":404
 *         Calculates the distance from each token in the sentence to the argument.
 *         """
 *         distances = positions.copy()             # <<<<<<<<<<<<<<
 * 
 *         # the ones before the argument
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_positions, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 404, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_distances = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":408
 *         # the ones before the argument
 *         #print(argument)
 *         lo = np.less(positions, argument[0])             # <<<<<<<<<<<<<<
 *         distances[lo] -= argument[0]
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_less); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_argument, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 408, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_positions, __pyx_t_2};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 408, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_positions, __pyx_t_2};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 408, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(__pyx_v_positions);
    __Pyx_GIVEREF(__pyx_v_positions);
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_positions);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_lo = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":409
 *         #print(argument)
 *         lo = np.less(positions, argument[0])
 *         distances[lo] -= argument[0]             # <<<<<<<<<<<<<<
 * 
 *         # the ones after the argument
 */
  __Pyx_INCREF(__pyx_v_lo);
  __pyx_t_1 = __pyx_v_lo;
  __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_distances, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_argument, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = PyNumber_InPlaceSubtract(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(PyObject_SetItem(__pyx_v_distances, __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(1, 409, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":412
 * 
 *         # the ones after the argument
 *         hi = np.greater(positions, argument[1])             # <<<<<<<<<<<<<<
 *         distances[hi] -= argument[1]
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_greater); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_argument, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_positions, __pyx_t_2};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 412, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_positions, __pyx_t_2};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 412, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else
  #endif
  {
    __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(__pyx_v_positions);
    __Pyx_GIVEREF(__pyx_v_positions);
    PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_positions);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_hi = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":413
 *         # the ones after the argument
 *         hi = np.greater(positions, argument[1])
 *         distances[hi] -= argument[1]             # <<<<<<<<<<<<<<
 * 
 *         # the ones inside the argument
 */
  __Pyx_INCREF(__pyx_v_hi);
  __pyx_t_1 = __pyx_v_hi;
  __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_distances, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_argument, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyNumber_InPlaceSubtract(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 413, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(PyObject_SetItem(__pyx_v_distances, __pyx_t_1, __pyx_t_2) < 0)) __PYX_ERR(1, 413, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":416
 * 
 *         # the ones inside the argument
 *         distances[np.logical_not(hi | lo)] = 0             # <<<<<<<<<<<<<<
 * 
 *         return distances
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_logical_not); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Or(__pyx_v_hi, __pyx_v_lo); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(PyObject_SetItem(__pyx_v_distances, __pyx_t_1, __pyx_int_0) < 0)) __PYX_ERR(1, 416, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":418
 *         distances[np.logical_not(hi | lo)] = 0
 * 
 *         return distances             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  if (!(likely(((__pyx_v_distances) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_distances, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 418, __pyx_L1_error)
  __Pyx_INCREF(__pyx_v_distances);
  __pyx_r = ((PyArrayObject *)__pyx_v_distances);
  goto __pyx_L0;

  /* "networkconv.pyx":400
 *                                   logprob=logprob, allow_repeats=allow_repeats)
 * 
 *     cdef np.ndarray argument_distances(self, positions, argument):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the distance from each token in the sentence to the argument.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.argument_distances", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_distances);
  __Pyx_XDECREF(__pyx_v_lo);
  __Pyx_XDECREF(__pyx_v_hi);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":423
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _sentence_convolution(self, sentence, predicate, argument_blocks=None,             # <<<<<<<<<<<<<<
 *                               training=False):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_29_sentence_convolution(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_28_sentence_convolution[] = "ConvolutionalNetwork._sentence_convolution(self, sentence, predicate, argument_blocks=None, training=False)\n\n        Perform the convolution for a given predicate.\n        \n        :param sentence: a sequence of tokens, each represented as an array of \n            indices\n        :param predicate: the index of the predicate in the sentence\n        :param argument_blocks: (used only in SRL argument classification) the\n            starting and end positions of all delimited arguments\n        :return: the scores for all tokens with respect to the given predicate\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_29_sentence_convolution(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentence = 0;
  PyObject *__pyx_v_predicate = 0;
  PyObject *__pyx_v_argument_blocks = 0;
  PyObject *__pyx_v_training = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_sentence_convolution (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_predicate,&__pyx_n_s_argument_blocks,&__pyx_n_s_training,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)Py_None);

    /* "networkconv.pyx":424
 *     @cython.wraparound(False)
 *     def _sentence_convolution(self, sentence, predicate, argument_blocks=None,
 *                               training=False):             # <<<<<<<<<<<<<<
 *         """
 *         Perform the convolution for a given predicate.
 */
    values[3] = ((PyObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicate)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_sentence_convolution", 0, 2, 4, 1); __PYX_ERR(1, 423, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_argument_blocks);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_training);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_sentence_convolution") < 0)) __PYX_ERR(1, 423, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = values[0];
    __pyx_v_predicate = values[1];
    __pyx_v_argument_blocks = values[2];
    __pyx_v_training = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_sentence_convolution", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 423, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._sentence_convolution", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_28_sentence_convolution(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_predicate, __pyx_v_argument_blocks, __pyx_v_training);

  /* "networkconv.pyx":423
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _sentence_convolution(self, sentence, predicate, argument_blocks=None,             # <<<<<<<<<<<<<<
 *                               training=False):
 *         """
 */

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_28_sentence_convolution(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentence, PyObject *__pyx_v_predicate, PyObject *__pyx_v_argument_blocks, PyObject *__pyx_v_training) {
  PyArrayObject *__pyx_v_convolution_values = 0;
  PyArrayObject *__pyx_v_scores = 0;
  PyArrayObject *__pyx_v_input_and_pred_dist_values = 0;
  PyObject *__pyx_v_pred_dist_indices = NULL;
  PyObject *__pyx_v_pred_dist_values = NULL;
  PyObject *__pyx_v_target = NULL;
  PyObject *__pyx_v_target_dist_indices = NULL;
  PyObject *__pyx_v_argument = NULL;
  PyObject *__pyx_v_target_dist_values = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_convolution_values;
  __Pyx_Buffer __pyx_pybuffer_convolution_values;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_input_and_pred_dist_values;
  __Pyx_Buffer __pyx_pybuffer_input_and_pred_dist_values;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_scores;
  __Pyx_Buffer __pyx_pybuffer_scores;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  Py_ssize_t __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyArrayObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  int __pyx_t_15;
  PyArrayObject *__pyx_t_16 = NULL;
  struct __pyx_opt_args_4libs_7network_hardtanh __pyx_t_17;
  PyArrayObject *__pyx_t_18 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_sentence_convolution", 0);
  __Pyx_TraceCall("_sentence_convolution", __pyx_f[1], 423, 0, __PYX_ERR(1, 423, __pyx_L1_error));
  __pyx_pybuffer_convolution_values.pybuffer.buf = NULL;
  __pyx_pybuffer_convolution_values.refcount = 0;
  __pyx_pybuffernd_convolution_values.data = NULL;
  __pyx_pybuffernd_convolution_values.rcbuffer = &__pyx_pybuffer_convolution_values;
  __pyx_pybuffer_scores.pybuffer.buf = NULL;
  __pyx_pybuffer_scores.refcount = 0;
  __pyx_pybuffernd_scores.data = NULL;
  __pyx_pybuffernd_scores.rcbuffer = &__pyx_pybuffer_scores;
  __pyx_pybuffer_input_and_pred_dist_values.pybuffer.buf = NULL;
  __pyx_pybuffer_input_and_pred_dist_values.refcount = 0;
  __pyx_pybuffernd_input_and_pred_dist_values.data = NULL;
  __pyx_pybuffernd_input_and_pred_dist_values.rcbuffer = &__pyx_pybuffer_input_and_pred_dist_values;

  /* "networkconv.pyx":444
 *         cdef np.ndarray[FLOAT_t, ndim=2] input_and_pred_dist_values
 * 
 *         self.num_targets = len(sentence) if argument_blocks is None else len(argument_blocks)             # <<<<<<<<<<<<<<
 * 
 *         # maximum values found by convolution
 */
  __pyx_t_2 = (__pyx_v_argument_blocks == Py_None);
  if ((__pyx_t_2 != 0)) {
    __pyx_t_3 = PyObject_Length(__pyx_v_sentence); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 444, __pyx_L1_error)
    __pyx_t_1 = __pyx_t_3;
  } else {
    __pyx_t_3 = PyObject_Length(__pyx_v_argument_blocks); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 444, __pyx_L1_error)
    __pyx_t_1 = __pyx_t_3;
  }
  __pyx_v_self->num_targets = __pyx_t_1;

  /* "networkconv.pyx":447
 * 
 *         # maximum values found by convolution
 *         self.hidden_values = np.zeros((self.num_targets, self.hidden_size))             # <<<<<<<<<<<<<<
 * 
 *         if training:
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->num_targets); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
  __pyx_t_5 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 447, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_4);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.hidden_values);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_values));
  __pyx_v_self->__pyx_base.hidden_values = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "networkconv.pyx":449
 *         self.hidden_values = np.zeros((self.num_targets, self.hidden_size))
 * 
 *         if training:             # <<<<<<<<<<<<<<
 *             # hidden sent values: results after tanh
 *             self.hidden_values = np.zeros((self.num_targets, self.hidden_size))
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 449, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "networkconv.pyx":451
 *         if training:
 *             # hidden sent values: results after tanh
 *             self.hidden_values = np.zeros((self.num_targets, self.hidden_size))             # <<<<<<<<<<<<<<
 *             self.max_indices = np.empty((self.num_targets, self.hidden_size), int)
 *             #self.max_indices = np.empty((self.num_targets, self.hidden_size), np.int)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_self->num_targets); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 451, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.hidden_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_values));
    __pyx_v_self->__pyx_base.hidden_values = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "networkconv.pyx":452
 *             # hidden sent values: results after tanh
 *             self.hidden_values = np.zeros((self.num_targets, self.hidden_size))
 *             self.max_indices = np.empty((self.num_targets, self.hidden_size), int)             # <<<<<<<<<<<<<<
 *             #self.max_indices = np.empty((self.num_targets, self.hidden_size), np.int)
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 452, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 452, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->num_targets); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 452, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 452, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 452, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7);
    __pyx_t_8 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, ((PyObject *)(&PyInt_Type))};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 452, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, ((PyObject *)(&PyInt_Type))};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 452, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_9, __pyx_t_6);
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_9, ((PyObject *)(&PyInt_Type)));
      __pyx_t_6 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 452, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->max_indices);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->max_indices));
    __pyx_v_self->max_indices = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;

    /* "networkconv.pyx":449
 *         self.hidden_values = np.zeros((self.num_targets, self.hidden_size))
 * 
 *         if training:             # <<<<<<<<<<<<<<
 *             # hidden sent values: results after tanh
 *             self.hidden_values = np.zeros((self.num_targets, self.hidden_size))
 */
  }

  /* "networkconv.pyx":456
 * 
 *         # predicate distances are the same across all targets
 *         pred_dist_indices = np.arange(len(sentence)) - predicate             # <<<<<<<<<<<<<<
 *         pred_dist_values = self.pred_convolution_lookup.take(pred_dist_indices + self.pred_dist_offset,
 *                                                              0, mode='clip')
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_arange); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_1 = PyObject_Length(__pyx_v_sentence); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 456, __pyx_L1_error)
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_Subtract(__pyx_t_4, __pyx_v_predicate); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_pred_dist_indices = __pyx_t_8;
  __pyx_t_8 = 0;

  /* "networkconv.pyx":457
 *         # predicate distances are the same across all targets
 *         pred_dist_indices = np.arange(len(sentence)) - predicate
 *         pred_dist_values = self.pred_convolution_lookup.take(pred_dist_indices + self.pred_dist_offset,             # <<<<<<<<<<<<<<
 *                                                              0, mode='clip')
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pred_convolution_lookup), __pyx_n_s_take); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->pred_dist_offset); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyNumber_Add(__pyx_v_pred_dist_indices, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_0);
  __pyx_t_5 = 0;

  /* "networkconv.pyx":458
 *         pred_dist_indices = np.arange(len(sentence)) - predicate
 *         pred_dist_values = self.pred_convolution_lookup.take(pred_dist_indices + self.pred_dist_offset,
 *                                                              0, mode='clip')             # <<<<<<<<<<<<<<
 * 
 *         input_and_pred_dist_values = pred_dist_values + self.convolution_lookup
 */
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 458, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_mode, __pyx_n_u_clip) < 0) __PYX_ERR(1, 458, __pyx_L1_error)

  /* "networkconv.pyx":457
 *         # predicate distances are the same across all targets
 *         pred_dist_indices = np.arange(len(sentence)) - predicate
 *         pred_dist_values = self.pred_convolution_lookup.take(pred_dist_indices + self.pred_dist_offset,             # <<<<<<<<<<<<<<
 *                                                              0, mode='clip')
 * 
 */
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 457, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_pred_dist_values = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "networkconv.pyx":460
 *                                                              0, mode='clip')
 * 
 *         input_and_pred_dist_values = pred_dist_values + self.convolution_lookup             # <<<<<<<<<<<<<<
 * 
 *         for target in range(self.num_targets):
 */
  __pyx_t_6 = PyNumber_Add(__pyx_v_pred_dist_values, ((PyObject *)__pyx_v_self->convolution_lookup)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 460, __pyx_L1_error)
  __pyx_t_10 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_input_and_pred_dist_values, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
    }
    __pyx_pybuffernd_input_and_pred_dist_values.diminfo[0].strides = __pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input_and_pred_dist_values.diminfo[0].shape = __pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_input_and_pred_dist_values.diminfo[1].strides = __pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_input_and_pred_dist_values.diminfo[1].shape = __pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 460, __pyx_L1_error)
  }
  __pyx_t_10 = 0;
  __pyx_v_input_and_pred_dist_values = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "networkconv.pyx":462
 *         input_and_pred_dist_values = pred_dist_values + self.convolution_lookup
 * 
 *         for target in range(self.num_targets):             # <<<<<<<<<<<<<<
 *             # loop over targets and add the weighted distance features to each token
 *             # this is necessary for the convolution layer
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_self->num_targets); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 462, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_1 = 0;
    __pyx_t_14 = NULL;
  } else {
    __pyx_t_1 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 462, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_14 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 462, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (likely(!__pyx_t_14)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 462, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 462, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 462, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 462, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_14(__pyx_t_6);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 462, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_target, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "networkconv.pyx":470
 *             # if we are classifying arguments, pick the distance to the closest boundary
 *             # of the argument (beginning or end)
 *             if argument_blocks is None:             # <<<<<<<<<<<<<<
 *                 target_dist_indices = np.arange(len(sentence)) - target
 *             else:
 */
    __pyx_t_2 = (__pyx_v_argument_blocks == Py_None);
    __pyx_t_15 = (__pyx_t_2 != 0);
    if (__pyx_t_15) {

      /* "networkconv.pyx":471
 *             # of the argument (beginning or end)
 *             if argument_blocks is None:
 *                 target_dist_indices = np.arange(len(sentence)) - target             # <<<<<<<<<<<<<<
 *             else:
 *                 argument = argument_blocks[target]
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_arange); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_3 = PyObject_Length(__pyx_v_sentence); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 471, __pyx_L1_error)
      __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_Subtract(__pyx_t_5, __pyx_v_target); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 471, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_target_dist_indices, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "networkconv.pyx":470
 *             # if we are classifying arguments, pick the distance to the closest boundary
 *             # of the argument (beginning or end)
 *             if argument_blocks is None:             # <<<<<<<<<<<<<<
 *                 target_dist_indices = np.arange(len(sentence)) - target
 *             else:
 */
      goto __pyx_L6;
    }

    /* "networkconv.pyx":473
 *                 target_dist_indices = np.arange(len(sentence)) - target
 *             else:
 *                 argument = argument_blocks[target]             # <<<<<<<<<<<<<<
 *                 #print(argument_blocks)
 *                 target_dist_indices = self.argument_distances(np.arange(len(sentence)), argument)
 */
    /*else*/ {
      __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_argument_blocks, __pyx_v_target); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 473, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_XDECREF_SET(__pyx_v_argument, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "networkconv.pyx":475
 *                 argument = argument_blocks[target]
 *                 #print(argument_blocks)
 *                 target_dist_indices = self.argument_distances(np.arange(len(sentence)), argument)             # <<<<<<<<<<<<<<
 * 
 *             target_dist_values = self.target_convolution_lookup.take(target_dist_indices + self.target_dist_offset,
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 475, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_arange); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 475, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_3 = PyObject_Length(__pyx_v_sentence); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 475, __pyx_L1_error)
      __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 475, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_8 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 475, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = ((PyObject *)((struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork *)__pyx_v_self->__pyx_vtab)->argument_distances(__pyx_v_self, __pyx_t_8, __pyx_v_argument)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 475, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF_SET(__pyx_v_target_dist_indices, __pyx_t_4);
      __pyx_t_4 = 0;
    }
    __pyx_L6:;

    /* "networkconv.pyx":477
 *                 target_dist_indices = self.argument_distances(np.arange(len(sentence)), argument)
 * 
 *             target_dist_values = self.target_convolution_lookup.take(target_dist_indices + self.target_dist_offset,             # <<<<<<<<<<<<<<
 *                                                                      0, mode='clip')
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->target_convolution_lookup), __pyx_n_s_take); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->target_dist_offset); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = PyNumber_Add(__pyx_v_target_dist_indices, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_0);
    __pyx_t_5 = 0;

    /* "networkconv.pyx":478
 * 
 *             target_dist_values = self.target_convolution_lookup.take(target_dist_indices + self.target_dist_offset,
 *                                                                      0, mode='clip')             # <<<<<<<<<<<<<<
 * 
 *             convolution_values = target_dist_values + input_and_pred_dist_values
 */
    __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_mode, __pyx_n_u_clip) < 0) __PYX_ERR(1, 478, __pyx_L1_error)

    /* "networkconv.pyx":477
 *                 target_dist_indices = self.argument_distances(np.arange(len(sentence)), argument)
 * 
 *             target_dist_values = self.target_convolution_lookup.take(target_dist_indices + self.target_dist_offset,             # <<<<<<<<<<<<<<
 *                                                                      0, mode='clip')
 * 
 */
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_target_dist_values, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "networkconv.pyx":480
 *                                                                      0, mode='clip')
 * 
 *             convolution_values = target_dist_values + input_and_pred_dist_values             # <<<<<<<<<<<<<<
 * 
 *             # now, find the maximum values
 */
    __pyx_t_7 = PyNumber_Add(__pyx_v_target_dist_values, ((PyObject *)__pyx_v_input_and_pred_dist_values)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 480, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 480, __pyx_L1_error)
    __pyx_t_16 = ((PyArrayObject *)__pyx_t_7);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_convolution_values.rcbuffer->pybuffer);
      __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_convolution_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_9 < 0)) {
        PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_convolution_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_convolution_values, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
        }
        __pyx_t_13 = __pyx_t_12 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_convolution_values.diminfo[0].strides = __pyx_pybuffernd_convolution_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_convolution_values.diminfo[0].shape = __pyx_pybuffernd_convolution_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_convolution_values.diminfo[1].strides = __pyx_pybuffernd_convolution_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_convolution_values.diminfo[1].shape = __pyx_pybuffernd_convolution_values.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 480, __pyx_L1_error)
    }
    __pyx_t_16 = 0;
    __Pyx_XDECREF_SET(__pyx_v_convolution_values, ((PyArrayObject *)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "networkconv.pyx":483
 * 
 *             # now, find the maximum values
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.max_indices[target] = convolution_values.argmax(0)
 *             self.hidden_values[target] = convolution_values.max(0)
 */
    __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(1, 483, __pyx_L1_error)
    if (__pyx_t_15) {

      /* "networkconv.pyx":484
 *             # now, find the maximum values
 *             if training:
 *                 self.max_indices[target] = convolution_values.argmax(0)             # <<<<<<<<<<<<<<
 *             self.hidden_values[target] = convolution_values.max(0)
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_convolution_values), __pyx_n_s_argmax); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 484, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_8, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_int_0);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 484, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->max_indices), __pyx_v_target, __pyx_t_7) < 0)) __PYX_ERR(1, 484, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "networkconv.pyx":483
 * 
 *             # now, find the maximum values
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.max_indices[target] = convolution_values.argmax(0)
 *             self.hidden_values[target] = convolution_values.max(0)
 */
    }

    /* "networkconv.pyx":485
 *             if training:
 *                 self.max_indices[target] = convolution_values.argmax(0)
 *             self.hidden_values[target] = convolution_values.max(0)             # <<<<<<<<<<<<<<
 * 
 *         # apply the bias and proceed to the next layer
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_convolution_values), __pyx_n_s_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_8, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_int_0);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 485, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->__pyx_base.hidden_values), __pyx_v_target, __pyx_t_7) < 0)) __PYX_ERR(1, 485, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "networkconv.pyx":462
 *         input_and_pred_dist_values = pred_dist_values + self.convolution_lookup
 * 
 *         for target in range(self.num_targets):             # <<<<<<<<<<<<<<
 *             # loop over targets and add the weighted distance features to each token
 *             # this is necessary for the convolution layer
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "networkconv.pyx":488
 * 
 *         # apply the bias and proceed to the next layer
 *         self.hidden_values += self.hidden_bias             # <<<<<<<<<<<<<<
 * 
 *         if self.hidden2_weights is not None:
 */
  __pyx_t_6 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->__pyx_base.hidden_values), ((PyObject *)__pyx_v_self->__pyx_base.hidden_bias)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 488, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 488, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.hidden_values);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_values));
  __pyx_v_self->__pyx_base.hidden_values = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "networkconv.pyx":490
 *         self.hidden_values += self.hidden_bias
 * 
 *         if self.hidden2_weights is not None:             # <<<<<<<<<<<<<<
 *             self.hidden2_values = self.hidden_values.dot(self.hidden2_weights.T) + self.hidden2_bias
 * 
 */
  __pyx_t_15 = (((PyObject *)__pyx_v_self->hidden2_weights) != Py_None);
  __pyx_t_2 = (__pyx_t_15 != 0);
  if (__pyx_t_2) {

    /* "networkconv.pyx":491
 * 
 *         if self.hidden2_weights is not None:
 *             self.hidden2_values = self.hidden_values.dot(self.hidden2_weights.T) + self.hidden2_bias             # <<<<<<<<<<<<<<
 * 
 *             if training:
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.hidden_values), __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hidden2_weights), __pyx_n_s_T); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_v_self->hidden2_bias)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 491, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 491, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_7);
    __Pyx_GOTREF(__pyx_v_self->hidden2_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_values));
    __pyx_v_self->hidden2_values = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "networkconv.pyx":493
 *             self.hidden2_values = self.hidden_values.dot(self.hidden2_weights.T) + self.hidden2_bias
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.hidden2_before_activation = self.hidden2_values.copy()
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 493, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "networkconv.pyx":494
 * 
 *             if training:
 *                 self.hidden2_before_activation = self.hidden2_values.copy()             # <<<<<<<<<<<<<<
 * 
 *             hardtanh(self.hidden2_values, inplace=True)
 */
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hidden2_values), __pyx_n_s_copy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 494, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      __pyx_t_7 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 494, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 494, __pyx_L1_error)
      __Pyx_GIVEREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_v_self->hidden2_before_activation);
      __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_before_activation));
      __pyx_v_self->hidden2_before_activation = ((PyArrayObject *)__pyx_t_7);
      __pyx_t_7 = 0;

      /* "networkconv.pyx":493
 *             self.hidden2_values = self.hidden_values.dot(self.hidden2_weights.T) + self.hidden2_bias
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.hidden2_before_activation = self.hidden2_values.copy()
 * 
 */
    }

    /* "networkconv.pyx":496
 *                 self.hidden2_before_activation = self.hidden2_values.copy()
 * 
 *             hardtanh(self.hidden2_values, inplace=True)             # <<<<<<<<<<<<<<
 *         else:
 *             # apply non-linearity here
 */
    __pyx_t_7 = ((PyObject *)__pyx_v_self->hidden2_values);
    __Pyx_INCREF(__pyx_t_7);
    __pyx_t_17.__pyx_n = 1;
    __pyx_t_17.inplace = Py_True;
    __pyx_t_6 = __pyx_f_4libs_7network_hardtanh(((PyArrayObject *)__pyx_t_7), &__pyx_t_17); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 496, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "networkconv.pyx":490
 *         self.hidden_values += self.hidden_bias
 * 
 *         if self.hidden2_weights is not None:             # <<<<<<<<<<<<<<
 *             self.hidden2_values = self.hidden_values.dot(self.hidden2_weights.T) + self.hidden2_bias
 * 
 */
    goto __pyx_L8;
  }

  /* "networkconv.pyx":499
 *         else:
 *             # apply non-linearity here
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.hidden_before_activation = self.hidden_values.copy()
 * 
 */
  /*else*/ {
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 499, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "networkconv.pyx":500
 *             # apply non-linearity here
 *             if training:
 *                 self.hidden_before_activation = self.hidden_values.copy()             # <<<<<<<<<<<<<<
 * 
 *             self.hidden2_values = self.hidden_values
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.hidden_values), __pyx_n_s_copy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 500, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      __pyx_t_6 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 500, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 500, __pyx_L1_error)
      __Pyx_GIVEREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_v_self->hidden_before_activation);
      __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_before_activation));
      __pyx_v_self->hidden_before_activation = ((PyArrayObject *)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "networkconv.pyx":499
 *         else:
 *             # apply non-linearity here
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.hidden_before_activation = self.hidden_values.copy()
 * 
 */
    }

    /* "networkconv.pyx":502
 *                 self.hidden_before_activation = self.hidden_values.copy()
 * 
 *             self.hidden2_values = self.hidden_values             # <<<<<<<<<<<<<<
 *             hardtanh(self.hidden_values, inplace=True)
 * 
 */
    __pyx_t_6 = ((PyObject *)__pyx_v_self->__pyx_base.hidden_values);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __Pyx_GOTREF(__pyx_v_self->hidden2_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_values));
    __pyx_v_self->hidden2_values = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "networkconv.pyx":503
 * 
 *             self.hidden2_values = self.hidden_values
 *             hardtanh(self.hidden_values, inplace=True)             # <<<<<<<<<<<<<<
 * 
 *         scores = self.hidden2_values.dot(self.output_weights.T) + self.output_bias
 */
    __pyx_t_6 = ((PyObject *)__pyx_v_self->__pyx_base.hidden_values);
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_17.__pyx_n = 1;
    __pyx_t_17.inplace = Py_True;
    __pyx_t_7 = __pyx_f_4libs_7network_hardtanh(((PyArrayObject *)__pyx_t_6), &__pyx_t_17); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 503, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __pyx_L8:;

  /* "networkconv.pyx":505
 *             hardtanh(self.hidden_values, inplace=True)
 * 
 *         scores = self.hidden2_values.dot(self.output_weights.T) + self.output_bias             # <<<<<<<<<<<<<<
 * 
 *         return scores
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hidden2_values), __pyx_n_s_dot); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.output_weights), __pyx_n_s_T); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_7 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_v_self->__pyx_base.output_bias)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 505, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 505, __pyx_L1_error)
  __pyx_t_18 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
    __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_scores.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_9 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_scores.rcbuffer->pybuffer, (PyObject*)__pyx_v_scores, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      }
      __pyx_t_11 = __pyx_t_12 = __pyx_t_13 = 0;
    }
    __pyx_pybuffernd_scores.diminfo[0].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_scores.diminfo[0].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_scores.diminfo[1].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_scores.diminfo[1].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 505, __pyx_L1_error)
  }
  __pyx_t_18 = 0;
  __pyx_v_scores = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "networkconv.pyx":507
 *         scores = self.hidden2_values.dot(self.output_weights.T) + self.output_bias
 * 
 *         return scores             # <<<<<<<<<<<<<<
 * 
 *     def _pre_tagging_setup(self, np.ndarray sentence, bool training):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_scores));
  __pyx_r = ((PyObject *)__pyx_v_scores);
  goto __pyx_L0;

  /* "networkconv.pyx":423
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _sentence_convolution(self, sentence, predicate, argument_blocks=None,             # <<<<<<<<<<<<<<
 *                               training=False):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_convolution_values.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._sentence_convolution", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_convolution_values.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_and_pred_dist_values.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_convolution_values);
  __Pyx_XDECREF((PyObject *)__pyx_v_scores);
  __Pyx_XDECREF((PyObject *)__pyx_v_input_and_pred_dist_values);
  __Pyx_XDECREF(__pyx_v_pred_dist_indices);
  __Pyx_XDECREF(__pyx_v_pred_dist_values);
  __Pyx_XDECREF(__pyx_v_target);
  __Pyx_XDECREF(__pyx_v_target_dist_indices);
  __Pyx_XDECREF(__pyx_v_argument);
  __Pyx_XDECREF(__pyx_v_target_dist_values);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":509
 *         return scores
 * 
 *     def _pre_tagging_setup(self, np.ndarray sentence, bool training):             # <<<<<<<<<<<<<<
 *         """
 *         Perform some initialization actions before the actual tagging.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_31_pre_tagging_setup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_30_pre_tagging_setup[] = "ConvolutionalNetwork._pre_tagging_setup(self, ndarray sentence, bool training)\n\n        Perform some initialization actions before the actual tagging.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_31_pre_tagging_setup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_sentence = 0;
  PyBoolObject *__pyx_v_training = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_pre_tagging_setup (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_training,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_training)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_pre_tagging_setup", 1, 2, 2, 1); __PYX_ERR(1, 509, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_pre_tagging_setup") < 0)) __PYX_ERR(1, 509, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sentence = ((PyArrayObject *)values[0]);
    __pyx_v_training = ((PyBoolObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_pre_tagging_setup", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 509, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._pre_tagging_setup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(1, 509, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_training), __pyx_ptype_7cpython_4bool_bool, 1, "training", 0))) __PYX_ERR(1, 509, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_30_pre_tagging_setup(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_training);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_30_pre_tagging_setup(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyBoolObject *__pyx_v_training) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_pre_tagging_setup", 0);
  __Pyx_TraceCall("_pre_tagging_setup", __pyx_f[1], 509, 0, __PYX_ERR(1, 509, __pyx_L1_error));

  /* "networkconv.pyx":513
 *         Perform some initialization actions before the actual tagging.
 *         """
 *         if training:             # <<<<<<<<<<<<<<
 *             # this table will store the values of the neurons for each input token
 *             # they will be needed during weight adjustments
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_training)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 513, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "networkconv.pyx":516
 *             # this table will store the values of the neurons for each input token
 *             # they will be needed during weight adjustments
 *             self.input_sent_values = np.empty((len(sentence), self.input_size))             # <<<<<<<<<<<<<<
 * 
 *         # store the convolution values to save time
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 516, __pyx_L1_error)
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.input_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
    __pyx_t_3 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 516, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.input_sent_values);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.input_sent_values));
    __pyx_v_self->__pyx_base.input_sent_values = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "networkconv.pyx":513
 *         Perform some initialization actions before the actual tagging.
 *         """
 *         if training:             # <<<<<<<<<<<<<<
 *             # this table will store the values of the neurons for each input token
 *             # they will be needed during weight adjustments
 */
  }

  /* "networkconv.pyx":519
 * 
 *         # store the convolution values to save time
 *         self._create_convolution_lookup(sentence, training)             # <<<<<<<<<<<<<<
 * 
 *         if self.target_dist_lookup is None: self._create_target_lookup()
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_convolution_lookup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = NULL;
  __pyx_t_8 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_8 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_sentence), ((PyObject *)__pyx_v_training)};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 519, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[3] = {__pyx_t_7, ((PyObject *)__pyx_v_sentence), ((PyObject *)__pyx_v_training)};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 519, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_7) {
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_8, ((PyObject *)__pyx_v_sentence));
    __Pyx_INCREF(((PyObject *)__pyx_v_training));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_training));
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_8, ((PyObject *)__pyx_v_training));
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":521
 *         self._create_convolution_lookup(sentence, training)
 * 
 *         if self.target_dist_lookup is None: self._create_target_lookup()             # <<<<<<<<<<<<<<
 *         if self.pred_dist_lookup is None: self._create_pred_lookup()
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->target_dist_lookup) == Py_None);
  __pyx_t_9 = (__pyx_t_1 != 0);
  if (__pyx_t_9) {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_target_lookup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "networkconv.pyx":522
 * 
 *         if self.target_dist_lookup is None: self._create_target_lookup()
 *         if self.pred_dist_lookup is None: self._create_pred_lookup()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_9 = (((PyObject *)__pyx_v_self->pred_dist_lookup) == Py_None);
  __pyx_t_1 = (__pyx_t_9 != 0);
  if (__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_pred_lookup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "networkconv.pyx":509
 *         return scores
 * 
 *     def _pre_tagging_setup(self, np.ndarray sentence, bool training):             # <<<<<<<<<<<<<<
 *         """
 *         Perform some initialization actions before the actual tagging.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._pre_tagging_setup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":527
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _tag_sentence(self, np.ndarray sentence, np.ndarray predicates,             # <<<<<<<<<<<<<<
 *                       list tags=None, list argument_blocks=None,
 *                       bool allow_repeats=True, bool logprob=False):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_33_tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_32_tag_sentence[] = "ConvolutionalNetwork._tag_sentence(self, ndarray sentence, ndarray predicates, list tags=None, list argument_blocks=None, bool allow_repeats=True, bool logprob=False)\n\n        Runs the network for every predicate in the sentence.\n        Refer to the Network class for more information.\n        \n        :param tags: this is a list rather than a numpy array because in\n            argument classification, each predicate may have a differente number\n            of arguments.\n        :param argument_blocks: (used only in SRL argument classification) a list\n            with the starting and end positions of all delimited arguments (one for \n            each predicate)\n        :param predicates: a numpy array with the indices of the predicates in the sentence.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_33_tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_sentence = 0;
  PyArrayObject *__pyx_v_predicates = 0;
  PyObject *__pyx_v_tags = 0;
  PyObject *__pyx_v_argument_blocks = 0;
  PyBoolObject *__pyx_v_allow_repeats = 0;
  PyBoolObject *__pyx_v_logprob = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_tag_sentence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_predicates,&__pyx_n_s_tags,&__pyx_n_s_argument_blocks,&__pyx_n_s_allow_repeats,&__pyx_n_s_logprob,0};
    PyObject* values[6] = {0,0,0,0,0,0};

    /* "networkconv.pyx":528
 *     @cython.wraparound(False)
 *     def _tag_sentence(self, np.ndarray sentence, np.ndarray predicates,
 *                       list tags=None, list argument_blocks=None,             # <<<<<<<<<<<<<<
 *                       bool allow_repeats=True, bool logprob=False):
 *         """
 */
    values[2] = ((PyObject*)Py_None);
    values[3] = ((PyObject*)Py_None);

    /* "networkconv.pyx":529
 *     def _tag_sentence(self, np.ndarray sentence, np.ndarray predicates,
 *                       list tags=None, list argument_blocks=None,
 *                       bool allow_repeats=True, bool logprob=False):             # <<<<<<<<<<<<<<
 *         """
 *         Runs the network for every predicate in the sentence.
 */
    values[4] = (PyObject *)((PyBoolObject *)Py_True);
    values[5] = (PyObject *)((PyBoolObject *)Py_False);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicates)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_tag_sentence", 0, 2, 6, 1); __PYX_ERR(1, 527, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_argument_blocks);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allow_repeats);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_logprob);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_tag_sentence") < 0)) __PYX_ERR(1, 527, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = ((PyArrayObject *)values[0]);
    __pyx_v_predicates = ((PyArrayObject *)values[1]);
    __pyx_v_tags = ((PyObject*)values[2]);
    __pyx_v_argument_blocks = ((PyObject*)values[3]);
    __pyx_v_allow_repeats = ((PyBoolObject *)values[4]);
    __pyx_v_logprob = ((PyBoolObject *)values[5]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_tag_sentence", 0, 2, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 527, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(1, 527, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_predicates), __pyx_ptype_5numpy_ndarray, 1, "predicates", 0))) __PYX_ERR(1, 527, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tags), (&PyList_Type), 1, "tags", 1))) __PYX_ERR(1, 528, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_argument_blocks), (&PyList_Type), 1, "argument_blocks", 1))) __PYX_ERR(1, 528, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_allow_repeats), __pyx_ptype_7cpython_4bool_bool, 1, "allow_repeats", 0))) __PYX_ERR(1, 529, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_logprob), __pyx_ptype_7cpython_4bool_bool, 1, "logprob", 0))) __PYX_ERR(1, 529, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_32_tag_sentence(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_predicates, __pyx_v_tags, __pyx_v_argument_blocks, __pyx_v_allow_repeats, __pyx_v_logprob);

  /* "networkconv.pyx":527
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _tag_sentence(self, np.ndarray sentence, np.ndarray predicates,             # <<<<<<<<<<<<<<
 *                       list tags=None, list argument_blocks=None,
 *                       bool allow_repeats=True, bool logprob=False):
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_32_tag_sentence(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_predicates, PyObject *__pyx_v_tags, PyObject *__pyx_v_argument_blocks, PyBoolObject *__pyx_v_allow_repeats, PyBoolObject *__pyx_v_logprob) {
  PyObject *__pyx_v_answer = NULL;
  PyObject *__pyx_v_training = NULL;
  PyArrayObject *__pyx_v_token_scores = 0;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_predicate = NULL;
  PyObject *__pyx_v_pred_arguments = NULL;
  PyObject *__pyx_v_pred_answer = NULL;
  PyObject *__pyx_v_pred_tags = NULL;
  PyObject *__pyx_v_all_scores = NULL;
  Py_ssize_t __pyx_v_last_token;
  PyObject *__pyx_v_logadd = NULL;
  PyObject *__pyx_v_confidence = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_token_scores;
  __Pyx_Buffer __pyx_pybuffer_token_scores;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_t_20;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_tag_sentence", 0);
  __Pyx_TraceCall("_tag_sentence", __pyx_f[1], 527, 0, __PYX_ERR(1, 527, __pyx_L1_error));
  __pyx_pybuffer_token_scores.pybuffer.buf = NULL;
  __pyx_pybuffer_token_scores.refcount = 0;
  __pyx_pybuffernd_token_scores.data = NULL;
  __pyx_pybuffernd_token_scores.rcbuffer = &__pyx_pybuffer_token_scores;

  /* "networkconv.pyx":542
 *         :param predicates: a numpy array with the indices of the predicates in the sentence.
 *         """
 *         answer = []             # <<<<<<<<<<<<<<
 *         training = tags is not None
 *         self._pre_tagging_setup(sentence, training)
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 542, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_answer = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":543
 *         """
 *         answer = []
 *         training = tags is not None             # <<<<<<<<<<<<<<
 *         self._pre_tagging_setup(sentence, training)
 *         cdef np.ndarray[FLOAT_t, ndim=2] token_scores
 */
  __pyx_t_2 = (__pyx_v_tags != ((PyObject*)Py_None));
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_training = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":544
 *         answer = []
 *         training = tags is not None
 *         self._pre_tagging_setup(sentence, training)             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[FLOAT_t, ndim=2] token_scores
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pre_tagging_setup); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_sentence), __pyx_v_training};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 544, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_sentence), __pyx_v_training};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 544, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 544, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
    __Pyx_INCREF(__pyx_v_training);
    __Pyx_GIVEREF(__pyx_v_training);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_training);
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 544, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":547
 *         cdef np.ndarray[FLOAT_t, ndim=2] token_scores
 * 
 *         for i, predicate in enumerate(predicates):             # <<<<<<<<<<<<<<
 *             pred_arguments = None if not self.only_classify else argument_blocks[i]
 *             pred_arguments = argument_blocks[i]
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_predicates))) || PyTuple_CheckExact(((PyObject *)__pyx_v_predicates))) {
    __pyx_t_3 = ((PyObject *)__pyx_v_predicates); __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_predicates)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 547, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 547, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 547, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 547, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 547, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_8(__pyx_t_3);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 547, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_predicate, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 547, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "networkconv.pyx":548
 * 
 *         for i, predicate in enumerate(predicates):
 *             pred_arguments = None if not self.only_classify else argument_blocks[i]             # <<<<<<<<<<<<<<
 *             pred_arguments = argument_blocks[i]
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->only_classify)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 548, __pyx_L1_error)
    if (((!__pyx_t_2) != 0)) {
      __Pyx_INCREF(Py_None);
      __pyx_t_6 = Py_None;
    } else {
      if (unlikely(__pyx_v_argument_blocks == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 548, __pyx_L1_error)
      }
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_argument_blocks, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 548, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __Pyx_XDECREF_SET(__pyx_v_pred_arguments, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "networkconv.pyx":549
 *         for i, predicate in enumerate(predicates):
 *             pred_arguments = None if not self.only_classify else argument_blocks[i]
 *             pred_arguments = argument_blocks[i]             # <<<<<<<<<<<<<<
 * 
 *             token_scores = self._sentence_convolution(sentence, predicate, pred_arguments, training)
 */
    if (unlikely(__pyx_v_argument_blocks == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(1, 549, __pyx_L1_error)
    }
    __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_argument_blocks, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 549, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF_SET(__pyx_v_pred_arguments, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "networkconv.pyx":551
 *             pred_arguments = argument_blocks[i]
 * 
 *             token_scores = self._sentence_convolution(sentence, predicate, pred_arguments, training)             # <<<<<<<<<<<<<<
 *             pred_answer = self._viterbi(token_scores, allow_repeats)
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sentence_convolution); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 551, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, ((PyObject *)__pyx_v_sentence), __pyx_v_predicate, __pyx_v_pred_arguments, __pyx_v_training};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 551, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[5] = {__pyx_t_9, ((PyObject *)__pyx_v_sentence), __pyx_v_predicate, __pyx_v_pred_arguments, __pyx_v_training};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 551, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 551, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
      __Pyx_INCREF(__pyx_v_predicate);
      __Pyx_GIVEREF(__pyx_v_predicate);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_v_predicate);
      __Pyx_INCREF(__pyx_v_pred_arguments);
      __Pyx_GIVEREF(__pyx_v_pred_arguments);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_5, __pyx_v_pred_arguments);
      __Pyx_INCREF(__pyx_v_training);
      __Pyx_GIVEREF(__pyx_v_training);
      PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_5, __pyx_v_training);
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 551, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 551, __pyx_L1_error)
    __pyx_t_11 = ((PyArrayObject *)__pyx_t_6);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer, (PyObject*)__pyx_v_token_scores, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        }
        __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0;
      }
      __pyx_pybuffernd_token_scores.diminfo[0].strides = __pyx_pybuffernd_token_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_token_scores.diminfo[0].shape = __pyx_pybuffernd_token_scores.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_token_scores.diminfo[1].strides = __pyx_pybuffernd_token_scores.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_token_scores.diminfo[1].shape = __pyx_pybuffernd_token_scores.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(1, 551, __pyx_L1_error)
    }
    __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_token_scores, ((PyArrayObject *)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "networkconv.pyx":552
 * 
 *             token_scores = self._sentence_convolution(sentence, predicate, pred_arguments, training)
 *             pred_answer = self._viterbi(token_scores, allow_repeats)             # <<<<<<<<<<<<<<
 * 
 *             if training:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_viterbi); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_token_scores), ((PyObject *)__pyx_v_allow_repeats)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 552, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_token_scores), ((PyObject *)__pyx_v_allow_repeats)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 552, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 552, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_token_scores));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_token_scores));
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, ((PyObject *)__pyx_v_token_scores));
      __Pyx_INCREF(((PyObject *)__pyx_v_allow_repeats));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_allow_repeats));
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, ((PyObject *)__pyx_v_allow_repeats));
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 552, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_pred_answer, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "networkconv.pyx":554
 *             pred_answer = self._viterbi(token_scores, allow_repeats)
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 pred_tags = tags[i]
 *                 if self._calculate_gradients(pred_tags, token_scores):
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 554, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "networkconv.pyx":555
 * 
 *             if training:
 *                 pred_tags = tags[i]             # <<<<<<<<<<<<<<
 *                 if self._calculate_gradients(pred_tags, token_scores):
 *                     self._backpropagate()
 */
      if (unlikely(__pyx_v_tags == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(1, 555, __pyx_L1_error)
      }
      __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_tags, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_pred_tags, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "networkconv.pyx":556
 *             if training:
 *                 pred_tags = tags[i]
 *                 if self._calculate_gradients(pred_tags, token_scores):             # <<<<<<<<<<<<<<
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, predicate, pred_arguments)
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_gradients); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 556, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_pred_tags, ((PyObject *)__pyx_v_token_scores)};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 556, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_pred_tags, ((PyObject *)__pyx_v_token_scores)};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 556, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_9) {
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        }
        __Pyx_INCREF(__pyx_v_pred_tags);
        __Pyx_GIVEREF(__pyx_v_pred_tags);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_v_pred_tags);
        __Pyx_INCREF(((PyObject *)__pyx_v_token_scores));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_token_scores));
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, ((PyObject *)__pyx_v_token_scores));
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 556, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_2) {

        /* "networkconv.pyx":557
 *                 pred_tags = tags[i]
 *                 if self._calculate_gradients(pred_tags, token_scores):
 *                     self._backpropagate()             # <<<<<<<<<<<<<<
 *                     self._calculate_input_deltas(sentence, predicate, pred_arguments)
 *                     self._adjust_weights(predicate, pred_arguments)
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_backpropagate); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 557, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        __pyx_t_6 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 557, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "networkconv.pyx":558
 *                 if self._calculate_gradients(pred_tags, token_scores):
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, predicate, pred_arguments)             # <<<<<<<<<<<<<<
 *                     self._adjust_weights(predicate, pred_arguments)
 *                     self._adjust_features(sentence, predicate)
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_input_deltas); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_10, ((PyObject *)__pyx_v_sentence), __pyx_v_predicate, __pyx_v_pred_arguments};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 558, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[4] = {__pyx_t_10, ((PyObject *)__pyx_v_sentence), __pyx_v_predicate, __pyx_v_pred_arguments};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 558, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 558, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
          PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
          __Pyx_INCREF(__pyx_v_predicate);
          __Pyx_GIVEREF(__pyx_v_predicate);
          PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, __pyx_v_predicate);
          __Pyx_INCREF(__pyx_v_pred_arguments);
          __Pyx_GIVEREF(__pyx_v_pred_arguments);
          PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_5, __pyx_v_pred_arguments);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 558, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "networkconv.pyx":559
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, predicate, pred_arguments)
 *                     self._adjust_weights(predicate, pred_arguments)             # <<<<<<<<<<<<<<
 *                     self._adjust_features(sentence, predicate)
 * 
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_adjust_weights); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 559, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_9 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_9)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_9);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_predicate, __pyx_v_pred_arguments};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 559, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_predicate, __pyx_v_pred_arguments};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 559, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 559, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          if (__pyx_t_9) {
            __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
          }
          __Pyx_INCREF(__pyx_v_predicate);
          __Pyx_GIVEREF(__pyx_v_predicate);
          PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, __pyx_v_predicate);
          __Pyx_INCREF(__pyx_v_pred_arguments);
          __Pyx_GIVEREF(__pyx_v_pred_arguments);
          PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_v_pred_arguments);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 559, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "networkconv.pyx":560
 *                     self._calculate_input_deltas(sentence, predicate, pred_arguments)
 *                     self._adjust_weights(predicate, pred_arguments)
 *                     self._adjust_features(sentence, predicate)             # <<<<<<<<<<<<<<
 * 
 *             if logprob:
 */
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_adjust_features); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 560, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_sentence), __pyx_v_predicate};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 560, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_sentence), __pyx_v_predicate};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 560, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_6);
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 560, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
          PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
          __Pyx_INCREF(__pyx_v_predicate);
          __Pyx_GIVEREF(__pyx_v_predicate);
          PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, __pyx_v_predicate);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 560, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "networkconv.pyx":556
 *             if training:
 *                 pred_tags = tags[i]
 *                 if self._calculate_gradients(pred_tags, token_scores):             # <<<<<<<<<<<<<<
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, predicate, pred_arguments)
 */
      }

      /* "networkconv.pyx":554
 *             pred_answer = self._viterbi(token_scores, allow_repeats)
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 pred_tags = tags[i]
 *                 if self._calculate_gradients(pred_tags, token_scores):
 */
    }

    /* "networkconv.pyx":562
 *                     self._adjust_features(sentence, predicate)
 * 
 *             if logprob:             # <<<<<<<<<<<<<<
 *                 if self.only_classify:
 *                     raise NotImplementedError('Confidence measure not implemented for argument classifying')
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_logprob)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 562, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "networkconv.pyx":563
 * 
 *             if logprob:
 *                 if self.only_classify:             # <<<<<<<<<<<<<<
 *                     raise NotImplementedError('Confidence measure not implemented for argument classifying')
 * 
 */
      __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->only_classify)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 563, __pyx_L1_error)
      if (unlikely(__pyx_t_2)) {

        /* "networkconv.pyx":564
 *             if logprob:
 *                 if self.only_classify:
 *                     raise NotImplementedError('Confidence measure not implemented for argument classifying')             # <<<<<<<<<<<<<<
 * 
 *                 all_scores = self._calculate_all_scores(token_scores)
 */
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 564, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_Raise(__pyx_t_6, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __PYX_ERR(1, 564, __pyx_L1_error)

        /* "networkconv.pyx":563
 * 
 *             if logprob:
 *                 if self.only_classify:             # <<<<<<<<<<<<<<
 *                     raise NotImplementedError('Confidence measure not implemented for argument classifying')
 * 
 */
      }

      /* "networkconv.pyx":566
 *                     raise NotImplementedError('Confidence measure not implemented for argument classifying')
 * 
 *                 all_scores = self._calculate_all_scores(token_scores)             # <<<<<<<<<<<<<<
 *                 last_token = len(sentence) - 1
 *                 logadd = np.log(np.sum(np.exp(all_scores[last_token])))
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_all_scores); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 566, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_9, ((PyObject *)__pyx_v_token_scores)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_token_scores));
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 566, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_all_scores, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "networkconv.pyx":567
 * 
 *                 all_scores = self._calculate_all_scores(token_scores)
 *                 last_token = len(sentence) - 1             # <<<<<<<<<<<<<<
 *                 logadd = np.log(np.sum(np.exp(all_scores[last_token])))
 *                 confidence = self.answer_score - logadd
 */
      __pyx_t_15 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(1, 567, __pyx_L1_error)
      __pyx_v_last_token = (__pyx_t_15 - 1);

      /* "networkconv.pyx":568
 *                 all_scores = self._calculate_all_scores(token_scores)
 *                 last_token = len(sentence) - 1
 *                 logadd = np.log(np.sum(np.exp(all_scores[last_token])))             # <<<<<<<<<<<<<<
 *                 confidence = self.answer_score - logadd
 *                 pred_answer = (pred_answer, confidence)
 */
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_log); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_sum); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_np); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_exp); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = __Pyx_GetItemInt(__pyx_v_all_scores, __pyx_v_last_token, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_19 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_18))) {
        __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_18);
        if (likely(__pyx_t_19)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
          __Pyx_INCREF(__pyx_t_19);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_18, function);
        }
      }
      __pyx_t_10 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_18, __pyx_t_19, __pyx_t_17) : __Pyx_PyObject_CallOneArg(__pyx_t_18, __pyx_t_17);
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      __pyx_t_18 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
        __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_16);
        if (likely(__pyx_t_18)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_16, function);
        }
      }
      __pyx_t_4 = (__pyx_t_18) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_18, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_10);
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      __pyx_t_6 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_16, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF_SET(__pyx_v_logadd, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "networkconv.pyx":569
 *                 last_token = len(sentence) - 1
 *                 logadd = np.log(np.sum(np.exp(all_scores[last_token])))
 *                 confidence = self.answer_score - logadd             # <<<<<<<<<<<<<<
 *                 pred_answer = (pred_answer, confidence)
 * 
 */
      __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.answer_score); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PyNumber_Subtract(__pyx_t_6, __pyx_v_logadd); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF_SET(__pyx_v_confidence, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "networkconv.pyx":570
 *                 logadd = np.log(np.sum(np.exp(all_scores[last_token])))
 *                 confidence = self.answer_score - logadd
 *                 pred_answer = (pred_answer, confidence)             # <<<<<<<<<<<<<<
 * 
 *             answer.append(pred_answer)
 */
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_pred_answer);
      __Pyx_GIVEREF(__pyx_v_pred_answer);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_pred_answer);
      __Pyx_INCREF(__pyx_v_confidence);
      __Pyx_GIVEREF(__pyx_v_confidence);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_confidence);
      __Pyx_DECREF_SET(__pyx_v_pred_answer, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "networkconv.pyx":562
 *                     self._adjust_features(sentence, predicate)
 * 
 *             if logprob:             # <<<<<<<<<<<<<<
 *                 if self.only_classify:
 *                     raise NotImplementedError('Confidence measure not implemented for argument classifying')
 */
    }

    /* "networkconv.pyx":572
 *                 pred_answer = (pred_answer, confidence)
 * 
 *             answer.append(pred_answer)             # <<<<<<<<<<<<<<
 * 
 *         return answer
 */
    __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_answer, __pyx_v_pred_answer); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(1, 572, __pyx_L1_error)

    /* "networkconv.pyx":547
 *         cdef np.ndarray[FLOAT_t, ndim=2] token_scores
 * 
 *         for i, predicate in enumerate(predicates):             # <<<<<<<<<<<<<<
 *             pred_arguments = None if not self.only_classify else argument_blocks[i]
 *             pred_arguments = argument_blocks[i]
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":574
 *             answer.append(pred_answer)
 * 
 *         return answer             # <<<<<<<<<<<<<<
 * 
 *     def _validate(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_answer);
  __pyx_r = __pyx_v_answer;
  goto __pyx_L0;

  /* "networkconv.pyx":527
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _tag_sentence(self, np.ndarray sentence, np.ndarray predicates,             # <<<<<<<<<<<<<<
 *                       list tags=None, list argument_blocks=None,
 *                       bool allow_repeats=True, bool logprob=False):
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_answer);
  __Pyx_XDECREF(__pyx_v_training);
  __Pyx_XDECREF((PyObject *)__pyx_v_token_scores);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_predicate);
  __Pyx_XDECREF(__pyx_v_pred_arguments);
  __Pyx_XDECREF(__pyx_v_pred_answer);
  __Pyx_XDECREF(__pyx_v_pred_tags);
  __Pyx_XDECREF(__pyx_v_all_scores);
  __Pyx_XDECREF(__pyx_v_logadd);
  __Pyx_XDECREF(__pyx_v_confidence);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":576
 *         return answer
 * 
 *     def _validate(self):             # <<<<<<<<<<<<<<
 *         """
 *         Evaluates the network performance, updating its hits count.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_35_validate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_34_validate[] = "ConvolutionalNetwork._validate(self)\n\n        Evaluates the network performance, updating its hits count.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_35_validate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_validate (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_34_validate(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_34_validate(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_v_num_items = NULL;
  PyObject *__pyx_v_hits = NULL;
  PyObject *__pyx_v_i_args = NULL;
  PyObject *__pyx_v_sent_args = NULL;
  PyObject *__pyx_v_sent = NULL;
  PyObject *__pyx_v_sent_preds = NULL;
  PyObject *__pyx_v_sent_tags = NULL;
  PyObject *__pyx_v_answer = NULL;
  PyObject *__pyx_v_predicate_answer = NULL;
  PyObject *__pyx_v_predicate_tags = NULL;
  PyObject *__pyx_v_net_tag = NULL;
  PyObject *__pyx_v_gold_tag = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  PyObject *(*__pyx_t_14)(PyObject *);
  Py_ssize_t __pyx_t_15;
  PyObject *(*__pyx_t_16)(PyObject *);
  PyObject *__pyx_t_17 = NULL;
  float __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_validate", 0);
  __Pyx_TraceCall("_validate", __pyx_f[1], 576, 0, __PYX_ERR(1, 576, __pyx_L1_error));

  /* "networkconv.pyx":582
 *         # call it "item" instead of token because the same token may be counted
 *         # more than once (sentences with multiple predicates)
 *         num_items = 0             # <<<<<<<<<<<<<<
 *         hits = 0
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_num_items = __pyx_int_0;

  /* "networkconv.pyx":583
 *         # more than once (sentences with multiple predicates)
 *         num_items = 0
 *         hits = 0             # <<<<<<<<<<<<<<
 * 
 *         if self.validation_arguments is not None:
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_hits = __pyx_int_0;

  /* "networkconv.pyx":585
 *         hits = 0
 * 
 *         if self.validation_arguments is not None:             # <<<<<<<<<<<<<<
 *             i_args = iter(self.validation_arguments)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_self->validation_arguments != ((PyObject*)Py_None));
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "networkconv.pyx":586
 * 
 *         if self.validation_arguments is not None:
 *             i_args = iter(self.validation_arguments)             # <<<<<<<<<<<<<<
 *         else:
 *             sent_args = None
 */
    __pyx_t_3 = __pyx_v_self->validation_arguments;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 586, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_i_args = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "networkconv.pyx":585
 *         hits = 0
 * 
 *         if self.validation_arguments is not None:             # <<<<<<<<<<<<<<
 *             i_args = iter(self.validation_arguments)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "networkconv.pyx":588
 *             i_args = iter(self.validation_arguments)
 *         else:
 *             sent_args = None             # <<<<<<<<<<<<<<
 * 
 *         for sent, sent_preds, sent_tags in zip(self.validation_sentences,
 */
  /*else*/ {
    __Pyx_INCREF(Py_None);
    __pyx_v_sent_args = Py_None;
  }
  __pyx_L3:;

  /* "networkconv.pyx":590
 *             sent_args = None
 * 
 *         for sent, sent_preds, sent_tags in zip(self.validation_sentences,             # <<<<<<<<<<<<<<
 *                                                 self.validation_predicates,
 *                                                 self.validation_tags):
 */
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 590, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.validation_sentences);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.validation_sentences);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_self->__pyx_base.validation_sentences);
  __Pyx_INCREF(__pyx_v_self->validation_predicates);
  __Pyx_GIVEREF(__pyx_v_self->validation_predicates);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->validation_predicates);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.validation_tags);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.validation_tags);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_self->__pyx_base.validation_tags);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 590, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 590, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 590, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 590, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 590, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 590, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 590, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 590, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 3)) {
        if (size > 3) __Pyx_RaiseTooManyValuesError(3);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(1, 590, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
      } else {
        __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
      }
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      #else
      __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_7 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      index = 1; __pyx_t_8 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      index = 2; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 3) < 0) __PYX_ERR(1, 590, __pyx_L1_error)
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(1, 590, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_sent, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_sent_preds, __pyx_t_8);
    __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_sent_tags, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "networkconv.pyx":593
 *                                                 self.validation_predicates,
 *                                                 self.validation_tags):
 *             if self.validation_arguments is not None:             # <<<<<<<<<<<<<<
 *                 sent_args = next(i_args)
 *                 #sent_args = i_args.next()
 */
    __pyx_t_2 = (__pyx_v_self->validation_arguments != ((PyObject*)Py_None));
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "networkconv.pyx":594
 *                                                 self.validation_tags):
 *             if self.validation_arguments is not None:
 *                 sent_args = next(i_args)             # <<<<<<<<<<<<<<
 *                 #sent_args = i_args.next()
 * 
 */
      if (unlikely(!__pyx_v_i_args)) { __Pyx_RaiseUnboundLocalError("i_args"); __PYX_ERR(1, 594, __pyx_L1_error) }
      __pyx_t_3 = __Pyx_PyIter_Next(__pyx_v_i_args); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_sent_args, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "networkconv.pyx":593
 *                                                 self.validation_predicates,
 *                                                 self.validation_tags):
 *             if self.validation_arguments is not None:             # <<<<<<<<<<<<<<
 *                 sent_args = next(i_args)
 *                 #sent_args = i_args.next()
 */
    }

    /* "networkconv.pyx":597
 *                 #sent_args = i_args.next()
 * 
 *             answer = self._tag_sentence(sent, sent_preds, None, sent_args)             # <<<<<<<<<<<<<<
 *             for predicate_answer, predicate_tags in zip(answer, sent_tags):
 *                 for net_tag, gold_tag in zip(predicate_answer, predicate_tags):
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 597, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (unlikely(!__pyx_v_sent_args)) { __Pyx_RaiseUnboundLocalError("sent_args"); __PYX_ERR(1, 597, __pyx_L1_error) }
    __pyx_t_8 = NULL;
    __pyx_t_12 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_12 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_v_sent, __pyx_v_sent_preds, Py_None, __pyx_v_sent_args};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 4+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 597, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[5] = {__pyx_t_8, __pyx_v_sent, __pyx_v_sent_preds, Py_None, __pyx_v_sent_args};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_12, 4+__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 597, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(4+__pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(__pyx_v_sent);
      __Pyx_GIVEREF(__pyx_v_sent);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_12, __pyx_v_sent);
      __Pyx_INCREF(__pyx_v_sent_preds);
      __Pyx_GIVEREF(__pyx_v_sent_preds);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_12, __pyx_v_sent_preds);
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_12, Py_None);
      __Pyx_INCREF(__pyx_v_sent_args);
      __Pyx_GIVEREF(__pyx_v_sent_args);
      PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_12, __pyx_v_sent_args);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 597, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF_SET(__pyx_v_answer, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":598
 * 
 *             answer = self._tag_sentence(sent, sent_preds, None, sent_args)
 *             for predicate_answer, predicate_tags in zip(answer, sent_tags):             # <<<<<<<<<<<<<<
 *                 for net_tag, gold_tag in zip(predicate_answer, predicate_tags):
 *                     if net_tag == gold_tag:
 */
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_answer);
    __Pyx_GIVEREF(__pyx_v_answer);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_answer);
    __Pyx_INCREF(__pyx_v_sent_tags);
    __Pyx_GIVEREF(__pyx_v_sent_tags);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_sent_tags);
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
      __pyx_t_3 = __pyx_t_9; __Pyx_INCREF(__pyx_t_3); __pyx_t_13 = 0;
      __pyx_t_14 = NULL;
    } else {
      __pyx_t_13 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 598, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_14 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 598, __pyx_L1_error)
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    for (;;) {
      if (likely(!__pyx_t_14)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_9); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(1, 598, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 598, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        } else {
          if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_13); __Pyx_INCREF(__pyx_t_9); __pyx_t_13++; if (unlikely(0 < 0)) __PYX_ERR(1, 598, __pyx_L1_error)
          #else
          __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 598, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          #endif
        }
      } else {
        __pyx_t_9 = __pyx_t_14(__pyx_t_3);
        if (unlikely(!__pyx_t_9)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 598, __pyx_L1_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_9);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
        PyObject* sequence = __pyx_t_9;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(1, 598, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        #else
        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 598, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 598, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_10 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 598, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
        index = 0; __pyx_t_7 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_7)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_7);
        index = 1; __pyx_t_8 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_8)) goto __pyx_L11_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_8);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(1, 598, __pyx_L1_error)
        __pyx_t_11 = NULL;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L12_unpacking_done;
        __pyx_L11_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(1, 598, __pyx_L1_error)
        __pyx_L12_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_predicate_answer, __pyx_t_7);
      __pyx_t_7 = 0;
      __Pyx_XDECREF_SET(__pyx_v_predicate_tags, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "networkconv.pyx":599
 *             answer = self._tag_sentence(sent, sent_preds, None, sent_args)
 *             for predicate_answer, predicate_tags in zip(answer, sent_tags):
 *                 for net_tag, gold_tag in zip(predicate_answer, predicate_tags):             # <<<<<<<<<<<<<<
 *                     if net_tag == gold_tag:
 *                         hits += 1
 */
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 599, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_predicate_answer);
      __Pyx_GIVEREF(__pyx_v_predicate_answer);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_predicate_answer);
      __Pyx_INCREF(__pyx_v_predicate_tags);
      __Pyx_GIVEREF(__pyx_v_predicate_tags);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_predicate_tags);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 599, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) {
        __pyx_t_9 = __pyx_t_8; __Pyx_INCREF(__pyx_t_9); __pyx_t_15 = 0;
        __pyx_t_16 = NULL;
      } else {
        __pyx_t_15 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 599, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_16 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 599, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      for (;;) {
        if (likely(!__pyx_t_16)) {
          if (likely(PyList_CheckExact(__pyx_t_9))) {
            if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_9)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_15); __Pyx_INCREF(__pyx_t_8); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(1, 599, __pyx_L1_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_9, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 599, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          } else {
            if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_15); __Pyx_INCREF(__pyx_t_8); __pyx_t_15++; if (unlikely(0 < 0)) __PYX_ERR(1, 599, __pyx_L1_error)
            #else
            __pyx_t_8 = PySequence_ITEM(__pyx_t_9, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 599, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            #endif
          }
        } else {
          __pyx_t_8 = __pyx_t_16(__pyx_t_9);
          if (unlikely(!__pyx_t_8)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(1, 599, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_8);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
          PyObject* sequence = __pyx_t_8;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(1, 599, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_7 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_10);
          #else
          __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 599, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 599, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          #endif
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_17 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 599, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_11 = Py_TYPE(__pyx_t_17)->tp_iternext;
          index = 0; __pyx_t_7 = __pyx_t_11(__pyx_t_17); if (unlikely(!__pyx_t_7)) goto __pyx_L15_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_7);
          index = 1; __pyx_t_10 = __pyx_t_11(__pyx_t_17); if (unlikely(!__pyx_t_10)) goto __pyx_L15_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_10);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_17), 2) < 0) __PYX_ERR(1, 599, __pyx_L1_error)
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          goto __pyx_L16_unpacking_done;
          __pyx_L15_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(1, 599, __pyx_L1_error)
          __pyx_L16_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_v_net_tag, __pyx_t_7);
        __pyx_t_7 = 0;
        __Pyx_XDECREF_SET(__pyx_v_gold_tag, __pyx_t_10);
        __pyx_t_10 = 0;

        /* "networkconv.pyx":600
 *             for predicate_answer, predicate_tags in zip(answer, sent_tags):
 *                 for net_tag, gold_tag in zip(predicate_answer, predicate_tags):
 *                     if net_tag == gold_tag:             # <<<<<<<<<<<<<<
 *                         hits += 1
 * 
 */
        __pyx_t_8 = PyObject_RichCompare(__pyx_v_net_tag, __pyx_v_gold_tag, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 600, __pyx_L1_error)
        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 600, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (__pyx_t_1) {

          /* "networkconv.pyx":601
 *                 for net_tag, gold_tag in zip(predicate_answer, predicate_tags):
 *                     if net_tag == gold_tag:
 *                         hits += 1             # <<<<<<<<<<<<<<
 * 
 *                 num_items += len(predicate_answer)
 */
          __pyx_t_8 = __Pyx_PyInt_AddObjC(__pyx_v_hits, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 601, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF_SET(__pyx_v_hits, __pyx_t_8);
          __pyx_t_8 = 0;

          /* "networkconv.pyx":600
 *             for predicate_answer, predicate_tags in zip(answer, sent_tags):
 *                 for net_tag, gold_tag in zip(predicate_answer, predicate_tags):
 *                     if net_tag == gold_tag:             # <<<<<<<<<<<<<<
 *                         hits += 1
 * 
 */
        }

        /* "networkconv.pyx":599
 *             answer = self._tag_sentence(sent, sent_preds, None, sent_args)
 *             for predicate_answer, predicate_tags in zip(answer, sent_tags):
 *                 for net_tag, gold_tag in zip(predicate_answer, predicate_tags):             # <<<<<<<<<<<<<<
 *                     if net_tag == gold_tag:
 *                         hits += 1
 */
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "networkconv.pyx":603
 *                         hits += 1
 * 
 *                 num_items += len(predicate_answer)             # <<<<<<<<<<<<<<
 * 
 *         self.accuracy = float(hits) / num_items
 */
      __pyx_t_15 = PyObject_Length(__pyx_v_predicate_answer); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(1, 603, __pyx_L1_error)
      __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 603, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_v_num_items, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 603, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF_SET(__pyx_v_num_items, __pyx_t_8);
      __pyx_t_8 = 0;

      /* "networkconv.pyx":598
 * 
 *             answer = self._tag_sentence(sent, sent_preds, None, sent_args)
 *             for predicate_answer, predicate_tags in zip(answer, sent_tags):             # <<<<<<<<<<<<<<
 *                 for net_tag, gold_tag in zip(predicate_answer, predicate_tags):
 *                     if net_tag == gold_tag:
 */
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkconv.pyx":590
 *             sent_args = None
 * 
 *         for sent, sent_preds, sent_tags in zip(self.validation_sentences,             # <<<<<<<<<<<<<<
 *                                                 self.validation_predicates,
 *                                                 self.validation_tags):
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "networkconv.pyx":605
 *                 num_items += len(predicate_answer)
 * 
 *         self.accuracy = float(hits) / num_items             # <<<<<<<<<<<<<<
 *         # normalize error
 *         self.error /= num_items
 */
  __pyx_t_4 = __Pyx_PyNumber_Float(__pyx_v_hits); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_v_num_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 605, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_18 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_18 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 605, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_self->__pyx_base.accuracy = __pyx_t_18;

  /* "networkconv.pyx":607
 *         self.accuracy = float(hits) / num_items
 *         # normalize error
 *         self.error /= num_items             # <<<<<<<<<<<<<<
 * 
 *     def _calculate_gradients(self, tags, scores):
 */
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.error); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 607, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyNumber_InPlaceDivide(__pyx_t_3, __pyx_v_num_items); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 607, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_18 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_18 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 607, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_self->__pyx_base.error = __pyx_t_18;

  /* "networkconv.pyx":576
 *         return answer
 * 
 *     def _validate(self):             # <<<<<<<<<<<<<<
 *         """
 *         Evaluates the network performance, updating its hits count.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._validate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_num_items);
  __Pyx_XDECREF(__pyx_v_hits);
  __Pyx_XDECREF(__pyx_v_i_args);
  __Pyx_XDECREF(__pyx_v_sent_args);
  __Pyx_XDECREF(__pyx_v_sent);
  __Pyx_XDECREF(__pyx_v_sent_preds);
  __Pyx_XDECREF(__pyx_v_sent_tags);
  __Pyx_XDECREF(__pyx_v_answer);
  __Pyx_XDECREF(__pyx_v_predicate_answer);
  __Pyx_XDECREF(__pyx_v_predicate_tags);
  __Pyx_XDECREF(__pyx_v_net_tag);
  __Pyx_XDECREF(__pyx_v_gold_tag);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":609
 *         self.error /= num_items
 * 
 *     def _calculate_gradients(self, tags, scores):             # <<<<<<<<<<<<<<
 *         """Delegates the call to the appropriate function."""
 *         if self.only_classify:
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_37_calculate_gradients(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_36_calculate_gradients[] = "ConvolutionalNetwork._calculate_gradients(self, tags, scores)\nDelegates the call to the appropriate function.";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_37_calculate_gradients(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tags = 0;
  PyObject *__pyx_v_scores = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_gradients (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tags,&__pyx_n_s_scores,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_scores)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_calculate_gradients", 1, 2, 2, 1); __PYX_ERR(1, 609, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_calculate_gradients") < 0)) __PYX_ERR(1, 609, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_tags = values[0];
    __pyx_v_scores = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_calculate_gradients", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 609, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._calculate_gradients", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_36_calculate_gradients(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_tags, __pyx_v_scores);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_36_calculate_gradients(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_tags, PyObject *__pyx_v_scores) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculate_gradients", 0);
  __Pyx_TraceCall("_calculate_gradients", __pyx_f[1], 609, 0, __PYX_ERR(1, 609, __pyx_L1_error));

  /* "networkconv.pyx":611
 *     def _calculate_gradients(self, tags, scores):
 *         """Delegates the call to the appropriate function."""
 *         if self.only_classify:             # <<<<<<<<<<<<<<
 *             return self._calculate_gradients_classify(tags, scores)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->only_classify)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 611, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "networkconv.pyx":612
 *         """Delegates the call to the appropriate function."""
 *         if self.only_classify:
 *             return self._calculate_gradients_classify(tags, scores)             # <<<<<<<<<<<<<<
 *         else:
 *             return self._calculate_gradients_sll(tags, scores)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_gradients_classify); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_tags, __pyx_v_scores};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_tags, __pyx_v_scores};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 612, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_tags);
      __Pyx_GIVEREF(__pyx_v_tags);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_tags);
      __Pyx_INCREF(__pyx_v_scores);
      __Pyx_GIVEREF(__pyx_v_scores);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_scores);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;

    /* "networkconv.pyx":611
 *     def _calculate_gradients(self, tags, scores):
 *         """Delegates the call to the appropriate function."""
 *         if self.only_classify:             # <<<<<<<<<<<<<<
 *             return self._calculate_gradients_classify(tags, scores)
 *         else:
 */
  }

  /* "networkconv.pyx":614
 *             return self._calculate_gradients_classify(tags, scores)
 *         else:
 *             return self._calculate_gradients_sll(tags, scores)             # <<<<<<<<<<<<<<
 * 
 *     def _calculate_gradients_classify(self, tags, scores):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_gradients_sll); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 614, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_tags, __pyx_v_scores};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 614, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_tags, __pyx_v_scores};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 614, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 614, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_tags);
      __Pyx_GIVEREF(__pyx_v_tags);
      PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_tags);
      __Pyx_INCREF(__pyx_v_scores);
      __Pyx_GIVEREF(__pyx_v_scores);
      PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_v_scores);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 614, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "networkconv.pyx":609
 *         self.error /= num_items
 * 
 *     def _calculate_gradients(self, tags, scores):             # <<<<<<<<<<<<<<
 *         """Delegates the call to the appropriate function."""
 *         if self.only_classify:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._calculate_gradients", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":616
 *             return self._calculate_gradients_sll(tags, scores)
 * 
 *     def _calculate_gradients_classify(self, tags, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the output deltas for each target in a network that only
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_39_calculate_gradients_classify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_38_calculate_gradients_classify[] = "ConvolutionalNetwork._calculate_gradients_classify(self, tags, scores)\n\n        Calculates the output deltas for each target in a network that only \n        classifies predelimited arguments.\n        The aim is to minimize the cost, for each argument:\n        logadd(score for all possible tags) - score(correct tag)\n        \n        :returns: whether a correction is necessary or not.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_39_calculate_gradients_classify(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tags = 0;
  PyObject *__pyx_v_scores = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_gradients_classify (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_tags,&__pyx_n_s_scores,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tags)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_scores)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_calculate_gradients_classify", 1, 2, 2, 1); __PYX_ERR(1, 616, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_calculate_gradients_classify") < 0)) __PYX_ERR(1, 616, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_tags = values[0];
    __pyx_v_scores = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_calculate_gradients_classify", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 616, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._calculate_gradients_classify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_38_calculate_gradients_classify(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_tags, __pyx_v_scores);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_38_calculate_gradients_classify(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_tags, PyObject *__pyx_v_scores) {
  int __pyx_v_correction;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_tag_scores = NULL;
  PyObject *__pyx_v_tag = NULL;
  PyObject *__pyx_v_exponentials = NULL;
  PyObject *__pyx_v_exp_sum = NULL;
  PyObject *__pyx_v_logadd = NULL;
  PyObject *__pyx_v_error = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  float __pyx_t_9;
  int __pyx_t_10;
  PyArrayObject *__pyx_t_11 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculate_gradients_classify", 0);
  __Pyx_TraceCall("_calculate_gradients_classify", __pyx_f[1], 616, 0, __PYX_ERR(1, 616, __pyx_L1_error));

  /* "networkconv.pyx":625
 *         :returns: whether a correction is necessary or not.
 *         """
 *         self.net_gradients = np.zeros_like(scores, float)             # <<<<<<<<<<<<<<
 *         #self.net_gradients = np.zeros_like(scores, np.float)
 *         correction = False
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros_like); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  __pyx_t_4 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_4 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_scores, ((PyObject *)(&PyFloat_Type))};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 625, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_scores, ((PyObject *)(&PyFloat_Type))};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 625, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 625, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_2) {
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
    }
    __Pyx_INCREF(__pyx_v_scores);
    __Pyx_GIVEREF(__pyx_v_scores);
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_scores);
    __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, ((PyObject *)(&PyFloat_Type)));
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 625, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 625, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.net_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.net_gradients));
  __pyx_v_self->__pyx_base.net_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":627
 *         self.net_gradients = np.zeros_like(scores, float)
 *         #self.net_gradients = np.zeros_like(scores, np.float)
 *         correction = False             # <<<<<<<<<<<<<<
 * 
 *         for i, tag_scores in enumerate(scores):
 */
  __pyx_v_correction = 0;

  /* "networkconv.pyx":629
 *         correction = False
 * 
 *         for i, tag_scores in enumerate(scores):             # <<<<<<<<<<<<<<
 *             tag = tags[i]
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_scores)) || PyTuple_CheckExact(__pyx_v_scores)) {
    __pyx_t_3 = __pyx_v_scores; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_scores); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 629, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 629, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 629, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 629, __pyx_L1_error)
        #else
        __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 629, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        #endif
      }
    } else {
      __pyx_t_5 = __pyx_t_7(__pyx_t_3);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 629, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XDECREF_SET(__pyx_v_tag_scores, __pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "networkconv.pyx":630
 * 
 *         for i, tag_scores in enumerate(scores):
 *             tag = tags[i]             # <<<<<<<<<<<<<<
 * 
 *             exponentials = np.exp(tag_scores)
 */
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_tags, __pyx_v_i); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 630, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XDECREF_SET(__pyx_v_tag, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "networkconv.pyx":632
 *             tag = tags[i]
 * 
 *             exponentials = np.exp(tag_scores)             # <<<<<<<<<<<<<<
 *             exp_sum = np.sum(exponentials)
 *             logadd = np.log(exp_sum)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_exp); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_2, __pyx_v_tag_scores) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_tag_scores);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_exponentials, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "networkconv.pyx":633
 * 
 *             exponentials = np.exp(tag_scores)
 *             exp_sum = np.sum(exponentials)             # <<<<<<<<<<<<<<
 *             logadd = np.log(exp_sum)
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_8, __pyx_v_exponentials) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_exponentials);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 633, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_exp_sum, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "networkconv.pyx":634
 *             exponentials = np.exp(tag_scores)
 *             exp_sum = np.sum(exponentials)
 *             logadd = np.log(exp_sum)             # <<<<<<<<<<<<<<
 * 
 *             # update the total error
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_log); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_2, __pyx_v_exp_sum) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_exp_sum);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 634, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_logadd, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "networkconv.pyx":637
 * 
 *             # update the total error
 *             error = logadd - tag_scores[tag]             # <<<<<<<<<<<<<<
 *             self.error += error
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_tag_scores, __pyx_v_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = PyNumber_Subtract(__pyx_v_logadd, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF_SET(__pyx_v_error, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "networkconv.pyx":638
 *             # update the total error
 *             error = logadd - tag_scores[tag]
 *             self.error += error             # <<<<<<<<<<<<<<
 * 
 *             # like the non-convolutional network, don't adjust weights if the error
 */
    __pyx_t_8 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.error); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_8, __pyx_v_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 638, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_5); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 638, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_self->__pyx_base.error = __pyx_t_9;

    /* "networkconv.pyx":643
 *             # is too low. An error of 0.01 means a log-prob of -0.01 for the right
 *             # tag, i.e., more than 99% probability
 *             if error <= 0.01:             # <<<<<<<<<<<<<<
 *                 self.skips += 1
 *                 continue
 */
    __pyx_t_5 = PyObject_RichCompare(__pyx_v_error, __pyx_float_0_01, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 643, __pyx_L1_error)
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 643, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_10) {

      /* "networkconv.pyx":644
 *             # tag, i.e., more than 99% probability
 *             if error <= 0.01:
 *                 self.skips += 1             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      __pyx_v_self->__pyx_base.skips = (__pyx_v_self->__pyx_base.skips + 1);

      /* "networkconv.pyx":645
 *             if error <= 0.01:
 *                 self.skips += 1
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             correction = True
 */
      goto __pyx_L3_continue;

      /* "networkconv.pyx":643
 *             # is too low. An error of 0.01 means a log-prob of -0.01 for the right
 *             # tag, i.e., more than 99% probability
 *             if error <= 0.01:             # <<<<<<<<<<<<<<
 *                 self.skips += 1
 *                 continue
 */
    }

    /* "networkconv.pyx":647
 *                 continue
 * 
 *             correction = True             # <<<<<<<<<<<<<<
 *             self.net_gradients[i] = - exponentials / exp_sum
 *             self.net_gradients[i, tag] += 1
 */
    __pyx_v_correction = 1;

    /* "networkconv.pyx":648
 * 
 *             correction = True
 *             self.net_gradients[i] = - exponentials / exp_sum             # <<<<<<<<<<<<<<
 *             self.net_gradients[i, tag] += 1
 * 
 */
    __pyx_t_5 = PyNumber_Negative(__pyx_v_exponentials); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_5, __pyx_v_exp_sum); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->__pyx_base.net_gradients), __pyx_v_i, __pyx_t_8) < 0)) __PYX_ERR(1, 648, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "networkconv.pyx":649
 *             correction = True
 *             self.net_gradients[i] = - exponentials / exp_sum
 *             self.net_gradients[i, tag] += 1             # <<<<<<<<<<<<<<
 * 
 *         return correction
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.net_gradients));
    __pyx_t_11 = __pyx_v_self->__pyx_base.net_gradients;
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_v_i);
    __Pyx_GIVEREF(__pyx_v_i);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_i);
    __Pyx_INCREF(__pyx_v_tag);
    __Pyx_GIVEREF(__pyx_v_tag);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_tag);
    __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_t_11), __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 649, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_t_11), __pyx_t_8, __pyx_t_2) < 0)) __PYX_ERR(1, 649, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;

    /* "networkconv.pyx":629
 *         correction = False
 * 
 *         for i, tag_scores in enumerate(scores):             # <<<<<<<<<<<<<<
 *             tag = tags[i]
 * 
 */
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":651
 *             self.net_gradients[i, tag] += 1
 * 
 *         return correction             # <<<<<<<<<<<<<<
 * 
 *     def _backpropagate(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_correction); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 651, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "networkconv.pyx":616
 *             return self._calculate_gradients_sll(tags, scores)
 * 
 *     def _calculate_gradients_classify(self, tags, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the output deltas for each target in a network that only
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(((PyObject *)__pyx_t_11));
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._calculate_gradients_classify", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_tag_scores);
  __Pyx_XDECREF(__pyx_v_tag);
  __Pyx_XDECREF(__pyx_v_exponentials);
  __Pyx_XDECREF(__pyx_v_exp_sum);
  __Pyx_XDECREF(__pyx_v_logadd);
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":653
 *         return correction
 * 
 *     def _backpropagate(self):             # <<<<<<<<<<<<<<
 *         """Backpropagates the error gradient."""
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_41_backpropagate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_40_backpropagate[] = "ConvolutionalNetwork._backpropagate(self)\nBackpropagates the error gradient.";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_41_backpropagate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_backpropagate (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_40_backpropagate(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_40_backpropagate(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_v_dCd_tanh = NULL;
  PyObject *__pyx_v_dCd_hidden2 = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_backpropagate", 0);
  __Pyx_TraceCall("_backpropagate", __pyx_f[1], 653, 0, __PYX_ERR(1, 653, __pyx_L1_error));

  /* "networkconv.pyx":663
 * 
 *         # derivative with respect to the non-linearity layer (tanh)
 *         dCd_tanh = self.net_gradients.dot(self.output_weights)             # <<<<<<<<<<<<<<
 * 
 *         if self.hidden2_weights is not None:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.net_gradients), __pyx_n_s_dot); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_self->__pyx_base.output_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self->__pyx_base.output_weights));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_dCd_tanh = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":665
 *         dCd_tanh = self.net_gradients.dot(self.output_weights)
 * 
 *         if self.hidden2_weights is not None:             # <<<<<<<<<<<<<<
 *             # derivative with respect to the second hidden layer
 *             dCd_hidden2 = dCd_tanh * hardtanhd(self.hidden2_before_activation)
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_self->hidden2_weights) != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "networkconv.pyx":667
 *         if self.hidden2_weights is not None:
 *             # derivative with respect to the second hidden layer
 *             dCd_hidden2 = dCd_tanh * hardtanhd(self.hidden2_before_activation)             # <<<<<<<<<<<<<<
 *             self.hidden2_gradients = dCd_hidden2
 * 
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_self->hidden2_before_activation);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = __pyx_f_4libs_7network_hardtanhd(((PyArrayObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Multiply(__pyx_v_dCd_tanh, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_dCd_hidden2 = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "networkconv.pyx":668
 *             # derivative with respect to the second hidden layer
 *             dCd_hidden2 = dCd_tanh * hardtanhd(self.hidden2_before_activation)
 *             self.hidden2_gradients = dCd_hidden2             # <<<<<<<<<<<<<<
 * 
 *             self.hidden_gradients = self.hidden2_gradients.dot(self.hidden2_weights)
 */
    if (!(likely(((__pyx_v_dCd_hidden2) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dCd_hidden2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 668, __pyx_L1_error)
    __pyx_t_1 = __pyx_v_dCd_hidden2;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->hidden2_gradients);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_gradients));
    __pyx_v_self->hidden2_gradients = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkconv.pyx":670
 *             self.hidden2_gradients = dCd_hidden2
 * 
 *             self.hidden_gradients = self.hidden2_gradients.dot(self.hidden2_weights)             # <<<<<<<<<<<<<<
 *         else:
 *             # the non-linearity appears right after the convolution max
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hidden2_gradients), __pyx_n_s_dot); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 670, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_self->hidden2_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_self->hidden2_weights));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 670, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 670, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->hidden_gradients);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_gradients));
    __pyx_v_self->hidden_gradients = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkconv.pyx":665
 *         dCd_tanh = self.net_gradients.dot(self.output_weights)
 * 
 *         if self.hidden2_weights is not None:             # <<<<<<<<<<<<<<
 *             # derivative with respect to the second hidden layer
 *             dCd_hidden2 = dCd_tanh * hardtanhd(self.hidden2_before_activation)
 */
    goto __pyx_L3;
  }

  /* "networkconv.pyx":673
 *         else:
 *             # the non-linearity appears right after the convolution max
 *             self.hidden_gradients = dCd_tanh * hardtanhd(self.hidden_before_activation)             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  /*else*/ {
    __pyx_t_1 = ((PyObject *)__pyx_v_self->hidden_before_activation);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = __pyx_f_4libs_7network_hardtanhd(((PyArrayObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 673, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Multiply(__pyx_v_dCd_tanh, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 673, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 673, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->hidden_gradients);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden_gradients));
    __pyx_v_self->hidden_gradients = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "networkconv.pyx":653
 *         return correction
 * 
 *     def _backpropagate(self):             # <<<<<<<<<<<<<<
 *         """Backpropagates the error gradient."""
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._backpropagate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_dCd_tanh);
  __Pyx_XDECREF(__pyx_v_dCd_hidden2);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":677
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _adjust_weights(self, predicate, arguments=None):             # <<<<<<<<<<<<<<
 *         """
 *         Adjusts the network weights after gradients have been calculated.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_43_adjust_weights(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_42_adjust_weights[] = "ConvolutionalNetwork._adjust_weights(self, predicate, arguments=None)\n\n        Adjusts the network weights after gradients have been calculated.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_43_adjust_weights(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_predicate = 0;
  PyObject *__pyx_v_arguments = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_adjust_weights (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_predicate,&__pyx_n_s_arguments,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicate)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arguments);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_adjust_weights") < 0)) __PYX_ERR(1, 677, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_predicate = values[0];
    __pyx_v_arguments = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_adjust_weights", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 677, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._adjust_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_42_adjust_weights(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_predicate, __pyx_v_arguments);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_42_adjust_weights(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_predicate, PyObject *__pyx_v_arguments) {
  int __pyx_v_i;
  PyArrayObject *__pyx_v_gradients_t = 0;
  PyArrayObject *__pyx_v_last_values = 0;
  PyArrayObject *__pyx_v_deltas = 0;
  PyArrayObject *__pyx_v_grad_matrix = 0;
  PyArrayObject *__pyx_v_input_values = 0;
  PyObject *__pyx_v_neuron_maxes = NULL;
  PyObject *__pyx_v_target_dists = NULL;
  PyObject *__pyx_v_argument = NULL;
  PyObject *__pyx_v_dist_features = NULL;
  PyObject *__pyx_v_pred_dists = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_deltas;
  __Pyx_Buffer __pyx_pybuffer_deltas;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_grad_matrix;
  __Pyx_Buffer __pyx_pybuffer_grad_matrix;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_gradients_t;
  __Pyx_Buffer __pyx_pybuffer_gradients_t;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_input_values;
  __Pyx_Buffer __pyx_pybuffer_input_values;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_last_values;
  __Pyx_Buffer __pyx_pybuffer_last_values;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_adjust_weights", 0);
  __Pyx_TraceCall("_adjust_weights", __pyx_f[1], 677, 0, __PYX_ERR(1, 677, __pyx_L1_error));
  __pyx_pybuffer_gradients_t.pybuffer.buf = NULL;
  __pyx_pybuffer_gradients_t.refcount = 0;
  __pyx_pybuffernd_gradients_t.data = NULL;
  __pyx_pybuffernd_gradients_t.rcbuffer = &__pyx_pybuffer_gradients_t;
  __pyx_pybuffer_last_values.pybuffer.buf = NULL;
  __pyx_pybuffer_last_values.refcount = 0;
  __pyx_pybuffernd_last_values.data = NULL;
  __pyx_pybuffernd_last_values.rcbuffer = &__pyx_pybuffer_last_values;
  __pyx_pybuffer_deltas.pybuffer.buf = NULL;
  __pyx_pybuffer_deltas.refcount = 0;
  __pyx_pybuffernd_deltas.data = NULL;
  __pyx_pybuffernd_deltas.rcbuffer = &__pyx_pybuffer_deltas;
  __pyx_pybuffer_grad_matrix.pybuffer.buf = NULL;
  __pyx_pybuffer_grad_matrix.refcount = 0;
  __pyx_pybuffernd_grad_matrix.data = NULL;
  __pyx_pybuffernd_grad_matrix.rcbuffer = &__pyx_pybuffer_grad_matrix;
  __pyx_pybuffer_input_values.pybuffer.buf = NULL;
  __pyx_pybuffer_input_values.refcount = 0;
  __pyx_pybuffernd_input_values.data = NULL;
  __pyx_pybuffernd_input_values.rcbuffer = &__pyx_pybuffer_input_values;

  /* "networkconv.pyx":685
 *         cdef np.ndarray[FLOAT_t, ndim=2] last_values, deltas, grad_matrix, input_values
 * 
 *         last_values = self.hidden2_values if self.hidden2_weights is not None else self.hidden_values             # <<<<<<<<<<<<<<
 *         deltas = self.net_gradients.T.dot(last_values) * self.learning_rate
 *         self.output_weights += deltas
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_self->hidden2_weights) != Py_None);
  if ((__pyx_t_2 != 0)) {
    __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_values));
    __pyx_t_1 = ((PyObject *)__pyx_v_self->hidden2_values);
  } else {
    __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_values));
    __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.hidden_values);
  }
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_last_values.rcbuffer->pybuffer);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_last_values.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_last_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_last_values, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_4, __pyx_t_5, __pyx_t_6);
      }
      __pyx_t_4 = __pyx_t_5 = __pyx_t_6 = 0;
    }
    __pyx_pybuffernd_last_values.diminfo[0].strides = __pyx_pybuffernd_last_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_last_values.diminfo[0].shape = __pyx_pybuffernd_last_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_last_values.diminfo[1].strides = __pyx_pybuffernd_last_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_last_values.diminfo[1].shape = __pyx_pybuffernd_last_values.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 685, __pyx_L1_error)
  }
  __pyx_v_last_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":686
 * 
 *         last_values = self.hidden2_values if self.hidden2_weights is not None else self.hidden_values
 *         deltas = self.net_gradients.T.dot(last_values) * self.learning_rate             # <<<<<<<<<<<<<<
 *         self.output_weights += deltas
 *         self.output_bias += self.net_gradients.sum(0) * self.learning_rate
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.net_gradients), __pyx_n_s_T); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dot); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, ((PyObject *)__pyx_v_last_values)) : __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_last_values));
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 686, __pyx_L1_error)
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_7);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_v_deltas, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_6, __pyx_t_5, __pyx_t_4);
      }
      __pyx_t_6 = __pyx_t_5 = __pyx_t_4 = 0;
    }
    __pyx_pybuffernd_deltas.diminfo[0].strides = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_deltas.diminfo[0].shape = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_deltas.diminfo[1].strides = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_deltas.diminfo[1].shape = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 686, __pyx_L1_error)
  }
  __pyx_t_9 = 0;
  __pyx_v_deltas = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "networkconv.pyx":687
 *         last_values = self.hidden2_values if self.hidden2_weights is not None else self.hidden_values
 *         deltas = self.net_gradients.T.dot(last_values) * self.learning_rate
 *         self.output_weights += deltas             # <<<<<<<<<<<<<<
 *         self.output_bias += self.net_gradients.sum(0) * self.learning_rate
 * 
 */
  __pyx_t_7 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->__pyx_base.output_weights), ((PyObject *)__pyx_v_deltas)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 687, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 687, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.output_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.output_weights));
  __pyx_v_self->__pyx_base.output_weights = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "networkconv.pyx":688
 *         deltas = self.net_gradients.T.dot(last_values) * self.learning_rate
 *         self.output_weights += deltas
 *         self.output_bias += self.net_gradients.sum(0) * self.learning_rate             # <<<<<<<<<<<<<<
 * 
 *         if self.hidden2_weights is not None:
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.net_gradients), __pyx_n_s_sum); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_7 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_1, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_int_0);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->__pyx_base.output_bias), __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 688, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_8);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.output_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.output_bias));
  __pyx_v_self->__pyx_base.output_bias = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "networkconv.pyx":690
 *         self.output_bias += self.net_gradients.sum(0) * self.learning_rate
 * 
 *         if self.hidden2_weights is not None:             # <<<<<<<<<<<<<<
 *             deltas = self.hidden2_gradients.T.dot(self.hidden_values) * self.learning_rate
 *             self.hidden2_weights += deltas
 */
  __pyx_t_2 = (((PyObject *)__pyx_v_self->hidden2_weights) != Py_None);
  __pyx_t_10 = (__pyx_t_2 != 0);
  if (__pyx_t_10) {

    /* "networkconv.pyx":691
 * 
 *         if self.hidden2_weights is not None:
 *             deltas = self.hidden2_gradients.T.dot(self.hidden_values) * self.learning_rate             # <<<<<<<<<<<<<<
 *             self.hidden2_weights += deltas
 *             self.hidden2_bias += self.hidden2_gradients.sum(0) * self.learning_rate
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hidden2_gradients), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_8 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_1, ((PyObject *)__pyx_v_self->__pyx_base.hidden_values)) : __Pyx_PyObject_CallOneArg(__pyx_t_7, ((PyObject *)__pyx_v_self->__pyx_base.hidden_values));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 691, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 691, __pyx_L1_error)
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
      __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_3 < 0)) {
        PyErr_Fetch(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer, (PyObject*)__pyx_v_deltas, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_4, __pyx_t_5, __pyx_t_6);
        }
        __pyx_t_4 = __pyx_t_5 = __pyx_t_6 = 0;
      }
      __pyx_pybuffernd_deltas.diminfo[0].strides = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_deltas.diminfo[0].shape = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_deltas.diminfo[1].strides = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_deltas.diminfo[1].shape = __pyx_pybuffernd_deltas.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 691, __pyx_L1_error)
    }
    __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_deltas, ((PyArrayObject *)__pyx_t_1));
    __pyx_t_1 = 0;

    /* "networkconv.pyx":692
 *         if self.hidden2_weights is not None:
 *             deltas = self.hidden2_gradients.T.dot(self.hidden_values) * self.learning_rate
 *             self.hidden2_weights += deltas             # <<<<<<<<<<<<<<
 *             self.hidden2_bias += self.hidden2_gradients.sum(0) * self.learning_rate
 * 
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->hidden2_weights), ((PyObject *)__pyx_v_deltas)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 692, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 692, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->hidden2_weights);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_weights));
    __pyx_v_self->hidden2_weights = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkconv.pyx":693
 *             deltas = self.hidden2_gradients.T.dot(self.hidden_values) * self.learning_rate
 *             self.hidden2_weights += deltas
 *             self.hidden2_bias += self.hidden2_gradients.sum(0) * self.learning_rate             # <<<<<<<<<<<<<<
 * 
 *         # now adjust weights from input to convolution. these will be trickier.
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hidden2_gradients), __pyx_n_s_sum); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
      }
    }
    __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_int_0);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyNumber_Multiply(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->hidden2_bias), __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 693, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 693, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_7);
    __Pyx_GOTREF(__pyx_v_self->hidden2_bias);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->hidden2_bias));
    __pyx_v_self->hidden2_bias = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "networkconv.pyx":690
 *         self.output_bias += self.net_gradients.sum(0) * self.learning_rate
 * 
 *         if self.hidden2_weights is not None:             # <<<<<<<<<<<<<<
 *             deltas = self.hidden2_gradients.T.dot(self.hidden_values) * self.learning_rate
 *             self.hidden2_weights += deltas
 */
  }

  /* "networkconv.pyx":700
 *         # I tried vectorizing this loop but it got a bit slower, probably because
 *         # of the overhead in building matrices/tensors with the max indices
 *         for i, neuron_maxes in enumerate(self.max_indices):             # <<<<<<<<<<<<<<
 *             # i indicates the i-th target
 * 
 */
  __pyx_t_3 = 0;
  if (likely(PyList_CheckExact(((PyObject *)__pyx_v_self->max_indices))) || PyTuple_CheckExact(((PyObject *)__pyx_v_self->max_indices))) {
    __pyx_t_7 = ((PyObject *)__pyx_v_self->max_indices); __Pyx_INCREF(__pyx_t_7); __pyx_t_11 = 0;
    __pyx_t_12 = NULL;
  } else {
    __pyx_t_11 = -1; __pyx_t_7 = PyObject_GetIter(((PyObject *)__pyx_v_self->max_indices)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 700, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_12 = Py_TYPE(__pyx_t_7)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 700, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_12)) {
      if (likely(PyList_CheckExact(__pyx_t_7))) {
        if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_11); __Pyx_INCREF(__pyx_t_8); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(1, 700, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 700, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      } else {
        if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_11); __Pyx_INCREF(__pyx_t_8); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(1, 700, __pyx_L1_error)
        #else
        __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 700, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        #endif
      }
    } else {
      __pyx_t_8 = __pyx_t_12(__pyx_t_7);
      if (unlikely(!__pyx_t_8)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 700, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_8);
    }
    __Pyx_XDECREF_SET(__pyx_v_neuron_maxes, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_v_i = __pyx_t_3;
    __pyx_t_3 = (__pyx_t_3 + 1);

    /* "networkconv.pyx":703
 *             # i indicates the i-th target
 * 
 *             gradients_t = self.hidden_gradients[i] * self.learning_rate             # <<<<<<<<<<<<<<
 * 
 *             # table containing in each line the input values selected for each convolution neuron
 */
    __pyx_t_8 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->hidden_gradients), __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 703, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 703, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_13 = PyNumber_Multiply(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 703, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 703, __pyx_L1_error)
    __pyx_t_14 = ((PyArrayObject *)__pyx_t_13);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gradients_t.rcbuffer->pybuffer);
      __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_gradients_t.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_15 < 0)) {
        PyErr_Fetch(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_gradients_t.rcbuffer->pybuffer, (PyObject*)__pyx_v_gradients_t, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_6, __pyx_t_5, __pyx_t_4);
        }
        __pyx_t_6 = __pyx_t_5 = __pyx_t_4 = 0;
      }
      __pyx_pybuffernd_gradients_t.diminfo[0].strides = __pyx_pybuffernd_gradients_t.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_gradients_t.diminfo[0].shape = __pyx_pybuffernd_gradients_t.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(1, 703, __pyx_L1_error)
    }
    __pyx_t_14 = 0;
    __Pyx_XDECREF_SET(__pyx_v_gradients_t, ((PyArrayObject *)__pyx_t_13));
    __pyx_t_13 = 0;

    /* "networkconv.pyx":706
 * 
 *             # table containing in each line the input values selected for each convolution neuron
 *             input_values = self.input_sent_values.take(neuron_maxes, 0)             # <<<<<<<<<<<<<<
 * 
 *             # stack the gradients to multiply all weights for a neuron
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.input_sent_values), __pyx_n_s_take); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = NULL;
    __pyx_t_15 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_15 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_neuron_maxes, __pyx_int_0};
      __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 706, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_neuron_maxes, __pyx_int_0};
      __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 706, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_13);
    } else
    #endif
    {
      __pyx_t_16 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 706, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(__pyx_v_neuron_maxes);
      __Pyx_GIVEREF(__pyx_v_neuron_maxes);
      PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_15, __pyx_v_neuron_maxes);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_15, __pyx_int_0);
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_16, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 706, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 706, __pyx_L1_error)
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_13);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_values.rcbuffer->pybuffer);
      __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_values.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_15 < 0)) {
        PyErr_Fetch(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_input_values, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_4, __pyx_t_5, __pyx_t_6);
        }
        __pyx_t_4 = __pyx_t_5 = __pyx_t_6 = 0;
      }
      __pyx_pybuffernd_input_values.diminfo[0].strides = __pyx_pybuffernd_input_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input_values.diminfo[0].shape = __pyx_pybuffernd_input_values.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_input_values.diminfo[1].strides = __pyx_pybuffernd_input_values.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_input_values.diminfo[1].shape = __pyx_pybuffernd_input_values.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(1, 706, __pyx_L1_error)
    }
    __pyx_t_9 = 0;
    __Pyx_XDECREF_SET(__pyx_v_input_values, ((PyArrayObject *)__pyx_t_13));
    __pyx_t_13 = 0;

    /* "networkconv.pyx":709
 * 
 *             # stack the gradients to multiply all weights for a neuron
 *             grad_matrix = np.tile(gradients_t, [self.input_size, 1]).T             # <<<<<<<<<<<<<<
 *             self.hidden_weights += grad_matrix * input_values
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tile); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.input_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyList_SET_ITEM(__pyx_t_8, 1, __pyx_int_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    __pyx_t_15 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_16);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_16, function);
        __pyx_t_15 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_16)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_gradients_t), __pyx_t_8};
      __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 709, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_gradients_t), __pyx_t_8};
      __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 709, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_17 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 709, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_gradients_t));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_gradients_t));
      PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_15, ((PyObject *)__pyx_v_gradients_t));
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_15, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_17, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 709, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_T); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 709, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (!(likely(((__pyx_t_16) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_16, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 709, __pyx_L1_error)
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_16);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer);
      __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_15 < 0)) {
        PyErr_Fetch(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer, (PyObject*)__pyx_v_grad_matrix, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_6, __pyx_t_5, __pyx_t_4);
        }
        __pyx_t_6 = __pyx_t_5 = __pyx_t_4 = 0;
      }
      __pyx_pybuffernd_grad_matrix.diminfo[0].strides = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_grad_matrix.diminfo[0].shape = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_grad_matrix.diminfo[1].strides = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_grad_matrix.diminfo[1].shape = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(1, 709, __pyx_L1_error)
    }
    __pyx_t_9 = 0;
    __Pyx_XDECREF_SET(__pyx_v_grad_matrix, ((PyArrayObject *)__pyx_t_16));
    __pyx_t_16 = 0;

    /* "networkconv.pyx":710
 *             # stack the gradients to multiply all weights for a neuron
 *             grad_matrix = np.tile(gradients_t, [self.input_size, 1]).T
 *             self.hidden_weights += grad_matrix * input_values             # <<<<<<<<<<<<<<
 * 
 *             # target distance weights
 */
    __pyx_t_16 = PyNumber_Multiply(((PyObject *)__pyx_v_grad_matrix), ((PyObject *)__pyx_v_input_values)); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_13 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->__pyx_base.hidden_weights), __pyx_t_16); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 710, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_13);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.hidden_weights);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_weights));
    __pyx_v_self->__pyx_base.hidden_weights = ((PyArrayObject *)__pyx_t_13);
    __pyx_t_13 = 0;

    /* "networkconv.pyx":714
 *             # target distance weights
 *             # get the relative distance from each max token to its target
 *             if arguments is None:             # <<<<<<<<<<<<<<
 *                 target_dists = neuron_maxes - i
 *             else:
 */
    __pyx_t_10 = (__pyx_v_arguments == Py_None);
    __pyx_t_2 = (__pyx_t_10 != 0);
    if (__pyx_t_2) {

      /* "networkconv.pyx":715
 *             # get the relative distance from each max token to its target
 *             if arguments is None:
 *                 target_dists = neuron_maxes - i             # <<<<<<<<<<<<<<
 *             else:
 *                 argument = arguments[i]
 */
      __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 715, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_16 = PyNumber_Subtract(__pyx_v_neuron_maxes, __pyx_t_13); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 715, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF_SET(__pyx_v_target_dists, __pyx_t_16);
      __pyx_t_16 = 0;

      /* "networkconv.pyx":714
 *             # target distance weights
 *             # get the relative distance from each max token to its target
 *             if arguments is None:             # <<<<<<<<<<<<<<
 *                 target_dists = neuron_maxes - i
 *             else:
 */
      goto __pyx_L6;
    }

    /* "networkconv.pyx":717
 *                 target_dists = neuron_maxes - i
 *             else:
 *                 argument = arguments[i]             # <<<<<<<<<<<<<<
 *                 target_dists = self.argument_distances(neuron_maxes, argument)
 * 
 */
    /*else*/ {
      __pyx_t_16 = __Pyx_GetItemInt(__pyx_v_arguments, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 0, 0); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 717, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_XDECREF_SET(__pyx_v_argument, __pyx_t_16);
      __pyx_t_16 = 0;

      /* "networkconv.pyx":718
 *             else:
 *                 argument = arguments[i]
 *                 target_dists = self.argument_distances(neuron_maxes, argument)             # <<<<<<<<<<<<<<
 * 
 *             dist_features = self.target_dist_lookup.take(target_dists + self.target_dist_offset,
 */
      __pyx_t_16 = ((PyObject *)((struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork *)__pyx_v_self->__pyx_vtab)->argument_distances(__pyx_v_self, __pyx_v_neuron_maxes, __pyx_v_argument)); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 718, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_XDECREF_SET(__pyx_v_target_dists, __pyx_t_16);
      __pyx_t_16 = 0;
    }
    __pyx_L6:;

    /* "networkconv.pyx":720
 *                 target_dists = self.argument_distances(neuron_maxes, argument)
 * 
 *             dist_features = self.target_dist_lookup.take(target_dists + self.target_dist_offset,             # <<<<<<<<<<<<<<
 *                                                          0, mode='clip')
 *             grad_matrix = np.tile(gradients_t, [self.target_dist_weights.shape[0], 1]).T
 */
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->target_dist_lookup), __pyx_n_s_take); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_self->target_dist_offset); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_17 = PyNumber_Add(__pyx_v_target_dists, __pyx_t_13); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_17);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_int_0);
    __pyx_t_17 = 0;

    /* "networkconv.pyx":721
 * 
 *             dist_features = self.target_dist_lookup.take(target_dists + self.target_dist_offset,
 *                                                          0, mode='clip')             # <<<<<<<<<<<<<<
 *             grad_matrix = np.tile(gradients_t, [self.target_dist_weights.shape[0], 1]).T
 *             self.target_dist_weights += (grad_matrix * dist_features).T
 */
    __pyx_t_17 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 721, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_mode, __pyx_n_u_clip) < 0) __PYX_ERR(1, 721, __pyx_L1_error)

    /* "networkconv.pyx":720
 *                 target_dists = self.argument_distances(neuron_maxes, argument)
 * 
 *             dist_features = self.target_dist_lookup.take(target_dists + self.target_dist_offset,             # <<<<<<<<<<<<<<
 *                                                          0, mode='clip')
 *             grad_matrix = np.tile(gradients_t, [self.target_dist_weights.shape[0], 1]).T
 */
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_13, __pyx_t_17); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 720, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF_SET(__pyx_v_dist_features, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "networkconv.pyx":722
 *             dist_features = self.target_dist_lookup.take(target_dists + self.target_dist_offset,
 *                                                          0, mode='clip')
 *             grad_matrix = np.tile(gradients_t, [self.target_dist_weights.shape[0], 1]).T             # <<<<<<<<<<<<<<
 *             self.target_dist_weights += (grad_matrix * dist_features).T
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_np); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_tile); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_17 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->target_dist_weights->dimensions[0])); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_16 = PyList_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_GIVEREF(__pyx_t_17);
    PyList_SET_ITEM(__pyx_t_16, 0, __pyx_t_17);
    __Pyx_INCREF(__pyx_int_1);
    __Pyx_GIVEREF(__pyx_int_1);
    PyList_SET_ITEM(__pyx_t_16, 1, __pyx_int_1);
    __pyx_t_17 = 0;
    __pyx_t_17 = NULL;
    __pyx_t_15 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_13);
      if (likely(__pyx_t_17)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_17);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_13, function);
        __pyx_t_15 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_17, ((PyObject *)__pyx_v_gradients_t), __pyx_t_16};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 722, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_17, ((PyObject *)__pyx_v_gradients_t), __pyx_t_16};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 722, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 722, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_17) {
        __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_17); __pyx_t_17 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_gradients_t));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_gradients_t));
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_15, ((PyObject *)__pyx_v_gradients_t));
      __Pyx_GIVEREF(__pyx_t_16);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_15, __pyx_t_16);
      __pyx_t_16 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 722, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_T); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 722, __pyx_L1_error)
    __pyx_t_9 = ((PyArrayObject *)__pyx_t_13);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer);
      __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_15 < 0)) {
        PyErr_Fetch(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer, (PyObject*)__pyx_v_grad_matrix, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_4); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_4, __pyx_t_5, __pyx_t_6);
        }
        __pyx_t_4 = __pyx_t_5 = __pyx_t_6 = 0;
      }
      __pyx_pybuffernd_grad_matrix.diminfo[0].strides = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_grad_matrix.diminfo[0].shape = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_grad_matrix.diminfo[1].strides = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_grad_matrix.diminfo[1].shape = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(1, 722, __pyx_L1_error)
    }
    __pyx_t_9 = 0;
    __Pyx_DECREF_SET(__pyx_v_grad_matrix, ((PyArrayObject *)__pyx_t_13));
    __pyx_t_13 = 0;

    /* "networkconv.pyx":723
 *                                                          0, mode='clip')
 *             grad_matrix = np.tile(gradients_t, [self.target_dist_weights.shape[0], 1]).T
 *             self.target_dist_weights += (grad_matrix * dist_features).T             # <<<<<<<<<<<<<<
 * 
 *             # predicate distance weights
 */
    __pyx_t_13 = PyNumber_Multiply(((PyObject *)__pyx_v_grad_matrix), __pyx_v_dist_features); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 723, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_T); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 723, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->target_dist_weights), __pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 723, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 723, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_13);
    __Pyx_GOTREF(__pyx_v_self->target_dist_weights);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->target_dist_weights));
    __pyx_v_self->target_dist_weights = ((PyArrayObject *)__pyx_t_13);
    __pyx_t_13 = 0;

    /* "networkconv.pyx":727
 *             # predicate distance weights
 *             # get the distance from each max token to its predicate
 *             pred_dists = neuron_maxes - predicate             # <<<<<<<<<<<<<<
 *             dist_features = self.pred_dist_lookup.take(pred_dists + self.pred_dist_offset,
 *                                                        0, mode='clip')
 */
    __pyx_t_13 = PyNumber_Subtract(__pyx_v_neuron_maxes, __pyx_v_predicate); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 727, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_XDECREF_SET(__pyx_v_pred_dists, __pyx_t_13);
    __pyx_t_13 = 0;

    /* "networkconv.pyx":728
 *             # get the distance from each max token to its predicate
 *             pred_dists = neuron_maxes - predicate
 *             dist_features = self.pred_dist_lookup.take(pred_dists + self.pred_dist_offset,             # <<<<<<<<<<<<<<
 *                                                        0, mode='clip')
 *             # try to recycle the grad_matrix if sizes match
 */
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pred_dist_lookup), __pyx_n_s_take); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->pred_dist_offset); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = PyNumber_Add(__pyx_v_pred_dists, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
    __Pyx_INCREF(__pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_0);
    __pyx_t_1 = 0;

    /* "networkconv.pyx":729
 *             pred_dists = neuron_maxes - predicate
 *             dist_features = self.pred_dist_lookup.take(pred_dists + self.pred_dist_offset,
 *                                                        0, mode='clip')             # <<<<<<<<<<<<<<
 *             # try to recycle the grad_matrix if sizes match
 *             if self.target_dist_weights.shape[0] != self.pred_dist_weights.shape[0]:
 */
    __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mode, __pyx_n_u_clip) < 0) __PYX_ERR(1, 729, __pyx_L1_error)

    /* "networkconv.pyx":728
 *             # get the distance from each max token to its predicate
 *             pred_dists = neuron_maxes - predicate
 *             dist_features = self.pred_dist_lookup.take(pred_dists + self.pred_dist_offset,             # <<<<<<<<<<<<<<
 *                                                        0, mode='clip')
 *             # try to recycle the grad_matrix if sizes match
 */
    __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_dist_features, __pyx_t_16);
    __pyx_t_16 = 0;

    /* "networkconv.pyx":731
 *                                                        0, mode='clip')
 *             # try to recycle the grad_matrix if sizes match
 *             if self.target_dist_weights.shape[0] != self.pred_dist_weights.shape[0]:             # <<<<<<<<<<<<<<
 *                 grad_matrix = np.tile(gradients_t, [self.pred_dist_weights.shape[0], 1]).T
 * 
 */
    __pyx_t_2 = (((__pyx_v_self->target_dist_weights->dimensions[0]) != (__pyx_v_self->pred_dist_weights->dimensions[0])) != 0);
    if (__pyx_t_2) {

      /* "networkconv.pyx":732
 *             # try to recycle the grad_matrix if sizes match
 *             if self.target_dist_weights.shape[0] != self.pred_dist_weights.shape[0]:
 *                 grad_matrix = np.tile(gradients_t, [self.pred_dist_weights.shape[0], 1]).T             # <<<<<<<<<<<<<<
 * 
 *             self.pred_dist_weights += (grad_matrix * dist_features).T
 */
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tile); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->pred_dist_weights->dimensions[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_13 = PyList_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_13, 0, __pyx_t_1);
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyList_SET_ITEM(__pyx_t_13, 1, __pyx_int_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      __pyx_t_15 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
          __pyx_t_15 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_gradients_t), __pyx_t_13};
        __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 732, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_gradients_t), __pyx_t_13};
        __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_15, 2+__pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 732, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(2+__pyx_t_15); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 732, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        if (__pyx_t_1) {
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1); __pyx_t_1 = NULL;
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_gradients_t));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_gradients_t));
        PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_15, ((PyObject *)__pyx_v_gradients_t));
        __Pyx_GIVEREF(__pyx_t_13);
        PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_15, __pyx_t_13);
        __pyx_t_13 = 0;
        __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_17, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 732, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_T); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 732, __pyx_L1_error)
      __pyx_t_9 = ((PyArrayObject *)__pyx_t_8);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer);
        __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_15 < 0)) {
          PyErr_Fetch(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer, (PyObject*)__pyx_v_grad_matrix, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_4);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_6, __pyx_t_5, __pyx_t_4);
          }
          __pyx_t_6 = __pyx_t_5 = __pyx_t_4 = 0;
        }
        __pyx_pybuffernd_grad_matrix.diminfo[0].strides = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_grad_matrix.diminfo[0].shape = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_grad_matrix.diminfo[1].strides = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_grad_matrix.diminfo[1].shape = __pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(1, 732, __pyx_L1_error)
      }
      __pyx_t_9 = 0;
      __Pyx_DECREF_SET(__pyx_v_grad_matrix, ((PyArrayObject *)__pyx_t_8));
      __pyx_t_8 = 0;

      /* "networkconv.pyx":731
 *                                                        0, mode='clip')
 *             # try to recycle the grad_matrix if sizes match
 *             if self.target_dist_weights.shape[0] != self.pred_dist_weights.shape[0]:             # <<<<<<<<<<<<<<
 *                 grad_matrix = np.tile(gradients_t, [self.pred_dist_weights.shape[0], 1]).T
 * 
 */
    }

    /* "networkconv.pyx":734
 *                 grad_matrix = np.tile(gradients_t, [self.pred_dist_weights.shape[0], 1]).T
 * 
 *             self.pred_dist_weights += (grad_matrix * dist_features).T             # <<<<<<<<<<<<<<
 * 
 *         self.hidden_bias += self.hidden_gradients.sum(0) * self.learning_rate
 */
    __pyx_t_8 = PyNumber_Multiply(((PyObject *)__pyx_v_grad_matrix), __pyx_v_dist_features); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 734, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_T); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 734, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->pred_dist_weights), __pyx_t_16); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 734, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 734, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_8);
    __Pyx_GOTREF(__pyx_v_self->pred_dist_weights);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_dist_weights));
    __pyx_v_self->pred_dist_weights = ((PyArrayObject *)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "networkconv.pyx":700
 *         # I tried vectorizing this loop but it got a bit slower, probably because
 *         # of the overhead in building matrices/tensors with the max indices
 *         for i, neuron_maxes in enumerate(self.max_indices):             # <<<<<<<<<<<<<<
 *             # i indicates the i-th target
 * 
 */
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "networkconv.pyx":736
 *             self.pred_dist_weights += (grad_matrix * dist_features).T
 * 
 *         self.hidden_bias += self.hidden_gradients.sum(0) * self.learning_rate             # <<<<<<<<<<<<<<
 * 
 *         # Adjusts the transition scores table with the calculated gradients.
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->hidden_gradients), __pyx_n_s_sum); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_16 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_16)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_7 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_16, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_int_0);
  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
  if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_16 = PyNumber_Multiply(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->__pyx_base.hidden_bias), __pyx_t_16); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 736, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 736, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_8);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.hidden_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_bias));
  __pyx_v_self->__pyx_base.hidden_bias = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "networkconv.pyx":739
 * 
 *         # Adjusts the transition scores table with the calculated gradients.
 *         if not self.only_classify and self.transitions is not None:             # <<<<<<<<<<<<<<
 *             self.transitions += self.trans_gradients * self.learning_rate_trans
 * 
 */
  __pyx_t_10 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->only_classify)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(1, 739, __pyx_L1_error)
  __pyx_t_18 = ((!__pyx_t_10) != 0);
  if (__pyx_t_18) {
  } else {
    __pyx_t_2 = __pyx_t_18;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_18 = (((PyObject *)__pyx_v_self->__pyx_base.transitions) != Py_None);
  __pyx_t_10 = (__pyx_t_18 != 0);
  __pyx_t_2 = __pyx_t_10;
  __pyx_L9_bool_binop_done:;
  if (__pyx_t_2) {

    /* "networkconv.pyx":740
 *         # Adjusts the transition scores table with the calculated gradients.
 *         if not self.only_classify and self.transitions is not None:
 *             self.transitions += self.trans_gradients * self.learning_rate_trans             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
    __pyx_t_8 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate_trans); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_16 = PyNumber_Multiply(((PyObject *)__pyx_v_self->__pyx_base.trans_gradients), __pyx_t_8); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_self->__pyx_base.transitions), __pyx_t_16); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 740, __pyx_L1_error)
    __Pyx_GIVEREF(__pyx_t_8);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.transitions);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.transitions));
    __pyx_v_self->__pyx_base.transitions = ((PyArrayObject *)__pyx_t_8);
    __pyx_t_8 = 0;

    /* "networkconv.pyx":739
 * 
 *         # Adjusts the transition scores table with the calculated gradients.
 *         if not self.only_classify and self.transitions is not None:             # <<<<<<<<<<<<<<
 *             self.transitions += self.trans_gradients * self.learning_rate_trans
 * 
 */
  }

  /* "networkconv.pyx":677
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _adjust_weights(self, predicate, arguments=None):             # <<<<<<<<<<<<<<
 *         """
 *         Adjusts the network weights after gradients have been calculated.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gradients_t.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_values.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_last_values.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._adjust_weights", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_deltas.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_matrix.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gradients_t.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_values.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_last_values.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_gradients_t);
  __Pyx_XDECREF((PyObject *)__pyx_v_last_values);
  __Pyx_XDECREF((PyObject *)__pyx_v_deltas);
  __Pyx_XDECREF((PyObject *)__pyx_v_grad_matrix);
  __Pyx_XDECREF((PyObject *)__pyx_v_input_values);
  __Pyx_XDECREF(__pyx_v_neuron_maxes);
  __Pyx_XDECREF(__pyx_v_target_dists);
  __Pyx_XDECREF(__pyx_v_argument);
  __Pyx_XDECREF(__pyx_v_dist_features);
  __Pyx_XDECREF(__pyx_v_pred_dists);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":744
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _calculate_input_deltas(self, np.ndarray sentence, int predicate,             # <<<<<<<<<<<<<<
 *                                  object arguments=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_45_calculate_input_deltas(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_44_calculate_input_deltas[] = "ConvolutionalNetwork._calculate_input_deltas(self, ndarray sentence, int predicate, arguments=None)\n\n        Calculates the input deltas to be applied in the feature tables.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_45_calculate_input_deltas(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_sentence = 0;
  int __pyx_v_predicate;
  PyObject *__pyx_v_arguments = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_input_deltas (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_predicate,&__pyx_n_s_arguments,0};
    PyObject* values[3] = {0,0,0};

    /* "networkconv.pyx":745
 *     @cython.wraparound(False)
 *     def _calculate_input_deltas(self, np.ndarray sentence, int predicate,
 *                                  object arguments=None):             # <<<<<<<<<<<<<<
 *         """
 *         Calculates the input deltas to be applied in the feature tables.
 */
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicate)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_calculate_input_deltas", 0, 2, 3, 1); __PYX_ERR(1, 744, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_arguments);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_calculate_input_deltas") < 0)) __PYX_ERR(1, 744, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = ((PyArrayObject *)values[0]);
    __pyx_v_predicate = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_predicate == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 744, __pyx_L3_error)
    __pyx_v_arguments = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_calculate_input_deltas", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 744, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._calculate_input_deltas", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(1, 744, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_44_calculate_input_deltas(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_predicate, __pyx_v_arguments);

  /* "networkconv.pyx":744
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _calculate_input_deltas(self, np.ndarray sentence, int predicate,             # <<<<<<<<<<<<<<
 *                                  object arguments=None):
 *         """
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_44_calculate_input_deltas(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, int __pyx_v_predicate, PyObject *__pyx_v_arguments) {
  PyArrayObject *__pyx_v_hidden_gradients = 0;
  PyArrayObject *__pyx_v_input_gradients = 0;
  PyArrayObject *__pyx_v_target_dist_gradients = 0;
  PyArrayObject *__pyx_v_pred_dist_gradients = 0;
  PyArrayObject *__pyx_v_gradients = 0;
  PyArrayObject *__pyx_v_convolution_max = 0;
  PyArrayObject *__pyx_v_target_dists = 0;
  CYTHON_UNUSED PyArrayObject *__pyx_v_column_numbers = 0;
  PyObject *__pyx_v_target = NULL;
  PyObject *__pyx_v_argument = NULL;
  PyObject *__pyx_v_pred_dists = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_column_numbers;
  __Pyx_Buffer __pyx_pybuffer_column_numbers;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_convolution_max;
  __Pyx_Buffer __pyx_pybuffer_convolution_max;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_gradients;
  __Pyx_Buffer __pyx_pybuffer_gradients;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_hidden_gradients;
  __Pyx_Buffer __pyx_pybuffer_hidden_gradients;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_input_gradients;
  __Pyx_Buffer __pyx_pybuffer_input_gradients;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_pred_dist_gradients;
  __Pyx_Buffer __pyx_pybuffer_pred_dist_gradients;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target_dist_gradients;
  __Pyx_Buffer __pyx_pybuffer_target_dist_gradients;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_target_dists;
  __Pyx_Buffer __pyx_pybuffer_target_dists;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyArrayObject *__pyx_t_12 = NULL;
  PyArrayObject *__pyx_t_13 = NULL;
  PyObject *(*__pyx_t_14)(PyObject *);
  PyArrayObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyArrayObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculate_input_deltas", 0);
  __Pyx_TraceCall("_calculate_input_deltas", __pyx_f[1], 744, 0, __PYX_ERR(1, 744, __pyx_L1_error));
  __pyx_pybuffer_hidden_gradients.pybuffer.buf = NULL;
  __pyx_pybuffer_hidden_gradients.refcount = 0;
  __pyx_pybuffernd_hidden_gradients.data = NULL;
  __pyx_pybuffernd_hidden_gradients.rcbuffer = &__pyx_pybuffer_hidden_gradients;
  __pyx_pybuffer_input_gradients.pybuffer.buf = NULL;
  __pyx_pybuffer_input_gradients.refcount = 0;
  __pyx_pybuffernd_input_gradients.data = NULL;
  __pyx_pybuffernd_input_gradients.rcbuffer = &__pyx_pybuffer_input_gradients;
  __pyx_pybuffer_target_dist_gradients.pybuffer.buf = NULL;
  __pyx_pybuffer_target_dist_gradients.refcount = 0;
  __pyx_pybuffernd_target_dist_gradients.data = NULL;
  __pyx_pybuffernd_target_dist_gradients.rcbuffer = &__pyx_pybuffer_target_dist_gradients;
  __pyx_pybuffer_pred_dist_gradients.pybuffer.buf = NULL;
  __pyx_pybuffer_pred_dist_gradients.refcount = 0;
  __pyx_pybuffernd_pred_dist_gradients.data = NULL;
  __pyx_pybuffernd_pred_dist_gradients.rcbuffer = &__pyx_pybuffer_pred_dist_gradients;
  __pyx_pybuffer_gradients.pybuffer.buf = NULL;
  __pyx_pybuffer_gradients.refcount = 0;
  __pyx_pybuffernd_gradients.data = NULL;
  __pyx_pybuffernd_gradients.rcbuffer = &__pyx_pybuffer_gradients;
  __pyx_pybuffer_convolution_max.pybuffer.buf = NULL;
  __pyx_pybuffer_convolution_max.refcount = 0;
  __pyx_pybuffernd_convolution_max.data = NULL;
  __pyx_pybuffernd_convolution_max.rcbuffer = &__pyx_pybuffer_convolution_max;
  __pyx_pybuffer_target_dists.pybuffer.buf = NULL;
  __pyx_pybuffer_target_dists.refcount = 0;
  __pyx_pybuffernd_target_dists.data = NULL;
  __pyx_pybuffernd_target_dists.rcbuffer = &__pyx_pybuffer_target_dists;
  __pyx_pybuffer_column_numbers.pybuffer.buf = NULL;
  __pyx_pybuffer_column_numbers.refcount = 0;
  __pyx_pybuffernd_column_numbers.data = NULL;
  __pyx_pybuffernd_column_numbers.rcbuffer = &__pyx_pybuffer_column_numbers;

  /* "networkconv.pyx":756
 *         # matrices accumulating gradients over each target
 *         # each matrix has a whole window in each line
 *         input_gradients = np.zeros((len(sentence), self.hidden_size))             # <<<<<<<<<<<<<<
 *         target_dist_gradients = np.zeros((self.target_dist_lookup.shape[0], self.hidden_size))
 *         pred_dist_gradients = np.zeros((self.pred_dist_lookup.shape[0], self.hidden_size))
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 756, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 756, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_v_input_gradients, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __pyx_t_9 = __pyx_t_10 = __pyx_t_11 = 0;
    }
    __pyx_pybuffernd_input_gradients.diminfo[0].strides = __pyx_pybuffernd_input_gradients.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_input_gradients.diminfo[0].shape = __pyx_pybuffernd_input_gradients.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_input_gradients.diminfo[1].strides = __pyx_pybuffernd_input_gradients.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_input_gradients.diminfo[1].shape = __pyx_pybuffernd_input_gradients.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 756, __pyx_L1_error)
  }
  __pyx_t_7 = 0;
  __pyx_v_input_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":757
 *         # each matrix has a whole window in each line
 *         input_gradients = np.zeros((len(sentence), self.hidden_size))
 *         target_dist_gradients = np.zeros((self.target_dist_lookup.shape[0], self.hidden_size))             # <<<<<<<<<<<<<<
 *         pred_dist_gradients = np.zeros((self.pred_dist_lookup.shape[0], self.hidden_size))
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->target_dist_lookup->dimensions[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 757, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 757, __pyx_L1_error)
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_v_target_dist_gradients, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
      }
      __pyx_t_11 = __pyx_t_10 = __pyx_t_9 = 0;
    }
    __pyx_pybuffernd_target_dist_gradients.diminfo[0].strides = __pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target_dist_gradients.diminfo[0].shape = __pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_target_dist_gradients.diminfo[1].strides = __pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_target_dist_gradients.diminfo[1].shape = __pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 757, __pyx_L1_error)
  }
  __pyx_t_12 = 0;
  __pyx_v_target_dist_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":758
 *         input_gradients = np.zeros((len(sentence), self.hidden_size))
 *         target_dist_gradients = np.zeros((self.target_dist_lookup.shape[0], self.hidden_size))
 *         pred_dist_gradients = np.zeros((self.pred_dist_lookup.shape[0], self.hidden_size))             # <<<<<<<<<<<<<<
 * 
 *         # avoid multiplying by the learning rate multiple times
 */
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->pred_dist_lookup->dimensions[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
  __pyx_t_6 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 758, __pyx_L1_error)
  __pyx_t_12 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_v_pred_dist_gradients, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __pyx_t_9 = __pyx_t_10 = __pyx_t_11 = 0;
    }
    __pyx_pybuffernd_pred_dist_gradients.diminfo[0].strides = __pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pred_dist_gradients.diminfo[0].shape = __pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pred_dist_gradients.diminfo[1].strides = __pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pred_dist_gradients.diminfo[1].shape = __pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 758, __pyx_L1_error)
  }
  __pyx_t_12 = 0;
  __pyx_v_pred_dist_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":761
 * 
 *         # avoid multiplying by the learning rate multiple times
 *         hidden_gradients = self.hidden_gradients * self.learning_rate_features             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[INT_t, ndim=1] column_numbers = np.arange(self.hidden_size)
 * 
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate_features); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(((PyObject *)__pyx_v_self->hidden_gradients), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 761, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 761, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer);
    __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_8 < 0)) {
      PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_v_hidden_gradients, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
      }
      __pyx_t_11 = __pyx_t_10 = __pyx_t_9 = 0;
    }
    __pyx_pybuffernd_hidden_gradients.diminfo[0].strides = __pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_hidden_gradients.diminfo[0].shape = __pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_hidden_gradients.diminfo[1].strides = __pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_hidden_gradients.diminfo[1].shape = __pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 761, __pyx_L1_error)
  }
  __pyx_t_7 = 0;
  __pyx_v_hidden_gradients = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":762
 *         # avoid multiplying by the learning rate multiple times
 *         hidden_gradients = self.hidden_gradients * self.learning_rate_features
 *         cdef np.ndarray[INT_t, ndim=1] column_numbers = np.arange(self.hidden_size)             # <<<<<<<<<<<<<<
 * 
 *         for target in range(self.num_targets):
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_arange); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 762, __pyx_L1_error)
  __pyx_t_13 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_column_numbers.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_column_numbers = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_column_numbers.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(1, 762, __pyx_L1_error)
    } else {__pyx_pybuffernd_column_numbers.diminfo[0].strides = __pyx_pybuffernd_column_numbers.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_column_numbers.diminfo[0].shape = __pyx_pybuffernd_column_numbers.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_13 = 0;
  __pyx_v_column_numbers = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":764
 *         cdef np.ndarray[INT_t, ndim=1] column_numbers = np.arange(self.hidden_size)
 * 
 *         for target in range(self.num_targets):             # <<<<<<<<<<<<<<
 * 
 *             # array with the tokens that yielded the maximum value in each neuron
 */
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->num_targets); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 764, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_14 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_14 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 764, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_14)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 764, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 764, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(1, 764, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 764, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_14(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 764, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_target, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":768
 *             # array with the tokens that yielded the maximum value in each neuron
 *             # for this target
 *             convolution_max = self.max_indices[target]             # <<<<<<<<<<<<<<
 * 
 *             if not self.only_classify:
 */
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->max_indices), __pyx_v_target); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 768, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 768, __pyx_L1_error)
    __pyx_t_15 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_convolution_max.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_convolution_max.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_convolution_max.rcbuffer->pybuffer, (PyObject*)__pyx_v_convolution_max, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
        }
        __pyx_t_9 = __pyx_t_10 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_convolution_max.diminfo[0].strides = __pyx_pybuffernd_convolution_max.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_convolution_max.diminfo[0].shape = __pyx_pybuffernd_convolution_max.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 768, __pyx_L1_error)
    }
    __pyx_t_15 = 0;
    __Pyx_XDECREF_SET(__pyx_v_convolution_max, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "networkconv.pyx":770
 *             convolution_max = self.max_indices[target]
 * 
 *             if not self.only_classify:             # <<<<<<<<<<<<<<
 *                 target_dists = convolution_max - target
 *             else:
 */
    __pyx_t_16 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->only_classify)); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(1, 770, __pyx_L1_error)
    __pyx_t_17 = ((!__pyx_t_16) != 0);
    if (__pyx_t_17) {

      /* "networkconv.pyx":771
 * 
 *             if not self.only_classify:
 *                 target_dists = convolution_max - target             # <<<<<<<<<<<<<<
 *             else:
 *                 argument = arguments[target]
 */
      __pyx_t_3 = PyNumber_Subtract(((PyObject *)__pyx_v_convolution_max), __pyx_v_target); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 771, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 771, __pyx_L1_error)
      __pyx_t_15 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer);
        __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_8 < 0)) {
          PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer, (PyObject*)__pyx_v_target_dists, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
          }
          __pyx_t_11 = __pyx_t_10 = __pyx_t_9 = 0;
        }
        __pyx_pybuffernd_target_dists.diminfo[0].strides = __pyx_pybuffernd_target_dists.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target_dists.diminfo[0].shape = __pyx_pybuffernd_target_dists.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 771, __pyx_L1_error)
      }
      __pyx_t_15 = 0;
      __Pyx_XDECREF_SET(__pyx_v_target_dists, ((PyArrayObject *)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "networkconv.pyx":770
 *             convolution_max = self.max_indices[target]
 * 
 *             if not self.only_classify:             # <<<<<<<<<<<<<<
 *                 target_dists = convolution_max - target
 *             else:
 */
      goto __pyx_L5;
    }

    /* "networkconv.pyx":773
 *                 target_dists = convolution_max - target
 *             else:
 *                 argument = arguments[target]             # <<<<<<<<<<<<<<
 *                 target_dists = self.argument_distances(convolution_max, argument)
 * 
 */
    /*else*/ {
      __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_arguments, __pyx_v_target); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 773, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_XDECREF_SET(__pyx_v_argument, __pyx_t_3);
      __pyx_t_3 = 0;

      /* "networkconv.pyx":774
 *             else:
 *                 argument = arguments[target]
 *                 target_dists = self.argument_distances(convolution_max, argument)             # <<<<<<<<<<<<<<
 * 
 *             target_dists = np.clip(target_dists + self.target_dist_offset, 0,
 */
      __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork *)__pyx_v_self->__pyx_vtab)->argument_distances(__pyx_v_self, ((PyObject *)__pyx_v_convolution_max), __pyx_v_argument)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 774, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer);
        __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_3), &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_8 < 0)) {
          PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer, (PyObject*)__pyx_v_target_dists, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
          }
          __pyx_t_9 = __pyx_t_10 = __pyx_t_11 = 0;
        }
        __pyx_pybuffernd_target_dists.diminfo[0].strides = __pyx_pybuffernd_target_dists.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target_dists.diminfo[0].shape = __pyx_pybuffernd_target_dists.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 774, __pyx_L1_error)
      }
      __Pyx_XDECREF_SET(__pyx_v_target_dists, ((PyArrayObject *)__pyx_t_3));
      __pyx_t_3 = 0;
    }
    __pyx_L5:;

    /* "networkconv.pyx":776
 *                 target_dists = self.argument_distances(convolution_max, argument)
 * 
 *             target_dists = np.clip(target_dists + self.target_dist_offset, 0,             # <<<<<<<<<<<<<<
 *                                    self.target_dist_lookup.shape[0] - 1)
 *             pred_dists = convolution_max - predicate
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_clip); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->target_dist_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_v_target_dists), __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "networkconv.pyx":777
 * 
 *             target_dists = np.clip(target_dists + self.target_dist_offset, 0,
 *                                    self.target_dist_lookup.shape[0] - 1)             # <<<<<<<<<<<<<<
 *             pred_dists = convolution_max - predicate
 *             pred_dists = np.clip(pred_dists + self.pred_dist_offset, 0,
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(((__pyx_v_self->target_dist_lookup->dimensions[0]) - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_18 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_18)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_18);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[4] = {__pyx_t_18, __pyx_t_6, __pyx_int_0, __pyx_t_1};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 776, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[4] = {__pyx_t_18, __pyx_t_6, __pyx_int_0, __pyx_t_1};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 776, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_19 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 776, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_19);
      if (__pyx_t_18) {
        __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_18); __pyx_t_18 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_8, __pyx_t_6);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_8, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_19, 2+__pyx_t_8, __pyx_t_1);
      __pyx_t_6 = 0;
      __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_19, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 776, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "networkconv.pyx":776
 *                 target_dists = self.argument_distances(convolution_max, argument)
 * 
 *             target_dists = np.clip(target_dists + self.target_dist_offset, 0,             # <<<<<<<<<<<<<<
 *                                    self.target_dist_lookup.shape[0] - 1)
 *             pred_dists = convolution_max - predicate
 */
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 776, __pyx_L1_error)
    __pyx_t_15 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer, (PyObject*)__pyx_v_target_dists, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_INT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
        }
        __pyx_t_11 = __pyx_t_10 = __pyx_t_9 = 0;
      }
      __pyx_pybuffernd_target_dists.diminfo[0].strides = __pyx_pybuffernd_target_dists.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_target_dists.diminfo[0].shape = __pyx_pybuffernd_target_dists.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 776, __pyx_L1_error)
    }
    __pyx_t_15 = 0;
    __Pyx_DECREF_SET(__pyx_v_target_dists, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "networkconv.pyx":778
 *             target_dists = np.clip(target_dists + self.target_dist_offset, 0,
 *                                    self.target_dist_lookup.shape[0] - 1)
 *             pred_dists = convolution_max - predicate             # <<<<<<<<<<<<<<
 *             pred_dists = np.clip(pred_dists + self.pred_dist_offset, 0,
 *                                  self.pred_dist_lookup.shape[0] - 1)
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_predicate); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyNumber_Subtract(((PyObject *)__pyx_v_convolution_max), __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_pred_dists, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "networkconv.pyx":779
 *                                    self.target_dist_lookup.shape[0] - 1)
 *             pred_dists = convolution_max - predicate
 *             pred_dists = np.clip(pred_dists + self.pred_dist_offset, 0,             # <<<<<<<<<<<<<<
 *                                  self.pred_dist_lookup.shape[0] - 1)
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_clip); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->pred_dist_offset); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyNumber_Add(__pyx_v_pred_dists, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkconv.pyx":780
 *             pred_dists = convolution_max - predicate
 *             pred_dists = np.clip(pred_dists + self.pred_dist_offset, 0,
 *                                  self.pred_dist_lookup.shape[0] - 1)             # <<<<<<<<<<<<<<
 * 
 *             gradients = hidden_gradients[target]
 */
    __pyx_t_3 = __Pyx_PyInt_From_long(((__pyx_v_self->pred_dist_lookup->dimensions[0]) - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 780, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_8 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_19);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_19, function);
        __pyx_t_8 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_19)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_int_0, __pyx_t_3};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 779, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_19)) {
      PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_int_0, __pyx_t_3};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 779, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_18 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 779, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_18, 0+__pyx_t_8, __pyx_t_1);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_18, 1+__pyx_t_8, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_18, 2+__pyx_t_8, __pyx_t_3);
      __pyx_t_1 = 0;
      __pyx_t_3 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_18, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 779, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    }
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF_SET(__pyx_v_pred_dists, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "networkconv.pyx":782
 *                                  self.pred_dist_lookup.shape[0] - 1)
 * 
 *             gradients = hidden_gradients[target]             # <<<<<<<<<<<<<<
 * 
 *             # sparse matrix with gradients to be applied over the input
 */
    __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_hidden_gradients), __pyx_v_target); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 782, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gradients.rcbuffer->pybuffer);
      __pyx_t_8 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_8 < 0)) {
        PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_gradients.rcbuffer->pybuffer, (PyObject*)__pyx_v_gradients, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
        }
        __pyx_t_9 = __pyx_t_10 = __pyx_t_11 = 0;
      }
      __pyx_pybuffernd_gradients.diminfo[0].strides = __pyx_pybuffernd_gradients.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_gradients.diminfo[0].shape = __pyx_pybuffernd_gradients.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(1, 782, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __Pyx_XDECREF_SET(__pyx_v_gradients, ((PyArrayObject *)__pyx_t_5));
    __pyx_t_5 = 0;

    /* "networkconv.pyx":786
 *             # sparse matrix with gradients to be applied over the input
 *             # line i has the gradients for the i-th token in the sentence
 *             input_gradients[convolution_max, np.arange(self.hidden_size)] += gradients             # <<<<<<<<<<<<<<
 * 
 *             # distance deltas
 */
    __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_np); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_arange); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_18))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_18);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_18, function);
      }
    }
    __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_18, __pyx_t_3, __pyx_t_19) : __Pyx_PyObject_CallOneArg(__pyx_t_18, __pyx_t_19);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_INCREF(((PyObject *)__pyx_v_convolution_max));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_convolution_max));
    PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_v_convolution_max));
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_input_gradients), __pyx_t_18); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_19 = PyNumber_InPlaceAdd(__pyx_t_5, ((PyObject *)__pyx_v_gradients)); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_input_gradients), __pyx_t_18, __pyx_t_19) < 0)) __PYX_ERR(1, 786, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

    /* "networkconv.pyx":789
 * 
 *             # distance deltas
 *             target_dist_gradients[target_dists, np.arange(self.hidden_size)] += gradients             # <<<<<<<<<<<<<<
 *             pred_dist_gradients[pred_dists, np.arange(self.hidden_size)] += gradients
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_np); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_18 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, __pyx_t_19) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_19);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_v_target_dists));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_target_dists));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_target_dists));
    __Pyx_GIVEREF(__pyx_t_18);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_18);
    __pyx_t_18 = 0;
    __pyx_t_18 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_target_dist_gradients), __pyx_t_5); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    __pyx_t_19 = PyNumber_InPlaceAdd(__pyx_t_18, ((PyObject *)__pyx_v_gradients)); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_target_dist_gradients), __pyx_t_5, __pyx_t_19) < 0)) __PYX_ERR(1, 789, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "networkconv.pyx":790
 *             # distance deltas
 *             target_dist_gradients[target_dists, np.arange(self.hidden_size)] += gradients
 *             pred_dist_gradients[pred_dists, np.arange(self.hidden_size)] += gradients             # <<<<<<<<<<<<<<
 * 
 *         self.input_deltas = input_gradients.dot(self.hidden_weights)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_np); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_arange); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_18))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_18);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_18, function);
      }
    }
    __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_18, __pyx_t_3, __pyx_t_19) : __Pyx_PyObject_CallOneArg(__pyx_t_18, __pyx_t_19);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_18);
    __Pyx_INCREF(__pyx_v_pred_dists);
    __Pyx_GIVEREF(__pyx_v_pred_dists);
    PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_v_pred_dists);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_pred_dist_gradients), __pyx_t_18); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_19 = PyNumber_InPlaceAdd(__pyx_t_5, ((PyObject *)__pyx_v_gradients)); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_pred_dist_gradients), __pyx_t_18, __pyx_t_19) < 0)) __PYX_ERR(1, 790, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

    /* "networkconv.pyx":764
 *         cdef np.ndarray[INT_t, ndim=1] column_numbers = np.arange(self.hidden_size)
 * 
 *         for target in range(self.num_targets):             # <<<<<<<<<<<<<<
 * 
 *             # array with the tokens that yielded the maximum value in each neuron
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":792
 *             pred_dist_gradients[pred_dists, np.arange(self.hidden_size)] += gradients
 * 
 *         self.input_deltas = input_gradients.dot(self.hidden_weights)             # <<<<<<<<<<<<<<
 *         self.target_dist_deltas = target_dist_gradients.dot(self.target_dist_weights.T)
 *         self.pred_dist_deltas = pred_dist_gradients.dot(self.pred_dist_weights.T)
 */
  __pyx_t_18 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_input_gradients), __pyx_n_s_dot); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_19 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_18))) {
    __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_18);
    if (likely(__pyx_t_19)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_18, function);
    }
  }
  __pyx_t_2 = (__pyx_t_19) ? __Pyx_PyObject_Call2Args(__pyx_t_18, __pyx_t_19, ((PyObject *)__pyx_v_self->__pyx_base.hidden_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_18, ((PyObject *)__pyx_v_self->__pyx_base.hidden_weights));
  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 792, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 792, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->input_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->input_deltas));
  __pyx_v_self->input_deltas = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":793
 * 
 *         self.input_deltas = input_gradients.dot(self.hidden_weights)
 *         self.target_dist_deltas = target_dist_gradients.dot(self.target_dist_weights.T)             # <<<<<<<<<<<<<<
 *         self.pred_dist_deltas = pred_dist_gradients.dot(self.pred_dist_weights.T)
 * 
 */
  __pyx_t_18 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_target_dist_gradients), __pyx_n_s_dot); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->target_dist_weights), __pyx_n_s_T); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_18))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_18);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_18, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_18, __pyx_t_5, __pyx_t_19) : __Pyx_PyObject_CallOneArg(__pyx_t_18, __pyx_t_19);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 793, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 793, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->target_dist_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->target_dist_deltas));
  __pyx_v_self->target_dist_deltas = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":794
 *         self.input_deltas = input_gradients.dot(self.hidden_weights)
 *         self.target_dist_deltas = target_dist_gradients.dot(self.target_dist_weights.T)
 *         self.pred_dist_deltas = pred_dist_gradients.dot(self.pred_dist_weights.T)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_18 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_pred_dist_gradients), __pyx_n_s_dot); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pred_dist_weights), __pyx_n_s_T); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_18))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_18);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_18, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_18, __pyx_t_5, __pyx_t_19) : __Pyx_PyObject_CallOneArg(__pyx_t_18, __pyx_t_19);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 794, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->pred_dist_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_dist_deltas));
  __pyx_v_self->pred_dist_deltas = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":744
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def _calculate_input_deltas(self, np.ndarray sentence, int predicate,             # <<<<<<<<<<<<<<
 *                                  object arguments=None):
 *         """
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_column_numbers.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_convolution_max.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gradients.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._calculate_input_deltas", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_column_numbers.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_convolution_max.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gradients.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_hidden_gradients.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_input_gradients.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pred_dist_gradients.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target_dist_gradients.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_target_dists.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_hidden_gradients);
  __Pyx_XDECREF((PyObject *)__pyx_v_input_gradients);
  __Pyx_XDECREF((PyObject *)__pyx_v_target_dist_gradients);
  __Pyx_XDECREF((PyObject *)__pyx_v_pred_dist_gradients);
  __Pyx_XDECREF((PyObject *)__pyx_v_gradients);
  __Pyx_XDECREF((PyObject *)__pyx_v_convolution_max);
  __Pyx_XDECREF((PyObject *)__pyx_v_target_dists);
  __Pyx_XDECREF((PyObject *)__pyx_v_column_numbers);
  __Pyx_XDECREF(__pyx_v_target);
  __Pyx_XDECREF(__pyx_v_argument);
  __Pyx_XDECREF(__pyx_v_pred_dists);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":797
 * 
 * 
 *     def _adjust_features(self, sentence, predicate):             # <<<<<<<<<<<<<<
 *         """Adjusts the features in all feature tables."""
 *         # compute each token in the window separately and
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_47_adjust_features(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_46_adjust_features[] = "ConvolutionalNetwork._adjust_features(self, sentence, predicate)\nAdjusts the features in all feature tables.";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_47_adjust_features(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentence = 0;
  CYTHON_UNUSED PyObject *__pyx_v_predicate = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_adjust_features (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_predicate,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicate)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_adjust_features", 1, 2, 2, 1); __PYX_ERR(1, 797, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_adjust_features") < 0)) __PYX_ERR(1, 797, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sentence = values[0];
    __pyx_v_predicate = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_adjust_features", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 797, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._adjust_features", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_46_adjust_features(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_predicate);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_46_adjust_features(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentence, CYTHON_UNUSED PyObject *__pyx_v_predicate) {
  PyObject *__pyx_v_start_from = NULL;
  PyObject *__pyx_v_dist_target_from = NULL;
  PyObject *__pyx_v_dist_pred_from = NULL;
  PyObject *__pyx_v_pre_dist = NULL;
  PyObject *__pyx_v_pos_dist = NULL;
  PyObject *__pyx_v_padded_sentence = NULL;
  int __pyx_v_i;
  PyObject *__pyx_v_j = NULL;
  PyObject *__pyx_v_table = NULL;
  PyObject *__pyx_v_table_deltas = NULL;
  PyObject *__pyx_v_token = NULL;
  PyObject *__pyx_v_deltas = NULL;
  PyObject *__pyx_v_dist_deltas = NULL;
  PyObject *__pyx_v_pre_deltas = NULL;
  PyObject *__pyx_v_pos_deltas = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyArrayObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_adjust_features", 0);
  __Pyx_TraceCall("_adjust_features", __pyx_f[1], 797, 0, __PYX_ERR(1, 797, __pyx_L1_error));

  /* "networkconv.pyx":801
 *         # compute each token in the window separately and
 *         # separate the feature deltas into tables
 *         start_from = 0             # <<<<<<<<<<<<<<
 *         dist_target_from = 0
 *         dist_pred_from = 0
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_start_from = __pyx_int_0;

  /* "networkconv.pyx":802
 *         # separate the feature deltas into tables
 *         start_from = 0
 *         dist_target_from = 0             # <<<<<<<<<<<<<<
 *         dist_pred_from = 0
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_dist_target_from = __pyx_int_0;

  /* "networkconv.pyx":803
 *         start_from = 0
 *         dist_target_from = 0
 *         dist_pred_from = 0             # <<<<<<<<<<<<<<
 * 
 *         # number of times that the minimum and maximum distances are repeated
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_dist_pred_from = __pyx_int_0;

  /* "networkconv.pyx":807
 *         # number of times that the minimum and maximum distances are repeated
 *         # in the lookup distance tables
 *         pre_dist = self.word_window_size             # <<<<<<<<<<<<<<
 *         pos_dist = 1
 *         if self.word_window_size > 1:
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.word_window_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 807, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_pre_dist = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":808
 *         # in the lookup distance tables
 *         pre_dist = self.word_window_size
 *         pos_dist = 1             # <<<<<<<<<<<<<<
 *         if self.word_window_size > 1:
 *             padded_sentence = np.concatenate((self.pre_padding,
 */
  __Pyx_INCREF(__pyx_int_1);
  __pyx_v_pos_dist = __pyx_int_1;

  /* "networkconv.pyx":809
 *         pre_dist = self.word_window_size
 *         pos_dist = 1
 *         if self.word_window_size > 1:             # <<<<<<<<<<<<<<
 *             padded_sentence = np.concatenate((self.pre_padding,
 *                                               sentence,
 */
  __pyx_t_2 = ((__pyx_v_self->__pyx_base.word_window_size > 1) != 0);
  if (__pyx_t_2) {

    /* "networkconv.pyx":810
 *         pos_dist = 1
 *         if self.word_window_size > 1:
 *             padded_sentence = np.concatenate((self.pre_padding,             # <<<<<<<<<<<<<<
 *                                               sentence,
 *                                               self.pos_padding))
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkconv.pyx":812
 *             padded_sentence = np.concatenate((self.pre_padding,
 *                                               sentence,
 *                                               self.pos_padding))             # <<<<<<<<<<<<<<
 *         else:
 *             padded_sentence = sentence
 */
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
    __Pyx_INCREF(__pyx_v_sentence);
    __Pyx_GIVEREF(__pyx_v_sentence);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_sentence);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
    PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_padded_sentence = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "networkconv.pyx":809
 *         pre_dist = self.word_window_size
 *         pos_dist = 1
 *         if self.word_window_size > 1:             # <<<<<<<<<<<<<<
 *             padded_sentence = np.concatenate((self.pre_padding,
 *                                               sentence,
 */
    goto __pyx_L3;
  }

  /* "networkconv.pyx":814
 *                                               self.pos_padding))
 *         else:
 *             padded_sentence = sentence             # <<<<<<<<<<<<<<
 * 
 *         for i in range(self.word_window_size):
 */
  /*else*/ {
    __Pyx_INCREF(__pyx_v_sentence);
    __pyx_v_padded_sentence = __pyx_v_sentence;
  }
  __pyx_L3:;

  /* "networkconv.pyx":816
 *             padded_sentence = sentence
 * 
 *         for i in range(self.word_window_size):             # <<<<<<<<<<<<<<
 * 
 *             for j, table in enumerate(self.feature_tables):
 */
  __pyx_t_6 = __pyx_v_self->__pyx_base.word_window_size;
  __pyx_t_7 = __pyx_t_6;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "networkconv.pyx":818
 *         for i in range(self.word_window_size):
 * 
 *             for j, table in enumerate(self.feature_tables):             # <<<<<<<<<<<<<<
 *                 # this is the column for the i-th position in the window
 *                 # regarding features from the j-th table
 */
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
    __pyx_t_4 = __pyx_v_self->__pyx_base.feature_tables; __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = 0;
    for (;;) {
      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_4)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_3); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(1, 818, __pyx_L1_error)
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      #endif
      __Pyx_XDECREF_SET(__pyx_v_table, __pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_j, __pyx_t_1);
      __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1);
      __pyx_t_1 = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "networkconv.pyx":821
 *                 # this is the column for the i-th position in the window
 *                 # regarding features from the j-th table
 *                 table_deltas = self.input_deltas[:, start_from:start_from + table.shape[1]]             # <<<<<<<<<<<<<<
 *                 start_from += table.shape[1]
 * 
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 821, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 821, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Add(__pyx_v_start_from, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 821, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PySlice_New(__pyx_v_start_from, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 821, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 821, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_slice__3);
      __Pyx_GIVEREF(__pyx_slice__3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_slice__3);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->input_deltas), __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 821, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_table_deltas, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "networkconv.pyx":822
 *                 # regarding features from the j-th table
 *                 table_deltas = self.input_deltas[:, start_from:start_from + table.shape[1]]
 *                 start_from += table.shape[1]             # <<<<<<<<<<<<<<
 * 
 *                 for token, deltas in zip(padded_sentence[i:], table_deltas):
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_table, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 822, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 822, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_start_from, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 822, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_start_from, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "networkconv.pyx":824
 *                 start_from += table.shape[1]
 * 
 *                 for token, deltas in zip(padded_sentence[i:], table_deltas):             # <<<<<<<<<<<<<<
 *                     table[token[j]] += deltas
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_padded_sentence, __pyx_v_i, 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 824, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 824, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __Pyx_INCREF(__pyx_v_table_deltas);
      __Pyx_GIVEREF(__pyx_v_table_deltas);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_table_deltas);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 824, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
        __pyx_t_3 = __pyx_t_5; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 824, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 824, __pyx_L1_error)
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      for (;;) {
        if (likely(!__pyx_t_11)) {
          if (likely(PyList_CheckExact(__pyx_t_3))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 824, __pyx_L1_error)
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 824, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 824, __pyx_L1_error)
            #else
            __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 824, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            #endif
          }
        } else {
          __pyx_t_5 = __pyx_t_11(__pyx_t_3);
          if (unlikely(!__pyx_t_5)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(1, 824, __pyx_L1_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_5);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
          PyObject* sequence = __pyx_t_5;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(1, 824, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_13 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          #else
          __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 824, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_13 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 824, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_14 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 824, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext;
          index = 0; __pyx_t_12 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_12)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_12);
          index = 1; __pyx_t_13 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_13)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_13);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 2) < 0) __PYX_ERR(1, 824, __pyx_L1_error)
          __pyx_t_15 = NULL;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L11_unpacking_done;
          __pyx_L10_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_15 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(1, 824, __pyx_L1_error)
          __pyx_L11_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_v_token, __pyx_t_12);
        __pyx_t_12 = 0;
        __Pyx_XDECREF_SET(__pyx_v_deltas, __pyx_t_13);
        __pyx_t_13 = 0;

        /* "networkconv.pyx":825
 * 
 *                 for token, deltas in zip(padded_sentence[i:], table_deltas):
 *                     table[token[j]] += deltas             # <<<<<<<<<<<<<<
 * 
 *             dist_deltas = self.target_dist_deltas[:, dist_target_from : dist_target_from + self.target_dist_table.shape[1] ]
 */
        __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_token, __pyx_v_j); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_13 = __Pyx_PyObject_GetItem(__pyx_v_table, __pyx_t_5); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_t_13, __pyx_v_deltas); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(PyObject_SetItem(__pyx_v_table, __pyx_t_5, __pyx_t_12) < 0)) __PYX_ERR(1, 825, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "networkconv.pyx":824
 *                 start_from += table.shape[1]
 * 
 *                 for token, deltas in zip(padded_sentence[i:], table_deltas):             # <<<<<<<<<<<<<<
 *                     table[token[j]] += deltas
 * 
 */
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "networkconv.pyx":818
 *         for i in range(self.word_window_size):
 * 
 *             for j, table in enumerate(self.feature_tables):             # <<<<<<<<<<<<<<
 *                 # this is the column for the i-th position in the window
 *                 # regarding features from the j-th table
 */
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "networkconv.pyx":827
 *                     table[token[j]] += deltas
 * 
 *             dist_deltas = self.target_dist_deltas[:, dist_target_from : dist_target_from + self.target_dist_table.shape[1] ]             # <<<<<<<<<<<<<<
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 */
    __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->target_dist_table->dimensions[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 827, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Add(__pyx_v_dist_target_from, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PySlice_New(__pyx_v_dist_target_from, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 827, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 827, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_slice__3);
    __Pyx_GIVEREF(__pyx_slice__3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->target_dist_deltas), __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 827, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_dist_deltas, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkconv.pyx":828
 * 
 *             dist_deltas = self.target_dist_deltas[:, dist_target_from : dist_target_from + self.target_dist_table.shape[1] ]
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)             # <<<<<<<<<<<<<<
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 *             self.target_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dist_deltas, __pyx_n_s_take); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_arange); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_13, function);
      }
    }
    __pyx_t_5 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_v_pre_dist) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_pre_dist);
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = NULL;
    __pyx_t_16 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_16 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_5, __pyx_int_0};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_5, __pyx_int_0};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 828, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_13) {
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_16, __pyx_t_5);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_16, __pyx_int_0);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 828, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_int_0);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_pre_deltas, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkconv.pyx":829
 *             dist_deltas = self.target_dist_deltas[:, dist_target_from : dist_target_from + self.target_dist_table.shape[1] ]
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)             # <<<<<<<<<<<<<<
 *             self.target_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]
 *             self.target_dist_table[0] += pre_deltas
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dist_deltas, __pyx_n_s_take); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_arange); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Negative(__pyx_v_pos_dist); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_14 = NULL;
    __pyx_t_16 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_13, function);
        __pyx_t_16 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_5, __pyx_int_0};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 829, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_14, __pyx_t_5, __pyx_int_0};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 829, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_17 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 829, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      if (__pyx_t_14) {
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_14); __pyx_t_14 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_16, __pyx_t_5);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_16, __pyx_int_0);
      __pyx_t_5 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_17, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 829, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = NULL;
    __pyx_t_16 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_16 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_12, __pyx_int_0};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_12, __pyx_int_0};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    {
      __pyx_t_17 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 829, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      if (__pyx_t_13) {
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_13); __pyx_t_13 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_16, __pyx_t_12);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_16, __pyx_int_0);
      __pyx_t_12 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 829, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_int_0);
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF_SET(__pyx_v_pos_deltas, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkconv.pyx":830
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 *             self.target_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]             # <<<<<<<<<<<<<<
 *             self.target_dist_table[0] += pre_deltas
 *             self.target_dist_table[-1] += pos_deltas
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_table));
    __pyx_t_18 = __pyx_v_self->target_dist_table;
    __Pyx_INCREF(__pyx_tuple__10);
    __pyx_t_19 = __pyx_tuple__10;
    __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_t_18), __pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_Negative(__pyx_v_pos_dist); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_dist_deltas, 0, 0, &__pyx_v_pre_dist, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_t_18), __pyx_t_19, __pyx_t_4) < 0)) __PYX_ERR(1, 830, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;

    /* "networkconv.pyx":831
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 *             self.target_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]
 *             self.target_dist_table[0] += pre_deltas             # <<<<<<<<<<<<<<
 *             self.target_dist_table[-1] += pos_deltas
 *             dist_target_from += self.target_dist_table.shape[1]
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_table));
    __pyx_t_18 = __pyx_v_self->target_dist_table;
    __pyx_t_9 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_t_18), __pyx_t_9, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_v_pre_deltas); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_t_18), __pyx_t_9, __pyx_t_3, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(1, 831, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;

    /* "networkconv.pyx":832
 *             self.target_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]
 *             self.target_dist_table[0] += pre_deltas
 *             self.target_dist_table[-1] += pos_deltas             # <<<<<<<<<<<<<<
 *             dist_target_from += self.target_dist_table.shape[1]
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_table));
    __pyx_t_18 = __pyx_v_self->target_dist_table;
    __pyx_t_9 = -1L;
    __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_t_18), __pyx_t_9, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_pos_deltas); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_t_18), __pyx_t_9, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(1, 832, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;

    /* "networkconv.pyx":833
 *             self.target_dist_table[0] += pre_deltas
 *             self.target_dist_table[-1] += pos_deltas
 *             dist_target_from += self.target_dist_table.shape[1]             # <<<<<<<<<<<<<<
 * 
 *             dist_deltas = self.pred_dist_deltas[:, dist_pred_from : dist_pred_from + self.pred_dist_table.shape[1] ]
 */
    __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->target_dist_table->dimensions[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_dist_target_from, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 833, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_dist_target_from, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":835
 *             dist_target_from += self.target_dist_table.shape[1]
 * 
 *             dist_deltas = self.pred_dist_deltas[:, dist_pred_from : dist_pred_from + self.pred_dist_table.shape[1] ]             # <<<<<<<<<<<<<<
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 */
    __pyx_t_3 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->pred_dist_table->dimensions[1])); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Add(__pyx_v_dist_pred_from, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PySlice_New(__pyx_v_dist_pred_from, __pyx_t_4, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_slice__3);
    __Pyx_GIVEREF(__pyx_slice__3);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->pred_dist_deltas), __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_dist_deltas, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":836
 * 
 *             dist_deltas = self.pred_dist_deltas[:, dist_pred_from : dist_pred_from + self.pred_dist_table.shape[1] ]
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)             # <<<<<<<<<<<<<<
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 *             self.pred_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_dist_deltas, __pyx_n_s_take); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 836, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 836, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_arange); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 836, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_13, function);
      }
    }
    __pyx_t_17 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_13, __pyx_t_12, __pyx_v_pre_dist) : __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_v_pre_dist);
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 836, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = NULL;
    __pyx_t_16 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_16 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_17, __pyx_int_0};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_17, __pyx_int_0};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 836, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_13) {
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_16, __pyx_t_17);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_16, __pyx_int_0);
      __pyx_t_17 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 836, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 836, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_int_0);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 836, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_pre_deltas, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":837
 *             dist_deltas = self.pred_dist_deltas[:, dist_pred_from : dist_pred_from + self.pred_dist_table.shape[1] ]
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)             # <<<<<<<<<<<<<<
 *             self.pred_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]
 *             self.pred_dist_table[0] += pre_deltas
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_dist_deltas, __pyx_n_s_take); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_n_s_np); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_arange); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __pyx_t_17 = PyNumber_Negative(__pyx_v_pos_dist); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_5 = NULL;
    __pyx_t_16 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_13);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_13, function);
        __pyx_t_16 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_17, __pyx_int_0};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 837, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_17, __pyx_int_0};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 837, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_17);
      PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_16, __pyx_t_17);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_16, __pyx_int_0);
      __pyx_t_17 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_14, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_13 = NULL;
    __pyx_t_16 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_13)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_16 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_12, __pyx_int_0};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 837, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_12, __pyx_int_0};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_16, 2+__pyx_t_16); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 837, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(2+__pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (__pyx_t_13) {
        __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_16, __pyx_t_12);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_16, __pyx_int_0);
      __pyx_t_12 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_int_0);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 837, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_pos_deltas, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":838
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 *             self.pred_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]             # <<<<<<<<<<<<<<
 *             self.pred_dist_table[0] += pre_deltas
 *             self.pred_dist_table[-1] += pos_deltas
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_table));
    __pyx_t_18 = __pyx_v_self->pred_dist_table;
    __Pyx_INCREF(__pyx_tuple__10);
    __pyx_t_19 = __pyx_tuple__10;
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_t_18), __pyx_t_19); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Negative(__pyx_v_pos_dist); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_dist_deltas, 0, 0, &__pyx_v_pre_dist, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 838, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_t_18), __pyx_t_19, __pyx_t_4) < 0)) __PYX_ERR(1, 838, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;

    /* "networkconv.pyx":839
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 *             self.pred_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]
 *             self.pred_dist_table[0] += pre_deltas             # <<<<<<<<<<<<<<
 *             self.pred_dist_table[-1] += pos_deltas
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_table));
    __pyx_t_18 = __pyx_v_self->pred_dist_table;
    __pyx_t_9 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_t_18), __pyx_t_9, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 839, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_v_pre_deltas); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 839, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_t_18), __pyx_t_9, __pyx_t_1, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(1, 839, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;

    /* "networkconv.pyx":840
 *             self.pred_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]
 *             self.pred_dist_table[0] += pre_deltas
 *             self.pred_dist_table[-1] += pos_deltas             # <<<<<<<<<<<<<<
 * 
 *             pre_dist -= 1
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_table));
    __pyx_t_18 = __pyx_v_self->pred_dist_table;
    __pyx_t_9 = -1L;
    __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_t_18), __pyx_t_9, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_v_pos_deltas); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 840, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_t_18), __pyx_t_9, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0)) __PYX_ERR(1, 840, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;

    /* "networkconv.pyx":842
 *             self.pred_dist_table[-1] += pos_deltas
 * 
 *             pre_dist -= 1             # <<<<<<<<<<<<<<
 *             pos_dist += 1
 *             dist_pred_from += self.pred_dist_table.shape[1]
 */
    __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_pre_dist, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 842, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_pre_dist, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "networkconv.pyx":843
 * 
 *             pre_dist -= 1
 *             pos_dist += 1             # <<<<<<<<<<<<<<
 *             dist_pred_from += self.pred_dist_table.shape[1]
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_pos_dist, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 843, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_pos_dist, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "networkconv.pyx":844
 *             pre_dist -= 1
 *             pos_dist += 1
 *             dist_pred_from += self.pred_dist_table.shape[1]             # <<<<<<<<<<<<<<
 * 
 *         self._create_target_lookup()
 */
    __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->pred_dist_table->dimensions[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_dist_pred_from, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 844, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_dist_pred_from, __pyx_t_1);
    __pyx_t_1 = 0;
  }

  /* "networkconv.pyx":846
 *             dist_pred_from += self.pred_dist_table.shape[1]
 * 
 *         self._create_target_lookup()             # <<<<<<<<<<<<<<
 *         self._create_pred_lookup()
 * 
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_target_lookup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 846, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 846, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":847
 * 
 *         self._create_target_lookup()
 *         self._create_pred_lookup()             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_create_pred_lookup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 847, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":797
 * 
 * 
 *     def _adjust_features(self, sentence, predicate):             # <<<<<<<<<<<<<<
 *         """Adjusts the features in all feature tables."""
 *         # compute each token in the window separately and
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(((PyObject *)__pyx_t_18));
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._adjust_features", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_start_from);
  __Pyx_XDECREF(__pyx_v_dist_target_from);
  __Pyx_XDECREF(__pyx_v_dist_pred_from);
  __Pyx_XDECREF(__pyx_v_pre_dist);
  __Pyx_XDECREF(__pyx_v_pos_dist);
  __Pyx_XDECREF(__pyx_v_padded_sentence);
  __Pyx_XDECREF(__pyx_v_j);
  __Pyx_XDECREF(__pyx_v_table);
  __Pyx_XDECREF(__pyx_v_table_deltas);
  __Pyx_XDECREF(__pyx_v_token);
  __Pyx_XDECREF(__pyx_v_deltas);
  __Pyx_XDECREF(__pyx_v_dist_deltas);
  __Pyx_XDECREF(__pyx_v_pre_deltas);
  __Pyx_XDECREF(__pyx_v_pos_deltas);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":850
 * 
 *     @cython.boundscheck(False)
 *     def _viterbi(self, np.ndarray[FLOAT_t, ndim=2] scores, bool allow_repeats=True):             # <<<<<<<<<<<<<<
 *         """
 *         Performs a Viterbi search over the scores for each tag using
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_49_viterbi(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_48_viterbi[] = "ConvolutionalNetwork._viterbi(self, ndarray scores, bool allow_repeats=True)\n\n        Performs a Viterbi search over the scores for each tag using\n        the transitions matrix. If a matrix wasn't supplied, \n        it will return the tags with the highest scores individually.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_49_viterbi(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_scores = 0;
  PyBoolObject *__pyx_v_allow_repeats = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_viterbi (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_scores,&__pyx_n_s_allow_repeats,0};
    PyObject* values[2] = {0,0};
    values[1] = (PyObject *)((PyBoolObject *)Py_True);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_scores)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allow_repeats);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_viterbi") < 0)) __PYX_ERR(1, 850, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_scores = ((PyArrayObject *)values[0]);
    __pyx_v_allow_repeats = ((PyBoolObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_viterbi", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 850, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._viterbi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_scores), __pyx_ptype_5numpy_ndarray, 1, "scores", 0))) __PYX_ERR(1, 850, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_allow_repeats), __pyx_ptype_7cpython_4bool_bool, 1, "allow_repeats", 0))) __PYX_ERR(1, 850, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_48_viterbi(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_scores, __pyx_v_allow_repeats);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_48_viterbi(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyArrayObject *__pyx_v_scores, PyBoolObject *__pyx_v_allow_repeats) {
  PyObject *__pyx_v_best_scores = NULL;
  PyObject *__pyx_v_logadd = NULL;
  PyObject *__pyx_v_logprobs = NULL;
  PyObject *__pyx_v_counts = NULL;
  PyObject *__pyx_v_conflicting_tag = NULL;
  PyObject *__pyx_v_args = NULL;
  PyObject *__pyx_v_conflicting_probs = NULL;
  PyObject *__pyx_v_highest_prob_arg = NULL;
  PyObject *__pyx_v_other_args = NULL;
  PyObject *__pyx_v_path_scores = NULL;
  PyObject *__pyx_v_path_backtrack = NULL;
  PyObject *__pyx_v_i = NULL;
  CYTHON_UNUSED PyObject *__pyx_v_token = NULL;
  PyObject *__pyx_v_prev_score_and_trans = NULL;
  PyObject *__pyx_v_answer = NULL;
  PyObject *__pyx_v_previous_tag = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_scores;
  __Pyx_Buffer __pyx_pybuffer_scores;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  float __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_viterbi", 0);
  __Pyx_TraceCall("_viterbi", __pyx_f[1], 850, 0, __PYX_ERR(1, 850, __pyx_L1_error));
  __pyx_pybuffer_scores.pybuffer.buf = NULL;
  __pyx_pybuffer_scores.refcount = 0;
  __pyx_pybuffernd_scores.data = NULL;
  __pyx_pybuffernd_scores.rcbuffer = &__pyx_pybuffer_scores;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_scores.rcbuffer->pybuffer, (PyObject*)__pyx_v_scores, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) __PYX_ERR(1, 850, __pyx_L1_error)
  }
  __pyx_pybuffernd_scores.diminfo[0].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_scores.diminfo[0].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_scores.diminfo[1].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_scores.diminfo[1].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[1];

  /* "networkconv.pyx":856
 *         it will return the tags with the highest scores individually.
 *         """
 *         if self.transitions is None:             # <<<<<<<<<<<<<<
 *             best_scores = scores.argmax(1)
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_self->__pyx_base.transitions) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "networkconv.pyx":857
 *         """
 *         if self.transitions is None:
 *             best_scores = scores.argmax(1)             # <<<<<<<<<<<<<<
 * 
 *             if allow_repeats:
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_scores), __pyx_n_s_argmax); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_int_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_int_1);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_best_scores = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "networkconv.pyx":859
 *             best_scores = scores.argmax(1)
 * 
 *             if allow_repeats:             # <<<<<<<<<<<<<<
 *                 return best_scores
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_allow_repeats)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 859, __pyx_L1_error)
    if (__pyx_t_2) {

      /* "networkconv.pyx":860
 * 
 *             if allow_repeats:
 *                 return best_scores             # <<<<<<<<<<<<<<
 * 
 *             # we must find the combination of tags that maximizes the probabilities
 */
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_best_scores);
      __pyx_r = __pyx_v_best_scores;
      goto __pyx_L0;

      /* "networkconv.pyx":859
 *             best_scores = scores.argmax(1)
 * 
 *             if allow_repeats:             # <<<<<<<<<<<<<<
 *                 return best_scores
 * 
 */
    }

    /* "networkconv.pyx":863
 * 
 *             # we must find the combination of tags that maximizes the probabilities
 *             logadd = np.log(np.sum(np.exp(scores), 1))             # <<<<<<<<<<<<<<
 *             logprobs = (scores.T - logadd).T
 *             counts = np.bincount(best_scores)
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_log); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_sum); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_exp); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_8, ((PyObject *)__pyx_v_scores)) : __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_scores));
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    __pyx_t_10 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_7, function);
        __pyx_t_10 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_6, __pyx_int_1};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 863, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_6, __pyx_int_1};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 863, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 863, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_9) {
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL;
      }
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_10, __pyx_t_6);
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_10, __pyx_int_1);
      __pyx_t_6 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 863, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 863, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_logadd = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "networkconv.pyx":864
 *             # we must find the combination of tags that maximizes the probabilities
 *             logadd = np.log(np.sum(np.exp(scores), 1))
 *             logprobs = (scores.T - logadd).T             # <<<<<<<<<<<<<<
 *             counts = np.bincount(best_scores)
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_scores), __pyx_n_s_T); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 864, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyNumber_Subtract(__pyx_t_3, __pyx_v_logadd); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 864, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_T); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 864, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_logprobs = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "networkconv.pyx":865
 *             logadd = np.log(np.sum(np.exp(scores), 1))
 *             logprobs = (scores.T - logadd).T
 *             counts = np.bincount(best_scores)             # <<<<<<<<<<<<<<
 * 
 *             while counts.max() != 1:
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_bincount); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_best_scores) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_best_scores);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 865, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_counts = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "networkconv.pyx":867
 *             counts = np.bincount(best_scores)
 * 
 *             while counts.max() != 1:             # <<<<<<<<<<<<<<
 *                 # find the tag with the most conflicting args
 *                 conflicting_tag = counts.argmax()
 */
    while (1) {
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_counts, __pyx_n_s_max); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyInt_NeObjC(__pyx_t_3, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 867, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_2) break;

      /* "networkconv.pyx":869
 *             while counts.max() != 1:
 *                 # find the tag with the most conflicting args
 *                 conflicting_tag = counts.argmax()             # <<<<<<<<<<<<<<
 * 
 *                 # arguments with that tag as current maximum
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_counts, __pyx_n_s_argmax); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF_SET(__pyx_v_conflicting_tag, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "networkconv.pyx":872
 * 
 *                 # arguments with that tag as current maximum
 *                 args = np.where(best_scores == conflicting_tag)[0]             # <<<<<<<<<<<<<<
 * 
 *                 # get the logprobs for those args having this tag
 */
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_where); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_best_scores, __pyx_v_conflicting_tag, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 872, __pyx_L1_error)
      __pyx_t_7 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_7)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 872, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_args, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "networkconv.pyx":875
 * 
 *                 # get the logprobs for those args having this tag
 *                 conflicting_probs = logprobs[args, conflicting_tag]             # <<<<<<<<<<<<<<
 * 
 *                 # find the argument with the highest probability for that tag
 */
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 875, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_args);
      __Pyx_GIVEREF(__pyx_v_args);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_args);
      __Pyx_INCREF(__pyx_v_conflicting_tag);
      __Pyx_GIVEREF(__pyx_v_conflicting_tag);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_conflicting_tag);
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_logprobs, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 875, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_conflicting_probs, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "networkconv.pyx":878
 * 
 *                 # find the argument with the highest probability for that tag
 *                 highest_prob_arg = args[conflicting_probs.argmax()]             # <<<<<<<<<<<<<<
 * 
 *                 # set the score for other arguments in that tag to a low value
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_conflicting_probs, __pyx_n_s_argmax); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 878, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 878, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_args, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 878, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF_SET(__pyx_v_highest_prob_arg, __pyx_t_5);
      __pyx_t_5 = 0;

      /* "networkconv.pyx":881
 * 
 *                 # set the score for other arguments in that tag to a low value
 *                 other_args = args[args != highest_prob_arg]             # <<<<<<<<<<<<<<
 *                 scores[other_args, conflicting_tag] = -1000
 * 
 */
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_args, __pyx_v_highest_prob_arg, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 881, __pyx_L1_error)
      __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_args, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF_SET(__pyx_v_other_args, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "networkconv.pyx":882
 *                 # set the score for other arguments in that tag to a low value
 *                 other_args = args[args != highest_prob_arg]
 *                 scores[other_args, conflicting_tag] = -1000             # <<<<<<<<<<<<<<
 * 
 *                 # and find the new maxes, without recalculating probabilities
 */
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 882, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_other_args);
      __Pyx_GIVEREF(__pyx_v_other_args);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_other_args);
      __Pyx_INCREF(__pyx_v_conflicting_tag);
      __Pyx_GIVEREF(__pyx_v_conflicting_tag);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_conflicting_tag);
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_scores), __pyx_t_4, __pyx_int_neg_1000) < 0)) __PYX_ERR(1, 882, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "networkconv.pyx":885
 * 
 *                 # and find the new maxes, without recalculating probabilities
 *                 best_scores = scores.argmax(1)             # <<<<<<<<<<<<<<
 *                 counts = np.bincount(best_scores)
 * 
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_scores), __pyx_n_s_argmax); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 885, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, __pyx_int_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_int_1);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 885, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_best_scores, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "networkconv.pyx":886
 *                 # and find the new maxes, without recalculating probabilities
 *                 best_scores = scores.argmax(1)
 *                 counts = np.bincount(best_scores)             # <<<<<<<<<<<<<<
 * 
 *             return best_scores
 */
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_bincount); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_v_best_scores) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_best_scores);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 886, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF_SET(__pyx_v_counts, __pyx_t_4);
      __pyx_t_4 = 0;
    }

    /* "networkconv.pyx":888
 *                 counts = np.bincount(best_scores)
 * 
 *             return best_scores             # <<<<<<<<<<<<<<
 * 
 *         path_scores = np.empty_like(scores)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_best_scores);
    __pyx_r = __pyx_v_best_scores;
    goto __pyx_L0;

    /* "networkconv.pyx":856
 *         it will return the tags with the highest scores individually.
 *         """
 *         if self.transitions is None:             # <<<<<<<<<<<<<<
 *             best_scores = scores.argmax(1)
 * 
 */
  }

  /* "networkconv.pyx":890
 *             return best_scores
 * 
 *         path_scores = np.empty_like(scores)             # <<<<<<<<<<<<<<
 *         path_backtrack = np.empty_like(scores, int)
 *         #path_backtrack = np.empty_like(scores, np.int)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty_like); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_v_scores)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_scores));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_path_scores = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "networkconv.pyx":891
 * 
 *         path_scores = np.empty_like(scores)
 *         path_backtrack = np.empty_like(scores, int)             # <<<<<<<<<<<<<<
 *         #path_backtrack = np.empty_like(scores, np.int)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty_like); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 891, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_scores), ((PyObject *)(&PyInt_Type))};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 891, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_scores), ((PyObject *)(&PyInt_Type))};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 891, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_7 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_scores));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_scores));
    PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_10, ((PyObject *)__pyx_v_scores));
    __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
    __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
    PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_10, ((PyObject *)(&PyInt_Type)));
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 891, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_path_backtrack = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "networkconv.pyx":897
 *         # first, get the scores for each tag at token 0
 *         # the last row of the transitions table has the scores for the first tag
 *         path_scores[0] = scores[0] + self.transitions[-1]             # <<<<<<<<<<<<<<
 * 
 *         for i, token in enumerate(scores[1:], 1):
 */
  __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_v_scores), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->__pyx_base.transitions), -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 897, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(__Pyx_SetItemInt(__pyx_v_path_scores, 0, __pyx_t_7, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(1, 897, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "networkconv.pyx":899
 *         path_scores[0] = scores[0] + self.transitions[-1]
 * 
 *         for i, token in enumerate(scores[1:], 1):             # <<<<<<<<<<<<<<
 * 
 *             # each line contains the score until each tag t plus the transition to each other tag t'
 */
  __Pyx_INCREF(__pyx_int_1);
  __pyx_t_7 = __pyx_int_1;
  __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_scores), __pyx_slice__11); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_11 = 0;
    __pyx_t_12 = NULL;
  } else {
    __pyx_t_11 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 899, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 899, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_12)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(1, 899, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 899, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(1, 899, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 899, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_12(__pyx_t_4);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 899, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_token, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_7);
    __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_7, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 899, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7);
    __pyx_t_7 = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "networkconv.pyx":902
 * 
 *             # each line contains the score until each tag t plus the transition to each other tag t'
 *             prev_score_and_trans = (path_scores[i - 1] + self.transitions[:-1].T).T             # <<<<<<<<<<<<<<
 * 
 *             # find the previous tag that yielded the max score
 */
    __pyx_t_3 = __Pyx_PyInt_SubtractObjC(__pyx_v_i, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_path_scores, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_self->__pyx_base.transitions), 0, -1L, NULL, NULL, &__pyx_slice__4, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_T); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_T); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 902, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_prev_score_and_trans, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "networkconv.pyx":905
 * 
 *             # find the previous tag that yielded the max score
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)             # <<<<<<<<<<<<<<
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],
 *                                                   np.arange(self.output_size)] + scores[i]
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_prev_score_and_trans, __pyx_n_s_argmax); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_8 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_int_0);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(PyObject_SetItem(__pyx_v_path_backtrack, __pyx_v_i, __pyx_t_8) < 0)) __PYX_ERR(1, 905, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "networkconv.pyx":906
 *             # find the previous tag that yielded the max score
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],             # <<<<<<<<<<<<<<
 *                                                   np.arange(self.output_size)] + scores[i]
 * 
 */
    __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_path_backtrack, __pyx_v_i); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 906, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);

    /* "networkconv.pyx":907
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],
 *                                                   np.arange(self.output_size)] + scores[i]             # <<<<<<<<<<<<<<
 * 
 *         # now find the maximum score for the last token and follow the backtrack
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_arange); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.output_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_9, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "networkconv.pyx":906
 *             # find the previous tag that yielded the max score
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],             # <<<<<<<<<<<<<<
 *                                                   np.arange(self.output_size)] + scores[i]
 * 
 */
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 906, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
    __pyx_t_8 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_prev_score_and_trans, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 906, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "networkconv.pyx":907
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],
 *                                                   np.arange(self.output_size)] + scores[i]             # <<<<<<<<<<<<<<
 * 
 *         # now find the maximum score for the last token and follow the backtrack
 */
    __pyx_t_6 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_scores), __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 907, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "networkconv.pyx":906
 *             # find the previous tag that yielded the max score
 *             path_backtrack[i] = prev_score_and_trans.argmax(0)
 *             path_scores[i] = prev_score_and_trans[path_backtrack[i],             # <<<<<<<<<<<<<<
 *                                                   np.arange(self.output_size)] + scores[i]
 * 
 */
    if (unlikely(PyObject_SetItem(__pyx_v_path_scores, __pyx_v_i, __pyx_t_8) < 0)) __PYX_ERR(1, 906, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "networkconv.pyx":899
 *         path_scores[0] = scores[0] + self.transitions[-1]
 * 
 *         for i, token in enumerate(scores[1:], 1):             # <<<<<<<<<<<<<<
 * 
 *             # each line contains the score until each tag t plus the transition to each other tag t'
 */
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "networkconv.pyx":910
 * 
 *         # now find the maximum score for the last token and follow the backtrack
 *         answer = np.empty(len(scores), dtype=int)             # <<<<<<<<<<<<<<
 *         #answer = np.empty(len(scores), dtype=np.int)
 *         answer[-1] = path_scores[-1].argmax()
 */
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_11 = PyObject_Length(((PyObject *)__pyx_v_scores)); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(1, 910, __pyx_L1_error)
  __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(1, 910, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 910, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_answer = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "networkconv.pyx":912
 *         answer = np.empty(len(scores), dtype=int)
 *         #answer = np.empty(len(scores), dtype=np.int)
 *         answer[-1] = path_scores[-1].argmax()             # <<<<<<<<<<<<<<
 *         self.answer_score = path_scores[-1][answer[-1]]
 *         previous_tag = path_backtrack[-1][answer[-1]]
 */
  __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_path_scores, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_argmax); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_6 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 912, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (unlikely(__Pyx_SetItemInt(__pyx_v_answer, -1L, __pyx_t_6, long, 1, __Pyx_PyInt_From_long, 0, 1, 0) < 0)) __PYX_ERR(1, 912, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "networkconv.pyx":913
 *         #answer = np.empty(len(scores), dtype=np.int)
 *         answer[-1] = path_scores[-1].argmax()
 *         self.answer_score = path_scores[-1][answer[-1]]             # <<<<<<<<<<<<<<
 *         previous_tag = path_backtrack[-1][answer[-1]]
 * 
 */
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_path_scores, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 913, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_answer, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 913, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 913, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_13 = __pyx_PyFloat_AsFloat(__pyx_t_7); if (unlikely((__pyx_t_13 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 913, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_self->__pyx_base.answer_score = __pyx_t_13;

  /* "networkconv.pyx":914
 *         answer[-1] = path_scores[-1].argmax()
 *         self.answer_score = path_scores[-1][answer[-1]]
 *         previous_tag = path_backtrack[-1][answer[-1]]             # <<<<<<<<<<<<<<
 * 
 *         for i in range(len(scores) - 2, 0, -1):
 */
  __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_path_backtrack, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_answer, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 914, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_previous_tag = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "networkconv.pyx":916
 *         previous_tag = path_backtrack[-1][answer[-1]]
 * 
 *         for i in range(len(scores) - 2, 0, -1):             # <<<<<<<<<<<<<<
 *             answer[i] = previous_tag
 *             previous_tag = path_backtrack[i][previous_tag]
 */
  __pyx_t_11 = PyObject_Length(((PyObject *)__pyx_v_scores)); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(1, 916, __pyx_L1_error)
  __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_11 - 2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_0);
  __Pyx_INCREF(__pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_neg_1);
  __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 916, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_8 = __pyx_t_6; __Pyx_INCREF(__pyx_t_8); __pyx_t_11 = 0;
    __pyx_t_12 = NULL;
  } else {
    __pyx_t_11 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 916, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_12 = Py_TYPE(__pyx_t_8)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 916, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (likely(!__pyx_t_12)) {
      if (likely(PyList_CheckExact(__pyx_t_8))) {
        if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_6); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(1, 916, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 916, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      } else {
        if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_11); __Pyx_INCREF(__pyx_t_6); __pyx_t_11++; if (unlikely(0 < 0)) __PYX_ERR(1, 916, __pyx_L1_error)
        #else
        __pyx_t_6 = PySequence_ITEM(__pyx_t_8, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 916, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        #endif
      }
    } else {
      __pyx_t_6 = __pyx_t_12(__pyx_t_8);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 916, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "networkconv.pyx":917
 * 
 *         for i in range(len(scores) - 2, 0, -1):
 *             answer[i] = previous_tag             # <<<<<<<<<<<<<<
 *             previous_tag = path_backtrack[i][previous_tag]
 * 
 */
    if (unlikely(PyObject_SetItem(__pyx_v_answer, __pyx_v_i, __pyx_v_previous_tag) < 0)) __PYX_ERR(1, 917, __pyx_L1_error)

    /* "networkconv.pyx":918
 *         for i in range(len(scores) - 2, 0, -1):
 *             answer[i] = previous_tag
 *             previous_tag = path_backtrack[i][previous_tag]             # <<<<<<<<<<<<<<
 * 
 *         answer[0] = previous_tag
 */
    __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_path_backtrack, __pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_v_previous_tag); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 918, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_previous_tag, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "networkconv.pyx":916
 *         previous_tag = path_backtrack[-1][answer[-1]]
 * 
 *         for i in range(len(scores) - 2, 0, -1):             # <<<<<<<<<<<<<<
 *             answer[i] = previous_tag
 *             previous_tag = path_backtrack[i][previous_tag]
 */
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "networkconv.pyx":920
 *             previous_tag = path_backtrack[i][previous_tag]
 * 
 *         answer[0] = previous_tag             # <<<<<<<<<<<<<<
 *         return answer
 * 
 */
  if (unlikely(__Pyx_SetItemInt(__pyx_v_answer, 0, __pyx_v_previous_tag, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(1, 920, __pyx_L1_error)

  /* "networkconv.pyx":921
 * 
 *         answer[0] = previous_tag
 *         return answer             # <<<<<<<<<<<<<<
 * 
 *     def _create_target_lookup(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_answer);
  __pyx_r = __pyx_v_answer;
  goto __pyx_L0;

  /* "networkconv.pyx":850
 * 
 *     @cython.boundscheck(False)
 *     def _viterbi(self, np.ndarray[FLOAT_t, ndim=2] scores, bool allow_repeats=True):             # <<<<<<<<<<<<<<
 *         """
 *         Performs a Viterbi search over the scores for each tag using
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._viterbi", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_best_scores);
  __Pyx_XDECREF(__pyx_v_logadd);
  __Pyx_XDECREF(__pyx_v_logprobs);
  __Pyx_XDECREF(__pyx_v_counts);
  __Pyx_XDECREF(__pyx_v_conflicting_tag);
  __Pyx_XDECREF(__pyx_v_args);
  __Pyx_XDECREF(__pyx_v_conflicting_probs);
  __Pyx_XDECREF(__pyx_v_highest_prob_arg);
  __Pyx_XDECREF(__pyx_v_other_args);
  __Pyx_XDECREF(__pyx_v_path_scores);
  __Pyx_XDECREF(__pyx_v_path_backtrack);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_token);
  __Pyx_XDECREF(__pyx_v_prev_score_and_trans);
  __Pyx_XDECREF(__pyx_v_answer);
  __Pyx_XDECREF(__pyx_v_previous_tag);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":923
 *         return answer
 * 
 *     def _create_target_lookup(self):             # <<<<<<<<<<<<<<
 *         """
 *         Creates a lookup table with the window value for each different distance
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_51_create_target_lookup(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_50_create_target_lookup[] = "ConvolutionalNetwork._create_target_lookup(self)\n\n        Creates a lookup table with the window value for each different distance\n        to the target token (target_dist_lookup) and one with the precomputed\n        values in the convolution layer (target_convolution_lookup). \n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_51_create_target_lookup(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_target_lookup (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_50_create_target_lookup(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_50_create_target_lookup(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_v_num_distances = NULL;
  PyObject *__pyx_v_window_from = NULL;
  PyObject *__pyx_v_window_to = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_shift = NULL;
  PyObject *__pyx_v_inds = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_target_lookup", 0);
  __Pyx_TraceCall("_create_target_lookup", __pyx_f[1], 923, 0, __PYX_ERR(1, 923, __pyx_L1_error));

  /* "networkconv.pyx":931
 *         # consider padding. if the table has 10 entries, with a word window of 3,
 *         # we would have to consider up to the distance of 11, because of the padding.
 *         num_distances = self.target_dist_table.shape[0] + self.word_window_size - 1             # <<<<<<<<<<<<<<
 *         self.target_dist_lookup = np.empty((num_distances,
 *                                             self.word_window_size * self.target_dist_table.shape[1]))
 */
  __pyx_t_1 = __Pyx_PyInt_From_long((((__pyx_v_self->target_dist_table->dimensions[0]) + __pyx_v_self->__pyx_base.word_window_size) - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 931, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_num_distances = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":932
 *         # we would have to consider up to the distance of 11, because of the padding.
 *         num_distances = self.target_dist_table.shape[0] + self.word_window_size - 1
 *         self.target_dist_lookup = np.empty((num_distances,             # <<<<<<<<<<<<<<
 *                                             self.word_window_size * self.target_dist_table.shape[1]))
 *         self.target_dist_offset = num_distances / 2
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 932, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 932, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":933
 *         num_distances = self.target_dist_table.shape[0] + self.word_window_size - 1
 *         self.target_dist_lookup = np.empty((num_distances,
 *                                             self.word_window_size * self.target_dist_table.shape[1]))             # <<<<<<<<<<<<<<
 *         self.target_dist_offset = num_distances / 2
 *         window_from = 0
 */
  __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->__pyx_base.word_window_size * (__pyx_v_self->target_dist_table->dimensions[1]))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 933, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "networkconv.pyx":932
 *         # we would have to consider up to the distance of 11, because of the padding.
 *         num_distances = self.target_dist_table.shape[0] + self.word_window_size - 1
 *         self.target_dist_lookup = np.empty((num_distances,             # <<<<<<<<<<<<<<
 *                                             self.word_window_size * self.target_dist_table.shape[1]))
 *         self.target_dist_offset = num_distances / 2
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 932, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_num_distances);
  __Pyx_GIVEREF(__pyx_v_num_distances);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_num_distances);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 932, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 932, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->target_dist_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->target_dist_lookup));
  __pyx_v_self->target_dist_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":934
 *         self.target_dist_lookup = np.empty((num_distances,
 *                                             self.word_window_size * self.target_dist_table.shape[1]))
 *         self.target_dist_offset = num_distances / 2             # <<<<<<<<<<<<<<
 *         window_from = 0
 *         window_to = self.target_dist_table.shape[1]
 */
  __pyx_t_1 = __Pyx_PyInt_TrueDivideObjC(__pyx_v_num_distances, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 934, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 934, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->target_dist_offset = __pyx_t_5;

  /* "networkconv.pyx":935
 *                                             self.word_window_size * self.target_dist_table.shape[1]))
 *         self.target_dist_offset = num_distances / 2
 *         window_from = 0             # <<<<<<<<<<<<<<
 *         window_to = self.target_dist_table.shape[1]
 *         for i in range(self.word_window_size):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_window_from = __pyx_int_0;

  /* "networkconv.pyx":936
 *         self.target_dist_offset = num_distances / 2
 *         window_from = 0
 *         window_to = self.target_dist_table.shape[1]             # <<<<<<<<<<<<<<
 *         for i in range(self.word_window_size):
 *             # each token in the window will is shifted in relation to the middle one
 */
  __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->target_dist_table->dimensions[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 936, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_window_to = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":937
 *         window_from = 0
 *         window_to = self.target_dist_table.shape[1]
 *         for i in range(self.word_window_size):             # <<<<<<<<<<<<<<
 *             # each token in the window will is shifted in relation to the middle one
 *             shift = i - self.half_window
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.word_window_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 937, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 937, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 937, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 937, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 937, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 937, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 937, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 937, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":939
 *         for i in range(self.word_window_size):
 *             # each token in the window will is shifted in relation to the middle one
 *             shift = i - self.half_window             # <<<<<<<<<<<<<<
 * 
 *             # discount half window size because of the extra distances we added for padding
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->half_window); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 939, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Subtract(__pyx_v_i, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 939, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_shift, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "networkconv.pyx":942
 * 
 *             # discount half window size because of the extra distances we added for padding
 *             inds = np.arange(shift, num_distances + shift) - self.half_window             # <<<<<<<<<<<<<<
 *             inds = np.clip(inds, 0, self.target_dist_table.shape[0] - 1)
 *             self.target_dist_lookup[:,window_from : window_to] = self.target_dist_table[inds,]
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 942, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_arange); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 942, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_v_num_distances, __pyx_v_shift); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 942, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_shift, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 942, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_shift, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 942, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(__pyx_v_shift);
      __Pyx_GIVEREF(__pyx_v_shift);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, __pyx_v_shift);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 942, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->half_window); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 942, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = PyNumber_Subtract(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 942, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_inds, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "networkconv.pyx":943
 *             # discount half window size because of the extra distances we added for padding
 *             inds = np.arange(shift, num_distances + shift) - self.half_window
 *             inds = np.clip(inds, 0, self.target_dist_table.shape[0] - 1)             # <<<<<<<<<<<<<<
 *             self.target_dist_lookup[:,window_from : window_to] = self.target_dist_table[inds,]
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_clip); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_self->target_dist_table->dimensions[0]) - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 943, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_inds, __pyx_int_0, __pyx_t_2};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 943, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_inds, __pyx_int_0, __pyx_t_2};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 943, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 943, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_v_inds);
      __Pyx_GIVEREF(__pyx_v_inds);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_5, __pyx_v_inds);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_5, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_5, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 943, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_inds, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "networkconv.pyx":944
 *             inds = np.arange(shift, num_distances + shift) - self.half_window
 *             inds = np.clip(inds, 0, self.target_dist_table.shape[0] - 1)
 *             self.target_dist_lookup[:,window_from : window_to] = self.target_dist_table[inds,]             # <<<<<<<<<<<<<<
 * 
 *             window_from = window_to
 */
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 944, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_inds);
    __Pyx_GIVEREF(__pyx_v_inds);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_inds);
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->target_dist_table), __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 944, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PySlice_New(__pyx_v_window_from, __pyx_v_window_to, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 944, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 944, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_slice__3);
    __Pyx_GIVEREF(__pyx_slice__3);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_slice__3);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
    __pyx_t_9 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->target_dist_lookup), __pyx_t_8, __pyx_t_4) < 0)) __PYX_ERR(1, 944, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "networkconv.pyx":946
 *             self.target_dist_lookup[:,window_from : window_to] = self.target_dist_table[inds,]
 * 
 *             window_from = window_to             # <<<<<<<<<<<<<<
 *             window_to += self.target_dist_table.shape[1]
 * 
 */
    __Pyx_INCREF(__pyx_v_window_to);
    __Pyx_DECREF_SET(__pyx_v_window_from, __pyx_v_window_to);

    /* "networkconv.pyx":947
 * 
 *             window_from = window_to
 *             window_to += self.target_dist_table.shape[1]             # <<<<<<<<<<<<<<
 * 
 *         self.target_convolution_lookup = self.target_dist_lookup.dot(self.target_dist_weights)
 */
    __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->target_dist_table->dimensions[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 947, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_v_window_to, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 947, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_window_to, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "networkconv.pyx":937
 *         window_from = 0
 *         window_to = self.target_dist_table.shape[1]
 *         for i in range(self.word_window_size):             # <<<<<<<<<<<<<<
 *             # each token in the window will is shifted in relation to the middle one
 *             shift = i - self.half_window
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":949
 *             window_to += self.target_dist_table.shape[1]
 * 
 *         self.target_convolution_lookup = self.target_dist_lookup.dot(self.target_dist_weights)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->target_dist_lookup), __pyx_n_s_dot); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_4, ((PyObject *)__pyx_v_self->target_dist_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_self->target_dist_weights));
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 949, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 949, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->target_convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->target_convolution_lookup));
  __pyx_v_self->target_convolution_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":923
 *         return answer
 * 
 *     def _create_target_lookup(self):             # <<<<<<<<<<<<<<
 *         """
 *         Creates a lookup table with the window value for each different distance
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._create_target_lookup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_num_distances);
  __Pyx_XDECREF(__pyx_v_window_from);
  __Pyx_XDECREF(__pyx_v_window_to);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_shift);
  __Pyx_XDECREF(__pyx_v_inds);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":952
 * 
 * 
 *     def _create_pred_lookup(self):             # <<<<<<<<<<<<<<
 *         """
 *         Creates a lookup table with the window value for each different distance
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_53_create_pred_lookup(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_52_create_pred_lookup[] = "ConvolutionalNetwork._create_pred_lookup(self)\n\n        Creates a lookup table with the window value for each different distance\n        to the predicate token (pred_dist_lookup) and one with the precomputed\n        values in the convolution layer (pred_convolution_lookup). \n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_53_create_pred_lookup(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_pred_lookup (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_52_create_pred_lookup(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_52_create_pred_lookup(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_v_num_distances = NULL;
  PyObject *__pyx_v_window_from = NULL;
  PyObject *__pyx_v_window_to = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_shift = NULL;
  PyObject *__pyx_v_inds = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_pred_lookup", 0);
  __Pyx_TraceCall("_create_pred_lookup", __pyx_f[1], 952, 0, __PYX_ERR(1, 952, __pyx_L1_error));

  /* "networkconv.pyx":960
 *         # consider padding. if the table has 10 entries, with a word window of 3,
 *         # we would have to consider up to the distance of 11, because of the padding.
 *         num_distances = self.pred_dist_table.shape[0] + self.word_window_size - 1             # <<<<<<<<<<<<<<
 *         self.pred_dist_lookup = np.empty((num_distances,
 *                                           self.word_window_size * self.pred_dist_table.shape[1]))
 */
  __pyx_t_1 = __Pyx_PyInt_From_long((((__pyx_v_self->pred_dist_table->dimensions[0]) + __pyx_v_self->__pyx_base.word_window_size) - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 960, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_num_distances = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":961
 *         # we would have to consider up to the distance of 11, because of the padding.
 *         num_distances = self.pred_dist_table.shape[0] + self.word_window_size - 1
 *         self.pred_dist_lookup = np.empty((num_distances,             # <<<<<<<<<<<<<<
 *                                           self.word_window_size * self.pred_dist_table.shape[1]))
 *         self.pred_dist_offset = num_distances / 2
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":962
 *         num_distances = self.pred_dist_table.shape[0] + self.word_window_size - 1
 *         self.pred_dist_lookup = np.empty((num_distances,
 *                                           self.word_window_size * self.pred_dist_table.shape[1]))             # <<<<<<<<<<<<<<
 *         self.pred_dist_offset = num_distances / 2
 *         window_from = 0
 */
  __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->__pyx_base.word_window_size * (__pyx_v_self->pred_dist_table->dimensions[1]))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 962, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "networkconv.pyx":961
 *         # we would have to consider up to the distance of 11, because of the padding.
 *         num_distances = self.pred_dist_table.shape[0] + self.word_window_size - 1
 *         self.pred_dist_lookup = np.empty((num_distances,             # <<<<<<<<<<<<<<
 *                                           self.word_window_size * self.pred_dist_table.shape[1]))
 *         self.pred_dist_offset = num_distances / 2
 */
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_num_distances);
  __Pyx_GIVEREF(__pyx_v_num_distances);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_num_distances);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 961, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pred_dist_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_dist_lookup));
  __pyx_v_self->pred_dist_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":963
 *         self.pred_dist_lookup = np.empty((num_distances,
 *                                           self.word_window_size * self.pred_dist_table.shape[1]))
 *         self.pred_dist_offset = num_distances / 2             # <<<<<<<<<<<<<<
 *         window_from = 0
 *         window_to = self.pred_dist_table.shape[1]
 */
  __pyx_t_1 = __Pyx_PyInt_TrueDivideObjC(__pyx_v_num_distances, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 963, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 963, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->pred_dist_offset = __pyx_t_5;

  /* "networkconv.pyx":964
 *                                           self.word_window_size * self.pred_dist_table.shape[1]))
 *         self.pred_dist_offset = num_distances / 2
 *         window_from = 0             # <<<<<<<<<<<<<<
 *         window_to = self.pred_dist_table.shape[1]
 *         for i in range(self.word_window_size):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_window_from = __pyx_int_0;

  /* "networkconv.pyx":965
 *         self.pred_dist_offset = num_distances / 2
 *         window_from = 0
 *         window_to = self.pred_dist_table.shape[1]             # <<<<<<<<<<<<<<
 *         for i in range(self.word_window_size):
 *             # each token in the window will is shifted in relation to the middle one
 */
  __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->pred_dist_table->dimensions[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 965, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_window_to = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkconv.pyx":966
 *         window_from = 0
 *         window_to = self.pred_dist_table.shape[1]
 *         for i in range(self.word_window_size):             # <<<<<<<<<<<<<<
 *             # each token in the window will is shifted in relation to the middle one
 *             shift = i - self.half_window
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.word_window_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 966, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 966, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 966, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 966, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 966, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 966, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 966, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 966, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkconv.pyx":968
 *         for i in range(self.word_window_size):
 *             # each token in the window will is shifted in relation to the middle one
 *             shift = i - self.half_window             # <<<<<<<<<<<<<<
 * 
 *             # discount half window size because of the extra distances we added for padding
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_self->half_window); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyNumber_Subtract(__pyx_v_i, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_shift, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "networkconv.pyx":971
 * 
 *             # discount half window size because of the extra distances we added for padding
 *             inds = np.arange(shift, num_distances + shift) - self.half_window             # <<<<<<<<<<<<<<
 *             inds = np.clip(inds, 0, self.pred_dist_table.shape[0] - 1)
 *             self.pred_dist_lookup[:,window_from : window_to] = self.pred_dist_table[inds,]
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_arange); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_v_num_distances, __pyx_v_shift); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_shift, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 971, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_shift, __pyx_t_3};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 971, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 971, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(__pyx_v_shift);
      __Pyx_GIVEREF(__pyx_v_shift);
      PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_5, __pyx_v_shift);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_5, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 971, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->half_window); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = PyNumber_Subtract(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 971, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF_SET(__pyx_v_inds, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "networkconv.pyx":972
 *             # discount half window size because of the extra distances we added for padding
 *             inds = np.arange(shift, num_distances + shift) - self.half_window
 *             inds = np.clip(inds, 0, self.pred_dist_table.shape[0] - 1)             # <<<<<<<<<<<<<<
 *             self.pred_dist_lookup[:,window_from : window_to] = self.pred_dist_table[inds,]
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_clip); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_self->pred_dist_table->dimensions[0]) - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_inds, __pyx_int_0, __pyx_t_2};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 972, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_v_inds, __pyx_int_0, __pyx_t_2};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 972, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 972, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_3) {
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
      }
      __Pyx_INCREF(__pyx_v_inds);
      __Pyx_GIVEREF(__pyx_v_inds);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_5, __pyx_v_inds);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_5, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_5, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 972, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_inds, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "networkconv.pyx":973
 *             inds = np.arange(shift, num_distances + shift) - self.half_window
 *             inds = np.clip(inds, 0, self.pred_dist_table.shape[0] - 1)
 *             self.pred_dist_lookup[:,window_from : window_to] = self.pred_dist_table[inds,]             # <<<<<<<<<<<<<<
 * 
 *             window_from = window_to
 */
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_v_inds);
    __Pyx_GIVEREF(__pyx_v_inds);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_inds);
    __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->pred_dist_table), __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PySlice_New(__pyx_v_window_from, __pyx_v_window_to, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_slice__3);
    __Pyx_GIVEREF(__pyx_slice__3);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_slice__3);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
    __pyx_t_9 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->pred_dist_lookup), __pyx_t_8, __pyx_t_4) < 0)) __PYX_ERR(1, 973, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "networkconv.pyx":975
 *             self.pred_dist_lookup[:,window_from : window_to] = self.pred_dist_table[inds,]
 * 
 *             window_from = window_to             # <<<<<<<<<<<<<<
 *             window_to += self.pred_dist_table.shape[1]
 * 
 */
    __Pyx_INCREF(__pyx_v_window_to);
    __Pyx_DECREF_SET(__pyx_v_window_from, __pyx_v_window_to);

    /* "networkconv.pyx":976
 * 
 *             window_from = window_to
 *             window_to += self.pred_dist_table.shape[1]             # <<<<<<<<<<<<<<
 * 
 *         self.pred_convolution_lookup = self.pred_dist_lookup.dot(self.pred_dist_weights)
 */
    __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->pred_dist_table->dimensions[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 976, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_v_window_to, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 976, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_window_to, __pyx_t_8);
    __pyx_t_8 = 0;

    /* "networkconv.pyx":966
 *         window_from = 0
 *         window_to = self.pred_dist_table.shape[1]
 *         for i in range(self.word_window_size):             # <<<<<<<<<<<<<<
 *             # each token in the window will is shifted in relation to the middle one
 *             shift = i - self.half_window
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":978
 *             window_to += self.pred_dist_table.shape[1]
 * 
 *         self.pred_convolution_lookup = self.pred_dist_lookup.dot(self.pred_dist_weights)             # <<<<<<<<<<<<<<
 * 
 *     def _create_convolution_lookup(self, sentence, training):
 */
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->pred_dist_lookup), __pyx_n_s_dot); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_4, ((PyObject *)__pyx_v_self->pred_dist_weights)) : __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_self->pred_dist_weights));
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 978, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pred_convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_convolution_lookup));
  __pyx_v_self->pred_convolution_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkconv.pyx":952
 * 
 * 
 *     def _create_pred_lookup(self):             # <<<<<<<<<<<<<<
 *         """
 *         Creates a lookup table with the window value for each different distance
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._create_pred_lookup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_num_distances);
  __Pyx_XDECREF(__pyx_v_window_from);
  __Pyx_XDECREF(__pyx_v_window_to);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_shift);
  __Pyx_XDECREF(__pyx_v_inds);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":980
 *         self.pred_convolution_lookup = self.pred_dist_lookup.dot(self.pred_dist_weights)
 * 
 *     def _create_convolution_lookup(self, sentence, training):             # <<<<<<<<<<<<<<
 *         """
 *         Creates a lookup table storing the values found by each
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_55_create_convolution_lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_54_create_convolution_lookup[] = "ConvolutionalNetwork._create_convolution_lookup(self, sentence, training)\n\n        Creates a lookup table storing the values found by each\n        convolutional neuron before summing distance features.\n        The table has the format len(sent) x len(convol layer)\n        Biases are not included.\n        ";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_55_create_convolution_lookup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentence = 0;
  PyObject *__pyx_v_training = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_convolution_lookup (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_training,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_training)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_create_convolution_lookup", 1, 2, 2, 1); __PYX_ERR(1, 980, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_create_convolution_lookup") < 0)) __PYX_ERR(1, 980, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_sentence = values[0];
    __pyx_v_training = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_convolution_lookup", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 980, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._create_convolution_lookup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_54_create_convolution_lookup(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_training);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_54_create_convolution_lookup(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_sentence, PyObject *__pyx_v_training) {
  PyArrayObject *__pyx_v_padded_sentence = 0;
  PyArrayObject *__pyx_v_window = 0;
  PyArrayObject *__pyx_v_input_data = 0;
  PyArrayObject *__pyx_v_new_data = 0;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_element = NULL;
  PyObject *__pyx_8genexpr7__pyx_v_token_indices = NULL;
  PyObject *__pyx_8genexpr7__pyx_v_index = NULL;
  PyObject *__pyx_8genexpr7__pyx_v_table = NULL;
  PyObject *__pyx_8genexpr8__pyx_v_index = NULL;
  PyObject *__pyx_8genexpr8__pyx_v_table = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_new_data;
  __Pyx_Buffer __pyx_pybuffer_new_data;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *(*__pyx_t_15)(PyObject *);
  PyObject *__pyx_t_16 = NULL;
  PyArrayObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_convolution_lookup", 0);
  __Pyx_TraceCall("_create_convolution_lookup", __pyx_f[1], 980, 0, __PYX_ERR(1, 980, __pyx_L1_error));
  __pyx_pybuffer_new_data.pybuffer.buf = NULL;
  __pyx_pybuffer_new_data.refcount = 0;
  __pyx_pybuffernd_new_data.data = NULL;
  __pyx_pybuffernd_new_data.rcbuffer = &__pyx_pybuffer_new_data;

  /* "networkconv.pyx":990
 * 
 *         # add padding to the sentence
 *         if self.word_window_size > 1:             # <<<<<<<<<<<<<<
 *             padded_sentence = np.vstack((self.pre_padding,
 *                                          sentence,
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base.word_window_size > 1) != 0);
  if (__pyx_t_1) {

    /* "networkconv.pyx":991
 *         # add padding to the sentence
 *         if self.word_window_size > 1:
 *             padded_sentence = np.vstack((self.pre_padding,             # <<<<<<<<<<<<<<
 *                                          sentence,
 *                                          self.pos_padding))
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 991, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_vstack); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 991, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkconv.pyx":993
 *             padded_sentence = np.vstack((self.pre_padding,
 *                                          sentence,
 *                                          self.pos_padding))             # <<<<<<<<<<<<<<
 *         else:
 *             padded_sentence = sentence
 */
    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 991, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
    __Pyx_INCREF(__pyx_v_sentence);
    __Pyx_GIVEREF(__pyx_v_sentence);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_sentence);
    __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
    PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 991, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "networkconv.pyx":991
 *         # add padding to the sentence
 *         if self.word_window_size > 1:
 *             padded_sentence = np.vstack((self.pre_padding,             # <<<<<<<<<<<<<<
 *                                          sentence,
 *                                          self.pos_padding))
 */
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 991, __pyx_L1_error)
    __pyx_v_padded_sentence = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;

    /* "networkconv.pyx":990
 * 
 *         # add padding to the sentence
 *         if self.word_window_size > 1:             # <<<<<<<<<<<<<<
 *             padded_sentence = np.vstack((self.pre_padding,
 *                                          sentence,
 */
    goto __pyx_L3;
  }

  /* "networkconv.pyx":995
 *                                          self.pos_padding))
 *         else:
 *             padded_sentence = sentence             # <<<<<<<<<<<<<<
 * 
 *         self.convolution_lookup = np.empty((len(sentence), self.hidden_size))
 */
  /*else*/ {
    if (!(likely(((__pyx_v_sentence) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_sentence, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 995, __pyx_L1_error)
    __pyx_t_2 = __pyx_v_sentence;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_padded_sentence = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "networkconv.pyx":997
 *             padded_sentence = sentence
 * 
 *         self.convolution_lookup = np.empty((len(sentence), self.hidden_size))             # <<<<<<<<<<<<<<
 *         #print(len(sentence), self.hidden_size, len(self.convolution_lookup[0]))
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = PyObject_Length(__pyx_v_sentence); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(1, 997, __pyx_L1_error)
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 997, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 997, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->convolution_lookup));
  __pyx_v_self->convolution_lookup = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":1001
 * 
 *         # first window
 *         cdef np.ndarray window = padded_sentence[:self.word_window_size]             # <<<<<<<<<<<<<<
 *         cdef np.ndarray input_data
 *         input_data = np.concatenate(
 */
  __pyx_t_2 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_padded_sentence), 0, __pyx_v_self->__pyx_base.word_window_size, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1001, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 1001, __pyx_L1_error)
  __pyx_v_window = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":1003
 *         cdef np.ndarray window = padded_sentence[:self.word_window_size]
 *         cdef np.ndarray input_data
 *         input_data = np.concatenate(             # <<<<<<<<<<<<<<
 *                                     [table[index]
 *                                      for token_indices in window
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  { /* enter inner scope */

    /* "networkconv.pyx":1004
 *         cdef np.ndarray input_data
 *         input_data = np.concatenate(
 *                                     [table[index]             # <<<<<<<<<<<<<<
 *                                      for token_indices in window
 *                                      for index, table in zip(token_indices,
 */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1004, __pyx_L6_error)
    __Pyx_GOTREF(__pyx_t_3);

    /* "networkconv.pyx":1005
 *         input_data = np.concatenate(
 *                                     [table[index]
 *                                      for token_indices in window             # <<<<<<<<<<<<<<
 *                                      for index, table in zip(token_indices,
 *                                                              self.feature_tables)
 */
    if (likely(PyList_CheckExact(((PyObject *)__pyx_v_window))) || PyTuple_CheckExact(((PyObject *)__pyx_v_window))) {
      __pyx_t_5 = ((PyObject *)__pyx_v_window); __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
      __pyx_t_8 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(((PyObject *)__pyx_v_window)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1005, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1005, __pyx_L6_error)
    }
    for (;;) {
      if (likely(!__pyx_t_8)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 1005, __pyx_L6_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1005, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        } else {
          if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_4); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 1005, __pyx_L6_error)
          #else
          __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1005, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
        }
      } else {
        __pyx_t_4 = __pyx_t_8(__pyx_t_5);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(1, 1005, __pyx_L6_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_token_indices, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "networkconv.pyx":1006
 *                                     [table[index]
 *                                      for token_indices in window
 *                                      for index, table in zip(token_indices,             # <<<<<<<<<<<<<<
 *                                                              self.feature_tables)
 *                                      ]
 */
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1006, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_8genexpr7__pyx_v_token_indices);
      __Pyx_GIVEREF(__pyx_8genexpr7__pyx_v_token_indices);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_8genexpr7__pyx_v_token_indices);
      __Pyx_INCREF(__pyx_v_self->__pyx_base.feature_tables);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.feature_tables);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->__pyx_base.feature_tables);
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1006, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) {
        __pyx_t_4 = __pyx_t_9; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1006, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_11 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 1006, __pyx_L6_error)
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      for (;;) {
        if (likely(!__pyx_t_11)) {
          if (likely(PyList_CheckExact(__pyx_t_4))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_4)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_9 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_9); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 1006, __pyx_L6_error)
            #else
            __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1006, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_9); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 1006, __pyx_L6_error)
            #else
            __pyx_t_9 = PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1006, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_9);
            #endif
          }
        } else {
          __pyx_t_9 = __pyx_t_11(__pyx_t_4);
          if (unlikely(!__pyx_t_9)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(1, 1006, __pyx_L6_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_9);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
          PyObject* sequence = __pyx_t_9;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(1, 1006, __pyx_L6_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_13 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          #else
          __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1006, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_13 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1006, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          #endif
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_14 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 1006, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_15 = Py_TYPE(__pyx_t_14)->tp_iternext;
          index = 0; __pyx_t_12 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_12)) goto __pyx_L11_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_12);
          index = 1; __pyx_t_13 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_13)) goto __pyx_L11_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_13);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 2) < 0) __PYX_ERR(1, 1006, __pyx_L6_error)
          __pyx_t_15 = NULL;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L12_unpacking_done;
          __pyx_L11_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_15 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(1, 1006, __pyx_L6_error)
          __pyx_L12_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_index, __pyx_t_12);
        __pyx_t_12 = 0;
        __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_table, __pyx_t_13);
        __pyx_t_13 = 0;

        /* "networkconv.pyx":1004
 *         cdef np.ndarray input_data
 *         input_data = np.concatenate(
 *                                     [table[index]             # <<<<<<<<<<<<<<
 *                                      for token_indices in window
 *                                      for index, table in zip(token_indices,
 */
        __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_8genexpr7__pyx_v_table, __pyx_8genexpr7__pyx_v_index); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1004, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_9);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_9))) __PYX_ERR(1, 1004, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "networkconv.pyx":1006
 *                                     [table[index]
 *                                      for token_indices in window
 *                                      for index, table in zip(token_indices,             # <<<<<<<<<<<<<<
 *                                                              self.feature_tables)
 *                                      ]
 */
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "networkconv.pyx":1005
 *         input_data = np.concatenate(
 *                                     [table[index]
 *                                      for token_indices in window             # <<<<<<<<<<<<<<
 *                                      for index, table in zip(token_indices,
 *                                                              self.feature_tables)
 */
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_index); __pyx_8genexpr7__pyx_v_index = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_table); __pyx_8genexpr7__pyx_v_table = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_token_indices); __pyx_8genexpr7__pyx_v_token_indices = 0;
    goto __pyx_L13_exit_scope;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_index); __pyx_8genexpr7__pyx_v_index = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_table); __pyx_8genexpr7__pyx_v_table = 0;
    __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_token_indices); __pyx_8genexpr7__pyx_v_token_indices = 0;
    goto __pyx_L1_error;
    __pyx_L13_exit_scope:;
  } /* exit inner scope */
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1003, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "networkconv.pyx":1003
 *         cdef np.ndarray window = padded_sentence[:self.word_window_size]
 *         cdef np.ndarray input_data
 *         input_data = np.concatenate(             # <<<<<<<<<<<<<<
 *                                     [table[index]
 *                                      for token_indices in window
 */
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 1003, __pyx_L1_error)
  __pyx_v_input_data = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkconv.pyx":1010
 *                                      ]
 *                                     )
 *         self.convolution_lookup[0] = self.hidden_weights.dot(input_data)             # <<<<<<<<<<<<<<
 *         if training:
 *             # store the values of each input -- needed when adjusting features
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.hidden_weights), __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1010, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_3, ((PyObject *)__pyx_v_input_data)) : __Pyx_PyObject_CallOneArg(__pyx_t_7, ((PyObject *)__pyx_v_input_data));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1010, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_self->convolution_lookup), 0, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(1, 1010, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":1011
 *                                     )
 *         self.convolution_lookup[0] = self.hidden_weights.dot(input_data)
 *         if training:             # <<<<<<<<<<<<<<
 *             # store the values of each input -- needed when adjusting features
 *             self.input_sent_values[0] = input_data
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 1011, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "networkconv.pyx":1013
 *         if training:
 *             # store the values of each input -- needed when adjusting features
 *             self.input_sent_values[0] = input_data             # <<<<<<<<<<<<<<
 * 
 *         cdef np.ndarray[FLOAT_t, ndim=1] new_data
 */
    if (unlikely(__Pyx_SetItemInt(((PyObject *)__pyx_v_self->__pyx_base.input_sent_values), 0, ((PyObject *)__pyx_v_input_data), long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(1, 1013, __pyx_L1_error)

    /* "networkconv.pyx":1011
 *                                     )
 *         self.convolution_lookup[0] = self.hidden_weights.dot(input_data)
 *         if training:             # <<<<<<<<<<<<<<
 *             # store the values of each input -- needed when adjusting features
 *             self.input_sent_values[0] = input_data
 */
  }

  /* "networkconv.pyx":1016
 * 
 *         cdef np.ndarray[FLOAT_t, ndim=1] new_data
 *         for i, element in enumerate(padded_sentence[self.word_window_size:], 1):             # <<<<<<<<<<<<<<
 *             new_data = np.concatenate([table[index] for
 *                                        index, table in zip(element, self.feature_tables)])
 */
  __Pyx_INCREF(__pyx_int_1);
  __pyx_t_2 = __pyx_int_1;
  __pyx_t_7 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_padded_sentence), __pyx_v_self->__pyx_base.word_window_size, 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1016, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) {
    __pyx_t_3 = __pyx_t_7; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1016, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 1016, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_3))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 1016, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1016, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      } else {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(1, 1016, __pyx_L1_error)
        #else
        __pyx_t_7 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1016, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        #endif
      }
    } else {
      __pyx_t_7 = __pyx_t_8(__pyx_t_3);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(1, 1016, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_XDECREF_SET(__pyx_v_element, __pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
    __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1016, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2);
    __pyx_t_2 = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "networkconv.pyx":1017
 *         cdef np.ndarray[FLOAT_t, ndim=1] new_data
 *         for i, element in enumerate(padded_sentence[self.word_window_size:], 1):
 *             new_data = np.concatenate([table[index] for             # <<<<<<<<<<<<<<
 *                                        index, table in zip(element, self.feature_tables)])
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1017, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1017, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    { /* enter inner scope */
      __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1017, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_5);

      /* "networkconv.pyx":1018
 *         for i, element in enumerate(padded_sentence[self.word_window_size:], 1):
 *             new_data = np.concatenate([table[index] for
 *                                        index, table in zip(element, self.feature_tables)])             # <<<<<<<<<<<<<<
 * 
 *             # slide the window to the next element
 */
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1018, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_element);
      __Pyx_GIVEREF(__pyx_v_element);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_element);
      __Pyx_INCREF(__pyx_v_self->__pyx_base.feature_tables);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.feature_tables);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_self->__pyx_base.feature_tables);
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_9, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1018, __pyx_L19_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (likely(PyList_CheckExact(__pyx_t_13)) || PyTuple_CheckExact(__pyx_t_13)) {
        __pyx_t_9 = __pyx_t_13; __Pyx_INCREF(__pyx_t_9); __pyx_t_10 = 0;
        __pyx_t_11 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1018, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 1018, __pyx_L19_error)
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      for (;;) {
        if (likely(!__pyx_t_11)) {
          if (likely(PyList_CheckExact(__pyx_t_9))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_9)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_13 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_13); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 1018, __pyx_L19_error)
            #else
            __pyx_t_13 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1018, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_13);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_13 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_10); __Pyx_INCREF(__pyx_t_13); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(1, 1018, __pyx_L19_error)
            #else
            __pyx_t_13 = PySequence_ITEM(__pyx_t_9, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1018, __pyx_L19_error)
            __Pyx_GOTREF(__pyx_t_13);
            #endif
          }
        } else {
          __pyx_t_13 = __pyx_t_11(__pyx_t_9);
          if (unlikely(!__pyx_t_13)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(1, 1018, __pyx_L19_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_13);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_13))) || (PyList_CheckExact(__pyx_t_13))) {
          PyObject* sequence = __pyx_t_13;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(1, 1018, __pyx_L19_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_14 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_14 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_14);
          #else
          __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1018, __pyx_L19_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_14 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 1018, __pyx_L19_error)
          __Pyx_GOTREF(__pyx_t_14);
          #endif
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_16 = PyObject_GetIter(__pyx_t_13); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 1018, __pyx_L19_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_15 = Py_TYPE(__pyx_t_16)->tp_iternext;
          index = 0; __pyx_t_12 = __pyx_t_15(__pyx_t_16); if (unlikely(!__pyx_t_12)) goto __pyx_L22_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_12);
          index = 1; __pyx_t_14 = __pyx_t_15(__pyx_t_16); if (unlikely(!__pyx_t_14)) goto __pyx_L22_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_14);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_16), 2) < 0) __PYX_ERR(1, 1018, __pyx_L19_error)
          __pyx_t_15 = NULL;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          goto __pyx_L23_unpacking_done;
          __pyx_L22_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __pyx_t_15 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(1, 1018, __pyx_L19_error)
          __pyx_L23_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_8genexpr8__pyx_v_index, __pyx_t_12);
        __pyx_t_12 = 0;
        __Pyx_XDECREF_SET(__pyx_8genexpr8__pyx_v_table, __pyx_t_14);
        __pyx_t_14 = 0;

        /* "networkconv.pyx":1017
 *         cdef np.ndarray[FLOAT_t, ndim=1] new_data
 *         for i, element in enumerate(padded_sentence[self.word_window_size:], 1):
 *             new_data = np.concatenate([table[index] for             # <<<<<<<<<<<<<<
 *                                        index, table in zip(element, self.feature_tables)])
 * 
 */
        __pyx_t_13 = __Pyx_PyObject_GetItem(__pyx_8genexpr8__pyx_v_table, __pyx_8genexpr8__pyx_v_index); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 1017, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_13))) __PYX_ERR(1, 1017, __pyx_L19_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_index); __pyx_8genexpr8__pyx_v_index = 0;
      __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_table); __pyx_8genexpr8__pyx_v_table = 0;
      goto __pyx_L24_exit_scope;
      __pyx_L19_error:;
      __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_index); __pyx_8genexpr8__pyx_v_index = 0;
      __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_table); __pyx_8genexpr8__pyx_v_table = 0;
      goto __pyx_L1_error;
      __pyx_L24_exit_scope:;
    } /* exit inner scope */
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_9, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1017, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 1017, __pyx_L1_error)
    __pyx_t_17 = ((PyArrayObject *)__pyx_t_7);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_data.rcbuffer->pybuffer);
      __pyx_t_18 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_data.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_18 < 0)) {
        PyErr_Fetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_new_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_new_data, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_19, __pyx_t_20, __pyx_t_21);
        }
        __pyx_t_19 = __pyx_t_20 = __pyx_t_21 = 0;
      }
      __pyx_pybuffernd_new_data.diminfo[0].strides = __pyx_pybuffernd_new_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_new_data.diminfo[0].shape = __pyx_pybuffernd_new_data.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(1, 1017, __pyx_L1_error)
    }
    __pyx_t_17 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_data, ((PyArrayObject *)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "networkconv.pyx":1021
 * 
 *             # slide the window to the next element
 *             input_data = np.concatenate((input_data[self.features_per_token:],             # <<<<<<<<<<<<<<
 *                                          new_data))
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetSlice(((PyObject *)__pyx_v_input_data), __pyx_v_self->__pyx_base.features_per_token, 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);

    /* "networkconv.pyx":1022
 *             # slide the window to the next element
 *             input_data = np.concatenate((input_data[self.features_per_token:],
 *                                          new_data))             # <<<<<<<<<<<<<<
 * 
 *             #print(i, input_data)
 */
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_new_data));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_new_data));
    PyTuple_SET_ITEM(__pyx_t_9, 1, ((PyObject *)__pyx_v_new_data));
    __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_7 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "networkconv.pyx":1021
 * 
 *             # slide the window to the next element
 *             input_data = np.concatenate((input_data[self.features_per_token:],             # <<<<<<<<<<<<<<
 *                                          new_data))
 * 
 */
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 1021, __pyx_L1_error)
    __Pyx_DECREF_SET(__pyx_v_input_data, ((PyArrayObject *)__pyx_t_7));
    __pyx_t_7 = 0;

    /* "networkconv.pyx":1025
 * 
 *             #print(i, input_data)
 *             self.convolution_lookup[i] = self.hidden_weights.dot(input_data)             # <<<<<<<<<<<<<<
 *             if training:
 *                 self.input_sent_values[i] = input_data
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.hidden_weights), __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    __pyx_t_7 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_9, ((PyObject *)__pyx_v_input_data)) : __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_input_data));
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 1025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->convolution_lookup), __pyx_v_i, __pyx_t_7) < 0)) __PYX_ERR(1, 1025, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "networkconv.pyx":1026
 *             #print(i, input_data)
 *             self.convolution_lookup[i] = self.hidden_weights.dot(input_data)
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.input_sent_values[i] = input_data
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 1026, __pyx_L1_error)
    if (__pyx_t_1) {

      /* "networkconv.pyx":1027
 *             self.convolution_lookup[i] = self.hidden_weights.dot(input_data)
 *             if training:
 *                 self.input_sent_values[i] = input_data             # <<<<<<<<<<<<<<
 * 
 */
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->__pyx_base.input_sent_values), __pyx_v_i, ((PyObject *)__pyx_v_input_data)) < 0)) __PYX_ERR(1, 1027, __pyx_L1_error)

      /* "networkconv.pyx":1026
 *             #print(i, input_data)
 *             self.convolution_lookup[i] = self.hidden_weights.dot(input_data)
 *             if training:             # <<<<<<<<<<<<<<
 *                 self.input_sent_values[i] = input_data
 * 
 */
    }

    /* "networkconv.pyx":1016
 * 
 *         cdef np.ndarray[FLOAT_t, ndim=1] new_data
 *         for i, element in enumerate(padded_sentence[self.word_window_size:], 1):             # <<<<<<<<<<<<<<
 *             new_data = np.concatenate([table[index] for
 *                                        index, table in zip(element, self.feature_tables)])
 */
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkconv.pyx":980
 *         self.pred_convolution_lookup = self.pred_dist_lookup.dot(self.pred_dist_weights)
 * 
 *     def _create_convolution_lookup(self, sentence, training):             # <<<<<<<<<<<<<<
 *         """
 *         Creates a lookup table storing the values found by each
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_data.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork._create_convolution_lookup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_new_data.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_padded_sentence);
  __Pyx_XDECREF((PyObject *)__pyx_v_window);
  __Pyx_XDECREF((PyObject *)__pyx_v_input_data);
  __Pyx_XDECREF((PyObject *)__pyx_v_new_data);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_element);
  __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_token_indices);
  __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_index);
  __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_table);
  __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_index);
  __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_table);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":14
 * 
 *     # transition and distance feature tables
 *     cdef public np.ndarray target_dist_table, pred_dist_table             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray target_dist_weights, pred_dist_weights
 *     cdef readonly int target_dist_offset, pred_dist_offset
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 14, 0, __PYX_ERR(1, 14, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_table));
  __pyx_r = ((PyObject *)__pyx_v_self->target_dist_table);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.target_dist_table.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table_2__set__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table_2__set__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 14, 0, __PYX_ERR(1, 14, __pyx_L1_error));
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 14, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->target_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->target_dist_table));
  __pyx_v_self->target_dist_table = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.target_dist_table.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table_4__del__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_17target_dist_table_4__del__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 14, 0, __PYX_ERR(1, 14, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->target_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->target_dist_table));
  __pyx_v_self->target_dist_table = ((PyArrayObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.target_dist_table.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 14, 0, __PYX_ERR(1, 14, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_table));
  __pyx_r = ((PyObject *)__pyx_v_self->pred_dist_table);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.pred_dist_table.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_2__set__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_2__set__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 14, 0, __PYX_ERR(1, 14, __pyx_L1_error));
  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(1, 14, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_value;
  __Pyx_INCREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->pred_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_dist_table));
  __pyx_v_self->pred_dist_table = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.pred_dist_table.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_4__del__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_4__del__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 14, 0, __PYX_ERR(1, 14, __pyx_L1_error));
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->pred_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->pred_dist_table));
  __pyx_v_self->pred_dist_table = ((PyArrayObject *)Py_None);

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.pred_dist_table.__del__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":15
 *     # transition and distance feature tables
 *     cdef public np.ndarray target_dist_table, pred_dist_table
 *     cdef readonly np.ndarray target_dist_weights, pred_dist_weights             # <<<<<<<<<<<<<<
 *     cdef readonly int target_dist_offset, pred_dist_offset
 *     cdef readonly np.ndarray target_dist_lookup, pred_dist_lookup
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_19target_dist_weights_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_19target_dist_weights_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_19target_dist_weights___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_19target_dist_weights___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 15, 0, __PYX_ERR(1, 15, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_weights));
  __pyx_r = ((PyObject *)__pyx_v_self->target_dist_weights);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.target_dist_weights.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_17pred_dist_weights_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_17pred_dist_weights_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_17pred_dist_weights___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_17pred_dist_weights___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 15, 0, __PYX_ERR(1, 15, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_weights));
  __pyx_r = ((PyObject *)__pyx_v_self->pred_dist_weights);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.pred_dist_weights.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":16
 *     cdef public np.ndarray target_dist_table, pred_dist_table
 *     cdef readonly np.ndarray target_dist_weights, pred_dist_weights
 *     cdef readonly int target_dist_offset, pred_dist_offset             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray target_dist_lookup, pred_dist_lookup
 *     cdef readonly np.ndarray target_convolution_lookup, pred_convolution_lookup
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_offset_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_offset_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_offset___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_offset___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 16, 0, __PYX_ERR(1, 16, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->target_dist_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.target_dist_offset.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_offset_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_offset_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_offset___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_offset___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 16, 0, __PYX_ERR(1, 16, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->pred_dist_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 16, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.pred_dist_offset.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":17
 *     cdef readonly np.ndarray target_dist_weights, pred_dist_weights
 *     cdef readonly int target_dist_offset, pred_dist_offset
 *     cdef readonly np.ndarray target_dist_lookup, pred_dist_lookup             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray target_convolution_lookup, pred_convolution_lookup
 *     cdef readonly np.ndarray target_dist_deltas, pred_dist_deltas
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_lookup_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_lookup_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_lookup___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_lookup___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 17, 0, __PYX_ERR(1, 17, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_lookup));
  __pyx_r = ((PyObject *)__pyx_v_self->target_dist_lookup);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.target_dist_lookup.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_lookup_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_lookup_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_lookup___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_lookup___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 17, 0, __PYX_ERR(1, 17, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_lookup));
  __pyx_r = ((PyObject *)__pyx_v_self->pred_dist_lookup);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.pred_dist_lookup.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":18
 *     cdef readonly int target_dist_offset, pred_dist_offset
 *     cdef readonly np.ndarray target_dist_lookup, pred_dist_lookup
 *     cdef readonly np.ndarray target_convolution_lookup, pred_convolution_lookup             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray target_dist_deltas, pred_dist_deltas
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_25target_convolution_lookup_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_25target_convolution_lookup_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_25target_convolution_lookup___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_25target_convolution_lookup___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 18, 0, __PYX_ERR(1, 18, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_convolution_lookup));
  __pyx_r = ((PyObject *)__pyx_v_self->target_convolution_lookup);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.target_convolution_lookup.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_23pred_convolution_lookup_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_23pred_convolution_lookup_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_23pred_convolution_lookup___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_23pred_convolution_lookup___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 18, 0, __PYX_ERR(1, 18, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_convolution_lookup));
  __pyx_r = ((PyObject *)__pyx_v_self->pred_convolution_lookup);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.pred_convolution_lookup.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":19
 *     cdef readonly np.ndarray target_dist_lookup, pred_dist_lookup
 *     cdef readonly np.ndarray target_convolution_lookup, pred_convolution_lookup
 *     cdef readonly np.ndarray target_dist_deltas, pred_dist_deltas             # <<<<<<<<<<<<<<
 * 
 *     # the second hidden layer
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_deltas_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_deltas_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_deltas___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_18target_dist_deltas___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 19, 0, __PYX_ERR(1, 19, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_deltas));
  __pyx_r = ((PyObject *)__pyx_v_self->target_dist_deltas);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.target_dist_deltas.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_deltas_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_deltas_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_deltas___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_16pred_dist_deltas___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 19, 0, __PYX_ERR(1, 19, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_deltas));
  __pyx_r = ((PyObject *)__pyx_v_self->pred_dist_deltas);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.pred_dist_deltas.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":22
 * 
 *     # the second hidden layer
 *     cdef readonly int hidden2_size             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray hidden2_weights, hidden2_bias
 *     cdef readonly np.ndarray hidden2_values
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_12hidden2_size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_12hidden2_size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_12hidden2_size___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_12hidden2_size___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 22, 0, __PYX_ERR(1, 22, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->hidden2_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 22, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.hidden2_size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":23
 *     # the second hidden layer
 *     cdef readonly int hidden2_size
 *     cdef readonly np.ndarray hidden2_weights, hidden2_bias             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray hidden2_values
 *     cdef readonly np.ndarray hidden2_before_activation, hidden_before_activation
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_15hidden2_weights_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_15hidden2_weights_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_15hidden2_weights___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_15hidden2_weights___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 23, 0, __PYX_ERR(1, 23, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_weights));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden2_weights);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.hidden2_weights.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_12hidden2_bias_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_12hidden2_bias_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_12hidden2_bias___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_12hidden2_bias___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 23, 0, __PYX_ERR(1, 23, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_bias));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden2_bias);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.hidden2_bias.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":24
 *     cdef readonly int hidden2_size
 *     cdef readonly np.ndarray hidden2_weights, hidden2_bias
 *     cdef readonly np.ndarray hidden2_values             # <<<<<<<<<<<<<<
 *     cdef readonly np.ndarray hidden2_before_activation, hidden_before_activation
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_14hidden2_values_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_14hidden2_values_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_14hidden2_values___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_14hidden2_values___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 24, 0, __PYX_ERR(1, 24, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_values));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden2_values);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.hidden2_values.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":25
 *     cdef readonly np.ndarray hidden2_weights, hidden2_bias
 *     cdef readonly np.ndarray hidden2_values
 *     cdef readonly np.ndarray hidden2_before_activation, hidden_before_activation             # <<<<<<<<<<<<<<
 * 
 *     # lookup of convolution values (the same for each sentence, used to save time)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_25hidden2_before_activation_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_25hidden2_before_activation_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_25hidden2_before_activation___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_25hidden2_before_activation___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 25, 0, __PYX_ERR(1, 25, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_before_activation));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden2_before_activation);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.hidden2_before_activation.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_24hidden_before_activation_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_24hidden_before_activation_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_24hidden_before_activation___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_24hidden_before_activation___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 25, 0, __PYX_ERR(1, 25, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_before_activation));
  __pyx_r = ((PyObject *)__pyx_v_self->hidden_before_activation);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.hidden_before_activation.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkconv.pyx":31
 * 
 *     # maximum convolution indices
 *     cdef readonly np.ndarray max_indices             # <<<<<<<<<<<<<<
 * 
 *     # number of targets (all tokens in a sentence or the provided arguments)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_11max_indices_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_11max_indices_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_11max_indices___get__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_11max_indices___get__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 31, 0, __PYX_ERR(1, 31, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->max_indices));
  __pyx_r = ((PyObject *)__pyx_v_self->max_indices);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.max_indices.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_57__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_56__reduce_cython__[] = "ConvolutionalNetwork.__reduce_cython__(self)";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_57__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_56__reduce_cython__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_56__reduce_cython__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.accuracy, self.answer_score, self.convolution_lookup, self.decay_factor, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.half_window, self.hidden2_before_activation, self.hidden2_bias, self.hidden2_gradients, self.hidden2_size, self.hidden2_values, self.hidden2_weights, self.hidden_before_activation, self.hidden_bias, self.hidden_gradients, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_deltas, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.max_indices, self.net_gradients, self.network_filename, self.network_text_filename, self.num_sentences, self.num_targets, self.num_tokens, self.only_classify, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.pred_convolution_lookup, self.pred_dist_deltas, self.pred_dist_lookup, self.pred_dist_offset, self.pred_dist_table, self.pred_dist_weights, self.sentence_accuracy, self.sentence_lookup, self.skips, self.target_convolution_lookup, self.target_dist_deltas, self.target_dist_lookup, self.target_dist_offset, self.target_dist_table, self.target_dist_weights, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_arguments, self.validation_predicates, self.validation_sentences, self.validation_tags, self.word_window_size)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.accuracy); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.answer_score); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.decay_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.error); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.features_per_token); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.float_errors); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->half_window); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->hidden2_size); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden_size); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.input_size); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate_features); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.learning_rate_trans); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_self->num_sentences); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_self->num_targets); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.num_tokens); if (unlikely(!__pyx_t_16)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_17 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.output_size); if (unlikely(!__pyx_t_17)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_18 = __Pyx_PyInt_From_int(__pyx_v_self->pred_dist_offset); if (unlikely(!__pyx_t_18)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_19 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.sentence_accuracy); if (unlikely(!__pyx_t_19)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_20 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.skips); if (unlikely(!__pyx_t_20)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_21 = __Pyx_PyInt_From_int(__pyx_v_self->target_dist_offset); if (unlikely(!__pyx_t_21)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_22 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.word_window_size); if (unlikely(!__pyx_t_22)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_23 = PyTuple_New(69); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_23);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->convolution_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->convolution_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 2, ((PyObject *)__pyx_v_self->convolution_lookup));
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_23, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_23, 4, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.feature_tables);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.feature_tables);
  PyTuple_SET_ITEM(__pyx_t_23, 5, __pyx_v_self->__pyx_base.feature_tables);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_23, 6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_23, 7, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_23, 8, __pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_before_activation));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden2_before_activation));
  PyTuple_SET_ITEM(__pyx_t_23, 9, ((PyObject *)__pyx_v_self->hidden2_before_activation));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_bias));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden2_bias));
  PyTuple_SET_ITEM(__pyx_t_23, 10, ((PyObject *)__pyx_v_self->hidden2_bias));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden2_gradients));
  PyTuple_SET_ITEM(__pyx_t_23, 11, ((PyObject *)__pyx_v_self->hidden2_gradients));
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_23, 12, __pyx_t_8);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden2_values));
  PyTuple_SET_ITEM(__pyx_t_23, 13, ((PyObject *)__pyx_v_self->hidden2_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden2_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden2_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 14, ((PyObject *)__pyx_v_self->hidden2_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_before_activation));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden_before_activation));
  PyTuple_SET_ITEM(__pyx_t_23, 15, ((PyObject *)__pyx_v_self->hidden_before_activation));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_bias));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_bias));
  PyTuple_SET_ITEM(__pyx_t_23, 16, ((PyObject *)__pyx_v_self->__pyx_base.hidden_bias));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->hidden_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->hidden_gradients));
  PyTuple_SET_ITEM(__pyx_t_23, 17, ((PyObject *)__pyx_v_self->hidden_gradients));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_sent_values));
  PyTuple_SET_ITEM(__pyx_t_23, 18, ((PyObject *)__pyx_v_self->__pyx_base.hidden_sent_values));
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_23, 19, __pyx_t_9);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_values));
  PyTuple_SET_ITEM(__pyx_t_23, 20, ((PyObject *)__pyx_v_self->__pyx_base.hidden_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 21, ((PyObject *)__pyx_v_self->__pyx_base.hidden_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->input_deltas));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->input_deltas));
  PyTuple_SET_ITEM(__pyx_t_23, 22, ((PyObject *)__pyx_v_self->input_deltas));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.input_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.input_sent_values));
  PyTuple_SET_ITEM(__pyx_t_23, 23, ((PyObject *)__pyx_v_self->__pyx_base.input_sent_values));
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_23, 24, __pyx_t_10);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.input_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.input_values));
  PyTuple_SET_ITEM(__pyx_t_23, 25, ((PyObject *)__pyx_v_self->__pyx_base.input_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.layer2_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.layer2_sent_values));
  PyTuple_SET_ITEM(__pyx_t_23, 26, ((PyObject *)__pyx_v_self->__pyx_base.layer2_sent_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.layer2_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.layer2_values));
  PyTuple_SET_ITEM(__pyx_t_23, 27, ((PyObject *)__pyx_v_self->__pyx_base.layer2_values));
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_23, 28, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_23, 29, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_23, 30, __pyx_t_13);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->max_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->max_indices));
  PyTuple_SET_ITEM(__pyx_t_23, 31, ((PyObject *)__pyx_v_self->max_indices));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.net_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.net_gradients));
  PyTuple_SET_ITEM(__pyx_t_23, 32, ((PyObject *)__pyx_v_self->__pyx_base.net_gradients));
  __Pyx_INCREF(__pyx_v_self->__pyx_base.network_filename);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.network_filename);
  PyTuple_SET_ITEM(__pyx_t_23, 33, __pyx_v_self->__pyx_base.network_filename);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.network_text_filename);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.network_text_filename);
  PyTuple_SET_ITEM(__pyx_t_23, 34, __pyx_v_self->__pyx_base.network_text_filename);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_23, 35, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_23, 36, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_23, 37, __pyx_t_16);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->only_classify));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->only_classify));
  PyTuple_SET_ITEM(__pyx_t_23, 38, ((PyObject *)__pyx_v_self->only_classify));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.output_bias));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.output_bias));
  PyTuple_SET_ITEM(__pyx_t_23, 39, ((PyObject *)__pyx_v_self->__pyx_base.output_bias));
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_23, 40, __pyx_t_17);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.output_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.output_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 41, ((PyObject *)__pyx_v_self->__pyx_base.output_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.padding_left));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.padding_left));
  PyTuple_SET_ITEM(__pyx_t_23, 42, ((PyObject *)__pyx_v_self->__pyx_base.padding_left));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.padding_right));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.padding_right));
  PyTuple_SET_ITEM(__pyx_t_23, 43, ((PyObject *)__pyx_v_self->__pyx_base.padding_right));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
  PyTuple_SET_ITEM(__pyx_t_23, 44, ((PyObject *)__pyx_v_self->__pyx_base.pos_padding));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
  PyTuple_SET_ITEM(__pyx_t_23, 45, ((PyObject *)__pyx_v_self->__pyx_base.pre_padding));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_convolution_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pred_convolution_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 46, ((PyObject *)__pyx_v_self->pred_convolution_lookup));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_deltas));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pred_dist_deltas));
  PyTuple_SET_ITEM(__pyx_t_23, 47, ((PyObject *)__pyx_v_self->pred_dist_deltas));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pred_dist_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 48, ((PyObject *)__pyx_v_self->pred_dist_lookup));
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_23, 49, __pyx_t_18);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_table));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pred_dist_table));
  PyTuple_SET_ITEM(__pyx_t_23, 50, ((PyObject *)__pyx_v_self->pred_dist_table));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->pred_dist_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->pred_dist_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 51, ((PyObject *)__pyx_v_self->pred_dist_weights));
  __Pyx_GIVEREF(__pyx_t_19);
  PyTuple_SET_ITEM(__pyx_t_23, 52, __pyx_t_19);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.sentence_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.sentence_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 53, ((PyObject *)__pyx_v_self->__pyx_base.sentence_lookup));
  __Pyx_GIVEREF(__pyx_t_20);
  PyTuple_SET_ITEM(__pyx_t_23, 54, __pyx_t_20);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_convolution_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->target_convolution_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 55, ((PyObject *)__pyx_v_self->target_convolution_lookup));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_deltas));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->target_dist_deltas));
  PyTuple_SET_ITEM(__pyx_t_23, 56, ((PyObject *)__pyx_v_self->target_dist_deltas));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->target_dist_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 57, ((PyObject *)__pyx_v_self->target_dist_lookup));
  __Pyx_GIVEREF(__pyx_t_21);
  PyTuple_SET_ITEM(__pyx_t_23, 58, __pyx_t_21);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_table));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->target_dist_table));
  PyTuple_SET_ITEM(__pyx_t_23, 59, ((PyObject *)__pyx_v_self->target_dist_table));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->target_dist_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->target_dist_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 60, ((PyObject *)__pyx_v_self->target_dist_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.trans_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.trans_gradients));
  PyTuple_SET_ITEM(__pyx_t_23, 61, ((PyObject *)__pyx_v_self->__pyx_base.trans_gradients));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.transitions));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.transitions));
  PyTuple_SET_ITEM(__pyx_t_23, 62, ((PyObject *)__pyx_v_self->__pyx_base.transitions));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.use_learning_rate_decay));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.use_learning_rate_decay));
  PyTuple_SET_ITEM(__pyx_t_23, 63, ((PyObject *)__pyx_v_self->__pyx_base.use_learning_rate_decay));
  __Pyx_INCREF(__pyx_v_self->validation_arguments);
  __Pyx_GIVEREF(__pyx_v_self->validation_arguments);
  PyTuple_SET_ITEM(__pyx_t_23, 64, __pyx_v_self->validation_arguments);
  __Pyx_INCREF(__pyx_v_self->validation_predicates);
  __Pyx_GIVEREF(__pyx_v_self->validation_predicates);
  PyTuple_SET_ITEM(__pyx_t_23, 65, __pyx_v_self->validation_predicates);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.validation_sentences);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.validation_sentences);
  PyTuple_SET_ITEM(__pyx_t_23, 66, __pyx_v_self->__pyx_base.validation_sentences);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.validation_tags);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.validation_tags);
  PyTuple_SET_ITEM(__pyx_t_23, 67, __pyx_v_self->__pyx_base.validation_tags);
  __Pyx_GIVEREF(__pyx_t_22);
  PyTuple_SET_ITEM(__pyx_t_23, 68, __pyx_t_22);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_t_16 = 0;
  __pyx_t_17 = 0;
  __pyx_t_18 = 0;
  __pyx_t_19 = 0;
  __pyx_t_20 = 0;
  __pyx_t_21 = 0;
  __pyx_t_22 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_23);
  __pyx_t_23 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.accuracy, self.answer_score, self.convolution_lookup, self.decay_factor, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.half_window, self.hidden2_before_activation, self.hidden2_bias, self.hidden2_gradients, self.hidden2_size, self.hidden2_values, self.hidden2_weights, self.hidden_before_activation, self.hidden_bias, self.hidden_gradients, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_deltas, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.max_indices, self.net_gradients, self.network_filename, self.network_text_filename, self.num_sentences, self.num_targets, self.num_tokens, self.only_classify, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.pred_convolution_lookup, self.pred_dist_deltas, self.pred_dist_lookup, self.pred_dist_offset, self.pred_dist_table, self.pred_dist_weights, self.sentence_accuracy, self.sentence_lookup, self.skips, self.target_convolution_lookup, self.target_dist_deltas, self.target_dist_lookup, self.target_dist_offset, self.target_dist_table, self.target_dist_weights, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_arguments, self.validation_predicates, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_23 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_23);
  __pyx_v__dict = __pyx_t_23;
  __pyx_t_23 = 0;

  /* "(tree fragment)":7
 *     state = (self.accuracy, self.answer_score, self.convolution_lookup, self.decay_factor, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.half_window, self.hidden2_before_activation, self.hidden2_bias, self.hidden2_gradients, self.hidden2_size, self.hidden2_values, self.hidden2_weights, self.hidden_before_activation, self.hidden_bias, self.hidden_gradients, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_deltas, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.max_indices, self.net_gradients, self.network_filename, self.network_text_filename, self.num_sentences, self.num_targets, self.num_tokens, self.only_classify, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.pred_convolution_lookup, self.pred_dist_deltas, self.pred_dist_lookup, self.pred_dist_offset, self.pred_dist_table, self.pred_dist_weights, self.sentence_accuracy, self.sentence_lookup, self.skips, self.target_convolution_lookup, self.target_dist_deltas, self.target_dist_lookup, self.target_dist_offset, self.target_dist_table, self.target_dist_weights, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_arguments, self.validation_predicates, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_24 = (__pyx_v__dict != Py_None);
  __pyx_t_25 = (__pyx_t_24 != 0);
  if (__pyx_t_25) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_23 = PyTuple_New(1); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_v__dict);
    __pyx_t_22 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_23); if (unlikely(!__pyx_t_22)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_22));
    __pyx_t_22 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.convolution_lookup is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.accuracy, self.answer_score, self.convolution_lookup, self.decay_factor, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.half_window, self.hidden2_before_activation, self.hidden2_bias, self.hidden2_gradients, self.hidden2_size, self.hidden2_values, self.hidden2_weights, self.hidden_before_activation, self.hidden_bias, self.hidden_gradients, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_deltas, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.max_indices, self.net_gradients, self.network_filename, self.network_text_filename, self.num_sentences, self.num_targets, self.num_tokens, self.only_classify, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.pred_convolution_lookup, self.pred_dist_deltas, self.pred_dist_lookup, self.pred_dist_offset, self.pred_dist_table, self.pred_dist_weights, self.sentence_accuracy, self.sentence_lookup, self.skips, self.target_convolution_lookup, self.target_dist_deltas, self.target_dist_lookup, self.target_dist_offset, self.target_dist_table, self.target_dist_weights, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_arguments, self.validation_predicates, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.convolution_lookup is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, None), state
 */
  /*else*/ {
    __pyx_t_24 = (((PyObject *)__pyx_v_self->convolution_lookup) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (__pyx_v_self->__pyx_base.feature_tables != ((PyObject*)Py_None));
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->hidden2_before_activation) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->hidden2_bias) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->hidden2_gradients) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->hidden2_values) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->hidden2_weights) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->hidden_before_activation) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.hidden_bias) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->hidden_gradients) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.hidden_sent_values) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.hidden_values) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.hidden_weights) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->input_deltas) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.input_sent_values) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.input_values) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.layer2_sent_values) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.layer2_values) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->max_indices) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.net_gradients) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_self->__pyx_base.network_filename != ((PyObject*)Py_None));
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (__pyx_v_self->__pyx_base.network_text_filename != ((PyObject*)Py_None));
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->only_classify) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.output_bias) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.output_weights) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.padding_left) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.padding_right) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.pos_padding) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.pre_padding) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->pred_convolution_lookup) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->pred_dist_deltas) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->pred_dist_lookup) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->pred_dist_table) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->pred_dist_weights) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.sentence_lookup) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->target_convolution_lookup) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->target_dist_deltas) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->target_dist_lookup) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->target_dist_table) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->target_dist_weights) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.trans_gradients) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.transitions) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.use_learning_rate_decay) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (__pyx_v_self->validation_arguments != ((PyObject*)Py_None));
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_self->validation_predicates != ((PyObject*)Py_None));
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (__pyx_v_self->__pyx_base.validation_sentences != ((PyObject*)Py_None));
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_self->__pyx_base.validation_tags != ((PyObject*)Py_None));
    __pyx_t_26 = (__pyx_t_24 != 0);
    __pyx_t_25 = __pyx_t_26;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_25;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.convolution_lookup is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, None), state
 *     else:
 */
  __pyx_t_25 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_25) {

    /* "(tree fragment)":13
 *         use_setstate = self.convolution_lookup is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_n_s_pyx_unpickle_ConvolutionalNetw); if (unlikely(!__pyx_t_22)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __pyx_t_23 = PyTuple_New(3); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_23, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_149446146);
    __Pyx_GIVEREF(__pyx_int_149446146);
    PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_int_149446146);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_23, 2, Py_None);
    __pyx_t_21 = PyTuple_New(3); if (unlikely(!__pyx_t_21)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_22);
    __Pyx_GIVEREF(__pyx_t_23);
    PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_t_23);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_21, 2, __pyx_v_state);
    __pyx_t_22 = 0;
    __pyx_t_23 = 0;
    __pyx_r = __pyx_t_21;
    __pyx_t_21 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.convolution_lookup is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, None), state
 *     else:
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ConvolutionalNetwork__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_n_s_pyx_unpickle_ConvolutionalNetw); if (unlikely(!__pyx_t_21)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_23 = PyTuple_New(3); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_23, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_149446146);
    __Pyx_GIVEREF(__pyx_int_149446146);
    PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_int_149446146);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_23, 2, __pyx_v_state);
    __pyx_t_22 = PyTuple_New(2); if (unlikely(!__pyx_t_22)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_GIVEREF(__pyx_t_21);
    PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21);
    __Pyx_GIVEREF(__pyx_t_23);
    PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_t_23);
    __pyx_t_21 = 0;
    __pyx_t_23 = 0;
    __pyx_r = __pyx_t_22;
    __pyx_t_22 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ConvolutionalNetwork__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_59__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4libs_7network_20ConvolutionalNetwork_58__setstate_cython__[] = "ConvolutionalNetwork.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4libs_7network_20ConvolutionalNetwork_59__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_20ConvolutionalNetwork_58__setstate_cython__(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_20ConvolutionalNetwork_58__setstate_cython__(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ConvolutionalNetwork__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4libs_7network___pyx_unpickle_ConvolutionalNetwork__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ConvolutionalNetwork, (type(self), 0x8e85e02, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ConvolutionalNetwork__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.ConvolutionalNetwork.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":19
 *     cdef validation_heads
 * 
 *     def save(self):             # <<<<<<<<<<<<<<
 *         """
 *         Saves the neural network to a file.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_1save(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_save[] = "ConvolutionalDependencyNetwork.save(self)\n\n        Saves the neural network to a file.\n        It will save the weights, biases, sizes, padding and \n        distance tables, and other feature tables.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_1save(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("save (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_save(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_save(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("save", 0);
  __Pyx_TraceCall("save", __pyx_f[3], 19, 0, __PYX_ERR(3, 19, __pyx_L1_error));

  /* "networkdependencyconv.pyx":25
 *         distance tables, and other feature tables.
 *         """
 *         data = self._generate_save_dict()             # <<<<<<<<<<<<<<
 * 
 *         np.savez(self.network_filename, **data)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_generate_save_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 25, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_data = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":27
 *         data = self._generate_save_dict()
 * 
 *         np.savez(self.network_filename, **data)             # <<<<<<<<<<<<<<
 * 
 *     @classmethod
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_savez); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.network_filename);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.network_filename);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->__pyx_base.__pyx_base.network_filename);
  if (unlikely(__pyx_v_data == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
    __PYX_ERR(3, 27, __pyx_L1_error)
  }
  if (likely(PyDict_CheckExact(__pyx_v_data))) {
    __pyx_t_3 = PyDict_Copy(__pyx_v_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 27, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    __pyx_t_3 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_data, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 27, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 27, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "networkdependencyconv.pyx":19
 *     cdef validation_heads
 * 
 *     def save(self):             # <<<<<<<<<<<<<<
 *         """
 *         Saves the neural network to a file.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":30
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_3load_from_file(PyObject *__pyx_v_cls, PyObject *__pyx_v_filename); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_2load_from_file[] = "ConvolutionalDependencyNetwork.load_from_file(type cls, filename)\n\n        Loads the neural network from a file.\n        It will load weights, biases, sizes, padding and \n        distance tables, and other feature tables.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_3load_from_file(PyObject *__pyx_v_cls, PyObject *__pyx_v_filename) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("load_from_file (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_2load_from_file(((PyTypeObject*)__pyx_v_cls), ((PyObject *)__pyx_v_filename));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_2load_from_file(PyTypeObject *__pyx_v_cls, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_v_nn = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("load_from_file", 0);
  __Pyx_TraceCall("load_from_file", __pyx_f[3], 30, 0, __PYX_ERR(3, 30, __pyx_L1_error));

  /* "networkdependencyconv.pyx":36
 *         distance tables, and other feature tables.
 *         """
 *         data = np.load(filename, allow_pickle=True)             # <<<<<<<<<<<<<<
 *         nn = cls._load_from_file(data, filename)
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_load); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allow_pickle, Py_True) < 0) __PYX_ERR(3, 36, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 36, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_data = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "networkdependencyconv.pyx":37
 *         """
 *         data = np.load(filename, allow_pickle=True)
 *         nn = cls._load_from_file(data, filename)             # <<<<<<<<<<<<<<
 * 
 *         return nn
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_cls), __pyx_n_s_load_from_file); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 37, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_data, __pyx_v_filename};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 37, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_v_data, __pyx_v_filename};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 37, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else
  #endif
  {
    __pyx_t_2 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 37, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(__pyx_v_data);
    __Pyx_GIVEREF(__pyx_v_data);
    PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_5, __pyx_v_data);
    __Pyx_INCREF(__pyx_v_filename);
    __Pyx_GIVEREF(__pyx_v_filename);
    PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_5, __pyx_v_filename);
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 37, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_nn = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "networkdependencyconv.pyx":39
 *         nn = cls._load_from_file(data, filename)
 * 
 *         return nn             # <<<<<<<<<<<<<<
 * 
 *     def train(self, list sentences, list heads, int epochs,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_nn);
  __pyx_r = __pyx_v_nn;
  goto __pyx_L0;

  /* "networkdependencyconv.pyx":30
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.load_from_file", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_nn);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":41
 *         return nn
 * 
 *     def train(self, list sentences, list heads, int epochs,             # <<<<<<<<<<<<<<
 *               int epochs_between_reports=0, float desired_accuracy=0,
 *               list labels=None):
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_5train(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_4train[] = "ConvolutionalDependencyNetwork.train(self, list sentences, list heads, int epochs, int epochs_between_reports=0, float desired_accuracy=0, list labels=None)\n\n        Trains the convolutional network. Refer to the basic Network\n        train method for detailed explanation. \n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_5train(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentences = 0;
  PyObject *__pyx_v_heads = 0;
  int __pyx_v_epochs;
  int __pyx_v_epochs_between_reports;
  float __pyx_v_desired_accuracy;
  PyObject *__pyx_v_labels = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("train (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentences,&__pyx_n_s_heads,&__pyx_n_s_epochs,&__pyx_n_s_epochs_between_reports,&__pyx_n_s_desired_accuracy,&__pyx_n_s_labels,0};
    PyObject* values[6] = {0,0,0,0,0,0};

    /* "networkdependencyconv.pyx":43
 *     def train(self, list sentences, list heads, int epochs,
 *               int epochs_between_reports=0, float desired_accuracy=0,
 *               list labels=None):             # <<<<<<<<<<<<<<
 *         """
 *         Trains the convolutional network. Refer to the basic Network
 */
    values[5] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentences)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_heads)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("train", 0, 3, 6, 1); __PYX_ERR(3, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_epochs)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("train", 0, 3, 6, 2); __PYX_ERR(3, 41, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_epochs_between_reports);
          if (value) { values[3] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_desired_accuracy);
          if (value) { values[4] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  5:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_labels);
          if (value) { values[5] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "train") < 0)) __PYX_ERR(3, 41, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        CYTHON_FALLTHROUGH;
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentences = ((PyObject*)values[0]);
    __pyx_v_heads = ((PyObject*)values[1]);
    __pyx_v_epochs = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_epochs == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 41, __pyx_L3_error)
    if (values[3]) {
      __pyx_v_epochs_between_reports = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_epochs_between_reports == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 42, __pyx_L3_error)
    } else {
      __pyx_v_epochs_between_reports = ((int)0);
    }
    if (values[4]) {
      __pyx_v_desired_accuracy = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_desired_accuracy == (float)-1) && PyErr_Occurred())) __PYX_ERR(3, 42, __pyx_L3_error)
    } else {
      __pyx_v_desired_accuracy = ((float)0.0);
    }
    __pyx_v_labels = ((PyObject*)values[5]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("train", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 41, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.train", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentences), (&PyList_Type), 1, "sentences", 1))) __PYX_ERR(3, 41, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_heads), (&PyList_Type), 1, "heads", 1))) __PYX_ERR(3, 41, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), (&PyList_Type), 1, "labels", 1))) __PYX_ERR(3, 43, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_4train(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_sentences, __pyx_v_heads, __pyx_v_epochs, __pyx_v_epochs_between_reports, __pyx_v_desired_accuracy, __pyx_v_labels);

  /* "networkdependencyconv.pyx":41
 *         return nn
 * 
 *     def train(self, list sentences, list heads, int epochs,             # <<<<<<<<<<<<<<
 *               int epochs_between_reports=0, float desired_accuracy=0,
 *               list labels=None):
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_4train(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_heads, int __pyx_v_epochs, int __pyx_v_epochs_between_reports, float __pyx_v_desired_accuracy, PyObject *__pyx_v_labels) {
  PyObject *__pyx_v_predicates = NULL;
  PyObject *__pyx_8genexpr9__pyx_v_sentence = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("train", 0);
  __Pyx_TraceCall("train", __pyx_f[3], 41, 0, __PYX_ERR(3, 41, __pyx_L1_error));

  /* "networkdependencyconv.pyx":50
 *         # the ConvolutionalNetwork class was written primarily for SRL
 *         # every token acts as a predicate, and we don't need to tell it explicitely
 *         predicates = [np.arange(len(sentence)) for sentence in sentences]             # <<<<<<<<<<<<<<
 * 
 *         # the last argument in ConvolutionalNetwork.train is actually the argument
 */
  { /* enter inner scope */
    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 50, __pyx_L5_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (unlikely(__pyx_v_sentences == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
      __PYX_ERR(3, 50, __pyx_L5_error)
    }
    __pyx_t_2 = __pyx_v_sentences; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
    for (;;) {
      if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(3, 50, __pyx_L5_error)
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 50, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      #endif
      __Pyx_XDECREF_SET(__pyx_8genexpr9__pyx_v_sentence, __pyx_t_4);
      __pyx_t_4 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 50, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_arange); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 50, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = PyObject_Length(__pyx_8genexpr9__pyx_v_sentence); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(3, 50, __pyx_L5_error)
      __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 50, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 50, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) __PYX_ERR(3, 50, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_sentence); __pyx_8genexpr9__pyx_v_sentence = 0;
    goto __pyx_L8_exit_scope;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_sentence); __pyx_8genexpr9__pyx_v_sentence = 0;
    goto __pyx_L1_error;
    __pyx_L8_exit_scope:;
  } /* exit inner scope */
  __pyx_v_predicates = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":56
 *         # argument, which is correctly handled by the DependencyNetwork._tag(...) method.
 * 
 *         if self.validation_sentences is None:             # <<<<<<<<<<<<<<
 *             self.set_validation_data(sentences, heads, labels)
 * 
 */
  __pyx_t_9 = (__pyx_v_self->__pyx_base.__pyx_base.validation_sentences == ((PyObject*)Py_None));
  __pyx_t_10 = (__pyx_t_9 != 0);
  if (__pyx_t_10) {

    /* "networkdependencyconv.pyx":57
 * 
 *         if self.validation_sentences is None:
 *             self.set_validation_data(sentences, heads, labels)             # <<<<<<<<<<<<<<
 * 
 *         super(ConvolutionalDependencyNetwork, self).train(sentences, predicates,
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_set_validation_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 57, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_sentences, __pyx_v_heads, __pyx_v_labels};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 57, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_v_sentences, __pyx_v_heads, __pyx_v_labels};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 57, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(__pyx_v_sentences);
      __Pyx_GIVEREF(__pyx_v_sentences);
      PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_11, __pyx_v_sentences);
      __Pyx_INCREF(__pyx_v_heads);
      __Pyx_GIVEREF(__pyx_v_heads);
      PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_11, __pyx_v_heads);
      __Pyx_INCREF(__pyx_v_labels);
      __Pyx_GIVEREF(__pyx_v_labels);
      PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_11, __pyx_v_labels);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "networkdependencyconv.pyx":56
 *         # argument, which is correctly handled by the DependencyNetwork._tag(...) method.
 * 
 *         if self.validation_sentences is None:             # <<<<<<<<<<<<<<
 *             self.set_validation_data(sentences, heads, labels)
 * 
 */
  }

  /* "networkdependencyconv.pyx":59
 *             self.set_validation_data(sentences, heads, labels)
 * 
 *         super(ConvolutionalDependencyNetwork, self).train(sentences, predicates,             # <<<<<<<<<<<<<<
 *                                                           heads, epochs,
 *                                                           epochs_between_reports,
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork));
  __Pyx_GIVEREF(((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork));
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_train); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "networkdependencyconv.pyx":60
 * 
 *         super(ConvolutionalDependencyNetwork, self).train(sentences, predicates,
 *                                                           heads, epochs,             # <<<<<<<<<<<<<<
 *                                                           epochs_between_reports,
 *                                                           desired_accuracy,
 */
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_epochs); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 60, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);

  /* "networkdependencyconv.pyx":61
 *         super(ConvolutionalDependencyNetwork, self).train(sentences, predicates,
 *                                                           heads, epochs,
 *                                                           epochs_between_reports,             # <<<<<<<<<<<<<<
 *                                                           desired_accuracy,
 *                                                           labels)
 */
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_epochs_between_reports); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "networkdependencyconv.pyx":62
 *                                                           heads, epochs,
 *                                                           epochs_between_reports,
 *                                                           desired_accuracy,             # <<<<<<<<<<<<<<
 *                                                           labels)
 * 
 */
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_desired_accuracy); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);

  /* "networkdependencyconv.pyx":63
 *                                                           epochs_between_reports,
 *                                                           desired_accuracy,
 *                                                           labels)             # <<<<<<<<<<<<<<
 * 
 *     def set_validation_data(self, list sentences, list heads, list labels=None):
 */
  __pyx_t_8 = NULL;
  __pyx_t_11 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_11 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[8] = {__pyx_t_8, __pyx_v_sentences, __pyx_v_predicates, __pyx_v_heads, __pyx_t_6, __pyx_t_4, __pyx_t_5, __pyx_v_labels};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 7+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 59, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[8] = {__pyx_t_8, __pyx_v_sentences, __pyx_v_predicates, __pyx_v_heads, __pyx_t_6, __pyx_t_4, __pyx_t_5, __pyx_v_labels};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 7+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 59, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_12 = PyTuple_New(7+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 59, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (__pyx_t_8) {
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
    }
    __Pyx_INCREF(__pyx_v_sentences);
    __Pyx_GIVEREF(__pyx_v_sentences);
    PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_v_sentences);
    __Pyx_INCREF(__pyx_v_predicates);
    __Pyx_GIVEREF(__pyx_v_predicates);
    PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_v_predicates);
    __Pyx_INCREF(__pyx_v_heads);
    __Pyx_GIVEREF(__pyx_v_heads);
    PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_v_heads);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_12, 5+__pyx_t_11, __pyx_t_5);
    __Pyx_INCREF(__pyx_v_labels);
    __Pyx_GIVEREF(__pyx_v_labels);
    PyTuple_SET_ITEM(__pyx_t_12, 6+__pyx_t_11, __pyx_v_labels);
    __pyx_t_6 = 0;
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 59, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":41
 *         return nn
 * 
 *     def train(self, list sentences, list heads, int epochs,             # <<<<<<<<<<<<<<
 *               int epochs_between_reports=0, float desired_accuracy=0,
 *               list labels=None):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.train", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_predicates);
  __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_sentence);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":65
 *                                                           labels)
 * 
 *     def set_validation_data(self, list sentences, list heads, list labels=None):             # <<<<<<<<<<<<<<
 *         """
 *         Sets the data to be used in validation during training. If this function
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_7set_validation_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_6set_validation_data[] = "ConvolutionalDependencyNetwork.set_validation_data(self, list sentences, list heads, list labels=None)\n\n        Sets the data to be used in validation during training. If this function\n        is not called before training, the training data itself is used to \n        measure the model's performance.\n        \n        :param labels: only used when learning labels\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_7set_validation_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentences = 0;
  PyObject *__pyx_v_heads = 0;
  PyObject *__pyx_v_labels = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_validation_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentences,&__pyx_n_s_heads,&__pyx_n_s_labels,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject*)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentences)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_heads)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("set_validation_data", 0, 2, 3, 1); __PYX_ERR(3, 65, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_labels);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_validation_data") < 0)) __PYX_ERR(3, 65, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentences = ((PyObject*)values[0]);
    __pyx_v_heads = ((PyObject*)values[1]);
    __pyx_v_labels = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_validation_data", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 65, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.set_validation_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentences), (&PyList_Type), 1, "sentences", 1))) __PYX_ERR(3, 65, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_heads), (&PyList_Type), 1, "heads", 1))) __PYX_ERR(3, 65, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), (&PyList_Type), 1, "labels", 1))) __PYX_ERR(3, 65, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_6set_validation_data(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_sentences, __pyx_v_heads, __pyx_v_labels);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_6set_validation_data(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_sentences, PyObject *__pyx_v_heads, PyObject *__pyx_v_labels) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_validation_data", 0);
  __Pyx_TraceCall("set_validation_data", __pyx_f[3], 65, 0, __PYX_ERR(3, 65, __pyx_L1_error));

  /* "networkdependencyconv.pyx":73
 *         :param labels: only used when learning labels
 *         """
 *         self.validation_sentences = sentences             # <<<<<<<<<<<<<<
 *         self.validation_tags = labels
 *         self.validation_heads = heads
 */
  __Pyx_INCREF(__pyx_v_sentences);
  __Pyx_GIVEREF(__pyx_v_sentences);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.validation_sentences);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.validation_sentences);
  __pyx_v_self->__pyx_base.__pyx_base.validation_sentences = __pyx_v_sentences;

  /* "networkdependencyconv.pyx":74
 *         """
 *         self.validation_sentences = sentences
 *         self.validation_tags = labels             # <<<<<<<<<<<<<<
 *         self.validation_heads = heads
 * 
 */
  __Pyx_INCREF(__pyx_v_labels);
  __Pyx_GIVEREF(__pyx_v_labels);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.validation_tags);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.__pyx_base.validation_tags);
  __pyx_v_self->__pyx_base.__pyx_base.validation_tags = __pyx_v_labels;

  /* "networkdependencyconv.pyx":75
 *         self.validation_sentences = sentences
 *         self.validation_tags = labels
 *         self.validation_heads = heads             # <<<<<<<<<<<<<<
 * 
 *     def _tag_sentence(self, sentence, predicates=None, heads=None, labels=None):
 */
  __Pyx_INCREF(__pyx_v_heads);
  __Pyx_GIVEREF(__pyx_v_heads);
  __Pyx_GOTREF(__pyx_v_self->validation_heads);
  __Pyx_DECREF(__pyx_v_self->validation_heads);
  __pyx_v_self->validation_heads = __pyx_v_heads;

  /* "networkdependencyconv.pyx":65
 *                                                           labels)
 * 
 *     def set_validation_data(self, list sentences, list heads, list labels=None):             # <<<<<<<<<<<<<<
 *         """
 *         Sets the data to be used in validation during training. If this function
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.set_validation_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":77
 *         self.validation_heads = heads
 * 
 *     def _tag_sentence(self, sentence, predicates=None, heads=None, labels=None):             # <<<<<<<<<<<<<<
 *         """
 *         This function is just an interface to the _tag_sentence signature
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_9_tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_8_tag_sentence[] = "ConvolutionalDependencyNetwork._tag_sentence(self, sentence, predicates=None, heads=None, labels=None)\n\n        This function is just an interface to the _tag_sentence signature\n        defined in ConvolutionalNetwork.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_9_tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_sentence = 0;
  CYTHON_UNUSED PyObject *__pyx_v_predicates = 0;
  PyObject *__pyx_v_heads = 0;
  PyObject *__pyx_v_labels = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_tag_sentence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_predicates,&__pyx_n_s_heads,&__pyx_n_s_labels,0};
    PyObject* values[4] = {0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_predicates);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_heads);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_labels);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_tag_sentence") < 0)) __PYX_ERR(3, 77, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = values[0];
    __pyx_v_predicates = values[1];
    __pyx_v_heads = values[2];
    __pyx_v_labels = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_tag_sentence", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 77, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_8_tag_sentence(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_predicates, __pyx_v_heads, __pyx_v_labels);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_8_tag_sentence(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_sentence, CYTHON_UNUSED PyObject *__pyx_v_predicates, PyObject *__pyx_v_heads, PyObject *__pyx_v_labels) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_tag_sentence", 0);
  __Pyx_TraceCall("_tag_sentence", __pyx_f[3], 77, 0, __PYX_ERR(3, 77, __pyx_L1_error));

  /* "networkdependencyconv.pyx":82
 *         defined in ConvolutionalNetwork.
 *         """
 *         if labels is None:             # <<<<<<<<<<<<<<
 *             self._tag_sentence_unlabeled_dependency(sentence, heads)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_labels == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "networkdependencyconv.pyx":83
 *         """
 *         if labels is None:
 *             self._tag_sentence_unlabeled_dependency(sentence, heads)             # <<<<<<<<<<<<<<
 *         else:
 *             self._tag_sentence_labeled_dependency(sentence, heads, labels)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence_unlabeled_dependen); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 83, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_sentence, __pyx_v_heads};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 83, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_sentence, __pyx_v_heads};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 83, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(__pyx_v_sentence);
      __Pyx_GIVEREF(__pyx_v_sentence);
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_sentence);
      __Pyx_INCREF(__pyx_v_heads);
      __Pyx_GIVEREF(__pyx_v_heads);
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_heads);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":82
 *         defined in ConvolutionalNetwork.
 *         """
 *         if labels is None:             # <<<<<<<<<<<<<<
 *             self._tag_sentence_unlabeled_dependency(sentence, heads)
 *         else:
 */
    goto __pyx_L3;
  }

  /* "networkdependencyconv.pyx":85
 *             self._tag_sentence_unlabeled_dependency(sentence, heads)
 *         else:
 *             self._tag_sentence_labeled_dependency(sentence, heads, labels)             # <<<<<<<<<<<<<<
 * 
 *     def _tag_sentence_unlabeled_dependency(self, np.ndarray sentence, np.ndarray heads=None):
 */
  /*else*/ {
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence_labeled_dependency); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 85, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_sentence, __pyx_v_heads, __pyx_v_labels};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 85, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[4] = {__pyx_t_7, __pyx_v_sentence, __pyx_v_heads, __pyx_v_labels};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 85, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_7) {
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
      }
      __Pyx_INCREF(__pyx_v_sentence);
      __Pyx_GIVEREF(__pyx_v_sentence);
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_sentence);
      __Pyx_INCREF(__pyx_v_heads);
      __Pyx_GIVEREF(__pyx_v_heads);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_v_heads);
      __Pyx_INCREF(__pyx_v_labels);
      __Pyx_GIVEREF(__pyx_v_labels);
      PyTuple_SET_ITEM(__pyx_t_5, 2+__pyx_t_6, __pyx_v_labels);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __pyx_L3:;

  /* "networkdependencyconv.pyx":77
 *         self.validation_heads = heads
 * 
 *     def _tag_sentence(self, sentence, predicates=None, heads=None, labels=None):             # <<<<<<<<<<<<<<
 *         """
 *         This function is just an interface to the _tag_sentence signature
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":87
 *             self._tag_sentence_labeled_dependency(sentence, heads, labels)
 * 
 *     def _tag_sentence_unlabeled_dependency(self, np.ndarray sentence, np.ndarray heads=None):             # <<<<<<<<<<<<<<
 *         """
 *         Run the network for the unlabeled dependency task.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_11_tag_sentence_unlabeled_dependency(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_10_tag_sentence_unlabeled_dependency[] = "ConvolutionalDependencyNetwork._tag_sentence_unlabeled_dependency(self, ndarray sentence, ndarray heads=None)\n\n        Run the network for the unlabeled dependency task.\n        A graph with all weights for possible dependencies is built \n        and the final answer is obtained applying the Chu-Liu-Edmond's\n        algorithm.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_11_tag_sentence_unlabeled_dependency(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_sentence = 0;
  PyArrayObject *__pyx_v_heads = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_tag_sentence_unlabeled_dependency (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_heads,0};
    PyObject* values[2] = {0,0};
    values[1] = (PyObject *)((PyArrayObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_heads);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_tag_sentence_unlabeled_dependency") < 0)) __PYX_ERR(3, 87, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = ((PyArrayObject *)values[0]);
    __pyx_v_heads = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_tag_sentence_unlabeled_dependency", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 87, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._tag_sentence_unlabeled_dependency", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(3, 87, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_heads), __pyx_ptype_5numpy_ndarray, 1, "heads", 0))) __PYX_ERR(3, 87, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_10_tag_sentence_unlabeled_dependency(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_heads);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_10_tag_sentence_unlabeled_dependency(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_heads) {
  PyObject *__pyx_v_training = NULL;
  PyObject *__pyx_v_num_tokens = NULL;
  PyArrayObject *__pyx_v_token_scores = 0;
  PyObject *__pyx_v_token = NULL;
  PyObject *__pyx_v_head = NULL;
  PyObject *__pyx_v_answer = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_token_scores;
  __Pyx_Buffer __pyx_pybuffer_token_scores;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *(*__pyx_t_8)(PyObject *);
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyArrayObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_tag_sentence_unlabeled_dependency", 0);
  __Pyx_TraceCall("_tag_sentence_unlabeled_dependency", __pyx_f[3], 87, 0, __PYX_ERR(3, 87, __pyx_L1_error));
  __pyx_pybuffer_token_scores.pybuffer.buf = NULL;
  __pyx_pybuffer_token_scores.refcount = 0;
  __pyx_pybuffernd_token_scores.data = NULL;
  __pyx_pybuffernd_token_scores.rcbuffer = &__pyx_pybuffer_token_scores;

  /* "networkdependencyconv.pyx":94
 *         algorithm.
 *         """
 *         training = heads is not None             # <<<<<<<<<<<<<<
 *         self._pre_tagging_setup(sentence, training)
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_heads) != Py_None);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 94, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_training = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":95
 *         """
 *         training = heads is not None
 *         self._pre_tagging_setup(sentence, training)             # <<<<<<<<<<<<<<
 * 
 *         num_tokens = len(sentence)
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pre_tagging_setup); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 95, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_sentence), __pyx_v_training};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 95, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_sentence), __pyx_v_training};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 95, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
    __Pyx_INCREF(__pyx_v_training);
    __Pyx_GIVEREF(__pyx_v_training);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_training);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 95, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":97
 *         self._pre_tagging_setup(sentence, training)
 * 
 *         num_tokens = len(sentence)             # <<<<<<<<<<<<<<
 *         # dependency_weights [i, j] has the score for token i having j as a head.
 *         # the main diagonal has the values for dependencies from the root and is
 */
  __pyx_t_7 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(3, 97, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_num_tokens = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":101
 *         # the main diagonal has the values for dependencies from the root and is
 *         # later copied to the last column for easier processing
 *         self.dependency_weights = np.empty((num_tokens, num_tokens + 1))             # <<<<<<<<<<<<<<
 * 
 *         cdef np.ndarray[FLOAT_t, ndim=1] token_scores
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_num_tokens, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_num_tokens);
  __Pyx_GIVEREF(__pyx_v_num_tokens);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_num_tokens);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 101, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 101, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->dependency_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->dependency_weights));
  __pyx_v_self->dependency_weights = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":108
 *         # sentence tokens are scored with respect to it (in order to determine the
 *         # dependency weights)
 *         for token in range(num_tokens):             # <<<<<<<<<<<<<<
 * 
 *             # _sentence_convolution returns a 2-dim array. in dep parsing,
 */
  __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_num_tokens); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_6 = __pyx_t_2; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = Py_TYPE(__pyx_t_6)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 108, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(!__pyx_t_8)) {
      if (likely(PyList_CheckExact(__pyx_t_6))) {
        if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(3, 108, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 108, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(3, 108, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 108, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_8(__pyx_t_6);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(3, 108, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_token, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":112
 *             # _sentence_convolution returns a 2-dim array. in dep parsing,
 *             # we only have one dimension, so reshape it
 *             token_scores = self._sentence_convolution(sentence, token,             # <<<<<<<<<<<<<<
 *                                                       training=training).reshape(num_tokens)
 *             self.dependency_weights[token, :-1] = token_scores
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sentence_convolution); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_sentence));
    __Pyx_INCREF(__pyx_v_token);
    __Pyx_GIVEREF(__pyx_v_token);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_token);

    /* "networkdependencyconv.pyx":113
 *             # we only have one dimension, so reshape it
 *             token_scores = self._sentence_convolution(sentence, token,
 *                                                       training=training).reshape(num_tokens)             # <<<<<<<<<<<<<<
 *             self.dependency_weights[token, :-1] = token_scores
 * 
 */
    __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_training, __pyx_v_training) < 0) __PYX_ERR(3, 113, __pyx_L1_error)

    /* "networkdependencyconv.pyx":112
 *             # _sentence_convolution returns a 2-dim array. in dep parsing,
 *             # we only have one dimension, so reshape it
 *             token_scores = self._sentence_convolution(sentence, token,             # <<<<<<<<<<<<<<
 *                                                       training=training).reshape(num_tokens)
 *             self.dependency_weights[token, :-1] = token_scores
 */
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "networkdependencyconv.pyx":113
 *             # we only have one dimension, so reshape it
 *             token_scores = self._sentence_convolution(sentence, token,
 *                                                       training=training).reshape(num_tokens)             # <<<<<<<<<<<<<<
 *             self.dependency_weights[token, :-1] = token_scores
 * 
 */
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_reshape); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_2 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_v_num_tokens) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_num_tokens);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 113, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 113, __pyx_L1_error)
    __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer, (PyObject*)__pyx_v_token_scores, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        }
        __pyx_t_12 = __pyx_t_13 = __pyx_t_14 = 0;
      }
      __pyx_pybuffernd_token_scores.diminfo[0].strides = __pyx_pybuffernd_token_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_token_scores.diminfo[0].shape = __pyx_pybuffernd_token_scores.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(3, 112, __pyx_L1_error)
    }
    __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_token_scores, ((PyArrayObject *)__pyx_t_2));
    __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":114
 *             token_scores = self._sentence_convolution(sentence, token,
 *                                                       training=training).reshape(num_tokens)
 *             self.dependency_weights[token, :-1] = token_scores             # <<<<<<<<<<<<<<
 * 
 *             if training:
 */
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_token);
    __Pyx_GIVEREF(__pyx_v_token);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_token);
    __Pyx_INCREF(__pyx_slice__4);
    __Pyx_GIVEREF(__pyx_slice__4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__4);
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_2, ((PyObject *)__pyx_v_token_scores)) < 0)) __PYX_ERR(3, 114, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":116
 *             self.dependency_weights[token, :-1] = token_scores
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 head = heads[token]
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 116, __pyx_L1_error)
    if (__pyx_t_1) {

      /* "networkdependencyconv.pyx":117
 * 
 *             if training:
 *                 head = heads[token]             # <<<<<<<<<<<<<<
 * 
 *                 if self._calculate_gradients(head, token_scores):
 */
      __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_heads), __pyx_v_token); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 117, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_XDECREF_SET(__pyx_v_head, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "networkdependencyconv.pyx":119
 *                 head = heads[token]
 * 
 *                 if self._calculate_gradients(head, token_scores):             # <<<<<<<<<<<<<<
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, token)
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_gradients); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_head, ((PyObject *)__pyx_v_token_scores)};
        __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 119, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_v_head, ((PyObject *)__pyx_v_token_scores)};
        __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 119, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_2);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 119, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__pyx_t_10) {
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); __pyx_t_10 = NULL;
        }
        __Pyx_INCREF(__pyx_v_head);
        __Pyx_GIVEREF(__pyx_v_head);
        PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, __pyx_v_head);
        __Pyx_INCREF(((PyObject *)__pyx_v_token_scores));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_token_scores));
        PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, ((PyObject *)__pyx_v_token_scores));
        __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 119, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 119, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_1) {

        /* "networkdependencyconv.pyx":120
 * 
 *                 if self._calculate_gradients(head, token_scores):
 *                     self._backpropagate()             # <<<<<<<<<<<<<<
 *                     self._calculate_input_deltas(sentence, token)
 *                     self._adjust_weights(token)
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_backpropagate); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 120, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
          }
        }
        __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_9);
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 120, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "networkdependencyconv.pyx":121
 *                 if self._calculate_gradients(head, token_scores):
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, token)             # <<<<<<<<<<<<<<
 *                     self._adjust_weights(token)
 *                     self._adjust_features(sentence, token)
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_input_deltas); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_3 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_sentence), __pyx_v_token};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 121, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_sentence), __pyx_v_token};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 121, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 121, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          if (__pyx_t_3) {
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
          PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
          __Pyx_INCREF(__pyx_v_token);
          __Pyx_GIVEREF(__pyx_v_token);
          PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_v_token);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 121, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "networkdependencyconv.pyx":122
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, token)
 *                     self._adjust_weights(token)             # <<<<<<<<<<<<<<
 *                     self._adjust_features(sentence, token)
 * 
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_adjust_weights); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 122, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
          }
        }
        __pyx_t_2 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_v_token) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_v_token);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 122, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "networkdependencyconv.pyx":123
 *                     self._calculate_input_deltas(sentence, token)
 *                     self._adjust_weights(token)
 *                     self._adjust_features(sentence, token)             # <<<<<<<<<<<<<<
 * 
 *         # copy dependency weights from the root to each token to the last column and
 */
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_adjust_features); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 123, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_9, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_sentence), __pyx_v_token};
          __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 123, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_sentence), __pyx_v_token};
          __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 123, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else
        #endif
        {
          __pyx_t_3 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 123, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          if (__pyx_t_10) {
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); __pyx_t_10 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
          PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
          __Pyx_INCREF(__pyx_v_token);
          __Pyx_GIVEREF(__pyx_v_token);
          PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_v_token);
          __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 123, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "networkdependencyconv.pyx":119
 *                 head = heads[token]
 * 
 *                 if self._calculate_gradients(head, token_scores):             # <<<<<<<<<<<<<<
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, token)
 */
      }

      /* "networkdependencyconv.pyx":116
 *             self.dependency_weights[token, :-1] = token_scores
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 head = heads[token]
 * 
 */
    }

    /* "networkdependencyconv.pyx":108
 *         # sentence tokens are scored with respect to it (in order to determine the
 *         # dependency weights)
 *         for token in range(num_tokens):             # <<<<<<<<<<<<<<
 * 
 *             # _sentence_convolution returns a 2-dim array. in dep parsing,
 */
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "networkdependencyconv.pyx":128
 *         # effectively ignore the main diagonal (dependency to the token itself)
 *         self.dependency_weights[np.arange(num_tokens),
 *                                 -1] = self.dependency_weights.diagonal()             # <<<<<<<<<<<<<<
 *         np.fill_diagonal(self.dependency_weights, -np.Infinity)
 *         answer = self._find_maximum_spanning_tree()
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->dependency_weights), __pyx_n_s_diagonal); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_6 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":127
 *         # copy dependency weights from the root to each token to the last column and
 *         # effectively ignore the main diagonal (dependency to the token itself)
 *         self.dependency_weights[np.arange(num_tokens),             # <<<<<<<<<<<<<<
 *                                 -1] = self.dependency_weights.diagonal()
 *         np.fill_diagonal(self.dependency_weights, -np.Infinity)
 */
  __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_arange); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_2 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_9, __pyx_v_num_tokens) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_num_tokens);
  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_int_neg_1);
  __Pyx_GIVEREF(__pyx_int_neg_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_neg_1);
  __pyx_t_2 = 0;
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_3, __pyx_t_6) < 0)) __PYX_ERR(3, 127, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "networkdependencyconv.pyx":129
 *         self.dependency_weights[np.arange(num_tokens),
 *                                 -1] = self.dependency_weights.diagonal()
 *         np.fill_diagonal(self.dependency_weights, -np.Infinity)             # <<<<<<<<<<<<<<
 *         answer = self._find_maximum_spanning_tree()
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_fill_diagonal); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Infinity); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Negative(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_3};
    __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 129, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
    PyObject *__pyx_temp[3] = {__pyx_t_9, ((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_3};
    __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 129, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_9) {
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_self->dependency_weights));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self->dependency_weights));
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_5, ((PyObject *)__pyx_v_self->dependency_weights));
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_5, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 129, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "networkdependencyconv.pyx":130
 *                                 -1] = self.dependency_weights.diagonal()
 *         np.fill_diagonal(self.dependency_weights, -np.Infinity)
 *         answer = self._find_maximum_spanning_tree()             # <<<<<<<<<<<<<<
 * 
 *         return answer
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_find_maximum_spanning_tree); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_6 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_answer = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "networkdependencyconv.pyx":132
 *         answer = self._find_maximum_spanning_tree()
 * 
 *         return answer             # <<<<<<<<<<<<<<
 * 
 *     def _tag_sentence_labeled_dependency(self, np.ndarray sentence, np.ndarray heads,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_answer);
  __pyx_r = __pyx_v_answer;
  goto __pyx_L0;

  /* "networkdependencyconv.pyx":87
 *             self._tag_sentence_labeled_dependency(sentence, heads, labels)
 * 
 *     def _tag_sentence_unlabeled_dependency(self, np.ndarray sentence, np.ndarray heads=None):             # <<<<<<<<<<<<<<
 *         """
 *         Run the network for the unlabeled dependency task.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._tag_sentence_unlabeled_dependency", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_token_scores.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_training);
  __Pyx_XDECREF(__pyx_v_num_tokens);
  __Pyx_XDECREF((PyObject *)__pyx_v_token_scores);
  __Pyx_XDECREF(__pyx_v_token);
  __Pyx_XDECREF(__pyx_v_head);
  __Pyx_XDECREF(__pyx_v_answer);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":134
 *         return answer
 * 
 *     def _tag_sentence_labeled_dependency(self, np.ndarray sentence, np.ndarray heads,             # <<<<<<<<<<<<<<
 *                                          np.ndarray labels=None):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_13_tag_sentence_labeled_dependency(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_12_tag_sentence_labeled_dependency[] = "ConvolutionalDependencyNetwork._tag_sentence_labeled_dependency(self, ndarray sentence, ndarray heads, ndarray labels=None)\n\n        Run the network for labeling pre determined dependency edges between tokens.\n        This is similar to the classification step in SRL.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_13_tag_sentence_labeled_dependency(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_sentence = 0;
  PyArrayObject *__pyx_v_heads = 0;
  PyArrayObject *__pyx_v_labels = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_tag_sentence_labeled_dependency (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_heads,&__pyx_n_s_labels,0};
    PyObject* values[3] = {0,0,0};

    /* "networkdependencyconv.pyx":135
 * 
 *     def _tag_sentence_labeled_dependency(self, np.ndarray sentence, np.ndarray heads,
 *                                          np.ndarray labels=None):             # <<<<<<<<<<<<<<
 *         """
 *         Run the network for labeling pre determined dependency edges between tokens.
 */
    values[2] = (PyObject *)((PyArrayObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_heads)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_tag_sentence_labeled_dependency", 0, 2, 3, 1); __PYX_ERR(3, 134, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_labels);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_tag_sentence_labeled_dependency") < 0)) __PYX_ERR(3, 134, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = ((PyArrayObject *)values[0]);
    __pyx_v_heads = ((PyArrayObject *)values[1]);
    __pyx_v_labels = ((PyArrayObject *)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_tag_sentence_labeled_dependency", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 134, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._tag_sentence_labeled_dependency", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(3, 134, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_heads), __pyx_ptype_5numpy_ndarray, 1, "heads", 0))) __PYX_ERR(3, 134, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_labels), __pyx_ptype_5numpy_ndarray, 1, "labels", 0))) __PYX_ERR(3, 135, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_12_tag_sentence_labeled_dependency(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_heads, __pyx_v_labels);

  /* "networkdependencyconv.pyx":134
 *         return answer
 * 
 *     def _tag_sentence_labeled_dependency(self, np.ndarray sentence, np.ndarray heads,             # <<<<<<<<<<<<<<
 *                                          np.ndarray labels=None):
 *         """
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_12_tag_sentence_labeled_dependency(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_heads, PyArrayObject *__pyx_v_labels) {
  PyArrayObject *__pyx_v_answer = 0;
  PyArrayObject *__pyx_v_scores = 0;
  PyObject *__pyx_v_training = NULL;
  Py_ssize_t __pyx_v_token;
  PyObject *__pyx_v_head = NULL;
  PyObject *__pyx_v_label = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_answer;
  __Pyx_Buffer __pyx_pybuffer_answer;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_scores;
  __Pyx_Buffer __pyx_pybuffer_scores;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyArrayObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  Py_ssize_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyArrayObject *__pyx_t_15 = NULL;
  __pyx_t_4libs_7network_FLOAT_t __pyx_t_16;
  Py_ssize_t __pyx_t_17;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_tag_sentence_labeled_dependency", 0);
  __Pyx_TraceCall("_tag_sentence_labeled_dependency", __pyx_f[3], 134, 0, __PYX_ERR(3, 134, __pyx_L1_error));
  __pyx_pybuffer_answer.pybuffer.buf = NULL;
  __pyx_pybuffer_answer.refcount = 0;
  __pyx_pybuffernd_answer.data = NULL;
  __pyx_pybuffernd_answer.rcbuffer = &__pyx_pybuffer_answer;
  __pyx_pybuffer_scores.pybuffer.buf = NULL;
  __pyx_pybuffer_scores.refcount = 0;
  __pyx_pybuffernd_scores.data = NULL;
  __pyx_pybuffernd_scores.rcbuffer = &__pyx_pybuffer_scores;

  /* "networkdependencyconv.pyx":142
 *         cdef np.ndarray[FLOAT_t, ndim=1] answer
 *         cdef np.ndarray[FLOAT_t, ndim=2] scores
 *         training = labels is not None             # <<<<<<<<<<<<<<
 *         self._pre_tagging_setup(sentence, training)
 * 
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_labels) != Py_None);
  __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_training = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":143
 *         cdef np.ndarray[FLOAT_t, ndim=2] scores
 *         training = labels is not None
 *         self._pre_tagging_setup(sentence, training)             # <<<<<<<<<<<<<<
 * 
 *         answer = np.zeros(len(sentence))
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pre_tagging_setup); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 143, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  __pyx_t_5 = 0;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_5 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_sentence), __pyx_v_training};
    __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 143, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, ((PyObject *)__pyx_v_sentence), __pyx_v_training};
    __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 143, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else
  #endif
  {
    __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
    PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
    __Pyx_INCREF(__pyx_v_training);
    __Pyx_GIVEREF(__pyx_v_training);
    PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_training);
    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":145
 *         self._pre_tagging_setup(sentence, training)
 * 
 *         answer = np.zeros(len(sentence))             # <<<<<<<<<<<<<<
 * 
 *         # as in unlabeled dependency, each token is treated as a predicate from the
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(3, 145, __pyx_L1_error)
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 145, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 145, __pyx_L1_error)
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_answer.rcbuffer->pybuffer);
    __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_answer.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_5 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_answer.rcbuffer->pybuffer, (PyObject*)__pyx_v_answer, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
      __pyx_t_9 = __pyx_t_10 = __pyx_t_11 = 0;
    }
    __pyx_pybuffernd_answer.diminfo[0].strides = __pyx_pybuffernd_answer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_answer.diminfo[0].shape = __pyx_pybuffernd_answer.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(3, 145, __pyx_L1_error)
  }
  __pyx_t_8 = 0;
  __pyx_v_answer = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":149
 *         # as in unlabeled dependency, each token is treated as a predicate from the
 *         # SRL point of view. The only target is its head
 *         for token in range(len(sentence)):             # <<<<<<<<<<<<<<
 *             head = heads[token]
 * 
 */
  __pyx_t_7 = PyObject_Length(((PyObject *)__pyx_v_sentence)); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(3, 149, __pyx_L1_error)
  __pyx_t_12 = __pyx_t_7;
  for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
    __pyx_v_token = __pyx_t_13;

    /* "networkdependencyconv.pyx":150
 *         # SRL point of view. The only target is its head
 *         for token in range(len(sentence)):
 *             head = heads[token]             # <<<<<<<<<<<<<<
 * 
 *             # weird format just to take advantage of the SRL classification code
 */
    __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_heads), __pyx_v_token, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_XDECREF_SET(__pyx_v_head, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":154
 *             # weird format just to take advantage of the SRL classification code
 *             # it means that the target starts at position *head* and ends at *head*
 *             head = [[head, head]]             # <<<<<<<<<<<<<<
 * 
 *             # it will return a 2-dim array, but we only have one target
 */
    __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_head);
    __Pyx_GIVEREF(__pyx_v_head);
    PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_head);
    __Pyx_INCREF(__pyx_v_head);
    __Pyx_GIVEREF(__pyx_v_head);
    PyList_SET_ITEM(__pyx_t_2, 1, __pyx_v_head);
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_2);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
    __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_head, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "networkdependencyconv.pyx":158
 *             # it will return a 2-dim array, but we only have one target
 *             # argmax() works as expected
 *             scores = self._sentence_convolution(sentence, token, head, training)             # <<<<<<<<<<<<<<
 *             answer[token] = scores.argmax()
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_sentence_convolution); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_token); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 158, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = NULL;
    __pyx_t_5 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
        __pyx_t_5 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_4, ((PyObject *)__pyx_v_sentence), __pyx_t_3, __pyx_v_head, __pyx_v_training};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 158, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[5] = {__pyx_t_4, ((PyObject *)__pyx_v_sentence), __pyx_t_3, __pyx_v_head, __pyx_v_training};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 158, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (__pyx_t_4) {
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __pyx_t_4 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
      PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_5, __pyx_t_3);
      __Pyx_INCREF(__pyx_v_head);
      __Pyx_GIVEREF(__pyx_v_head);
      PyTuple_SET_ITEM(__pyx_t_14, 2+__pyx_t_5, __pyx_v_head);
      __Pyx_INCREF(__pyx_v_training);
      __Pyx_GIVEREF(__pyx_v_training);
      PyTuple_SET_ITEM(__pyx_t_14, 3+__pyx_t_5, __pyx_v_training);
      __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 158, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 158, __pyx_L1_error)
    __pyx_t_15 = ((PyArrayObject *)__pyx_t_6);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
      __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_scores.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_5 < 0)) {
        PyErr_Fetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_scores.rcbuffer->pybuffer, (PyObject*)__pyx_v_scores, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
        }
        __pyx_t_11 = __pyx_t_10 = __pyx_t_9 = 0;
      }
      __pyx_pybuffernd_scores.diminfo[0].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_scores.diminfo[0].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_scores.diminfo[1].strides = __pyx_pybuffernd_scores.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_scores.diminfo[1].shape = __pyx_pybuffernd_scores.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(3, 158, __pyx_L1_error)
    }
    __pyx_t_15 = 0;
    __Pyx_XDECREF_SET(__pyx_v_scores, ((PyArrayObject *)__pyx_t_6));
    __pyx_t_6 = 0;

    /* "networkdependencyconv.pyx":159
 *             # argmax() works as expected
 *             scores = self._sentence_convolution(sentence, token, head, training)
 *             answer[token] = scores.argmax()             # <<<<<<<<<<<<<<
 * 
 *             if training:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_scores), __pyx_n_s_argmax); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_14 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_6 = (__pyx_t_14) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_14) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 159, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_16 == ((npy_double)-1)) && PyErr_Occurred())) __PYX_ERR(3, 159, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_17 = __pyx_v_token;
    __pyx_t_5 = -1;
    if (__pyx_t_17 < 0) {
      __pyx_t_17 += __pyx_pybuffernd_answer.diminfo[0].shape;
      if (unlikely(__pyx_t_17 < 0)) __pyx_t_5 = 0;
    } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_answer.diminfo[0].shape)) __pyx_t_5 = 0;
    if (unlikely(__pyx_t_5 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_5);
      __PYX_ERR(3, 159, __pyx_L1_error)
    }
    *__Pyx_BufPtrStrided1d(__pyx_t_4libs_7network_FLOAT_t *, __pyx_pybuffernd_answer.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_answer.diminfo[0].strides) = __pyx_t_16;

    /* "networkdependencyconv.pyx":161
 *             answer[token] = scores.argmax()
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 label = labels[token]
 *                 if self._calculate_gradients_classify([label], scores):
 */
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_training); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 161, __pyx_L1_error)
    if (__pyx_t_1) {

      /* "networkdependencyconv.pyx":162
 * 
 *             if training:
 *                 label = labels[token]             # <<<<<<<<<<<<<<
 *                 if self._calculate_gradients_classify([label], scores):
 *                     self._backpropagate()
 */
      __pyx_t_6 = __Pyx_GetItemInt(((PyObject *)__pyx_v_labels), __pyx_v_token, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 162, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_label, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "networkdependencyconv.pyx":163
 *             if training:
 *                 label = labels[token]
 *                 if self._calculate_gradients_classify([label], scores):             # <<<<<<<<<<<<<<
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, token, head)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_gradients_classify); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_14 = PyList_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 163, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_INCREF(__pyx_v_label);
      __Pyx_GIVEREF(__pyx_v_label);
      PyList_SET_ITEM(__pyx_t_14, 0, __pyx_v_label);
      __pyx_t_3 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_14, ((PyObject *)__pyx_v_scores)};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 163, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
        PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_14, ((PyObject *)__pyx_v_scores)};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 163, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      {
        __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 163, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (__pyx_t_3) {
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_t_14);
        __Pyx_INCREF(((PyObject *)__pyx_v_scores));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_scores));
        PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, ((PyObject *)__pyx_v_scores));
        __pyx_t_14 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 163, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(3, 163, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_1) {

        /* "networkdependencyconv.pyx":164
 *                 label = labels[token]
 *                 if self._calculate_gradients_classify([label], scores):
 *                     self._backpropagate()             # <<<<<<<<<<<<<<
 *                     self._calculate_input_deltas(sentence, token, head)
 *                     self._adjust_weights(token, head)
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_backpropagate); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 164, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
          }
        }
        __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 164, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "networkdependencyconv.pyx":165
 *                 if self._calculate_gradients_classify([label], scores):
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, token, head)             # <<<<<<<<<<<<<<
 *                     self._adjust_weights(token, head)
 *                     self._adjust_features(sentence, token)
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_calculate_input_deltas); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 165, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_token); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 165, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_14 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_14)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[4] = {__pyx_t_14, ((PyObject *)__pyx_v_sentence), __pyx_t_4, __pyx_v_head};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 165, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[4] = {__pyx_t_14, ((PyObject *)__pyx_v_sentence), __pyx_t_4, __pyx_v_head};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 3+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 165, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_3 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 165, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          if (__pyx_t_14) {
            __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_14); __pyx_t_14 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
          PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_5, __pyx_t_4);
          __Pyx_INCREF(__pyx_v_head);
          __Pyx_GIVEREF(__pyx_v_head);
          PyTuple_SET_ITEM(__pyx_t_3, 2+__pyx_t_5, __pyx_v_head);
          __pyx_t_4 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 165, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "networkdependencyconv.pyx":166
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, token, head)
 *                     self._adjust_weights(token, head)             # <<<<<<<<<<<<<<
 *                     self._adjust_features(sentence, token)
 * 
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_adjust_weights); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 166, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_token); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 166, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_v_head};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 166, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_3, __pyx_v_head};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 166, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_14 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 166, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          if (__pyx_t_4) {
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __pyx_t_4 = NULL;
          }
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_5, __pyx_t_3);
          __Pyx_INCREF(__pyx_v_head);
          __Pyx_GIVEREF(__pyx_v_head);
          PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_5, __pyx_v_head);
          __pyx_t_3 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 166, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "networkdependencyconv.pyx":167
 *                     self._calculate_input_deltas(sentence, token, head)
 *                     self._adjust_weights(token, head)
 *                     self._adjust_features(sentence, token)             # <<<<<<<<<<<<<<
 * 
 * 
 */
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_adjust_features); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 167, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_14 = PyInt_FromSsize_t(__pyx_v_token); if (unlikely(!__pyx_t_14)) __PYX_ERR(3, 167, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_3 = NULL;
        __pyx_t_5 = 0;
        if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_2, function);
            __pyx_t_5 = 1;
          }
        }
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_sentence), __pyx_t_14};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 167, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_sentence), __pyx_t_14};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 167, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 167, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (__pyx_t_3) {
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL;
          }
          __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
          PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, ((PyObject *)__pyx_v_sentence));
          __Pyx_GIVEREF(__pyx_t_14);
          PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_14);
          __pyx_t_14 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 167, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "networkdependencyconv.pyx":163
 *             if training:
 *                 label = labels[token]
 *                 if self._calculate_gradients_classify([label], scores):             # <<<<<<<<<<<<<<
 *                     self._backpropagate()
 *                     self._calculate_input_deltas(sentence, token, head)
 */
      }

      /* "networkdependencyconv.pyx":161
 *             answer[token] = scores.argmax()
 * 
 *             if training:             # <<<<<<<<<<<<<<
 *                 label = labels[token]
 *                 if self._calculate_gradients_classify([label], scores):
 */
    }
  }

  /* "networkdependencyconv.pyx":170
 * 
 * 
 *         return answer             # <<<<<<<<<<<<<<
 * 
 *     def _calculate_gradients(self, gold_head, scores):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_answer));
  __pyx_r = ((PyObject *)__pyx_v_answer);
  goto __pyx_L0;

  /* "networkdependencyconv.pyx":134
 *         return answer
 * 
 *     def _tag_sentence_labeled_dependency(self, np.ndarray sentence, np.ndarray heads,             # <<<<<<<<<<<<<<
 *                                          np.ndarray labels=None):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_14);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_answer.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._tag_sentence_labeled_dependency", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_answer.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_scores.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_answer);
  __Pyx_XDECREF((PyObject *)__pyx_v_scores);
  __Pyx_XDECREF(__pyx_v_training);
  __Pyx_XDECREF(__pyx_v_head);
  __Pyx_XDECREF(__pyx_v_label);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":172
 *         return answer
 * 
 *     def _calculate_gradients(self, gold_head, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculate the gradients to be applied in the backpropagation. Gradients
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_15_calculate_gradients(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_14_calculate_gradients[] = "ConvolutionalDependencyNetwork._calculate_gradients(self, gold_head, scores)\n\n        Calculate the gradients to be applied in the backpropagation. Gradients\n        are calculated after the network has output the scores for assigning \n        each token as head of a given token. \n        \n        We aim at maximizing the log probability of the right head:\n        log(p(head)) = score(head) - logadd(scores for all heads)\n        \n        :param gold_head: the index of the token that should have the highest \n            score\n        :param scores: the scores output by the network\n        :returns: if True, normal gradient calculation was performed.\n            If False, the error was too low and weight correction should be\n            skipped. \n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_15_calculate_gradients(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_gold_head = 0;
  PyObject *__pyx_v_scores = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_gradients (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_gold_head,&__pyx_n_s_scores,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gold_head)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_scores)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_calculate_gradients", 1, 2, 2, 1); __PYX_ERR(3, 172, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_calculate_gradients") < 0)) __PYX_ERR(3, 172, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_gold_head = values[0];
    __pyx_v_scores = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_calculate_gradients", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 172, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._calculate_gradients", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_14_calculate_gradients(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_gold_head, __pyx_v_scores);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_14_calculate_gradients(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_gold_head, PyObject *__pyx_v_scores) {
  PyArrayObject *__pyx_v_exp_scores = 0;
  PyObject *__pyx_v_exp_sum = NULL;
  PyObject *__pyx_v_error = NULL;
  PyObject *__pyx_v_new_shape = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_exp_scores;
  __Pyx_Buffer __pyx_pybuffer_exp_scores;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyArrayObject *__pyx_t_4 = NULL;
  float __pyx_t_5;
  int __pyx_t_6;
  PyArrayObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculate_gradients", 0);
  __Pyx_TraceCall("_calculate_gradients", __pyx_f[3], 172, 0, __PYX_ERR(3, 172, __pyx_L1_error));
  __pyx_pybuffer_exp_scores.pybuffer.buf = NULL;
  __pyx_pybuffer_exp_scores.refcount = 0;
  __pyx_pybuffernd_exp_scores.data = NULL;
  __pyx_pybuffernd_exp_scores.rcbuffer = &__pyx_pybuffer_exp_scores;

  /* "networkdependencyconv.pyx":191
 *         # -exp(score(token)) / sum_j exp(score(token_j))
 *         # i.e., the negative of its probability
 *         cdef np.ndarray[FLOAT_t, ndim=1] exp_scores = np.exp(scores)             # <<<<<<<<<<<<<<
 *         exp_sum = np.sum(exp_scores)
 *         self.net_gradients = -exp_scores / exp_sum
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_exp); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_scores) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_scores);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 191, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 191, __pyx_L1_error)
  __pyx_t_4 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_exp_scores.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_exp_scores = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_exp_scores.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(3, 191, __pyx_L1_error)
    } else {__pyx_pybuffernd_exp_scores.diminfo[0].strides = __pyx_pybuffernd_exp_scores.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_exp_scores.diminfo[0].shape = __pyx_pybuffernd_exp_scores.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_4 = 0;
  __pyx_v_exp_scores = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":192
 *         # i.e., the negative of its probability
 *         cdef np.ndarray[FLOAT_t, ndim=1] exp_scores = np.exp(scores)
 *         exp_sum = np.sum(exp_scores)             # <<<<<<<<<<<<<<
 *         self.net_gradients = -exp_scores / exp_sum
 *         error = 1 + self.net_gradients[gold_head]
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sum); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_v_exp_scores)) : __Pyx_PyObject_CallOneArg(__pyx_t_2, ((PyObject *)__pyx_v_exp_scores));
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 192, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_exp_sum = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":193
 *         cdef np.ndarray[FLOAT_t, ndim=1] exp_scores = np.exp(scores)
 *         exp_sum = np.sum(exp_scores)
 *         self.net_gradients = -exp_scores / exp_sum             # <<<<<<<<<<<<<<
 *         error = 1 + self.net_gradients[gold_head]
 *         self.error += error
 */
  __pyx_t_1 = PyNumber_Negative(((PyObject *)__pyx_v_exp_scores)); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_v_exp_sum); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 193, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.net_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients));
  __pyx_v_self->__pyx_base.__pyx_base.net_gradients = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":194
 *         exp_sum = np.sum(exp_scores)
 *         self.net_gradients = -exp_scores / exp_sum
 *         error = 1 + self.net_gradients[gold_head]             # <<<<<<<<<<<<<<
 *         self.error += error
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients), __pyx_v_gold_head); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_AddCObj(__pyx_int_1, __pyx_t_2, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_error = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":195
 *         self.net_gradients = -exp_scores / exp_sum
 *         error = 1 + self.net_gradients[gold_head]
 *         self.error += error             # <<<<<<<<<<<<<<
 * 
 *         # check if the error is too small - if so, not worth to continue
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.error); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_v_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) __PYX_ERR(3, 195, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->__pyx_base.__pyx_base.error = __pyx_t_5;

  /* "networkdependencyconv.pyx":198
 * 
 *         # check if the error is too small - if so, not worth to continue
 *         if error <= 0.01:             # <<<<<<<<<<<<<<
 *             self.skips += 1
 *             return False
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_error, __pyx_float_0_01, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 198, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_6) {

    /* "networkdependencyconv.pyx":199
 *         # check if the error is too small - if so, not worth to continue
 *         if error <= 0.01:
 *             self.skips += 1             # <<<<<<<<<<<<<<
 *             return False
 * 
 */
    __pyx_v_self->__pyx_base.__pyx_base.skips = (__pyx_v_self->__pyx_base.__pyx_base.skips + 1);

    /* "networkdependencyconv.pyx":200
 *         if error <= 0.01:
 *             self.skips += 1
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         # and add 1 to the right head
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "networkdependencyconv.pyx":198
 * 
 *         # check if the error is too small - if so, not worth to continue
 *         if error <= 0.01:             # <<<<<<<<<<<<<<
 *             self.skips += 1
 *             return False
 */
  }

  /* "networkdependencyconv.pyx":203
 * 
 *         # and add 1 to the right head
 *         self.net_gradients[gold_head] += 1             # <<<<<<<<<<<<<<
 * 
 *         # the ConvolutionalNetwork class deals with multi dimensional gradients
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients));
  __pyx_t_7 = __pyx_v_self->__pyx_base.__pyx_base.net_gradients;
  __Pyx_INCREF(__pyx_v_gold_head);
  __pyx_t_2 = __pyx_v_gold_head;
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_t_7), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_t_7), __pyx_t_2, __pyx_t_3) < 0)) __PYX_ERR(3, 203, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;

  /* "networkdependencyconv.pyx":207
 *         # the ConvolutionalNetwork class deals with multi dimensional gradients
 *         # (because of more than one output neuron), so let's reshape
 *         new_shape = (self.net_gradients.shape[0], 1)             # <<<<<<<<<<<<<<
 *         self.net_gradients = self.net_gradients.reshape(new_shape)
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_self->__pyx_base.__pyx_base.net_gradients->dimensions[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_1);
  __pyx_t_2 = 0;
  __pyx_v_new_shape = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "networkdependencyconv.pyx":208
 *         # (because of more than one output neuron), so let's reshape
 *         new_shape = (self.net_gradients.shape[0], 1)
 *         self.net_gradients = self.net_gradients.reshape(new_shape)             # <<<<<<<<<<<<<<
 * 
 *         return True
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients), __pyx_n_s_reshape); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_v_new_shape) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_new_shape);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 208, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 208, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_3);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.__pyx_base.net_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients));
  __pyx_v_self->__pyx_base.__pyx_base.net_gradients = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "networkdependencyconv.pyx":210
 *         self.net_gradients = self.net_gradients.reshape(new_shape)
 * 
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     def _validate(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;

  /* "networkdependencyconv.pyx":172
 *         return answer
 * 
 *     def _calculate_gradients(self, gold_head, scores):             # <<<<<<<<<<<<<<
 *         """
 *         Calculate the gradients to be applied in the backpropagation. Gradients
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(((PyObject *)__pyx_t_7));
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_exp_scores.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._calculate_gradients", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_exp_scores.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_exp_scores);
  __Pyx_XDECREF(__pyx_v_exp_sum);
  __Pyx_XDECREF(__pyx_v_error);
  __Pyx_XDECREF(__pyx_v_new_shape);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":212
 *         return True
 * 
 *     def _validate(self):             # <<<<<<<<<<<<<<
 *         """
 *         Evaluate the network performance by token hit and whole sentence hit.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_17_validate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_16_validate[] = "ConvolutionalDependencyNetwork._validate(self)\n\n        Evaluate the network performance by token hit and whole sentence hit.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_17_validate(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_validate (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_16_validate(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_16_validate(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self) {
  PyObject *__pyx_v_hits = NULL;
  PyObject *__pyx_v_num_tokens = NULL;
  PyObject *__pyx_v_sentence_hits = NULL;
  Py_ssize_t __pyx_v_i;
  PyObject *__pyx_v_sent = NULL;
  PyObject *__pyx_v_heads = NULL;
  int __pyx_v_sentence_hit;
  PyObject *__pyx_v_answer = NULL;
  PyObject *__pyx_v_gold_tags = NULL;
  Py_ssize_t __pyx_v_j;
  PyObject *__pyx_v_net_tag = NULL;
  PyObject *__pyx_v_gold_tag = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  Py_ssize_t __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  float __pyx_t_15;
  double __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_validate", 0);
  __Pyx_TraceCall("_validate", __pyx_f[3], 212, 0, __PYX_ERR(3, 212, __pyx_L1_error));

  /* "networkdependencyconv.pyx":216
 *         Evaluate the network performance by token hit and whole sentence hit.
 *         """
 *         hits = 0             # <<<<<<<<<<<<<<
 *         num_tokens = 0
 *         sentence_hits = 0
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_hits = __pyx_int_0;

  /* "networkdependencyconv.pyx":217
 *         """
 *         hits = 0
 *         num_tokens = 0             # <<<<<<<<<<<<<<
 *         sentence_hits = 0
 * 
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_num_tokens = __pyx_int_0;

  /* "networkdependencyconv.pyx":218
 *         hits = 0
 *         num_tokens = 0
 *         sentence_hits = 0             # <<<<<<<<<<<<<<
 * 
 *         for i in range(len(self.validation_sentences)):
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_sentence_hits = __pyx_int_0;

  /* "networkdependencyconv.pyx":220
 *         sentence_hits = 0
 * 
 *         for i in range(len(self.validation_sentences)):             # <<<<<<<<<<<<<<
 *             sent = self.validation_sentences[i]
 *             heads = self.validation_heads[i]
 */
  __pyx_t_1 = __pyx_v_self->__pyx_base.__pyx_base.validation_sentences;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(3, 220, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(3, 220, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_i = __pyx_t_4;

    /* "networkdependencyconv.pyx":221
 * 
 *         for i in range(len(self.validation_sentences)):
 *             sent = self.validation_sentences[i]             # <<<<<<<<<<<<<<
 *             heads = self.validation_heads[i]
 *             sentence_hit = True
 */
    if (unlikely(__pyx_v_self->__pyx_base.__pyx_base.validation_sentences == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(3, 221, __pyx_L1_error)
    }
    __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->__pyx_base.__pyx_base.validation_sentences, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 221, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_sent, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkdependencyconv.pyx":222
 *         for i in range(len(self.validation_sentences)):
 *             sent = self.validation_sentences[i]
 *             heads = self.validation_heads[i]             # <<<<<<<<<<<<<<
 *             sentence_hit = True
 * 
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->validation_heads, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 222, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_heads, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkdependencyconv.pyx":223
 *             sent = self.validation_sentences[i]
 *             heads = self.validation_heads[i]
 *             sentence_hit = True             # <<<<<<<<<<<<<<
 * 
 *             if self.validation_tags is None:
 */
    __pyx_v_sentence_hit = 1;

    /* "networkdependencyconv.pyx":225
 *             sentence_hit = True
 * 
 *             if self.validation_tags is None:             # <<<<<<<<<<<<<<
 *                 # unlabeled dependency
 *                 answer = self._tag_sentence_unlabeled_dependency(sent)
 */
    __pyx_t_5 = (__pyx_v_self->__pyx_base.__pyx_base.validation_tags == ((PyObject*)Py_None));
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "networkdependencyconv.pyx":227
 *             if self.validation_tags is None:
 *                 # unlabeled dependency
 *                 answer = self._tag_sentence_unlabeled_dependency(sent)             # <<<<<<<<<<<<<<
 *                 gold_tags = heads
 *             else:
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence_unlabeled_dependen); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 227, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_v_sent) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_sent);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 227, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF_SET(__pyx_v_answer, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "networkdependencyconv.pyx":228
 *                 # unlabeled dependency
 *                 answer = self._tag_sentence_unlabeled_dependency(sent)
 *                 gold_tags = heads             # <<<<<<<<<<<<<<
 *             else:
 *                 # labeled dependency
 */
      __Pyx_INCREF(__pyx_v_heads);
      __Pyx_XDECREF_SET(__pyx_v_gold_tags, __pyx_v_heads);

      /* "networkdependencyconv.pyx":225
 *             sentence_hit = True
 * 
 *             if self.validation_tags is None:             # <<<<<<<<<<<<<<
 *                 # unlabeled dependency
 *                 answer = self._tag_sentence_unlabeled_dependency(sent)
 */
      goto __pyx_L5;
    }

    /* "networkdependencyconv.pyx":231
 *             else:
 *                 # labeled dependency
 *                 gold_tags = self.validation_tags[i]             # <<<<<<<<<<<<<<
 *                 answer = self._tag_sentence_labeled_dependency(sent, heads)
 * 
 */
    /*else*/ {
      if (unlikely(__pyx_v_self->__pyx_base.__pyx_base.validation_tags == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        __PYX_ERR(3, 231, __pyx_L1_error)
      }
      __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->__pyx_base.__pyx_base.validation_tags, __pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 231, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_gold_tags, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "networkdependencyconv.pyx":232
 *                 # labeled dependency
 *                 gold_tags = self.validation_tags[i]
 *                 answer = self._tag_sentence_labeled_dependency(sent, heads)             # <<<<<<<<<<<<<<
 * 
 *             for j in range(len(gold_tags)):
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence_labeled_dependency); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 232, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = NULL;
      __pyx_t_9 = 0;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
          __pyx_t_9 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_sent, __pyx_v_heads};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 232, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
        PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_sent, __pyx_v_heads};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 232, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 232, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        if (__pyx_t_8) {
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
        }
        __Pyx_INCREF(__pyx_v_sent);
        __Pyx_GIVEREF(__pyx_v_sent);
        PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_v_sent);
        __Pyx_INCREF(__pyx_v_heads);
        __Pyx_GIVEREF(__pyx_v_heads);
        PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_heads);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 232, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF_SET(__pyx_v_answer, __pyx_t_1);
      __pyx_t_1 = 0;
    }
    __pyx_L5:;

    /* "networkdependencyconv.pyx":234
 *                 answer = self._tag_sentence_labeled_dependency(sent, heads)
 * 
 *             for j in range(len(gold_tags)):             # <<<<<<<<<<<<<<
 *                 net_tag = answer[j]
 *                 gold_tag = gold_tags[j]
 */
    __pyx_t_11 = PyObject_Length(__pyx_v_gold_tags); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(3, 234, __pyx_L1_error)
    __pyx_t_12 = __pyx_t_11;
    for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
      __pyx_v_j = __pyx_t_13;

      /* "networkdependencyconv.pyx":235
 * 
 *             for j in range(len(gold_tags)):
 *                 net_tag = answer[j]             # <<<<<<<<<<<<<<
 *                 gold_tag = gold_tags[j]
 * 
 */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_answer, __pyx_v_j, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_net_tag, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "networkdependencyconv.pyx":236
 *             for j in range(len(gold_tags)):
 *                 net_tag = answer[j]
 *                 gold_tag = gold_tags[j]             # <<<<<<<<<<<<<<
 * 
 *                 if net_tag == gold_tag or (gold_tag == j and net_tag == len(sent)):
 */
      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_gold_tags, __pyx_v_j, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 236, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_XDECREF_SET(__pyx_v_gold_tag, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "networkdependencyconv.pyx":238
 *                 gold_tag = gold_tags[j]
 * 
 *                 if net_tag == gold_tag or (gold_tag == j and net_tag == len(sent)):             # <<<<<<<<<<<<<<
 *                     hits += 1
 *                 else:
 */
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_net_tag, __pyx_v_gold_tag, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 238, __pyx_L1_error)
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(3, 238, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!__pyx_t_5) {
      } else {
        __pyx_t_6 = __pyx_t_5;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_j); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 238, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyObject_RichCompare(__pyx_v_gold_tag, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 238, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(3, 238, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_5) {
      } else {
        __pyx_t_6 = __pyx_t_5;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_14 = PyObject_Length(__pyx_v_sent); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(3, 238, __pyx_L1_error)
      __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 238, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = PyObject_RichCompare(__pyx_v_net_tag, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 238, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(3, 238, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_6 = __pyx_t_5;
      __pyx_L9_bool_binop_done:;
      if (__pyx_t_6) {

        /* "networkdependencyconv.pyx":239
 * 
 *                 if net_tag == gold_tag or (gold_tag == j and net_tag == len(sent)):
 *                     hits += 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     sentence_hit = False
 */
        __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_hits, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 239, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF_SET(__pyx_v_hits, __pyx_t_1);
        __pyx_t_1 = 0;

        /* "networkdependencyconv.pyx":238
 *                 gold_tag = gold_tags[j]
 * 
 *                 if net_tag == gold_tag or (gold_tag == j and net_tag == len(sent)):             # <<<<<<<<<<<<<<
 *                     hits += 1
 *                 else:
 */
        goto __pyx_L8;
      }

      /* "networkdependencyconv.pyx":241
 *                     hits += 1
 *                 else:
 *                     sentence_hit = False             # <<<<<<<<<<<<<<
 * 
 *             if sentence_hit:
 */
      /*else*/ {
        __pyx_v_sentence_hit = 0;
      }
      __pyx_L8:;
    }

    /* "networkdependencyconv.pyx":243
 *                     sentence_hit = False
 * 
 *             if sentence_hit:             # <<<<<<<<<<<<<<
 *                 sentence_hits += 1
 *             num_tokens += len(sent)
 */
    __pyx_t_6 = (__pyx_v_sentence_hit != 0);
    if (__pyx_t_6) {

      /* "networkdependencyconv.pyx":244
 * 
 *             if sentence_hit:
 *                 sentence_hits += 1             # <<<<<<<<<<<<<<
 *             num_tokens += len(sent)
 * 
 */
      __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_sentence_hits, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 244, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF_SET(__pyx_v_sentence_hits, __pyx_t_1);
      __pyx_t_1 = 0;

      /* "networkdependencyconv.pyx":243
 *                     sentence_hit = False
 * 
 *             if sentence_hit:             # <<<<<<<<<<<<<<
 *                 sentence_hits += 1
 *             num_tokens += len(sent)
 */
    }

    /* "networkdependencyconv.pyx":245
 *             if sentence_hit:
 *                 sentence_hits += 1
 *             num_tokens += len(sent)             # <<<<<<<<<<<<<<
 * 
 *         self.accuracy = float(hits) / num_tokens
 */
    __pyx_t_11 = PyObject_Length(__pyx_v_sent); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(3, 245, __pyx_L1_error)
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 245, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_num_tokens, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 245, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_num_tokens, __pyx_t_7);
    __pyx_t_7 = 0;
  }

  /* "networkdependencyconv.pyx":247
 *             num_tokens += len(sent)
 * 
 *         self.accuracy = float(hits) / num_tokens             # <<<<<<<<<<<<<<
 *         self.sentence_accuracy = float(sentence_hits) / len(self.validation_sentences)
 * 
 */
  __pyx_t_7 = __Pyx_PyNumber_Float(__pyx_v_hits); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_v_num_tokens); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_15 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_15 == (float)-1) && PyErr_Occurred())) __PYX_ERR(3, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->__pyx_base.__pyx_base.accuracy = __pyx_t_15;

  /* "networkdependencyconv.pyx":248
 * 
 *         self.accuracy = float(hits) / num_tokens
 *         self.sentence_accuracy = float(sentence_hits) / len(self.validation_sentences)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_16 = __Pyx_PyObject_AsDouble(__pyx_v_sentence_hits); if (unlikely(__pyx_t_16 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(3, 248, __pyx_L1_error)
  __pyx_t_1 = __pyx_v_self->__pyx_base.__pyx_base.validation_sentences;
  __Pyx_INCREF(__pyx_t_1);
  if (unlikely(__pyx_t_1 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(3, 248, __pyx_L1_error)
  }
  __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(3, 248, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (unlikely(__pyx_t_2 == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(3, 248, __pyx_L1_error)
  }
  __pyx_v_self->__pyx_base.__pyx_base.sentence_accuracy = (__pyx_t_16 / ((double)__pyx_t_2));

  /* "networkdependencyconv.pyx":212
 *         return True
 * 
 *     def _validate(self):             # <<<<<<<<<<<<<<
 *         """
 *         Evaluate the network performance by token hit and whole sentence hit.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._validate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_hits);
  __Pyx_XDECREF(__pyx_v_num_tokens);
  __Pyx_XDECREF(__pyx_v_sentence_hits);
  __Pyx_XDECREF(__pyx_v_sent);
  __Pyx_XDECREF(__pyx_v_heads);
  __Pyx_XDECREF(__pyx_v_answer);
  __Pyx_XDECREF(__pyx_v_gold_tags);
  __Pyx_XDECREF(__pyx_v_net_tag);
  __Pyx_XDECREF(__pyx_v_gold_tag);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":251
 * 
 * 
 *     def _average_error(self):             # <<<<<<<<<<<<<<
 *         """
 *         Average the network error over tokens.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_19_average_error(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_18_average_error[] = "ConvolutionalDependencyNetwork._average_error(self)\n\n        Average the network error over tokens.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_19_average_error(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_average_error (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_18_average_error(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_18_average_error(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_average_error", 0);
  __Pyx_TraceCall("_average_error", __pyx_f[3], 251, 0, __PYX_ERR(3, 251, __pyx_L1_error));

  /* "networkdependencyconv.pyx":255
 *         Average the network error over tokens.
 *         """
 *         self.error = self.error / self.num_tokens             # <<<<<<<<<<<<<<
 * 
 *     def _print_epoch_report(self, int num):
 */
  if (unlikely(__pyx_v_self->__pyx_base.__pyx_base.num_tokens == 0)) {
    PyErr_SetString(PyExc_ZeroDivisionError, "float division");
    __PYX_ERR(3, 255, __pyx_L1_error)
  }
  __pyx_v_self->__pyx_base.__pyx_base.error = (__pyx_v_self->__pyx_base.__pyx_base.error / ((float)__pyx_v_self->__pyx_base.__pyx_base.num_tokens));

  /* "networkdependencyconv.pyx":251
 * 
 * 
 *     def _average_error(self):             # <<<<<<<<<<<<<<
 *         """
 *         Average the network error over tokens.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._average_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":257
 *         self.error = self.error / self.num_tokens
 * 
 *     def _print_epoch_report(self, int num):             # <<<<<<<<<<<<<<
 *         """
 *         Reports the status of the network in the given training
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_21_print_epoch_report(PyObject *__pyx_v_self, PyObject *__pyx_arg_num); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_20_print_epoch_report[] = "ConvolutionalDependencyNetwork._print_epoch_report(self, int num)\n\n        Reports the status of the network in the given training\n        epoch, including error, token and sentence accuracy.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_21_print_epoch_report(PyObject *__pyx_v_self, PyObject *__pyx_arg_num) {
  int __pyx_v_num;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_print_epoch_report (wrapper)", 0);
  assert(__pyx_arg_num); {
    __pyx_v_num = __Pyx_PyInt_As_int(__pyx_arg_num); if (unlikely((__pyx_v_num == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 257, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._print_epoch_report", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_20_print_epoch_report(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), ((int)__pyx_v_num));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_20_print_epoch_report(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, int __pyx_v_num) {
  PyObject *__pyx_v_logger = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  Py_UCS4 __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_print_epoch_report", 0);
  __Pyx_TraceCall("_print_epoch_report", __pyx_f[3], 257, 0, __PYX_ERR(3, 257, __pyx_L1_error));

  /* "networkdependencyconv.pyx":262
 *         epoch, including error, token and sentence accuracy.
 *         """
 *         logger = logging.getLogger("Logger")             # <<<<<<<<<<<<<<
 *         logger.info("%d epochs   Error: %f   Token accuracy: %f   " \
 *                     "Sentence accuracy: %f    " \
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_n_u_Logger) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_n_u_Logger);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 262, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_logger = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":263
 *         """
 *         logger = logging.getLogger("Logger")
 *         logger.info("%d epochs   Error: %f   Token accuracy: %f   " \             # <<<<<<<<<<<<<<
 *                     "Sentence accuracy: %f    " \
 *                     "%d corrections skipped   " \
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_logger, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(11); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_5 = 127;

  /* "networkdependencyconv.pyx":266
 *                     "Sentence accuracy: %f    " \
 *                     "%d corrections skipped   " \
 *                     "Learning rate: %f"  % (num,             # <<<<<<<<<<<<<<
 *                                             self.error,
 *                                             self.accuracy,
 */
  __pyx_t_6 = __Pyx_PyUnicode_From_int(__pyx_v_num, 0, ' ', 'd'); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_kp_u_epochs_Error);
  __pyx_t_4 += 17;
  __Pyx_GIVEREF(__pyx_kp_u_epochs_Error);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_kp_u_epochs_Error);

  /* "networkdependencyconv.pyx":267
 *                     "%d corrections skipped   " \
 *                     "Learning rate: %f"  % (num,
 *                                             self.error,             # <<<<<<<<<<<<<<
 *                                             self.accuracy,
 *                                             self.sentence_accuracy,
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.error); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_Format(__pyx_t_6, __pyx_n_u_f); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_5;
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_7);
  __pyx_t_7 = 0;
  __Pyx_INCREF(__pyx_kp_u_Token_accuracy);
  __pyx_t_4 += 19;
  __Pyx_GIVEREF(__pyx_kp_u_Token_accuracy);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_kp_u_Token_accuracy);

  /* "networkdependencyconv.pyx":268
 *                     "Learning rate: %f"  % (num,
 *                                             self.error,
 *                                             self.accuracy,             # <<<<<<<<<<<<<<
 *                                             self.sentence_accuracy,
 *                                             self.skips,
 */
  __pyx_t_7 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.accuracy); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_Format(__pyx_t_7, __pyx_n_u_f); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5;
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_6);
  __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_kp_u_Sentence_accuracy);
  __pyx_t_4 += 22;
  __Pyx_GIVEREF(__pyx_kp_u_Sentence_accuracy);
  PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_kp_u_Sentence_accuracy);

  /* "networkdependencyconv.pyx":269
 *                                             self.error,
 *                                             self.accuracy,
 *                                             self.sentence_accuracy,             # <<<<<<<<<<<<<<
 *                                             self.skips,
 *                                             self.learning_rate))
 */
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.sentence_accuracy); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_Format(__pyx_t_6, __pyx_n_u_f); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_5;
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_t_7);
  __pyx_t_7 = 0;
  __Pyx_INCREF(__pyx_kp_u__12);
  __pyx_t_4 += 4;
  __Pyx_GIVEREF(__pyx_kp_u__12);
  PyTuple_SET_ITEM(__pyx_t_2, 7, __pyx_kp_u__12);

  /* "networkdependencyconv.pyx":270
 *                                             self.accuracy,
 *                                             self.sentence_accuracy,
 *                                             self.skips,             # <<<<<<<<<<<<<<
 *                                             self.learning_rate))
 * 
 */
  __pyx_t_7 = __Pyx_PyUnicode_From_int(__pyx_v_self->__pyx_base.__pyx_base.skips, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_2, 8, __pyx_t_7);
  __pyx_t_7 = 0;
  __Pyx_INCREF(__pyx_kp_u_corrections_skipped_Learning_ra);
  __pyx_t_4 += 38;
  __Pyx_GIVEREF(__pyx_kp_u_corrections_skipped_Learning_ra);
  PyTuple_SET_ITEM(__pyx_t_2, 9, __pyx_kp_u_corrections_skipped_Learning_ra);

  /* "networkdependencyconv.pyx":271
 *                                             self.sentence_accuracy,
 *                                             self.skips,
 *                                             self.learning_rate))             # <<<<<<<<<<<<<<
 * 
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray heads=None):
 */
  __pyx_t_7 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.learning_rate); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = __Pyx_PyObject_Format(__pyx_t_7, __pyx_n_u_f); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5;
  __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_2, 10, __pyx_t_6);
  __pyx_t_6 = 0;

  /* "networkdependencyconv.pyx":263
 *         """
 *         logger = logging.getLogger("Logger")
 *         logger.info("%d epochs   Error: %f   Token accuracy: %f   " \             # <<<<<<<<<<<<<<
 *                     "Sentence accuracy: %f    " \
 *                     "%d corrections skipped   " \
 */
  __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_2, 11, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(3, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6);
  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":257
 *         self.error = self.error / self.num_tokens
 * 
 *     def _print_epoch_report(self, int num):             # <<<<<<<<<<<<<<
 *         """
 *         Reports the status of the network in the given training
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._print_epoch_report", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_logger);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":273
 *                                             self.learning_rate))
 * 
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray heads=None):             # <<<<<<<<<<<<<<
 *         """
 *         If heads is not given, compute the dependency edges in the sentence.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_23tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_22tag_sentence[] = "ConvolutionalDependencyNetwork.tag_sentence(self, ndarray sentence, ndarray heads=None)\n\n        If heads is not given, compute the dependency edges in the sentence.\n        If it is given, compute the label of each dependency.\n        \n        :returns: a numpy 1-dim array with the head for each token or label\n            of each edge. In the first case, a dependency from the root is \n            represented as a value equal to the sentence length. \n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_23tag_sentence(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_sentence = 0;
  PyArrayObject *__pyx_v_heads = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tag_sentence (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sentence,&__pyx_n_s_heads,0};
    PyObject* values[2] = {0,0};
    values[1] = (PyObject *)((PyArrayObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sentence)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_heads);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tag_sentence") < 0)) __PYX_ERR(3, 273, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_sentence = ((PyArrayObject *)values[0]);
    __pyx_v_heads = ((PyArrayObject *)values[1]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tag_sentence", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 273, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sentence), __pyx_ptype_5numpy_ndarray, 1, "sentence", 0))) __PYX_ERR(3, 273, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_heads), __pyx_ptype_5numpy_ndarray, 1, "heads", 0))) __PYX_ERR(3, 273, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_22tag_sentence(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_sentence, __pyx_v_heads);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_22tag_sentence(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_sentence, PyArrayObject *__pyx_v_heads) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("tag_sentence", 0);
  __Pyx_TraceCall("tag_sentence", __pyx_f[3], 273, 0, __PYX_ERR(3, 273, __pyx_L1_error));

  /* "networkdependencyconv.pyx":282
 *             represented as a value equal to the sentence length.
 *         """
 *         if heads is None:             # <<<<<<<<<<<<<<
 *             return self._tag_sentence_unlabeled_dependency(sentence)
 *         else:
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_heads) == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "networkdependencyconv.pyx":283
 *         """
 *         if heads is None:
 *             return self._tag_sentence_unlabeled_dependency(sentence)             # <<<<<<<<<<<<<<
 *         else:
 *             return self._tag_sentence_labeled_dependency(sentence, heads)
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence_unlabeled_dependen); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, ((PyObject *)__pyx_v_sentence)) : __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_sentence));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "networkdependencyconv.pyx":282
 *             represented as a value equal to the sentence length.
 *         """
 *         if heads is None:             # <<<<<<<<<<<<<<
 *             return self._tag_sentence_unlabeled_dependency(sentence)
 *         else:
 */
  }

  /* "networkdependencyconv.pyx":285
 *             return self._tag_sentence_unlabeled_dependency(sentence)
 *         else:
 *             return self._tag_sentence_labeled_dependency(sentence, heads)             # <<<<<<<<<<<<<<
 * 
 *     def _find_cycles(self, np.ndarray graph):
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_tag_sentence_labeled_dependency); if (unlikely(!__pyx_t_4)) __PYX_ERR(3, 285, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = NULL;
    __pyx_t_6 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
        __pyx_t_6 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_sentence), ((PyObject *)__pyx_v_heads)};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 285, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_sentence), ((PyObject *)__pyx_v_heads)};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 285, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else
    #endif
    {
      __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_sentence));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_sentence));
      PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_sentence));
      __Pyx_INCREF(((PyObject *)__pyx_v_heads));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_heads));
      PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_heads));
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 285, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "networkdependencyconv.pyx":273
 *                                             self.learning_rate))
 * 
 *     def tag_sentence(self, np.ndarray sentence, np.ndarray heads=None):             # <<<<<<<<<<<<<<
 *         """
 *         If heads is not given, compute the dependency edges in the sentence.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.tag_sentence", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":287
 *             return self._tag_sentence_labeled_dependency(sentence, heads)
 * 
 *     def _find_cycles(self, np.ndarray graph):             # <<<<<<<<<<<<<<
 *         """
 *         Check if the given graph has cycles and returns the first one
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_25_find_cycles(PyObject *__pyx_v_self, PyObject *__pyx_v_graph); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_24_find_cycles[] = "ConvolutionalDependencyNetwork._find_cycles(self, ndarray graph)\n\n        Check if the given graph has cycles and returns the first one\n        to be found.\n        \n        :param graph: an array where graph[i] has the number of a\n            vertex with an incoming connection to i\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_25_find_cycles(PyObject *__pyx_v_self, PyObject *__pyx_v_graph) {
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_cycles (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_graph), __pyx_ptype_5numpy_ndarray, 1, "graph", 0))) __PYX_ERR(3, 287, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_24_find_cycles(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), ((PyArrayObject *)__pyx_v_graph));

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_24_find_cycles(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_graph) {
  PyObject *__pyx_v_reachable_vertices = NULL;
  PyObject *__pyx_v_vertices_in_cycles = NULL;
  PyObject *__pyx_v_visited = NULL;
  PyObject *__pyx_v_cycles = NULL;
  Py_ssize_t __pyx_v_vertex;
  PyObject *__pyx_v_cycle = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  Py_ssize_t __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_find_cycles", 0);
  __Pyx_TraceCall("_find_cycles", __pyx_f[3], 287, 0, __PYX_ERR(3, 287, __pyx_L1_error));

  /* "networkdependencyconv.pyx":296
 *         """
 *         # this set stores all vertices with a valid path to the root
 *         reachable_vertices = set()             # <<<<<<<<<<<<<<
 * 
 *         # vertices known to be unreachable from the root, i.e., in a cycle
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_reachable_vertices = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":299
 * 
 *         # vertices known to be unreachable from the root, i.e., in a cycle
 *         vertices_in_cycles = set()             # <<<<<<<<<<<<<<
 * 
 *         # vertices currently being evaluated, not known if they're reachable
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_vertices_in_cycles = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":302
 * 
 *         # vertices currently being evaluated, not known if they're reachable
 *         visited = set()             # <<<<<<<<<<<<<<
 * 
 *         cycles = []
 */
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_visited = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":304
 *         visited = set()
 * 
 *         cycles = []             # <<<<<<<<<<<<<<
 * 
 *         # the directions of the edges don't matter if we only want to find cycles
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_cycles = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":307
 * 
 *         # the directions of the edges don't matter if we only want to find cycles
 *         for vertex in range(len(graph)):             # <<<<<<<<<<<<<<
 *             if vertex in reachable_vertices or vertex in vertices_in_cycles:
 *                 continue
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_graph)); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(3, 307, __pyx_L1_error)
  __pyx_t_3 = __pyx_t_2;
  for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
    __pyx_v_vertex = __pyx_t_4;

    /* "networkdependencyconv.pyx":308
 *         # the directions of the edges don't matter if we only want to find cycles
 *         for vertex in range(len(graph)):
 *             if vertex in reachable_vertices or vertex in vertices_in_cycles:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_vertex); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (__Pyx_PySet_ContainsTF(__pyx_t_1, __pyx_v_reachable_vertices, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 308, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = (__pyx_t_6 != 0);
    if (!__pyx_t_7) {
    } else {
      __pyx_t_5 = __pyx_t_7;
      goto __pyx_L6_bool_binop_done;
    }
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_vertex); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 308, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = (__Pyx_PySet_ContainsTF(__pyx_t_1, __pyx_v_vertices_in_cycles, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(3, 308, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = (__pyx_t_7 != 0);
    __pyx_t_5 = __pyx_t_6;
    __pyx_L6_bool_binop_done:;
    if (__pyx_t_5) {

      /* "networkdependencyconv.pyx":309
 *         for vertex in range(len(graph)):
 *             if vertex in reachable_vertices or vertex in vertices_in_cycles:
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *             cycle = self._find_cycle_recursive(graph, vertex, visited,
 */
      goto __pyx_L3_continue;

      /* "networkdependencyconv.pyx":308
 *         # the directions of the edges don't matter if we only want to find cycles
 *         for vertex in range(len(graph)):
 *             if vertex in reachable_vertices or vertex in vertices_in_cycles:             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
    }

    /* "networkdependencyconv.pyx":311
 *                 continue
 * 
 *             cycle = self._find_cycle_recursive(graph, vertex, visited,             # <<<<<<<<<<<<<<
 *                                                reachable_vertices, vertices_in_cycles)
 *             if cycle is not None:
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_find_cycle_recursive); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 311, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_vertex); if (unlikely(!__pyx_t_9)) __PYX_ERR(3, 311, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);

    /* "networkdependencyconv.pyx":312
 * 
 *             cycle = self._find_cycle_recursive(graph, vertex, visited,
 *                                                reachable_vertices, vertices_in_cycles)             # <<<<<<<<<<<<<<
 *             if cycle is not None:
 *                 cycles.append(cycle)
 */
    __pyx_t_10 = NULL;
    __pyx_t_11 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
        __pyx_t_11 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[6] = {__pyx_t_10, ((PyObject *)__pyx_v_graph), __pyx_t_9, __pyx_v_visited, __pyx_v_reachable_vertices, __pyx_v_vertices_in_cycles};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 311, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[6] = {__pyx_t_10, ((PyObject *)__pyx_v_graph), __pyx_t_9, __pyx_v_visited, __pyx_v_reachable_vertices, __pyx_v_vertices_in_cycles};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 5+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 311, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(5+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_graph));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_graph));
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, ((PyObject *)__pyx_v_graph));
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_9);
      __Pyx_INCREF(__pyx_v_visited);
      __Pyx_GIVEREF(__pyx_v_visited);
      PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_11, __pyx_v_visited);
      __Pyx_INCREF(__pyx_v_reachable_vertices);
      __Pyx_GIVEREF(__pyx_v_reachable_vertices);
      PyTuple_SET_ITEM(__pyx_t_12, 3+__pyx_t_11, __pyx_v_reachable_vertices);
      __Pyx_INCREF(__pyx_v_vertices_in_cycles);
      __Pyx_GIVEREF(__pyx_v_vertices_in_cycles);
      PyTuple_SET_ITEM(__pyx_t_12, 4+__pyx_t_11, __pyx_v_vertices_in_cycles);
      __pyx_t_9 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 311, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_cycle, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "networkdependencyconv.pyx":313
 *             cycle = self._find_cycle_recursive(graph, vertex, visited,
 *                                                reachable_vertices, vertices_in_cycles)
 *             if cycle is not None:             # <<<<<<<<<<<<<<
 *                 cycles.append(cycle)
 * 
 */
    __pyx_t_5 = (__pyx_v_cycle != Py_None);
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {

      /* "networkdependencyconv.pyx":314
 *                                                reachable_vertices, vertices_in_cycles)
 *             if cycle is not None:
 *                 cycles.append(cycle)             # <<<<<<<<<<<<<<
 * 
 *         return cycles
 */
      __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_cycles, __pyx_v_cycle); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(3, 314, __pyx_L1_error)

      /* "networkdependencyconv.pyx":313
 *             cycle = self._find_cycle_recursive(graph, vertex, visited,
 *                                                reachable_vertices, vertices_in_cycles)
 *             if cycle is not None:             # <<<<<<<<<<<<<<
 *                 cycles.append(cycle)
 * 
 */
    }
    __pyx_L3_continue:;
  }

  /* "networkdependencyconv.pyx":316
 *                 cycles.append(cycle)
 * 
 *         return cycles             # <<<<<<<<<<<<<<
 * 
 *     def _find_cycle_recursive(self, np.ndarray graph, int vertex, set visited,
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_cycles);
  __pyx_r = __pyx_v_cycles;
  goto __pyx_L0;

  /* "networkdependencyconv.pyx":287
 *             return self._tag_sentence_labeled_dependency(sentence, heads)
 * 
 *     def _find_cycles(self, np.ndarray graph):             # <<<<<<<<<<<<<<
 *         """
 *         Check if the given graph has cycles and returns the first one
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._find_cycles", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_reachable_vertices);
  __Pyx_XDECREF(__pyx_v_vertices_in_cycles);
  __Pyx_XDECREF(__pyx_v_visited);
  __Pyx_XDECREF(__pyx_v_cycles);
  __Pyx_XDECREF(__pyx_v_cycle);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":318
 *         return cycles
 * 
 *     def _find_cycle_recursive(self, np.ndarray graph, int vertex, set visited,             # <<<<<<<<<<<<<<
 *                               set reachable, set unreachable):
 *         """
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_27_find_cycle_recursive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_26_find_cycle_recursive[] = "ConvolutionalDependencyNetwork._find_cycle_recursive(self, ndarray graph, int vertex, set visited, set reachable, set unreachable)\n\n        Auxiliary recursive function for searching the graph for cycles.\n        It returns the first cycle it can find starting from the given\n        vertex, or None.\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_27_find_cycle_recursive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_graph = 0;
  int __pyx_v_vertex;
  PyObject *__pyx_v_visited = 0;
  PyObject *__pyx_v_reachable = 0;
  PyObject *__pyx_v_unreachable = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_cycle_recursive (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_graph,&__pyx_n_s_vertex,&__pyx_n_s_visited,&__pyx_n_s_reachable,&__pyx_n_s_unreachable,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        CYTHON_FALLTHROUGH;
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_graph)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_vertex)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_cycle_recursive", 1, 5, 5, 1); __PYX_ERR(3, 318, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_visited)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_cycle_recursive", 1, 5, 5, 2); __PYX_ERR(3, 318, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reachable)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_cycle_recursive", 1, 5, 5, 3); __PYX_ERR(3, 318, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  4:
        if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unreachable)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_find_cycle_recursive", 1, 5, 5, 4); __PYX_ERR(3, 318, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_find_cycle_recursive") < 0)) __PYX_ERR(3, 318, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_graph = ((PyArrayObject *)values[0]);
    __pyx_v_vertex = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_vertex == (int)-1) && PyErr_Occurred())) __PYX_ERR(3, 318, __pyx_L3_error)
    __pyx_v_visited = ((PyObject*)values[2]);
    __pyx_v_reachable = ((PyObject*)values[3]);
    __pyx_v_unreachable = ((PyObject*)values[4]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_find_cycle_recursive", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 318, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._find_cycle_recursive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_graph), __pyx_ptype_5numpy_ndarray, 1, "graph", 0))) __PYX_ERR(3, 318, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_visited), (&PySet_Type), 1, "visited", 1))) __PYX_ERR(3, 318, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reachable), (&PySet_Type), 1, "reachable", 1))) __PYX_ERR(3, 319, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_unreachable), (&PySet_Type), 1, "unreachable", 1))) __PYX_ERR(3, 319, __pyx_L1_error)
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_26_find_cycle_recursive(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_graph, __pyx_v_vertex, __pyx_v_visited, __pyx_v_reachable, __pyx_v_unreachable);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_26_find_cycle_recursive(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyArrayObject *__pyx_v_graph, int __pyx_v_vertex, PyObject *__pyx_v_visited, PyObject *__pyx_v_reachable, PyObject *__pyx_v_unreachable) {
  PyObject *__pyx_v_next_vertex = NULL;
  Py_ssize_t __pyx_v_root;
  PyObject *__pyx_v_cycle = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_find_cycle_recursive", 0);
  __Pyx_TraceCall("_find_cycle_recursive", __pyx_f[3], 318, 0, __PYX_ERR(3, 318, __pyx_L1_error));

  /* "networkdependencyconv.pyx":325
 *         vertex, or None.
 *         """
 *         next_vertex = graph[vertex]             # <<<<<<<<<<<<<<
 *         root = len(graph)
 *         visited.add(vertex)
 */
  __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_graph), __pyx_v_vertex, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 325, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_next_vertex = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":326
 *         """
 *         next_vertex = graph[vertex]
 *         root = len(graph)             # <<<<<<<<<<<<<<
 *         visited.add(vertex)
 * 
 */
  __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_graph)); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(3, 326, __pyx_L1_error)
  __pyx_v_root = __pyx_t_2;

  /* "networkdependencyconv.pyx":327
 *         next_vertex = graph[vertex]
 *         root = len(graph)
 *         visited.add(vertex)             # <<<<<<<<<<<<<<
 * 
 *         if next_vertex == root or next_vertex in reachable:
 */
  if (unlikely(__pyx_v_visited == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "add");
    __PYX_ERR(3, 327, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_vertex); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 327, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PySet_Add(__pyx_v_visited, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 327, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":329
 *         visited.add(vertex)
 * 
 *         if next_vertex == root or next_vertex in reachable:             # <<<<<<<<<<<<<<
 *             # vertex linked to root
 *             reachable.update(visited)
 */
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_root); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_next_vertex, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 329, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 329, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  if (unlikely(__pyx_v_reachable == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(3, 329, __pyx_L1_error)
  }
  __pyx_t_6 = (__Pyx_PySet_ContainsTF(__pyx_v_next_vertex, __pyx_v_reachable, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(3, 329, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "networkdependencyconv.pyx":331
 *         if next_vertex == root or next_vertex in reachable:
 *             # vertex linked to root
 *             reachable.update(visited)             # <<<<<<<<<<<<<<
 *             visited.clear()
 *             cycle = None
 */
    __pyx_t_5 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_update, __pyx_v_reachable, __pyx_v_visited); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 331, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "networkdependencyconv.pyx":332
 *             # vertex linked to root
 *             reachable.update(visited)
 *             visited.clear()             # <<<<<<<<<<<<<<
 *             cycle = None
 * 
 */
    if (unlikely(__pyx_v_visited == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "clear");
      __PYX_ERR(3, 332, __pyx_L1_error)
    }
    __pyx_t_3 = PySet_Clear(__pyx_v_visited); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 332, __pyx_L1_error)

    /* "networkdependencyconv.pyx":333
 *             reachable.update(visited)
 *             visited.clear()
 *             cycle = None             # <<<<<<<<<<<<<<
 * 
 *         elif next_vertex in visited:
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_cycle = Py_None;

    /* "networkdependencyconv.pyx":329
 *         visited.add(vertex)
 * 
 *         if next_vertex == root or next_vertex in reachable:             # <<<<<<<<<<<<<<
 *             # vertex linked to root
 *             reachable.update(visited)
 */
    goto __pyx_L3;
  }

  /* "networkdependencyconv.pyx":335
 *             cycle = None
 * 
 *         elif next_vertex in visited:             # <<<<<<<<<<<<<<
 *             # cycle detected! return all vertices in it
 *             visited.clear()
 */
  if (unlikely(__pyx_v_visited == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(3, 335, __pyx_L1_error)
  }
  __pyx_t_4 = (__Pyx_PySet_ContainsTF(__pyx_v_next_vertex, __pyx_v_visited, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(3, 335, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_4 != 0);
  if (__pyx_t_7) {

    /* "networkdependencyconv.pyx":337
 *         elif next_vertex in visited:
 *             # cycle detected! return all vertices in it
 *             visited.clear()             # <<<<<<<<<<<<<<
 *             cycle = set([vertex])
 *             while next_vertex != vertex:
 */
    if (unlikely(__pyx_v_visited == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "clear");
      __PYX_ERR(3, 337, __pyx_L1_error)
    }
    __pyx_t_3 = PySet_Clear(__pyx_v_visited); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 337, __pyx_L1_error)

    /* "networkdependencyconv.pyx":338
 *             # cycle detected! return all vertices in it
 *             visited.clear()
 *             cycle = set([vertex])             # <<<<<<<<<<<<<<
 *             while next_vertex != vertex:
 *                 cycle.add(next_vertex)
 */
    __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_vertex); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 338, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PySet_Add(__pyx_t_1, __pyx_t_5) < 0) __PYX_ERR(3, 338, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_cycle = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "networkdependencyconv.pyx":339
 *             visited.clear()
 *             cycle = set([vertex])
 *             while next_vertex != vertex:             # <<<<<<<<<<<<<<
 *                 cycle.add(next_vertex)
 *                 next_vertex = graph[next_vertex]
 */
    while (1) {
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_vertex); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 339, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_next_vertex, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 339, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(3, 339, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!__pyx_t_7) break;

      /* "networkdependencyconv.pyx":340
 *             cycle = set([vertex])
 *             while next_vertex != vertex:
 *                 cycle.add(next_vertex)             # <<<<<<<<<<<<<<
 *                 next_vertex = graph[next_vertex]
 * 
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_cycle, __pyx_n_s_add); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 340, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_8, __pyx_v_next_vertex) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_next_vertex);
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 340, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "networkdependencyconv.pyx":341
 *             while next_vertex != vertex:
 *                 cycle.add(next_vertex)
 *                 next_vertex = graph[next_vertex]             # <<<<<<<<<<<<<<
 * 
 *             unreachable.update(cycle)
 */
      __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_graph), __pyx_v_next_vertex); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 341, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF_SET(__pyx_v_next_vertex, __pyx_t_5);
      __pyx_t_5 = 0;
    }

    /* "networkdependencyconv.pyx":343
 *                 next_vertex = graph[next_vertex]
 * 
 *             unreachable.update(cycle)             # <<<<<<<<<<<<<<
 * 
 *         elif next_vertex in unreachable:
 */
    __pyx_t_5 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_update, __pyx_v_unreachable, __pyx_v_cycle); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 343, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "networkdependencyconv.pyx":335
 *             cycle = None
 * 
 *         elif next_vertex in visited:             # <<<<<<<<<<<<<<
 *             # cycle detected! return all vertices in it
 *             visited.clear()
 */
    goto __pyx_L3;
  }

  /* "networkdependencyconv.pyx":345
 *             unreachable.update(cycle)
 * 
 *         elif next_vertex in unreachable:             # <<<<<<<<<<<<<<
 *             # vertex linked to an existing cycle, but not part of it
 *             # (if it were, it should have been filtered out in _find_cycles)
 */
  if (unlikely(__pyx_v_unreachable == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    __PYX_ERR(3, 345, __pyx_L1_error)
  }
  __pyx_t_7 = (__Pyx_PySet_ContainsTF(__pyx_v_next_vertex, __pyx_v_unreachable, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(3, 345, __pyx_L1_error)
  __pyx_t_4 = (__pyx_t_7 != 0);
  if (__pyx_t_4) {

    /* "networkdependencyconv.pyx":348
 *             # vertex linked to an existing cycle, but not part of it
 *             # (if it were, it should have been filtered out in _find_cycles)
 *             visited.clear()             # <<<<<<<<<<<<<<
 *             cycle = None
 * 
 */
    if (unlikely(__pyx_v_visited == Py_None)) {
      PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "clear");
      __PYX_ERR(3, 348, __pyx_L1_error)
    }
    __pyx_t_3 = PySet_Clear(__pyx_v_visited); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(3, 348, __pyx_L1_error)

    /* "networkdependencyconv.pyx":349
 *             # (if it were, it should have been filtered out in _find_cycles)
 *             visited.clear()
 *             cycle = None             # <<<<<<<<<<<<<<
 * 
 *         else:
 */
    __Pyx_INCREF(Py_None);
    __pyx_v_cycle = Py_None;

    /* "networkdependencyconv.pyx":345
 *             unreachable.update(cycle)
 * 
 *         elif next_vertex in unreachable:             # <<<<<<<<<<<<<<
 *             # vertex linked to an existing cycle, but not part of it
 *             # (if it were, it should have been filtered out in _find_cycles)
 */
    goto __pyx_L3;
  }

  /* "networkdependencyconv.pyx":353
 *         else:
 *             # continue checking
 *             cycle = self._find_cycle_recursive(graph, next_vertex, visited,             # <<<<<<<<<<<<<<
 *                                                reachable, unreachable)
 * 
 */
  /*else*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_find_cycle_recursive); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);

    /* "networkdependencyconv.pyx":354
 *             # continue checking
 *             cycle = self._find_cycle_recursive(graph, next_vertex, visited,
 *                                                reachable, unreachable)             # <<<<<<<<<<<<<<
 * 
 *         return cycle
 */
    __pyx_t_8 = NULL;
    __pyx_t_9 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_9 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[6] = {__pyx_t_8, ((PyObject *)__pyx_v_graph), __pyx_v_next_vertex, __pyx_v_visited, __pyx_v_reachable, __pyx_v_unreachable};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 353, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[6] = {__pyx_t_8, ((PyObject *)__pyx_v_graph), __pyx_v_next_vertex, __pyx_v_visited, __pyx_v_reachable, __pyx_v_unreachable};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_9, 5+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 353, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(5+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(3, 353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_graph));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_graph));
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, ((PyObject *)__pyx_v_graph));
      __Pyx_INCREF(__pyx_v_next_vertex);
      __Pyx_GIVEREF(__pyx_v_next_vertex);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_v_next_vertex);
      __Pyx_INCREF(__pyx_v_visited);
      __Pyx_GIVEREF(__pyx_v_visited);
      PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_9, __pyx_v_visited);
      __Pyx_INCREF(__pyx_v_reachable);
      __Pyx_GIVEREF(__pyx_v_reachable);
      PyTuple_SET_ITEM(__pyx_t_10, 3+__pyx_t_9, __pyx_v_reachable);
      __Pyx_INCREF(__pyx_v_unreachable);
      __Pyx_GIVEREF(__pyx_v_unreachable);
      PyTuple_SET_ITEM(__pyx_t_10, 4+__pyx_t_9, __pyx_v_unreachable);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 353, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_cycle = __pyx_t_5;
    __pyx_t_5 = 0;
  }
  __pyx_L3:;

  /* "networkdependencyconv.pyx":356
 *                                                reachable, unreachable)
 * 
 *         return cycle             # <<<<<<<<<<<<<<
 * 
 *     def _contract_cycle(self, heads, cycle):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_cycle);
  __pyx_r = __pyx_v_cycle;
  goto __pyx_L0;

  /* "networkdependencyconv.pyx":318
 *         return cycles
 * 
 *     def _find_cycle_recursive(self, np.ndarray graph, int vertex, set visited,             # <<<<<<<<<<<<<<
 *                               set reachable, set unreachable):
 *         """
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._find_cycle_recursive", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_next_vertex);
  __Pyx_XDECREF(__pyx_v_cycle);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":358
 *         return cycle
 * 
 *     def _contract_cycle(self, heads, cycle):             # <<<<<<<<<<<<<<
 *         """
 *         Contract the given cycle in the dependency graph.
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_29_contract_cycle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_28_contract_cycle[] = "ConvolutionalDependencyNetwork._contract_cycle(self, heads, cycle)\n\n        Contract the given cycle in the dependency graph.\n        \n        :param heads: list of the heads of each token, such that\n            heads[i] contains the head for the i-th token\n        :param cycle: a set containing the numbers of the vertices\n            in the cycle\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_29_contract_cycle(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_heads = 0;
  PyObject *__pyx_v_cycle = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_contract_cycle (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_heads,&__pyx_n_s_cycle,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_heads)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cycle)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_contract_cycle", 1, 2, 2, 1); __PYX_ERR(3, 358, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_contract_cycle") < 0)) __PYX_ERR(3, 358, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_heads = values[0];
    __pyx_v_cycle = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_contract_cycle", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(3, 358, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._contract_cycle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_28_contract_cycle(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), __pyx_v_heads, __pyx_v_cycle);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_28_contract_cycle(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v_heads, PyObject *__pyx_v_cycle) {
  npy_intp __pyx_v_num_vertices;
  PyObject *__pyx_v_outside = NULL;
  PyArrayObject *__pyx_v_outgoing_weights = 0;
  PyObject *__pyx_v_outside_inds = NULL;
  PyObject *__pyx_v_max_outgoing_inds = NULL;
  PyObject *__pyx_v_max_outgoing_weights = NULL;
  PyObject *__pyx_v_cycle_inds = NULL;
  PyArrayObject *__pyx_v_incoming_weights = 0;
  PyObject *__pyx_v_cycle_score = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_vertex = NULL;
  PyObject *__pyx_v_head_to_v = NULL;
  PyObject *__pyx_v_max_incoming_inds = NULL;
  PyObject *__pyx_v_max_incoming_weights = NULL;
  PyObject *__pyx_v_new_head_ind = NULL;
  PyObject *__pyx_v_vertex_leaving_cycle_ind = NULL;
  PyObject *__pyx_v_new_head = NULL;
  PyObject *__pyx_v_vertex_leaving_cycle = NULL;
  PyObject *__pyx_v_old_head = NULL;
  npy_intp __pyx_9genexpr10__pyx_v_x;
  PyObject *__pyx_9genexpr11__pyx_v_i = NULL;
  PyObject *__pyx_9genexpr12__pyx_v_i = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_incoming_weights;
  __Pyx_Buffer __pyx_pybuffer_incoming_weights;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_outgoing_weights;
  __Pyx_Buffer __pyx_pybuffer_outgoing_weights;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  npy_intp __pyx_t_4;
  npy_intp __pyx_t_5;
  npy_intp __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyArrayObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyArrayObject *__pyx_t_18 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_contract_cycle", 0);
  __Pyx_TraceCall("_contract_cycle", __pyx_f[3], 358, 0, __PYX_ERR(3, 358, __pyx_L1_error));
  __Pyx_INCREF(__pyx_v_cycle);
  __pyx_pybuffer_outgoing_weights.pybuffer.buf = NULL;
  __pyx_pybuffer_outgoing_weights.refcount = 0;
  __pyx_pybuffernd_outgoing_weights.data = NULL;
  __pyx_pybuffernd_outgoing_weights.rcbuffer = &__pyx_pybuffer_outgoing_weights;
  __pyx_pybuffer_incoming_weights.pybuffer.buf = NULL;
  __pyx_pybuffer_incoming_weights.refcount = 0;
  __pyx_pybuffernd_incoming_weights.data = NULL;
  __pyx_pybuffernd_incoming_weights.rcbuffer = &__pyx_pybuffer_incoming_weights;

  /* "networkdependencyconv.pyx":369
 *         # each cell i, j has the score for token i having j as its head.
 * 
 *         num_vertices = self.dependency_weights.shape[1]             # <<<<<<<<<<<<<<
 *         outside = np.array([x for x in range(num_vertices) if x not in cycle])
 *         cycle = np.array(list(cycle))
 */
  __pyx_v_num_vertices = (__pyx_v_self->dependency_weights->dimensions[1]);

  /* "networkdependencyconv.pyx":370
 * 
 *         num_vertices = self.dependency_weights.shape[1]
 *         outside = np.array([x for x in range(num_vertices) if x not in cycle])             # <<<<<<<<<<<<<<
 *         cycle = np.array(list(cycle))
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  { /* enter inner scope */
    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 370, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_v_num_vertices;
    __pyx_t_5 = __pyx_t_4;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_9genexpr10__pyx_v_x = __pyx_t_6;
      __pyx_t_7 = __Pyx_PyInt_From_Py_intptr_t(__pyx_9genexpr10__pyx_v_x); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 370, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_t_7, __pyx_v_cycle, Py_NE)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(3, 370, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_9 = (__pyx_t_8 != 0);
      if (__pyx_t_9) {
        __pyx_t_7 = __Pyx_PyInt_From_Py_intptr_t(__pyx_9genexpr10__pyx_v_x); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 370, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) __PYX_ERR(3, 370, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
    }
  } /* exit inner scope */
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_outside = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":371
 *         num_vertices = self.dependency_weights.shape[1]
 *         outside = np.array([x for x in range(num_vertices) if x not in cycle])
 *         cycle = np.array(list(cycle))             # <<<<<<<<<<<<<<
 * 
 *         cdef np.ndarray[FLOAT_t, ndim=2] outgoing_weights
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PySequence_List(__pyx_v_cycle); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_7, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 371, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF_SET(__pyx_v_cycle, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":379
 * 
 *         # if len(outside) == 1, it means all vertices except for the root are in a cycle
 *         if len(outside) > 1:             # <<<<<<<<<<<<<<
 *             # weird index array we need in order to properly use fancy indexing
 *             # -1 because we can't take the root now
 */
  __pyx_t_10 = PyObject_Length(__pyx_v_outside); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(3, 379, __pyx_L1_error)
  __pyx_t_9 = ((__pyx_t_10 > 1) != 0);
  if (__pyx_t_9) {

    /* "networkdependencyconv.pyx":382
 *             # weird index array we need in order to properly use fancy indexing
 *             # -1 because we can't take the root now
 *             outside_inds = np.array([[i] for i in outside[:-1]])             # <<<<<<<<<<<<<<
 *             outgoing_weights = self.dependency_weights[outside_inds, cycle]
 * 
 */
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 382, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 382, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    { /* enter inner scope */
      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 382, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_outside, 0, -1L, NULL, NULL, &__pyx_slice__4, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 382, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) {
        __pyx_t_11 = __pyx_t_7; __Pyx_INCREF(__pyx_t_11); __pyx_t_10 = 0;
        __pyx_t_12 = NULL;
      } else {
        __pyx_t_10 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 382, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 382, __pyx_L9_error)
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      for (;;) {
        if (likely(!__pyx_t_12)) {
          if (likely(PyList_CheckExact(__pyx_t_11))) {
            if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_11)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_7 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(3, 382, __pyx_L9_error)
            #else
            __pyx_t_7 = PySequence_ITEM(__pyx_t_11, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 382, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_7);
            #endif
          } else {
            if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(3, 382, __pyx_L9_error)
            #else
            __pyx_t_7 = PySequence_ITEM(__pyx_t_11, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 382, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_7);
            #endif
          }
        } else {
          __pyx_t_7 = __pyx_t_12(__pyx_t_11);
          if (unlikely(!__pyx_t_7)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else __PYX_ERR(3, 382, __pyx_L9_error)
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_XDECREF_SET(__pyx_9genexpr11__pyx_v_i, __pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 382, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_9genexpr11__pyx_v_i);
        __Pyx_GIVEREF(__pyx_9genexpr11__pyx_v_i);
        PyList_SET_ITEM(__pyx_t_7, 0, __pyx_9genexpr11__pyx_v_i);
        if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_7))) __PYX_ERR(3, 382, __pyx_L9_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_i); __pyx_9genexpr11__pyx_v_i = 0;
      goto __pyx_L12_exit_scope;
      __pyx_L9_error:;
      __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_i); __pyx_9genexpr11__pyx_v_i = 0;
      goto __pyx_L1_error;
      __pyx_L12_exit_scope:;
    } /* exit inner scope */
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    __pyx_t_1 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_11, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 382, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_outside_inds = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "networkdependencyconv.pyx":383
 *             # -1 because we can't take the root now
 *             outside_inds = np.array([[i] for i in outside[:-1]])
 *             outgoing_weights = self.dependency_weights[outside_inds, cycle]             # <<<<<<<<<<<<<<
 * 
 *             # the cycle should have only one outgoing edge for each vertex outside it
 */
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_outside_inds);
    __Pyx_GIVEREF(__pyx_v_outside_inds);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_outside_inds);
    __Pyx_INCREF(__pyx_v_cycle);
    __Pyx_GIVEREF(__pyx_v_cycle);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_cycle);
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 383, __pyx_L1_error)
    __pyx_t_13 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_outgoing_weights, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
        }
        __pyx_t_15 = __pyx_t_16 = __pyx_t_17 = 0;
      }
      __pyx_pybuffernd_outgoing_weights.diminfo[0].strides = __pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_outgoing_weights.diminfo[0].shape = __pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_outgoing_weights.diminfo[1].strides = __pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_outgoing_weights.diminfo[1].shape = __pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(3, 383, __pyx_L1_error)
    }
    __pyx_t_13 = 0;
    __pyx_v_outgoing_weights = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":387
 *             # the cycle should have only one outgoing edge for each vertex outside it
 *             # so, search the maximum outgoing edge to each outside vertex
 *             max_outgoing_inds = outgoing_weights.argmax(1)             # <<<<<<<<<<<<<<
 *             max_outgoing_weights = outgoing_weights.max(1)
 * 
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_outgoing_weights), __pyx_n_s_argmax); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_int_1) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_int_1);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 387, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_max_outgoing_inds = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":388
 *             # so, search the maximum outgoing edge to each outside vertex
 *             max_outgoing_inds = outgoing_weights.argmax(1)
 *             max_outgoing_weights = outgoing_weights.max(1)             # <<<<<<<<<<<<<<
 * 
 *             # set every outgoing weight to -inf and then restore the highest ones
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_outgoing_weights), __pyx_n_s_max); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_2)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_int_1) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_int_1);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 388, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_max_outgoing_weights = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":391
 * 
 *             # set every outgoing weight to -inf and then restore the highest ones
 *             outgoing_weights[:] = -np.Infinity             # <<<<<<<<<<<<<<
 *             outgoing_weights[np.arange(len(outside_inds)),
 *                              max_outgoing_inds] = max_outgoing_weights
 */
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Infinity); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Negative(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 391, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_outgoing_weights), __pyx_slice__3, __pyx_t_3) < 0)) __PYX_ERR(3, 391, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":392
 *             # set every outgoing weight to -inf and then restore the highest ones
 *             outgoing_weights[:] = -np.Infinity
 *             outgoing_weights[np.arange(len(outside_inds)),             # <<<<<<<<<<<<<<
 *                              max_outgoing_inds] = max_outgoing_weights
 *             self.dependency_weights[outside_inds, cycle] = outgoing_weights
 */
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_arange); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = PyObject_Length(__pyx_v_outside_inds); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(3, 392, __pyx_L1_error)
    __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_2, function);
      }
    }
    __pyx_t_3 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_11, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1);
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":393
 *             outgoing_weights[:] = -np.Infinity
 *             outgoing_weights[np.arange(len(outside_inds)),
 *                              max_outgoing_inds] = max_outgoing_weights             # <<<<<<<<<<<<<<
 *             self.dependency_weights[outside_inds, cycle] = outgoing_weights
 * 
 */
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 392, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_INCREF(__pyx_v_max_outgoing_inds);
    __Pyx_GIVEREF(__pyx_v_max_outgoing_inds);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_max_outgoing_inds);
    __pyx_t_3 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_outgoing_weights), __pyx_t_2, __pyx_v_max_outgoing_weights) < 0)) __PYX_ERR(3, 392, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":394
 *             outgoing_weights[np.arange(len(outside_inds)),
 *                              max_outgoing_inds] = max_outgoing_weights
 *             self.dependency_weights[outside_inds, cycle] = outgoing_weights             # <<<<<<<<<<<<<<
 * 
 *         # now, adjust incoming edges. the incoming edge from each vertex v
 */
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 394, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_outside_inds);
    __Pyx_GIVEREF(__pyx_v_outside_inds);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_outside_inds);
    __Pyx_INCREF(__pyx_v_cycle);
    __Pyx_GIVEREF(__pyx_v_cycle);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_cycle);
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_2, ((PyObject *)__pyx_v_outgoing_weights)) < 0)) __PYX_ERR(3, 394, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":379
 * 
 *         # if len(outside) == 1, it means all vertices except for the root are in a cycle
 *         if len(outside) > 1:             # <<<<<<<<<<<<<<
 *             # weird index array we need in order to properly use fancy indexing
 *             # -1 because we can't take the root now
 */
  }

  /* "networkdependencyconv.pyx":401
 *         # and then we pick the highest edge for each outside vertex
 *         # s(c) = sum_v s(head(v), v)
 *         cycle_inds = np.array([[i] for i in cycle])             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[FLOAT_t, ndim=2] incoming_weights
 *         incoming_weights = self.dependency_weights[cycle_inds, outside]
 */
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  { /* enter inner scope */
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 401, __pyx_L15_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (likely(PyList_CheckExact(__pyx_v_cycle)) || PyTuple_CheckExact(__pyx_v_cycle)) {
      __pyx_t_11 = __pyx_v_cycle; __Pyx_INCREF(__pyx_t_11); __pyx_t_10 = 0;
      __pyx_t_12 = NULL;
    } else {
      __pyx_t_10 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_v_cycle); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 401, __pyx_L15_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 401, __pyx_L15_error)
    }
    for (;;) {
      if (likely(!__pyx_t_12)) {
        if (likely(PyList_CheckExact(__pyx_t_11))) {
          if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_11)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(3, 401, __pyx_L15_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_11, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 401, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        } else {
          if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(3, 401, __pyx_L15_error)
          #else
          __pyx_t_7 = PySequence_ITEM(__pyx_t_11, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 401, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_7);
          #endif
        }
      } else {
        __pyx_t_7 = __pyx_t_12(__pyx_t_11);
        if (unlikely(!__pyx_t_7)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else __PYX_ERR(3, 401, __pyx_L15_error)
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_XDECREF_SET(__pyx_9genexpr12__pyx_v_i, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 401, __pyx_L15_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_9genexpr12__pyx_v_i);
      __Pyx_GIVEREF(__pyx_9genexpr12__pyx_v_i);
      PyList_SET_ITEM(__pyx_t_7, 0, __pyx_9genexpr12__pyx_v_i);
      if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(3, 401, __pyx_L15_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_i); __pyx_9genexpr12__pyx_v_i = 0;
    goto __pyx_L18_exit_scope;
    __pyx_L15_error:;
    __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_i); __pyx_9genexpr12__pyx_v_i = 0;
    goto __pyx_L1_error;
    __pyx_L18_exit_scope:;
  } /* exit inner scope */
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_2 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_11, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
  __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_cycle_inds = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":403
 *         cycle_inds = np.array([[i] for i in cycle])
 *         cdef np.ndarray[FLOAT_t, ndim=2] incoming_weights
 *         incoming_weights = self.dependency_weights[cycle_inds, outside]             # <<<<<<<<<<<<<<
 * 
 *         cycle_score = 0
 */
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_cycle_inds);
  __Pyx_GIVEREF(__pyx_v_cycle_inds);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_cycle_inds);
  __Pyx_INCREF(__pyx_v_outside);
  __Pyx_GIVEREF(__pyx_v_outside);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_outside);
  __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 403, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(3, 403, __pyx_L1_error)
  __pyx_t_18 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_17, &__pyx_t_16, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer, (PyObject*)__pyx_v_incoming_weights, &__Pyx_TypeInfo_nn___pyx_t_4libs_7network_FLOAT_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_17, __pyx_t_16, __pyx_t_15);
      }
      __pyx_t_17 = __pyx_t_16 = __pyx_t_15 = 0;
    }
    __pyx_pybuffernd_incoming_weights.diminfo[0].strides = __pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_incoming_weights.diminfo[0].shape = __pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_incoming_weights.diminfo[1].strides = __pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_incoming_weights.diminfo[1].shape = __pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(3, 403, __pyx_L1_error)
  }
  __pyx_t_18 = 0;
  __pyx_v_incoming_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":405
 *         incoming_weights = self.dependency_weights[cycle_inds, outside]
 * 
 *         cycle_score = 0             # <<<<<<<<<<<<<<
 *         for i, vertex in enumerate(cycle):
 *             head_to_v = self.dependency_weights[vertex, heads[vertex]]
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_v_cycle_score = __pyx_int_0;

  /* "networkdependencyconv.pyx":406
 * 
 *         cycle_score = 0
 *         for i, vertex in enumerate(cycle):             # <<<<<<<<<<<<<<
 *             head_to_v = self.dependency_weights[vertex, heads[vertex]]
 *             cycle_score += head_to_v
 */
  __Pyx_INCREF(__pyx_int_0);
  __pyx_t_1 = __pyx_int_0;
  if (likely(PyList_CheckExact(__pyx_v_cycle)) || PyTuple_CheckExact(__pyx_v_cycle)) {
    __pyx_t_2 = __pyx_v_cycle; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0;
    __pyx_t_12 = NULL;
  } else {
    __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_cycle); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_12 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_12)) __PYX_ERR(3, 406, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_12)) {
      if (likely(PyList_CheckExact(__pyx_t_2))) {
        if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(3, 406, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 406, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      } else {
        if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely(0 < 0)) __PYX_ERR(3, 406, __pyx_L1_error)
        #else
        __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 406, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        #endif
      }
    } else {
      __pyx_t_3 = __pyx_t_12(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(3, 406, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_vertex, __pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_1);
    __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":407
 *         cycle_score = 0
 *         for i, vertex in enumerate(cycle):
 *             head_to_v = self.dependency_weights[vertex, heads[vertex]]             # <<<<<<<<<<<<<<
 *             cycle_score += head_to_v
 *             incoming_weights[i] -= head_to_v
 */
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_heads, __pyx_v_vertex); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_vertex);
    __Pyx_GIVEREF(__pyx_v_vertex);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_vertex);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_head_to_v, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":408
 *         for i, vertex in enumerate(cycle):
 *             head_to_v = self.dependency_weights[vertex, heads[vertex]]
 *             cycle_score += head_to_v             # <<<<<<<<<<<<<<
 *             incoming_weights[i] -= head_to_v
 * 
 */
    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_cycle_score, __pyx_v_head_to_v); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_cycle_score, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":409
 *             head_to_v = self.dependency_weights[vertex, heads[vertex]]
 *             cycle_score += head_to_v
 *             incoming_weights[i] -= head_to_v             # <<<<<<<<<<<<<<
 * 
 *         max_incoming_inds = incoming_weights.argmax(0)
 */
    __Pyx_INCREF(__pyx_v_i);
    __pyx_t_3 = __pyx_v_i;
    __pyx_t_11 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_incoming_weights), __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(3, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_7 = PyNumber_InPlaceSubtract(__pyx_t_11, __pyx_v_head_to_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(3, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_incoming_weights), __pyx_t_3, __pyx_t_7) < 0)) __PYX_ERR(3, 409, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "networkdependencyconv.pyx":406
 * 
 *         cycle_score = 0
 *         for i, vertex in enumerate(cycle):             # <<<<<<<<<<<<<<
 *             head_to_v = self.dependency_weights[vertex, heads[vertex]]
 *             cycle_score += head_to_v
 */
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":411
 *             incoming_weights[i] -= head_to_v
 * 
 *         max_incoming_inds = incoming_weights.argmax(0)             # <<<<<<<<<<<<<<
 *         max_incoming_weights = incoming_weights.max(0)
 *         # we leave the + s(c) to the end
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_incoming_weights), __pyx_n_s_argmax); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_int_0);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_max_incoming_inds = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":412
 * 
 *         max_incoming_inds = incoming_weights.argmax(0)
 *         max_incoming_weights = incoming_weights.max(0)             # <<<<<<<<<<<<<<
 *         # we leave the + s(c) to the end
 *         max_incoming_weights += cycle_score
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_incoming_weights), __pyx_n_s_max); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_int_0) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_int_0);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_max_incoming_weights = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":414
 *         max_incoming_weights = incoming_weights.max(0)
 *         # we leave the + s(c) to the end
 *         max_incoming_weights += cycle_score             # <<<<<<<<<<<<<<
 * 
 *         # the vertex with the maximum weighted incoming edge now changes
 */
  __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_max_incoming_weights, __pyx_v_cycle_score); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF_SET(__pyx_v_max_incoming_weights, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":418
 *         # the vertex with the maximum weighted incoming edge now changes
 *         # its head, thus breaking the cycle
 *         new_head_ind = max_incoming_weights.argmax()             # <<<<<<<<<<<<<<
 *         vertex_leaving_cycle_ind = max_incoming_inds[new_head_ind]
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_max_incoming_weights, __pyx_n_s_argmax); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_new_head_ind = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":419
 *         # its head, thus breaking the cycle
 *         new_head_ind = max_incoming_weights.argmax()
 *         vertex_leaving_cycle_ind = max_incoming_inds[new_head_ind]             # <<<<<<<<<<<<<<
 * 
 *         new_head = outside[new_head_ind]
 */
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_max_incoming_inds, __pyx_v_new_head_ind); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 419, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_vertex_leaving_cycle_ind = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":421
 *         vertex_leaving_cycle_ind = max_incoming_inds[new_head_ind]
 * 
 *         new_head = outside[new_head_ind]             # <<<<<<<<<<<<<<
 *         vertex_leaving_cycle = cycle[vertex_leaving_cycle_ind]
 *         old_head = heads[vertex_leaving_cycle]
 */
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_outside, __pyx_v_new_head_ind); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 421, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_new_head = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":422
 * 
 *         new_head = outside[new_head_ind]
 *         vertex_leaving_cycle = cycle[vertex_leaving_cycle_ind]             # <<<<<<<<<<<<<<
 *         old_head = heads[vertex_leaving_cycle]
 *         heads[vertex_leaving_cycle] = new_head
 */
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_cycle, __pyx_v_vertex_leaving_cycle_ind); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_vertex_leaving_cycle = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":423
 *         new_head = outside[new_head_ind]
 *         vertex_leaving_cycle = cycle[vertex_leaving_cycle_ind]
 *         old_head = heads[vertex_leaving_cycle]             # <<<<<<<<<<<<<<
 *         heads[vertex_leaving_cycle] = new_head
 *         self.dependency_weights[vertex_leaving_cycle, old_head] = -np.Infinity
 */
  __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_heads, __pyx_v_vertex_leaving_cycle); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 423, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_old_head = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":424
 *         vertex_leaving_cycle = cycle[vertex_leaving_cycle_ind]
 *         old_head = heads[vertex_leaving_cycle]
 *         heads[vertex_leaving_cycle] = new_head             # <<<<<<<<<<<<<<
 *         self.dependency_weights[vertex_leaving_cycle, old_head] = -np.Infinity
 * 
 */
  if (unlikely(PyObject_SetItem(__pyx_v_heads, __pyx_v_vertex_leaving_cycle, __pyx_v_new_head) < 0)) __PYX_ERR(3, 424, __pyx_L1_error)

  /* "networkdependencyconv.pyx":425
 *         old_head = heads[vertex_leaving_cycle]
 *         heads[vertex_leaving_cycle] = new_head
 *         self.dependency_weights[vertex_leaving_cycle, old_head] = -np.Infinity             # <<<<<<<<<<<<<<
 * 
 *         # analagous to the outgoing weights
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Infinity); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_vertex_leaving_cycle);
  __Pyx_GIVEREF(__pyx_v_vertex_leaving_cycle);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_vertex_leaving_cycle);
  __Pyx_INCREF(__pyx_v_old_head);
  __Pyx_GIVEREF(__pyx_v_old_head);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_old_head);
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_2, __pyx_t_1) < 0)) __PYX_ERR(3, 425, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":428
 * 
 *         # analagous to the outgoing weights
 *         incoming_weights[:] = -np.Infinity             # <<<<<<<<<<<<<<
 *         incoming_weights[max_incoming_inds,
 *                          np.arange(len(outside))] = max_incoming_weights
 */
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Infinity); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 428, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_incoming_weights), __pyx_slice__3, __pyx_t_1) < 0)) __PYX_ERR(3, 428, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":430
 *         incoming_weights[:] = -np.Infinity
 *         incoming_weights[max_incoming_inds,
 *                          np.arange(len(outside))] = max_incoming_weights             # <<<<<<<<<<<<<<
 *         self.dependency_weights[cycle_inds, outside] = incoming_weights
 * 
 */
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_arange); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_10 = PyObject_Length(__pyx_v_outside); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(3, 430, __pyx_L1_error)
  __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 430, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "networkdependencyconv.pyx":429
 *         # analagous to the outgoing weights
 *         incoming_weights[:] = -np.Infinity
 *         incoming_weights[max_incoming_inds,             # <<<<<<<<<<<<<<
 *                          np.arange(len(outside))] = max_incoming_weights
 *         self.dependency_weights[cycle_inds, outside] = incoming_weights
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 429, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_max_incoming_inds);
  __Pyx_GIVEREF(__pyx_v_max_incoming_inds);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_max_incoming_inds);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_incoming_weights), __pyx_t_3, __pyx_v_max_incoming_weights) < 0)) __PYX_ERR(3, 429, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "networkdependencyconv.pyx":431
 *         incoming_weights[max_incoming_inds,
 *                          np.arange(len(outside))] = max_incoming_weights
 *         self.dependency_weights[cycle_inds, outside] = incoming_weights             # <<<<<<<<<<<<<<
 * 
 *     def _find_maximum_spanning_tree(self):
 */
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 431, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_cycle_inds);
  __Pyx_GIVEREF(__pyx_v_cycle_inds);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_cycle_inds);
  __Pyx_INCREF(__pyx_v_outside);
  __Pyx_GIVEREF(__pyx_v_outside);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_outside);
  if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_self->dependency_weights), __pyx_t_3, ((PyObject *)__pyx_v_incoming_weights)) < 0)) __PYX_ERR(3, 431, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "networkdependencyconv.pyx":358
 *         return cycle
 * 
 *     def _contract_cycle(self, heads, cycle):             # <<<<<<<<<<<<<<
 *         """
 *         Contract the given cycle in the dependency graph.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_11);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._contract_cycle", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_incoming_weights.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_outgoing_weights.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_outside);
  __Pyx_XDECREF((PyObject *)__pyx_v_outgoing_weights);
  __Pyx_XDECREF(__pyx_v_outside_inds);
  __Pyx_XDECREF(__pyx_v_max_outgoing_inds);
  __Pyx_XDECREF(__pyx_v_max_outgoing_weights);
  __Pyx_XDECREF(__pyx_v_cycle_inds);
  __Pyx_XDECREF((PyObject *)__pyx_v_incoming_weights);
  __Pyx_XDECREF(__pyx_v_cycle_score);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_vertex);
  __Pyx_XDECREF(__pyx_v_head_to_v);
  __Pyx_XDECREF(__pyx_v_max_incoming_inds);
  __Pyx_XDECREF(__pyx_v_max_incoming_weights);
  __Pyx_XDECREF(__pyx_v_new_head_ind);
  __Pyx_XDECREF(__pyx_v_vertex_leaving_cycle_ind);
  __Pyx_XDECREF(__pyx_v_new_head);
  __Pyx_XDECREF(__pyx_v_vertex_leaving_cycle);
  __Pyx_XDECREF(__pyx_v_old_head);
  __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_i);
  __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_cycle);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":433
 *         self.dependency_weights[cycle_inds, outside] = incoming_weights
 * 
 *     def _find_maximum_spanning_tree(self):             # <<<<<<<<<<<<<<
 *         """
 *         Run the Chu-Liu / Edmond's algorithm in order to find the highest
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_31_find_maximum_spanning_tree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_30_find_maximum_spanning_tree[] = "ConvolutionalDependencyNetwork._find_maximum_spanning_tree(self)\n\n        Run the Chu-Liu / Edmond's algorithm in order to find the highest\n        scoring dependency tree from the dependency graph weights.\n        \n        :returns: a 1-dim array with the head of each token in the sentence\n        ";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_31_find_maximum_spanning_tree(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_find_maximum_spanning_tree (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_30_find_maximum_spanning_tree(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_30_find_maximum_spanning_tree(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self) {
  PyObject *__pyx_v_heads = NULL;
  PyObject *__pyx_v_cycles = NULL;
  PyObject *__pyx_v_cycle = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_find_maximum_spanning_tree", 0);
  __Pyx_TraceCall("_find_maximum_spanning_tree", __pyx_f[3], 433, 0, __PYX_ERR(3, 433, __pyx_L1_error));

  /* "networkdependencyconv.pyx":441
 *         """
 *         # pick the highest scoring dependency for each word
 *         heads = self.dependency_weights.argmax(1)             # <<<<<<<<<<<<<<
 * 
 *         # check if there are cycles. if there isn't any, we're done
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->dependency_weights), __pyx_n_s_argmax); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_int_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_int_1);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_heads = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":444
 * 
 *         # check if there are cycles. if there isn't any, we're done
 *         cycles = self._find_cycles(heads)             # <<<<<<<<<<<<<<
 * 
 *         for cycle in cycles:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_find_cycles); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_heads) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_heads);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_cycles = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":446
 *         cycles = self._find_cycles(heads)
 * 
 *         for cycle in cycles:             # <<<<<<<<<<<<<<
 *             # resolve each cycle c
 *             self._contract_cycle(heads, cycle)
 */
  if (likely(PyList_CheckExact(__pyx_v_cycles)) || PyTuple_CheckExact(__pyx_v_cycles)) {
    __pyx_t_1 = __pyx_v_cycles; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_cycles); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 446, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_5)) __PYX_ERR(3, 446, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_5)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(3, 446, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 446, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      } else {
        if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) __PYX_ERR(3, 446, __pyx_L1_error)
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 446, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        #endif
      }
    } else {
      __pyx_t_2 = __pyx_t_5(__pyx_t_1);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else __PYX_ERR(3, 446, __pyx_L1_error)
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XDECREF_SET(__pyx_v_cycle, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":448
 *         for cycle in cycles:
 *             # resolve each cycle c
 *             self._contract_cycle(heads, cycle)             # <<<<<<<<<<<<<<
 * 
 *         return heads
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_contract_cycle); if (unlikely(!__pyx_t_3)) __PYX_ERR(3, 448, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = NULL;
    __pyx_t_7 = 0;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
        __pyx_t_7 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_heads, __pyx_v_cycle};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 448, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_heads, __pyx_v_cycle};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 448, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(3, 448, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_6) {
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
      }
      __Pyx_INCREF(__pyx_v_heads);
      __Pyx_GIVEREF(__pyx_v_heads);
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_heads);
      __Pyx_INCREF(__pyx_v_cycle);
      __Pyx_GIVEREF(__pyx_v_cycle);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_cycle);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 448, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "networkdependencyconv.pyx":446
 *         cycles = self._find_cycles(heads)
 * 
 *         for cycle in cycles:             # <<<<<<<<<<<<<<
 *             # resolve each cycle c
 *             self._contract_cycle(heads, cycle)
 */
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkdependencyconv.pyx":450
 *             self._contract_cycle(heads, cycle)
 * 
 *         return heads             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_heads);
  __pyx_r = __pyx_v_heads;
  goto __pyx_L0;

  /* "networkdependencyconv.pyx":433
 *         self.dependency_weights[cycle_inds, outside] = incoming_weights
 * 
 *     def _find_maximum_spanning_tree(self):             # <<<<<<<<<<<<<<
 *         """
 *         Run the Chu-Liu / Edmond's algorithm in order to find the highest
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork._find_maximum_spanning_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_heads);
  __Pyx_XDECREF(__pyx_v_cycles);
  __Pyx_XDECREF(__pyx_v_cycle);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "networkdependencyconv.pyx":14
 * 
 *     # the weights of all possible dependency among tokens
 *     cdef readonly np.ndarray dependency_weights             # <<<<<<<<<<<<<<
 * 
 *     # validation data
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_18dependency_weights_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_18dependency_weights_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_18dependency_weights___get__(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_18dependency_weights___get__(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[3], 14, 0, __PYX_ERR(3, 14, __pyx_L1_error));
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dependency_weights));
  __pyx_r = ((PyObject *)__pyx_v_self->dependency_weights);
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.dependency_weights.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_33__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_32__reduce_cython__[] = "ConvolutionalDependencyNetwork.__reduce_cython__(self)";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_33__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_32__reduce_cython__(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_32__reduce_cython__(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self) {
  PyObject *__pyx_v_state = 0;
  PyObject *__pyx_v__dict = 0;
  int __pyx_v_use_setstate;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__reduce_cython__", 0);
  __Pyx_TraceCall("__reduce_cython__", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":5
 *     cdef object _dict
 *     cdef bint use_setstate
 *     state = (self.accuracy, self.answer_score, self.convolution_lookup, self.decay_factor, self.dependency_weights, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.half_window, self.hidden2_before_activation, self.hidden2_bias, self.hidden2_gradients, self.hidden2_size, self.hidden2_values, self.hidden2_weights, self.hidden_before_activation, self.hidden_bias, self.hidden_gradients, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_deltas, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.max_indices, self.net_gradients, self.network_filename, self.network_text_filename, self.num_sentences, self.num_targets, self.num_tokens, self.only_classify, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.pred_convolution_lookup, self.pred_dist_deltas, self.pred_dist_lookup, self.pred_dist_offset, self.pred_dist_table, self.pred_dist_weights, self.sentence_accuracy, self.sentence_lookup, self.skips, self.target_convolution_lookup, self.target_dist_deltas, self.target_dist_lookup, self.target_dist_offset, self.target_dist_table, self.target_dist_weights, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_arguments, self.validation_heads, self.validation_predicates, self.validation_sentences, self.validation_tags, self.word_window_size)             # <<<<<<<<<<<<<<
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 */
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.accuracy); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.answer_score); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.decay_factor); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.error); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.__pyx_base.features_per_token); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.float_errors); if (unlikely(!__pyx_t_6)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.half_window); if (unlikely(!__pyx_t_7)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.hidden2_size); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.__pyx_base.hidden_size); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.__pyx_base.input_size); if (unlikely(!__pyx_t_10)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.learning_rate); if (unlikely(!__pyx_t_11)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.learning_rate_features); if (unlikely(!__pyx_t_12)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.learning_rate_trans); if (unlikely(!__pyx_t_13)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.num_sentences); if (unlikely(!__pyx_t_14)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.num_targets); if (unlikely(!__pyx_t_15)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.__pyx_base.num_tokens); if (unlikely(!__pyx_t_16)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_17 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.__pyx_base.output_size); if (unlikely(!__pyx_t_17)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_18 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.pred_dist_offset); if (unlikely(!__pyx_t_18)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_18);
  __pyx_t_19 = PyFloat_FromDouble(__pyx_v_self->__pyx_base.__pyx_base.sentence_accuracy); if (unlikely(!__pyx_t_19)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_20 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.__pyx_base.skips); if (unlikely(!__pyx_t_20)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_21 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.target_dist_offset); if (unlikely(!__pyx_t_21)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_22 = __Pyx_PyInt_From_int(__pyx_v_self->__pyx_base.__pyx_base.word_window_size); if (unlikely(!__pyx_t_22)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_23 = PyTuple_New(71); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 5, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_23);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.convolution_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.convolution_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 2, ((PyObject *)__pyx_v_self->__pyx_base.convolution_lookup));
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_23, 3, __pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->dependency_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->dependency_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 4, ((PyObject *)__pyx_v_self->dependency_weights));
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_23, 5, __pyx_t_4);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.feature_tables);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.feature_tables);
  PyTuple_SET_ITEM(__pyx_t_23, 6, __pyx_v_self->__pyx_base.__pyx_base.feature_tables);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_23, 7, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_23, 8, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_23, 9, __pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_before_activation));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_before_activation));
  PyTuple_SET_ITEM(__pyx_t_23, 10, ((PyObject *)__pyx_v_self->__pyx_base.hidden2_before_activation));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_bias));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_bias));
  PyTuple_SET_ITEM(__pyx_t_23, 11, ((PyObject *)__pyx_v_self->__pyx_base.hidden2_bias));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_gradients));
  PyTuple_SET_ITEM(__pyx_t_23, 12, ((PyObject *)__pyx_v_self->__pyx_base.hidden2_gradients));
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_23, 13, __pyx_t_8);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_values));
  PyTuple_SET_ITEM(__pyx_t_23, 14, ((PyObject *)__pyx_v_self->__pyx_base.hidden2_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden2_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 15, ((PyObject *)__pyx_v_self->__pyx_base.hidden2_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_before_activation));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_before_activation));
  PyTuple_SET_ITEM(__pyx_t_23, 16, ((PyObject *)__pyx_v_self->__pyx_base.hidden_before_activation));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_bias));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_bias));
  PyTuple_SET_ITEM(__pyx_t_23, 17, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_bias));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.hidden_gradients));
  PyTuple_SET_ITEM(__pyx_t_23, 18, ((PyObject *)__pyx_v_self->__pyx_base.hidden_gradients));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_sent_values));
  PyTuple_SET_ITEM(__pyx_t_23, 19, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_sent_values));
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_23, 20, __pyx_t_9);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_values));
  PyTuple_SET_ITEM(__pyx_t_23, 21, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 22, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.input_deltas));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.input_deltas));
  PyTuple_SET_ITEM(__pyx_t_23, 23, ((PyObject *)__pyx_v_self->__pyx_base.input_deltas));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.input_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.input_sent_values));
  PyTuple_SET_ITEM(__pyx_t_23, 24, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.input_sent_values));
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_23, 25, __pyx_t_10);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.input_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.input_values));
  PyTuple_SET_ITEM(__pyx_t_23, 26, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.input_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.layer2_sent_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.layer2_sent_values));
  PyTuple_SET_ITEM(__pyx_t_23, 27, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.layer2_sent_values));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.layer2_values));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.layer2_values));
  PyTuple_SET_ITEM(__pyx_t_23, 28, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.layer2_values));
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_23, 29, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_23, 30, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_23, 31, __pyx_t_13);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.max_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.max_indices));
  PyTuple_SET_ITEM(__pyx_t_23, 32, ((PyObject *)__pyx_v_self->__pyx_base.max_indices));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients));
  PyTuple_SET_ITEM(__pyx_t_23, 33, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients));
  __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.network_filename);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.network_filename);
  PyTuple_SET_ITEM(__pyx_t_23, 34, __pyx_v_self->__pyx_base.__pyx_base.network_filename);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.network_text_filename);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.network_text_filename);
  PyTuple_SET_ITEM(__pyx_t_23, 35, __pyx_v_self->__pyx_base.__pyx_base.network_text_filename);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_23, 36, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_23, 37, __pyx_t_15);
  __Pyx_GIVEREF(__pyx_t_16);
  PyTuple_SET_ITEM(__pyx_t_23, 38, __pyx_t_16);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.only_classify));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.only_classify));
  PyTuple_SET_ITEM(__pyx_t_23, 39, ((PyObject *)__pyx_v_self->__pyx_base.only_classify));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.output_bias));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.output_bias));
  PyTuple_SET_ITEM(__pyx_t_23, 40, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.output_bias));
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_23, 41, __pyx_t_17);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.output_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.output_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 42, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.output_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.padding_left));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.padding_left));
  PyTuple_SET_ITEM(__pyx_t_23, 43, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.padding_left));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.padding_right));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.padding_right));
  PyTuple_SET_ITEM(__pyx_t_23, 44, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.padding_right));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.pos_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.pos_padding));
  PyTuple_SET_ITEM(__pyx_t_23, 45, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.pos_padding));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.pre_padding));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.pre_padding));
  PyTuple_SET_ITEM(__pyx_t_23, 46, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.pre_padding));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pred_convolution_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pred_convolution_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 47, ((PyObject *)__pyx_v_self->__pyx_base.pred_convolution_lookup));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pred_dist_deltas));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pred_dist_deltas));
  PyTuple_SET_ITEM(__pyx_t_23, 48, ((PyObject *)__pyx_v_self->__pyx_base.pred_dist_deltas));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pred_dist_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pred_dist_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 49, ((PyObject *)__pyx_v_self->__pyx_base.pred_dist_lookup));
  __Pyx_GIVEREF(__pyx_t_18);
  PyTuple_SET_ITEM(__pyx_t_23, 50, __pyx_t_18);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pred_dist_table));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pred_dist_table));
  PyTuple_SET_ITEM(__pyx_t_23, 51, ((PyObject *)__pyx_v_self->__pyx_base.pred_dist_table));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.pred_dist_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.pred_dist_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 52, ((PyObject *)__pyx_v_self->__pyx_base.pred_dist_weights));
  __Pyx_GIVEREF(__pyx_t_19);
  PyTuple_SET_ITEM(__pyx_t_23, 53, __pyx_t_19);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.sentence_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.sentence_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 54, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.sentence_lookup));
  __Pyx_GIVEREF(__pyx_t_20);
  PyTuple_SET_ITEM(__pyx_t_23, 55, __pyx_t_20);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.target_convolution_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.target_convolution_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 56, ((PyObject *)__pyx_v_self->__pyx_base.target_convolution_lookup));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.target_dist_deltas));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.target_dist_deltas));
  PyTuple_SET_ITEM(__pyx_t_23, 57, ((PyObject *)__pyx_v_self->__pyx_base.target_dist_deltas));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.target_dist_lookup));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.target_dist_lookup));
  PyTuple_SET_ITEM(__pyx_t_23, 58, ((PyObject *)__pyx_v_self->__pyx_base.target_dist_lookup));
  __Pyx_GIVEREF(__pyx_t_21);
  PyTuple_SET_ITEM(__pyx_t_23, 59, __pyx_t_21);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.target_dist_table));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.target_dist_table));
  PyTuple_SET_ITEM(__pyx_t_23, 60, ((PyObject *)__pyx_v_self->__pyx_base.target_dist_table));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.target_dist_weights));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.target_dist_weights));
  PyTuple_SET_ITEM(__pyx_t_23, 61, ((PyObject *)__pyx_v_self->__pyx_base.target_dist_weights));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.trans_gradients));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.trans_gradients));
  PyTuple_SET_ITEM(__pyx_t_23, 62, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.trans_gradients));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.transitions));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.transitions));
  PyTuple_SET_ITEM(__pyx_t_23, 63, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.transitions));
  __Pyx_INCREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.use_learning_rate_decay));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.use_learning_rate_decay));
  PyTuple_SET_ITEM(__pyx_t_23, 64, ((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.use_learning_rate_decay));
  __Pyx_INCREF(__pyx_v_self->__pyx_base.validation_arguments);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.validation_arguments);
  PyTuple_SET_ITEM(__pyx_t_23, 65, __pyx_v_self->__pyx_base.validation_arguments);
  __Pyx_INCREF(__pyx_v_self->validation_heads);
  __Pyx_GIVEREF(__pyx_v_self->validation_heads);
  PyTuple_SET_ITEM(__pyx_t_23, 66, __pyx_v_self->validation_heads);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.validation_predicates);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.validation_predicates);
  PyTuple_SET_ITEM(__pyx_t_23, 67, __pyx_v_self->__pyx_base.validation_predicates);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.validation_sentences);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.validation_sentences);
  PyTuple_SET_ITEM(__pyx_t_23, 68, __pyx_v_self->__pyx_base.__pyx_base.validation_sentences);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.__pyx_base.validation_tags);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.__pyx_base.validation_tags);
  PyTuple_SET_ITEM(__pyx_t_23, 69, __pyx_v_self->__pyx_base.__pyx_base.validation_tags);
  __Pyx_GIVEREF(__pyx_t_22);
  PyTuple_SET_ITEM(__pyx_t_23, 70, __pyx_t_22);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_9 = 0;
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_t_13 = 0;
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_t_16 = 0;
  __pyx_t_17 = 0;
  __pyx_t_18 = 0;
  __pyx_t_19 = 0;
  __pyx_t_20 = 0;
  __pyx_t_21 = 0;
  __pyx_t_22 = 0;
  __pyx_v_state = ((PyObject*)__pyx_t_23);
  __pyx_t_23 = 0;

  /* "(tree fragment)":6
 *     cdef bint use_setstate
 *     state = (self.accuracy, self.answer_score, self.convolution_lookup, self.decay_factor, self.dependency_weights, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.half_window, self.hidden2_before_activation, self.hidden2_bias, self.hidden2_gradients, self.hidden2_size, self.hidden2_values, self.hidden2_weights, self.hidden_before_activation, self.hidden_bias, self.hidden_gradients, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_deltas, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.max_indices, self.net_gradients, self.network_filename, self.network_text_filename, self.num_sentences, self.num_targets, self.num_tokens, self.only_classify, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.pred_convolution_lookup, self.pred_dist_deltas, self.pred_dist_lookup, self.pred_dist_offset, self.pred_dist_table, self.pred_dist_weights, self.sentence_accuracy, self.sentence_lookup, self.skips, self.target_convolution_lookup, self.target_dist_deltas, self.target_dist_lookup, self.target_dist_offset, self.target_dist_table, self.target_dist_weights, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_arguments, self.validation_heads, self.validation_predicates, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)             # <<<<<<<<<<<<<<
 *     if _dict is not None:
 *         state += (_dict,)
 */
  __pyx_t_23 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 6, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_23);
  __pyx_v__dict = __pyx_t_23;
  __pyx_t_23 = 0;

  /* "(tree fragment)":7
 *     state = (self.accuracy, self.answer_score, self.convolution_lookup, self.decay_factor, self.dependency_weights, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.half_window, self.hidden2_before_activation, self.hidden2_bias, self.hidden2_gradients, self.hidden2_size, self.hidden2_values, self.hidden2_weights, self.hidden_before_activation, self.hidden_bias, self.hidden_gradients, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_deltas, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.max_indices, self.net_gradients, self.network_filename, self.network_text_filename, self.num_sentences, self.num_targets, self.num_tokens, self.only_classify, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.pred_convolution_lookup, self.pred_dist_deltas, self.pred_dist_lookup, self.pred_dist_offset, self.pred_dist_table, self.pred_dist_weights, self.sentence_accuracy, self.sentence_lookup, self.skips, self.target_convolution_lookup, self.target_dist_deltas, self.target_dist_lookup, self.target_dist_offset, self.target_dist_table, self.target_dist_weights, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_arguments, self.validation_heads, self.validation_predicates, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
  __pyx_t_24 = (__pyx_v__dict != Py_None);
  __pyx_t_25 = (__pyx_t_24 != 0);
  if (__pyx_t_25) {

    /* "(tree fragment)":8
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:
 *         state += (_dict,)             # <<<<<<<<<<<<<<
 *         use_setstate = True
 *     else:
 */
    __pyx_t_23 = PyTuple_New(1); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_INCREF(__pyx_v__dict);
    __Pyx_GIVEREF(__pyx_v__dict);
    PyTuple_SET_ITEM(__pyx_t_23, 0, __pyx_v__dict);
    __pyx_t_22 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_23); if (unlikely(!__pyx_t_22)) __PYX_ERR(2, 8, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_22));
    __pyx_t_22 = 0;

    /* "(tree fragment)":9
 *     if _dict is not None:
 *         state += (_dict,)
 *         use_setstate = True             # <<<<<<<<<<<<<<
 *     else:
 *         use_setstate = self.convolution_lookup is not None or self.dependency_weights is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_heads is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None
 */
    __pyx_v_use_setstate = 1;

    /* "(tree fragment)":7
 *     state = (self.accuracy, self.answer_score, self.convolution_lookup, self.decay_factor, self.dependency_weights, self.error, self.feature_tables, self.features_per_token, self.float_errors, self.half_window, self.hidden2_before_activation, self.hidden2_bias, self.hidden2_gradients, self.hidden2_size, self.hidden2_values, self.hidden2_weights, self.hidden_before_activation, self.hidden_bias, self.hidden_gradients, self.hidden_sent_values, self.hidden_size, self.hidden_values, self.hidden_weights, self.input_deltas, self.input_sent_values, self.input_size, self.input_values, self.layer2_sent_values, self.layer2_values, self.learning_rate, self.learning_rate_features, self.learning_rate_trans, self.max_indices, self.net_gradients, self.network_filename, self.network_text_filename, self.num_sentences, self.num_targets, self.num_tokens, self.only_classify, self.output_bias, self.output_size, self.output_weights, self.padding_left, self.padding_right, self.pos_padding, self.pre_padding, self.pred_convolution_lookup, self.pred_dist_deltas, self.pred_dist_lookup, self.pred_dist_offset, self.pred_dist_table, self.pred_dist_weights, self.sentence_accuracy, self.sentence_lookup, self.skips, self.target_convolution_lookup, self.target_dist_deltas, self.target_dist_lookup, self.target_dist_offset, self.target_dist_table, self.target_dist_weights, self.trans_gradients, self.transitions, self.use_learning_rate_decay, self.validation_arguments, self.validation_heads, self.validation_predicates, self.validation_sentences, self.validation_tags, self.word_window_size)
 *     _dict = getattr(self, '__dict__', None)
 *     if _dict is not None:             # <<<<<<<<<<<<<<
 *         state += (_dict,)
 *         use_setstate = True
 */
    goto __pyx_L3;
  }

  /* "(tree fragment)":11
 *         use_setstate = True
 *     else:
 *         use_setstate = self.convolution_lookup is not None or self.dependency_weights is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_heads is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None             # <<<<<<<<<<<<<<
 *     if use_setstate:
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, None), state
 */
  /*else*/ {
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.convolution_lookup) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->dependency_weights) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_self->__pyx_base.__pyx_base.feature_tables != ((PyObject*)Py_None));
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.hidden2_before_activation) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.hidden2_bias) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.hidden2_gradients) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.hidden2_values) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.hidden2_weights) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.hidden_before_activation) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_bias) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.hidden_gradients) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_sent_values) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_values) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.hidden_weights) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.input_deltas) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.input_sent_values) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.input_values) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.layer2_sent_values) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.layer2_values) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.max_indices) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.net_gradients) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (__pyx_v_self->__pyx_base.__pyx_base.network_filename != ((PyObject*)Py_None));
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_self->__pyx_base.__pyx_base.network_text_filename != ((PyObject*)Py_None));
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.only_classify) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.output_bias) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.output_weights) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.padding_left) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.padding_right) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.pos_padding) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.pre_padding) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.pred_convolution_lookup) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.pred_dist_deltas) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.pred_dist_lookup) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.pred_dist_table) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.pred_dist_weights) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.sentence_lookup) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.target_convolution_lookup) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.target_dist_deltas) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.target_dist_lookup) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.target_dist_table) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.target_dist_weights) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.trans_gradients) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.transitions) != Py_None);
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (((PyObject *)__pyx_v_self->__pyx_base.__pyx_base.use_learning_rate_decay) != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_self->__pyx_base.validation_arguments != ((PyObject*)Py_None));
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (__pyx_v_self->validation_heads != Py_None);
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_self->__pyx_base.validation_predicates != ((PyObject*)Py_None));
    __pyx_t_26 = (__pyx_t_24 != 0);
    if (!__pyx_t_26) {
    } else {
      __pyx_t_25 = __pyx_t_26;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_26 = (__pyx_v_self->__pyx_base.__pyx_base.validation_sentences != ((PyObject*)Py_None));
    __pyx_t_24 = (__pyx_t_26 != 0);
    if (!__pyx_t_24) {
    } else {
      __pyx_t_25 = __pyx_t_24;
      goto __pyx_L4_bool_binop_done;
    }
    __pyx_t_24 = (__pyx_v_self->__pyx_base.__pyx_base.validation_tags != ((PyObject*)Py_None));
    __pyx_t_26 = (__pyx_t_24 != 0);
    __pyx_t_25 = __pyx_t_26;
    __pyx_L4_bool_binop_done:;
    __pyx_v_use_setstate = __pyx_t_25;
  }
  __pyx_L3:;

  /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.convolution_lookup is not None or self.dependency_weights is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_heads is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, None), state
 *     else:
 */
  __pyx_t_25 = (__pyx_v_use_setstate != 0);
  if (__pyx_t_25) {

    /* "(tree fragment)":13
 *         use_setstate = self.convolution_lookup is not None or self.dependency_weights is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_heads is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, None), state             # <<<<<<<<<<<<<<
 *     else:
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, state)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_n_s_pyx_unpickle_ConvolutionalDepe); if (unlikely(!__pyx_t_22)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __pyx_t_23 = PyTuple_New(3); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_23, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_27816595);
    __Pyx_GIVEREF(__pyx_int_27816595);
    PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_int_27816595);
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    PyTuple_SET_ITEM(__pyx_t_23, 2, Py_None);
    __pyx_t_21 = PyTuple_New(3); if (unlikely(!__pyx_t_21)) __PYX_ERR(2, 13, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_22);
    __Pyx_GIVEREF(__pyx_t_23);
    PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_t_23);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_21, 2, __pyx_v_state);
    __pyx_t_22 = 0;
    __pyx_t_23 = 0;
    __pyx_r = __pyx_t_21;
    __pyx_t_21 = 0;
    goto __pyx_L0;

    /* "(tree fragment)":12
 *     else:
 *         use_setstate = self.convolution_lookup is not None or self.dependency_weights is not None or self.feature_tables is not None or self.hidden2_before_activation is not None or self.hidden2_bias is not None or self.hidden2_gradients is not None or self.hidden2_values is not None or self.hidden2_weights is not None or self.hidden_before_activation is not None or self.hidden_bias is not None or self.hidden_gradients is not None or self.hidden_sent_values is not None or self.hidden_values is not None or self.hidden_weights is not None or self.input_deltas is not None or self.input_sent_values is not None or self.input_values is not None or self.layer2_sent_values is not None or self.layer2_values is not None or self.max_indices is not None or self.net_gradients is not None or self.network_filename is not None or self.network_text_filename is not None or self.only_classify is not None or self.output_bias is not None or self.output_weights is not None or self.padding_left is not None or self.padding_right is not None or self.pos_padding is not None or self.pre_padding is not None or self.pred_convolution_lookup is not None or self.pred_dist_deltas is not None or self.pred_dist_lookup is not None or self.pred_dist_table is not None or self.pred_dist_weights is not None or self.sentence_lookup is not None or self.target_convolution_lookup is not None or self.target_dist_deltas is not None or self.target_dist_lookup is not None or self.target_dist_table is not None or self.target_dist_weights is not None or self.trans_gradients is not None or self.transitions is not None or self.use_learning_rate_decay is not None or self.validation_arguments is not None or self.validation_heads is not None or self.validation_predicates is not None or self.validation_sentences is not None or self.validation_tags is not None
 *     if use_setstate:             # <<<<<<<<<<<<<<
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, None), state
 *     else:
 */
  }

  /* "(tree fragment)":15
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, None), state
 *     else:
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, state)             # <<<<<<<<<<<<<<
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(self, __pyx_state)
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_n_s_pyx_unpickle_ConvolutionalDepe); if (unlikely(!__pyx_t_21)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_23 = PyTuple_New(3); if (unlikely(!__pyx_t_23)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_23);
    __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    PyTuple_SET_ITEM(__pyx_t_23, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
    __Pyx_INCREF(__pyx_int_27816595);
    __Pyx_GIVEREF(__pyx_int_27816595);
    PyTuple_SET_ITEM(__pyx_t_23, 1, __pyx_int_27816595);
    __Pyx_INCREF(__pyx_v_state);
    __Pyx_GIVEREF(__pyx_v_state);
    PyTuple_SET_ITEM(__pyx_t_23, 2, __pyx_v_state);
    __pyx_t_22 = PyTuple_New(2); if (unlikely(!__pyx_t_22)) __PYX_ERR(2, 15, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_GIVEREF(__pyx_t_21);
    PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21);
    __Pyx_GIVEREF(__pyx_t_23);
    PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_t_23);
    __pyx_t_21 = 0;
    __pyx_t_23 = 0;
    __pyx_r = __pyx_t_22;
    __pyx_t_22 = 0;
    goto __pyx_L0;
  }

  /* "(tree fragment)":1
 * def __reduce_cython__(self):             # <<<<<<<<<<<<<<
 *     cdef tuple state
 *     cdef object _dict
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_state);
  __Pyx_XDECREF(__pyx_v__dict);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(self, __pyx_state)
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_35__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
static char __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_34__setstate_cython__[] = "ConvolutionalDependencyNetwork.__setstate_cython__(self, __pyx_state)";
static PyObject *__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_35__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_34__setstate_cython__(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_30ConvolutionalDependencyNetwork_34__setstate_cython__(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__setstate_cython__", 0);
  __Pyx_TraceCall("__setstate_cython__", __pyx_f[2], 16, 0, __PYX_ERR(2, 16, __pyx_L1_error));

  /* "(tree fragment)":17
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, state)
 * def __setstate_cython__(self, __pyx_state):
 *     __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(self, __pyx_state)             # <<<<<<<<<<<<<<
 */
  if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 17, __pyx_L1_error)
  __pyx_t_1 = __pyx_f_4libs_7network___pyx_unpickle_ConvolutionalDependencyNetwork__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":16
 *     else:
 *         return __pyx_unpickle_ConvolutionalDependencyNetwork, (type(self), 0x1a87293, state)
 * def __setstate_cython__(self, __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(self, __pyx_state)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("libs.network.ConvolutionalDependencyNetwork.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_Network(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_1__pyx_unpickle_Network(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network___pyx_unpickle_Network[] = "__pyx_unpickle_Network(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4libs_7network_1__pyx_unpickle_Network = {"__pyx_unpickle_Network", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_1__pyx_unpickle_Network, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network___pyx_unpickle_Network};
static PyObject *__pyx_pw_4libs_7network_1__pyx_unpickle_Network(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_Network (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Network", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Network", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Network") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Network", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_Network", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network___pyx_unpickle_Network(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network___pyx_unpickle_Network(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceFrameInit(__pyx_codeobj__13)
  __Pyx_RefNannySetupContext("__pyx_unpickle_Network", 0);
  __Pyx_TraceCall("__pyx_unpickle_Network", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xc0e08fa, 0x72479d4, 0xd248f0d):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__14, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xc0e08fa, 0x72479d4, 0xd248f0d):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = Network.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0xc0e08fa, 0x72479d4, 0xd248f0d):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = Network.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xc0e08fa, 0x72479d4, 0xd248f0d):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = Network.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Network__set_state(<Network> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4libs_7network_Network), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = Network.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Network__set_state(<Network> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = Network.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Network__set_state(<Network> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_Network__set_state(Network __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_4libs_7network___pyx_unpickle_Network__set_state(((struct __pyx_obj_4libs_7network_Network *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = Network.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_Network__set_state(<Network> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_Network__set_state(<Network> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_Network__set_state(Network __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.decay_factor = __pyx_state[2]; __pyx_result.error = __pyx_state[3]; __pyx_result.feature_tables = __pyx_state[4]; __pyx_result.features_per_token = __pyx_state[5]; __pyx_result.float_errors = __pyx_state[6]; __pyx_result.hidden_bias = __pyx_state[7]; __pyx_result.hidden_sent_values = __pyx_state[8]; __pyx_result.hidden_size = __pyx_state[9]; __pyx_result.hidden_values = __pyx_state[10]; __pyx_result.hidden_weights = __pyx_state[11]; __pyx_result.input_sent_values = __pyx_state[12]; __pyx_result.input_size = __pyx_state[13]; __pyx_result.input_values = __pyx_state[14]; __pyx_result.layer2_sent_values = __pyx_state[15]; __pyx_result.layer2_values = __pyx_state[16]; __pyx_result.learning_rate = __pyx_state[17]; __pyx_result.learning_rate_features = __pyx_state[18]; __pyx_result.learning_rate_trans = __pyx_state[19]; __pyx_result.net_gradients = __pyx_state[20]; __pyx_result.network_filename = __pyx_state[21]; __pyx_result.network_text_filename = __pyx_state[22]; __pyx_result.num_tokens = __pyx_state[23]; __pyx_result.output_bias = __pyx_state[24]; __pyx_result.output_size = __pyx_state[25]; __pyx_result.output_weights = __pyx_state[26]; __pyx_result.padding_left = __pyx_state[27]; __pyx_result.padding_right = __pyx_state[28]; __pyx_result.pos_padding = __pyx_state[29]; __pyx_result.pre_padding = __pyx_state[30]; __pyx_result.sentence_accuracy = __pyx_state[31]; __pyx_result.sentence_lookup = __pyx_state[32]; __pyx_result.skips = __pyx_state[33]; __pyx_result.trans_gradients = __pyx_state[34]; __pyx_result.transitions = __pyx_state[35]; __pyx_result.use_learning_rate_decay = __pyx_state[36]; __pyx_result.validation_sentences = __pyx_state[37]; __pyx_result.validation_tags = __pyx_state[38]; __pyx_result.word_window_size = __pyx_state[39]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_Network(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_Network", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_Network__set_state(<Network> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Network__set_state(Network __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.decay_factor = __pyx_state[2]; __pyx_result.error = __pyx_state[3]; __pyx_result.feature_tables = __pyx_state[4]; __pyx_result.features_per_token = __pyx_state[5]; __pyx_result.float_errors = __pyx_state[6]; __pyx_result.hidden_bias = __pyx_state[7]; __pyx_result.hidden_sent_values = __pyx_state[8]; __pyx_result.hidden_size = __pyx_state[9]; __pyx_result.hidden_values = __pyx_state[10]; __pyx_result.hidden_weights = __pyx_state[11]; __pyx_result.input_sent_values = __pyx_state[12]; __pyx_result.input_size = __pyx_state[13]; __pyx_result.input_values = __pyx_state[14]; __pyx_result.layer2_sent_values = __pyx_state[15]; __pyx_result.layer2_values = __pyx_state[16]; __pyx_result.learning_rate = __pyx_state[17]; __pyx_result.learning_rate_features = __pyx_state[18]; __pyx_result.learning_rate_trans = __pyx_state[19]; __pyx_result.net_gradients = __pyx_state[20]; __pyx_result.network_filename = __pyx_state[21]; __pyx_result.network_text_filename = __pyx_state[22]; __pyx_result.num_tokens = __pyx_state[23]; __pyx_result.output_bias = __pyx_state[24]; __pyx_result.output_size = __pyx_state[25]; __pyx_result.output_weights = __pyx_state[26]; __pyx_result.padding_left = __pyx_state[27]; __pyx_result.padding_right = __pyx_state[28]; __pyx_result.pos_padding = __pyx_state[29]; __pyx_result.pre_padding = __pyx_state[30]; __pyx_result.sentence_accuracy = __pyx_state[31]; __pyx_result.sentence_lookup = __pyx_state[32]; __pyx_result.skips = __pyx_state[33]; __pyx_result.trans_gradients = __pyx_state[34]; __pyx_result.transitions = __pyx_state[35]; __pyx_result.use_learning_rate_decay = __pyx_state[36]; __pyx_result.validation_sentences = __pyx_state[37]; __pyx_result.validation_tags = __pyx_state[38]; __pyx_result.word_window_size = __pyx_state[39]
 *     if len(__pyx_state) > 40 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4libs_7network___pyx_unpickle_Network__set_state(struct __pyx_obj_4libs_7network_Network *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  float __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_Network__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_Network__set_state", __pyx_f[2], 11, 0, __PYX_ERR(2, 11, __pyx_L1_error));

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_Network__set_state(Network __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.decay_factor = __pyx_state[2]; __pyx_result.error = __pyx_state[3]; __pyx_result.feature_tables = __pyx_state[4]; __pyx_result.features_per_token = __pyx_state[5]; __pyx_result.float_errors = __pyx_state[6]; __pyx_result.hidden_bias = __pyx_state[7]; __pyx_result.hidden_sent_values = __pyx_state[8]; __pyx_result.hidden_size = __pyx_state[9]; __pyx_result.hidden_values = __pyx_state[10]; __pyx_result.hidden_weights = __pyx_state[11]; __pyx_result.input_sent_values = __pyx_state[12]; __pyx_result.input_size = __pyx_state[13]; __pyx_result.input_values = __pyx_state[14]; __pyx_result.layer2_sent_values = __pyx_state[15]; __pyx_result.layer2_values = __pyx_state[16]; __pyx_result.learning_rate = __pyx_state[17]; __pyx_result.learning_rate_features = __pyx_state[18]; __pyx_result.learning_rate_trans = __pyx_state[19]; __pyx_result.net_gradients = __pyx_state[20]; __pyx_result.network_filename = __pyx_state[21]; __pyx_result.network_text_filename = __pyx_state[22]; __pyx_result.num_tokens = __pyx_state[23]; __pyx_result.output_bias = __pyx_state[24]; __pyx_result.output_size = __pyx_state[25]; __pyx_result.output_weights = __pyx_state[26]; __pyx_result.padding_left = __pyx_state[27]; __pyx_result.padding_right = __pyx_state[28]; __pyx_result.pos_padding = __pyx_state[29]; __pyx_result.pre_padding = __pyx_state[30]; __pyx_result.sentence_accuracy = __pyx_state[31]; __pyx_result.sentence_lookup = __pyx_state[32]; __pyx_result.skips = __pyx_state[33]; __pyx_result.trans_gradients = __pyx_state[34]; __pyx_result.transitions = __pyx_state[35]; __pyx_result.use_learning_rate_decay = __pyx_state[36]; __pyx_result.validation_sentences = __pyx_state[37]; __pyx_result.validation_tags = __pyx_state[38]; __pyx_result.word_window_size = __pyx_state[39]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 40 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[40])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->accuracy = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->answer_score = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->decay_factor = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->error = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->feature_tables);
  __Pyx_DECREF(__pyx_v___pyx_result->feature_tables);
  __pyx_v___pyx_result->feature_tables = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->features_per_token = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->float_errors = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden_bias));
  __pyx_v___pyx_result->hidden_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden_sent_values));
  __pyx_v___pyx_result->hidden_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->hidden_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden_values));
  __pyx_v___pyx_result->hidden_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden_weights));
  __pyx_v___pyx_result->hidden_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->input_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->input_sent_values));
  __pyx_v___pyx_result->input_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 13, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->input_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 14, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->input_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->input_values));
  __pyx_v___pyx_result->input_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 15, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->layer2_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->layer2_sent_values));
  __pyx_v___pyx_result->layer2_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 16, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->layer2_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->layer2_values));
  __pyx_v___pyx_result->layer2_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 17, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->learning_rate = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 18, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->learning_rate_features = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 19, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->learning_rate_trans = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 20, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->net_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->net_gradients));
  __pyx_v___pyx_result->net_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 21, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->network_filename);
  __Pyx_DECREF(__pyx_v___pyx_result->network_filename);
  __pyx_v___pyx_result->network_filename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 22, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->network_text_filename);
  __Pyx_DECREF(__pyx_v___pyx_result->network_text_filename);
  __pyx_v___pyx_result->network_text_filename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 23, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->num_tokens = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 24, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->output_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->output_bias));
  __pyx_v___pyx_result->output_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 25, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->output_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 26, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->output_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->output_weights));
  __pyx_v___pyx_result->output_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 27, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->padding_left);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->padding_left));
  __pyx_v___pyx_result->padding_left = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 28, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->padding_right);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->padding_right));
  __pyx_v___pyx_result->padding_right = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 29, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pos_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->pos_padding));
  __pyx_v___pyx_result->pos_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 30, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pre_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->pre_padding));
  __pyx_v___pyx_result->pre_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 31, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->sentence_accuracy = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 32, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->sentence_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->sentence_lookup));
  __pyx_v___pyx_result->sentence_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 33, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->skips = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 34, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->trans_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->trans_gradients));
  __pyx_v___pyx_result->trans_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 35, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->transitions);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->transitions));
  __pyx_v___pyx_result->transitions = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 36, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->use_learning_rate_decay);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->use_learning_rate_decay));
  __pyx_v___pyx_result->use_learning_rate_decay = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 37, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->validation_sentences);
  __Pyx_DECREF(__pyx_v___pyx_result->validation_sentences);
  __pyx_v___pyx_result->validation_sentences = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 38, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->validation_tags);
  __Pyx_DECREF(__pyx_v___pyx_result->validation_tags);
  __pyx_v___pyx_result->validation_tags = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 39, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->word_window_size = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_Network__set_state(Network __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.decay_factor = __pyx_state[2]; __pyx_result.error = __pyx_state[3]; __pyx_result.feature_tables = __pyx_state[4]; __pyx_result.features_per_token = __pyx_state[5]; __pyx_result.float_errors = __pyx_state[6]; __pyx_result.hidden_bias = __pyx_state[7]; __pyx_result.hidden_sent_values = __pyx_state[8]; __pyx_result.hidden_size = __pyx_state[9]; __pyx_result.hidden_values = __pyx_state[10]; __pyx_result.hidden_weights = __pyx_state[11]; __pyx_result.input_sent_values = __pyx_state[12]; __pyx_result.input_size = __pyx_state[13]; __pyx_result.input_values = __pyx_state[14]; __pyx_result.layer2_sent_values = __pyx_state[15]; __pyx_result.layer2_values = __pyx_state[16]; __pyx_result.learning_rate = __pyx_state[17]; __pyx_result.learning_rate_features = __pyx_state[18]; __pyx_result.learning_rate_trans = __pyx_state[19]; __pyx_result.net_gradients = __pyx_state[20]; __pyx_result.network_filename = __pyx_state[21]; __pyx_result.network_text_filename = __pyx_state[22]; __pyx_result.num_tokens = __pyx_state[23]; __pyx_result.output_bias = __pyx_state[24]; __pyx_result.output_size = __pyx_state[25]; __pyx_result.output_weights = __pyx_state[26]; __pyx_result.padding_left = __pyx_state[27]; __pyx_result.padding_right = __pyx_state[28]; __pyx_result.pos_padding = __pyx_state[29]; __pyx_result.pre_padding = __pyx_state[30]; __pyx_result.sentence_accuracy = __pyx_state[31]; __pyx_result.sentence_lookup = __pyx_state[32]; __pyx_result.skips = __pyx_state[33]; __pyx_result.trans_gradients = __pyx_state[34]; __pyx_result.transitions = __pyx_state[35]; __pyx_result.use_learning_rate_decay = __pyx_state[36]; __pyx_result.validation_sentences = __pyx_state[37]; __pyx_result.validation_tags = __pyx_state[38]; __pyx_result.word_window_size = __pyx_state[39]
 *     if len(__pyx_state) > 40 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[40])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_6 = ((__pyx_t_5 > 40) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "(tree fragment)":14
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.decay_factor = __pyx_state[2]; __pyx_result.error = __pyx_state[3]; __pyx_result.feature_tables = __pyx_state[4]; __pyx_result.features_per_token = __pyx_state[5]; __pyx_result.float_errors = __pyx_state[6]; __pyx_result.hidden_bias = __pyx_state[7]; __pyx_result.hidden_sent_values = __pyx_state[8]; __pyx_result.hidden_size = __pyx_state[9]; __pyx_result.hidden_values = __pyx_state[10]; __pyx_result.hidden_weights = __pyx_state[11]; __pyx_result.input_sent_values = __pyx_state[12]; __pyx_result.input_size = __pyx_state[13]; __pyx_result.input_values = __pyx_state[14]; __pyx_result.layer2_sent_values = __pyx_state[15]; __pyx_result.layer2_values = __pyx_state[16]; __pyx_result.learning_rate = __pyx_state[17]; __pyx_result.learning_rate_features = __pyx_state[18]; __pyx_result.learning_rate_trans = __pyx_state[19]; __pyx_result.net_gradients = __pyx_state[20]; __pyx_result.network_filename = __pyx_state[21]; __pyx_result.network_text_filename = __pyx_state[22]; __pyx_result.num_tokens = __pyx_state[23]; __pyx_result.output_bias = __pyx_state[24]; __pyx_result.output_size = __pyx_state[25]; __pyx_result.output_weights = __pyx_state[26]; __pyx_result.padding_left = __pyx_state[27]; __pyx_result.padding_right = __pyx_state[28]; __pyx_result.pos_padding = __pyx_state[29]; __pyx_result.pre_padding = __pyx_state[30]; __pyx_result.sentence_accuracy = __pyx_state[31]; __pyx_result.sentence_lookup = __pyx_state[32]; __pyx_result.skips = __pyx_state[33]; __pyx_result.trans_gradients = __pyx_state[34]; __pyx_result.transitions = __pyx_state[35]; __pyx_result.use_learning_rate_decay = __pyx_state[36]; __pyx_result.validation_sentences = __pyx_state[37]; __pyx_result.validation_tags = __pyx_state[38]; __pyx_result.word_window_size = __pyx_state[39]
 *     if len(__pyx_state) > 40 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[40])             # <<<<<<<<<<<<<<
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 40, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_Network__set_state(Network __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.decay_factor = __pyx_state[2]; __pyx_result.error = __pyx_state[3]; __pyx_result.feature_tables = __pyx_state[4]; __pyx_result.features_per_token = __pyx_state[5]; __pyx_result.float_errors = __pyx_state[6]; __pyx_result.hidden_bias = __pyx_state[7]; __pyx_result.hidden_sent_values = __pyx_state[8]; __pyx_result.hidden_size = __pyx_state[9]; __pyx_result.hidden_values = __pyx_state[10]; __pyx_result.hidden_weights = __pyx_state[11]; __pyx_result.input_sent_values = __pyx_state[12]; __pyx_result.input_size = __pyx_state[13]; __pyx_result.input_values = __pyx_state[14]; __pyx_result.layer2_sent_values = __pyx_state[15]; __pyx_result.layer2_values = __pyx_state[16]; __pyx_result.learning_rate = __pyx_state[17]; __pyx_result.learning_rate_features = __pyx_state[18]; __pyx_result.learning_rate_trans = __pyx_state[19]; __pyx_result.net_gradients = __pyx_state[20]; __pyx_result.network_filename = __pyx_state[21]; __pyx_result.network_text_filename = __pyx_state[22]; __pyx_result.num_tokens = __pyx_state[23]; __pyx_result.output_bias = __pyx_state[24]; __pyx_result.output_size = __pyx_state[25]; __pyx_result.output_weights = __pyx_state[26]; __pyx_result.padding_left = __pyx_state[27]; __pyx_result.padding_right = __pyx_state[28]; __pyx_result.pos_padding = __pyx_state[29]; __pyx_result.pre_padding = __pyx_state[30]; __pyx_result.sentence_accuracy = __pyx_state[31]; __pyx_result.sentence_lookup = __pyx_state[32]; __pyx_result.skips = __pyx_state[33]; __pyx_result.trans_gradients = __pyx_state[34]; __pyx_result.transitions = __pyx_state[35]; __pyx_result.use_learning_rate_decay = __pyx_state[36]; __pyx_result.validation_sentences = __pyx_state[37]; __pyx_result.validation_tags = __pyx_state[38]; __pyx_result.word_window_size = __pyx_state[39]
 *     if len(__pyx_state) > 40 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[40])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_Network__set_state(<Network> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Network__set_state(Network __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.decay_factor = __pyx_state[2]; __pyx_result.error = __pyx_state[3]; __pyx_result.feature_tables = __pyx_state[4]; __pyx_result.features_per_token = __pyx_state[5]; __pyx_result.float_errors = __pyx_state[6]; __pyx_result.hidden_bias = __pyx_state[7]; __pyx_result.hidden_sent_values = __pyx_state[8]; __pyx_result.hidden_size = __pyx_state[9]; __pyx_result.hidden_values = __pyx_state[10]; __pyx_result.hidden_weights = __pyx_state[11]; __pyx_result.input_sent_values = __pyx_state[12]; __pyx_result.input_size = __pyx_state[13]; __pyx_result.input_values = __pyx_state[14]; __pyx_result.layer2_sent_values = __pyx_state[15]; __pyx_result.layer2_values = __pyx_state[16]; __pyx_result.learning_rate = __pyx_state[17]; __pyx_result.learning_rate_features = __pyx_state[18]; __pyx_result.learning_rate_trans = __pyx_state[19]; __pyx_result.net_gradients = __pyx_state[20]; __pyx_result.network_filename = __pyx_state[21]; __pyx_result.network_text_filename = __pyx_state[22]; __pyx_result.num_tokens = __pyx_state[23]; __pyx_result.output_bias = __pyx_state[24]; __pyx_result.output_size = __pyx_state[25]; __pyx_result.output_weights = __pyx_state[26]; __pyx_result.padding_left = __pyx_state[27]; __pyx_result.padding_right = __pyx_state[28]; __pyx_result.pos_padding = __pyx_state[29]; __pyx_result.pre_padding = __pyx_state[30]; __pyx_result.sentence_accuracy = __pyx_state[31]; __pyx_result.sentence_lookup = __pyx_state[32]; __pyx_result.skips = __pyx_state[33]; __pyx_result.trans_gradients = __pyx_state[34]; __pyx_result.transitions = __pyx_state[35]; __pyx_result.use_learning_rate_decay = __pyx_state[36]; __pyx_result.validation_sentences = __pyx_state[37]; __pyx_result.validation_tags = __pyx_state[38]; __pyx_result.word_window_size = __pyx_state[39]
 *     if len(__pyx_state) > 40 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_Network__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ConvolutionalNetwork(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_3__pyx_unpickle_ConvolutionalNetwork(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_2__pyx_unpickle_ConvolutionalNetwork[] = "__pyx_unpickle_ConvolutionalNetwork(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4libs_7network_3__pyx_unpickle_ConvolutionalNetwork = {"__pyx_unpickle_ConvolutionalNetwork", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_3__pyx_unpickle_ConvolutionalNetwork, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_2__pyx_unpickle_ConvolutionalNetwork};
static PyObject *__pyx_pw_4libs_7network_3__pyx_unpickle_ConvolutionalNetwork(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ConvolutionalNetwork (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ConvolutionalNetwork", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ConvolutionalNetwork", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ConvolutionalNetwork") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ConvolutionalNetwork", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_ConvolutionalNetwork", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_2__pyx_unpickle_ConvolutionalNetwork(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_2__pyx_unpickle_ConvolutionalNetwork(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceFrameInit(__pyx_codeobj__15)
  __Pyx_RefNannySetupContext("__pyx_unpickle_ConvolutionalNetwork", 0);
  __Pyx_TraceCall("__pyx_unpickle_ConvolutionalNetwork", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x8e85e02, 0x2f64fba, 0x8d42e09):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e85e02, 0x2f64fba, 0x8d42e09) = (accuracy, answer_score, convolution_lookup, decay_factor, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__16, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x8e85e02, 0x2f64fba, 0x8d42e09):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e85e02, 0x2f64fba, 0x8d42e09) = (accuracy, answer_score, convolution_lookup, decay_factor, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = ConvolutionalNetwork.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0x8e85e02, 0x2f64fba, 0x8d42e09):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e85e02, 0x2f64fba, 0x8d42e09) = (accuracy, answer_score, convolution_lookup, decay_factor, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ConvolutionalNetwork.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x8e85e02, 0x2f64fba, 0x8d42e09):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e85e02, 0x2f64fba, 0x8d42e09) = (accuracy, answer_score, convolution_lookup, decay_factor, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e85e02, 0x2f64fba, 0x8d42e09) = (accuracy, answer_score, convolution_lookup, decay_factor, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = ConvolutionalNetwork.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ConvolutionalNetwork__set_state(<ConvolutionalNetwork> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e85e02, 0x2f64fba, 0x8d42e09) = (accuracy, answer_score, convolution_lookup, decay_factor, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = ConvolutionalNetwork.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ConvolutionalNetwork__set_state(<ConvolutionalNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = ConvolutionalNetwork.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ConvolutionalNetwork__set_state(<ConvolutionalNetwork> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ConvolutionalNetwork__set_state(ConvolutionalNetwork __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_4libs_7network___pyx_unpickle_ConvolutionalNetwork__set_state(((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x8e85e02, 0x2f64fba, 0x8d42e09) = (accuracy, answer_score, convolution_lookup, decay_factor, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = ConvolutionalNetwork.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ConvolutionalNetwork__set_state(<ConvolutionalNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ConvolutionalNetwork__set_state(<ConvolutionalNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ConvolutionalNetwork__set_state(ConvolutionalNetwork __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.error = __pyx_state[4]; __pyx_result.feature_tables = __pyx_state[5]; __pyx_result.features_per_token = __pyx_state[6]; __pyx_result.float_errors = __pyx_state[7]; __pyx_result.half_window = __pyx_state[8]; __pyx_result.hidden2_before_activation = __pyx_state[9]; __pyx_result.hidden2_bias = __pyx_state[10]; __pyx_result.hidden2_gradients = __pyx_state[11]; __pyx_result.hidden2_size = __pyx_state[12]; __pyx_result.hidden2_values = __pyx_state[13]; __pyx_result.hidden2_weights = __pyx_state[14]; __pyx_result.hidden_before_activation = __pyx_state[15]; __pyx_result.hidden_bias = __pyx_state[16]; __pyx_result.hidden_gradients = __pyx_state[17]; __pyx_result.hidden_sent_values = __pyx_state[18]; __pyx_result.hidden_size = __pyx_state[19]; __pyx_result.hidden_values = __pyx_state[20]; __pyx_result.hidden_weights = __pyx_state[21]; __pyx_result.input_deltas = __pyx_state[22]; __pyx_result.input_sent_values = __pyx_state[23]; __pyx_result.input_size = __pyx_state[24]; __pyx_result.input_values = __pyx_state[25]; __pyx_result.layer2_sent_values = __pyx_state[26]; __pyx_result.layer2_values = __pyx_state[27]; __pyx_result.learning_rate = __pyx_state[28]; __pyx_result.learning_rate_features = __pyx_state[29]; __pyx_result.learning_rate_trans = __pyx_state[30]; __pyx_result.max_indices = __pyx_state[31]; __pyx_result.net_gradients = __pyx_state[32]; __pyx_result.network_filename = __pyx_state[33]; __pyx_result.network_text_filename = __pyx_state[34]; __pyx_result.num_sentences = __pyx_state[35]; __pyx_result.num_targets = __pyx_state[36]; __pyx_result.num_tokens = __pyx_state[37]; __pyx_result.only_classify = __pyx_state[38]; __pyx_result.output_bias = __pyx_state[39]; __pyx_result.output_size = __pyx_state[40]; __pyx_result.output_weights = __pyx_state[41]; __pyx_result.padding_left = __pyx_state[42]; __pyx_result.padding_right = __pyx_state[43]; __pyx_result.pos_padding = __pyx_state[44]; __pyx_result.pre_padding = __pyx_state[45]; __pyx_result.pred_convolution_lookup = __pyx_state[46]; __pyx_result.pred_dist_deltas = __pyx_state[47]; __pyx_result.pred_dist_lookup = __pyx_state[48]; __pyx_result.pred_dist_offset = __pyx_state[49]; __pyx_result.pred_dist_table = __pyx_state[50]; __pyx_result.pred_dist_weights = __pyx_state[51]; __pyx_result.sentence_accuracy = __pyx_state[52]; __pyx_result.sentence_lookup = __pyx_state[53]; __pyx_result.skips = __pyx_state[54]; __pyx_result.target_convolution_lookup = __pyx_state[55]; __pyx_result.target_dist_deltas = __pyx_state[56]; __pyx_result.target_dist_lookup = __pyx_state[57]; __pyx_result.target_dist_offset = __pyx_state[58]; __pyx_result.target_dist_table = __pyx_state[59]; __pyx_result.target_dist_weights = __pyx_state[60]; __pyx_result.trans_gradients = __pyx_state[61]; __pyx_result.transitions = __pyx_state[62]; __pyx_result.use_learning_rate_decay = __pyx_state[63]; __pyx_result.validation_arguments = __pyx_state[64]; __pyx_result.validation_predicates = __pyx_state[65]; __pyx_result.validation_sentences = __pyx_state[66]; __pyx_result.validation_tags = __pyx_state[67]; __pyx_result.word_window_size = __pyx_state[68]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ConvolutionalNetwork(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_ConvolutionalNetwork", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ConvolutionalNetwork__set_state(<ConvolutionalNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ConvolutionalNetwork__set_state(ConvolutionalNetwork __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.error = __pyx_state[4]; __pyx_result.feature_tables = __pyx_state[5]; __pyx_result.features_per_token = __pyx_state[6]; __pyx_result.float_errors = __pyx_state[7]; __pyx_result.half_window = __pyx_state[8]; __pyx_result.hidden2_before_activation = __pyx_state[9]; __pyx_result.hidden2_bias = __pyx_state[10]; __pyx_result.hidden2_gradients = __pyx_state[11]; __pyx_result.hidden2_size = __pyx_state[12]; __pyx_result.hidden2_values = __pyx_state[13]; __pyx_result.hidden2_weights = __pyx_state[14]; __pyx_result.hidden_before_activation = __pyx_state[15]; __pyx_result.hidden_bias = __pyx_state[16]; __pyx_result.hidden_gradients = __pyx_state[17]; __pyx_result.hidden_sent_values = __pyx_state[18]; __pyx_result.hidden_size = __pyx_state[19]; __pyx_result.hidden_values = __pyx_state[20]; __pyx_result.hidden_weights = __pyx_state[21]; __pyx_result.input_deltas = __pyx_state[22]; __pyx_result.input_sent_values = __pyx_state[23]; __pyx_result.input_size = __pyx_state[24]; __pyx_result.input_values = __pyx_state[25]; __pyx_result.layer2_sent_values = __pyx_state[26]; __pyx_result.layer2_values = __pyx_state[27]; __pyx_result.learning_rate = __pyx_state[28]; __pyx_result.learning_rate_features = __pyx_state[29]; __pyx_result.learning_rate_trans = __pyx_state[30]; __pyx_result.max_indices = __pyx_state[31]; __pyx_result.net_gradients = __pyx_state[32]; __pyx_result.network_filename = __pyx_state[33]; __pyx_result.network_text_filename = __pyx_state[34]; __pyx_result.num_sentences = __pyx_state[35]; __pyx_result.num_targets = __pyx_state[36]; __pyx_result.num_tokens = __pyx_state[37]; __pyx_result.only_classify = __pyx_state[38]; __pyx_result.output_bias = __pyx_state[39]; __pyx_result.output_size = __pyx_state[40]; __pyx_result.output_weights = __pyx_state[41]; __pyx_result.padding_left = __pyx_state[42]; __pyx_result.padding_right = __pyx_state[43]; __pyx_result.pos_padding = __pyx_state[44]; __pyx_result.pre_padding = __pyx_state[45]; __pyx_result.pred_convolution_lookup = __pyx_state[46]; __pyx_result.pred_dist_deltas = __pyx_state[47]; __pyx_result.pred_dist_lookup = __pyx_state[48]; __pyx_result.pred_dist_offset = __pyx_state[49]; __pyx_result.pred_dist_table = __pyx_state[50]; __pyx_result.pred_dist_weights = __pyx_state[51]; __pyx_result.sentence_accuracy = __pyx_state[52]; __pyx_result.sentence_lookup = __pyx_state[53]; __pyx_result.skips = __pyx_state[54]; __pyx_result.target_convolution_lookup = __pyx_state[55]; __pyx_result.target_dist_deltas = __pyx_state[56]; __pyx_result.target_dist_lookup = __pyx_state[57]; __pyx_result.target_dist_offset = __pyx_state[58]; __pyx_result.target_dist_table = __pyx_state[59]; __pyx_result.target_dist_weights = __pyx_state[60]; __pyx_result.trans_gradients = __pyx_state[61]; __pyx_result.transitions = __pyx_state[62]; __pyx_result.use_learning_rate_decay = __pyx_state[63]; __pyx_result.validation_arguments = __pyx_state[64]; __pyx_result.validation_predicates = __pyx_state[65]; __pyx_result.validation_sentences = __pyx_state[66]; __pyx_result.validation_tags = __pyx_state[67]; __pyx_result.word_window_size = __pyx_state[68]
 *     if len(__pyx_state) > 69 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4libs_7network___pyx_unpickle_ConvolutionalNetwork__set_state(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  float __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ConvolutionalNetwork__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_ConvolutionalNetwork__set_state", __pyx_f[2], 11, 0, __PYX_ERR(2, 11, __pyx_L1_error));

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ConvolutionalNetwork__set_state(ConvolutionalNetwork __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.error = __pyx_state[4]; __pyx_result.feature_tables = __pyx_state[5]; __pyx_result.features_per_token = __pyx_state[6]; __pyx_result.float_errors = __pyx_state[7]; __pyx_result.half_window = __pyx_state[8]; __pyx_result.hidden2_before_activation = __pyx_state[9]; __pyx_result.hidden2_bias = __pyx_state[10]; __pyx_result.hidden2_gradients = __pyx_state[11]; __pyx_result.hidden2_size = __pyx_state[12]; __pyx_result.hidden2_values = __pyx_state[13]; __pyx_result.hidden2_weights = __pyx_state[14]; __pyx_result.hidden_before_activation = __pyx_state[15]; __pyx_result.hidden_bias = __pyx_state[16]; __pyx_result.hidden_gradients = __pyx_state[17]; __pyx_result.hidden_sent_values = __pyx_state[18]; __pyx_result.hidden_size = __pyx_state[19]; __pyx_result.hidden_values = __pyx_state[20]; __pyx_result.hidden_weights = __pyx_state[21]; __pyx_result.input_deltas = __pyx_state[22]; __pyx_result.input_sent_values = __pyx_state[23]; __pyx_result.input_size = __pyx_state[24]; __pyx_result.input_values = __pyx_state[25]; __pyx_result.layer2_sent_values = __pyx_state[26]; __pyx_result.layer2_values = __pyx_state[27]; __pyx_result.learning_rate = __pyx_state[28]; __pyx_result.learning_rate_features = __pyx_state[29]; __pyx_result.learning_rate_trans = __pyx_state[30]; __pyx_result.max_indices = __pyx_state[31]; __pyx_result.net_gradients = __pyx_state[32]; __pyx_result.network_filename = __pyx_state[33]; __pyx_result.network_text_filename = __pyx_state[34]; __pyx_result.num_sentences = __pyx_state[35]; __pyx_result.num_targets = __pyx_state[36]; __pyx_result.num_tokens = __pyx_state[37]; __pyx_result.only_classify = __pyx_state[38]; __pyx_result.output_bias = __pyx_state[39]; __pyx_result.output_size = __pyx_state[40]; __pyx_result.output_weights = __pyx_state[41]; __pyx_result.padding_left = __pyx_state[42]; __pyx_result.padding_right = __pyx_state[43]; __pyx_result.pos_padding = __pyx_state[44]; __pyx_result.pre_padding = __pyx_state[45]; __pyx_result.pred_convolution_lookup = __pyx_state[46]; __pyx_result.pred_dist_deltas = __pyx_state[47]; __pyx_result.pred_dist_lookup = __pyx_state[48]; __pyx_result.pred_dist_offset = __pyx_state[49]; __pyx_result.pred_dist_table = __pyx_state[50]; __pyx_result.pred_dist_weights = __pyx_state[51]; __pyx_result.sentence_accuracy = __pyx_state[52]; __pyx_result.sentence_lookup = __pyx_state[53]; __pyx_result.skips = __pyx_state[54]; __pyx_result.target_convolution_lookup = __pyx_state[55]; __pyx_result.target_dist_deltas = __pyx_state[56]; __pyx_result.target_dist_lookup = __pyx_state[57]; __pyx_result.target_dist_offset = __pyx_state[58]; __pyx_result.target_dist_table = __pyx_state[59]; __pyx_result.target_dist_weights = __pyx_state[60]; __pyx_result.trans_gradients = __pyx_state[61]; __pyx_result.transitions = __pyx_state[62]; __pyx_result.use_learning_rate_decay = __pyx_state[63]; __pyx_result.validation_arguments = __pyx_state[64]; __pyx_result.validation_predicates = __pyx_state[65]; __pyx_result.validation_sentences = __pyx_state[66]; __pyx_result.validation_tags = __pyx_state[67]; __pyx_result.word_window_size = __pyx_state[68]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 69 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[69])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.accuracy = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.answer_score = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->convolution_lookup));
  __pyx_v___pyx_result->convolution_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.decay_factor = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.error = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.feature_tables);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.feature_tables);
  __pyx_v___pyx_result->__pyx_base.feature_tables = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.features_per_token = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.float_errors = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->half_window = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden2_before_activation);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden2_before_activation));
  __pyx_v___pyx_result->hidden2_before_activation = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden2_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden2_bias));
  __pyx_v___pyx_result->hidden2_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden2_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden2_gradients));
  __pyx_v___pyx_result->hidden2_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->hidden2_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 13, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden2_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden2_values));
  __pyx_v___pyx_result->hidden2_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 14, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden2_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden2_weights));
  __pyx_v___pyx_result->hidden2_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 15, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden_before_activation);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden_before_activation));
  __pyx_v___pyx_result->hidden_before_activation = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 16, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden_bias));
  __pyx_v___pyx_result->__pyx_base.hidden_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 17, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->hidden_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->hidden_gradients));
  __pyx_v___pyx_result->hidden_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 18, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden_sent_values));
  __pyx_v___pyx_result->__pyx_base.hidden_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 19, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.hidden_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 20, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden_values));
  __pyx_v___pyx_result->__pyx_base.hidden_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 21, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden_weights));
  __pyx_v___pyx_result->__pyx_base.hidden_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 22, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->input_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->input_deltas));
  __pyx_v___pyx_result->input_deltas = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 23, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.input_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.input_sent_values));
  __pyx_v___pyx_result->__pyx_base.input_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 24, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.input_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 25, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.input_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.input_values));
  __pyx_v___pyx_result->__pyx_base.input_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 26, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.layer2_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.layer2_sent_values));
  __pyx_v___pyx_result->__pyx_base.layer2_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 27, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.layer2_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.layer2_values));
  __pyx_v___pyx_result->__pyx_base.layer2_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 28, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.learning_rate = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 29, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.learning_rate_features = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 30, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.learning_rate_trans = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 31, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->max_indices);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->max_indices));
  __pyx_v___pyx_result->max_indices = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 32, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.net_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.net_gradients));
  __pyx_v___pyx_result->__pyx_base.net_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 33, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.network_filename);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.network_filename);
  __pyx_v___pyx_result->__pyx_base.network_filename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 34, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.network_text_filename);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.network_text_filename);
  __pyx_v___pyx_result->__pyx_base.network_text_filename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 35, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->num_sentences = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 36, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->num_targets = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 37, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.num_tokens = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 38, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->only_classify);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->only_classify));
  __pyx_v___pyx_result->only_classify = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 39, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.output_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.output_bias));
  __pyx_v___pyx_result->__pyx_base.output_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 40, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.output_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 41, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.output_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.output_weights));
  __pyx_v___pyx_result->__pyx_base.output_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 42, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.padding_left);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.padding_left));
  __pyx_v___pyx_result->__pyx_base.padding_left = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 43, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.padding_right);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.padding_right));
  __pyx_v___pyx_result->__pyx_base.padding_right = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 44, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.pos_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.pos_padding));
  __pyx_v___pyx_result->__pyx_base.pos_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 45, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.pre_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.pre_padding));
  __pyx_v___pyx_result->__pyx_base.pre_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 46, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pred_convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->pred_convolution_lookup));
  __pyx_v___pyx_result->pred_convolution_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 47, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pred_dist_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->pred_dist_deltas));
  __pyx_v___pyx_result->pred_dist_deltas = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 48, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pred_dist_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->pred_dist_lookup));
  __pyx_v___pyx_result->pred_dist_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 49, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->pred_dist_offset = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 50, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pred_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->pred_dist_table));
  __pyx_v___pyx_result->pred_dist_table = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 51, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->pred_dist_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->pred_dist_weights));
  __pyx_v___pyx_result->pred_dist_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 52, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.sentence_accuracy = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 53, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.sentence_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.sentence_lookup));
  __pyx_v___pyx_result->__pyx_base.sentence_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 54, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.skips = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 55, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->target_convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->target_convolution_lookup));
  __pyx_v___pyx_result->target_convolution_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 56, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->target_dist_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->target_dist_deltas));
  __pyx_v___pyx_result->target_dist_deltas = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 57, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->target_dist_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->target_dist_lookup));
  __pyx_v___pyx_result->target_dist_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 58, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->target_dist_offset = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 59, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->target_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->target_dist_table));
  __pyx_v___pyx_result->target_dist_table = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 60, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->target_dist_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->target_dist_weights));
  __pyx_v___pyx_result->target_dist_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 61, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.trans_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.trans_gradients));
  __pyx_v___pyx_result->__pyx_base.trans_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 62, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.transitions);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.transitions));
  __pyx_v___pyx_result->__pyx_base.transitions = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 63, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.use_learning_rate_decay);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.use_learning_rate_decay));
  __pyx_v___pyx_result->__pyx_base.use_learning_rate_decay = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 64, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->validation_arguments);
  __Pyx_DECREF(__pyx_v___pyx_result->validation_arguments);
  __pyx_v___pyx_result->validation_arguments = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 65, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->validation_predicates);
  __Pyx_DECREF(__pyx_v___pyx_result->validation_predicates);
  __pyx_v___pyx_result->validation_predicates = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 66, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.validation_sentences);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.validation_sentences);
  __pyx_v___pyx_result->__pyx_base.validation_sentences = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 67, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.validation_tags);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.validation_tags);
  __pyx_v___pyx_result->__pyx_base.validation_tags = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 68, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.word_window_size = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ConvolutionalNetwork__set_state(ConvolutionalNetwork __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.error = __pyx_state[4]; __pyx_result.feature_tables = __pyx_state[5]; __pyx_result.features_per_token = __pyx_state[6]; __pyx_result.float_errors = __pyx_state[7]; __pyx_result.half_window = __pyx_state[8]; __pyx_result.hidden2_before_activation = __pyx_state[9]; __pyx_result.hidden2_bias = __pyx_state[10]; __pyx_result.hidden2_gradients = __pyx_state[11]; __pyx_result.hidden2_size = __pyx_state[12]; __pyx_result.hidden2_values = __pyx_state[13]; __pyx_result.hidden2_weights = __pyx_state[14]; __pyx_result.hidden_before_activation = __pyx_state[15]; __pyx_result.hidden_bias = __pyx_state[16]; __pyx_result.hidden_gradients = __pyx_state[17]; __pyx_result.hidden_sent_values = __pyx_state[18]; __pyx_result.hidden_size = __pyx_state[19]; __pyx_result.hidden_values = __pyx_state[20]; __pyx_result.hidden_weights = __pyx_state[21]; __pyx_result.input_deltas = __pyx_state[22]; __pyx_result.input_sent_values = __pyx_state[23]; __pyx_result.input_size = __pyx_state[24]; __pyx_result.input_values = __pyx_state[25]; __pyx_result.layer2_sent_values = __pyx_state[26]; __pyx_result.layer2_values = __pyx_state[27]; __pyx_result.learning_rate = __pyx_state[28]; __pyx_result.learning_rate_features = __pyx_state[29]; __pyx_result.learning_rate_trans = __pyx_state[30]; __pyx_result.max_indices = __pyx_state[31]; __pyx_result.net_gradients = __pyx_state[32]; __pyx_result.network_filename = __pyx_state[33]; __pyx_result.network_text_filename = __pyx_state[34]; __pyx_result.num_sentences = __pyx_state[35]; __pyx_result.num_targets = __pyx_state[36]; __pyx_result.num_tokens = __pyx_state[37]; __pyx_result.only_classify = __pyx_state[38]; __pyx_result.output_bias = __pyx_state[39]; __pyx_result.output_size = __pyx_state[40]; __pyx_result.output_weights = __pyx_state[41]; __pyx_result.padding_left = __pyx_state[42]; __pyx_result.padding_right = __pyx_state[43]; __pyx_result.pos_padding = __pyx_state[44]; __pyx_result.pre_padding = __pyx_state[45]; __pyx_result.pred_convolution_lookup = __pyx_state[46]; __pyx_result.pred_dist_deltas = __pyx_state[47]; __pyx_result.pred_dist_lookup = __pyx_state[48]; __pyx_result.pred_dist_offset = __pyx_state[49]; __pyx_result.pred_dist_table = __pyx_state[50]; __pyx_result.pred_dist_weights = __pyx_state[51]; __pyx_result.sentence_accuracy = __pyx_state[52]; __pyx_result.sentence_lookup = __pyx_state[53]; __pyx_result.skips = __pyx_state[54]; __pyx_result.target_convolution_lookup = __pyx_state[55]; __pyx_result.target_dist_deltas = __pyx_state[56]; __pyx_result.target_dist_lookup = __pyx_state[57]; __pyx_result.target_dist_offset = __pyx_state[58]; __pyx_result.target_dist_table = __pyx_state[59]; __pyx_result.target_dist_weights = __pyx_state[60]; __pyx_result.trans_gradients = __pyx_state[61]; __pyx_result.transitions = __pyx_state[62]; __pyx_result.use_learning_rate_decay = __pyx_state[63]; __pyx_result.validation_arguments = __pyx_state[64]; __pyx_result.validation_predicates = __pyx_state[65]; __pyx_result.validation_sentences = __pyx_state[66]; __pyx_result.validation_tags = __pyx_state[67]; __pyx_result.word_window_size = __pyx_state[68]
 *     if len(__pyx_state) > 69 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[69])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_6 = ((__pyx_t_5 > 69) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "(tree fragment)":14
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.error = __pyx_state[4]; __pyx_result.feature_tables = __pyx_state[5]; __pyx_result.features_per_token = __pyx_state[6]; __pyx_result.float_errors = __pyx_state[7]; __pyx_result.half_window = __pyx_state[8]; __pyx_result.hidden2_before_activation = __pyx_state[9]; __pyx_result.hidden2_bias = __pyx_state[10]; __pyx_result.hidden2_gradients = __pyx_state[11]; __pyx_result.hidden2_size = __pyx_state[12]; __pyx_result.hidden2_values = __pyx_state[13]; __pyx_result.hidden2_weights = __pyx_state[14]; __pyx_result.hidden_before_activation = __pyx_state[15]; __pyx_result.hidden_bias = __pyx_state[16]; __pyx_result.hidden_gradients = __pyx_state[17]; __pyx_result.hidden_sent_values = __pyx_state[18]; __pyx_result.hidden_size = __pyx_state[19]; __pyx_result.hidden_values = __pyx_state[20]; __pyx_result.hidden_weights = __pyx_state[21]; __pyx_result.input_deltas = __pyx_state[22]; __pyx_result.input_sent_values = __pyx_state[23]; __pyx_result.input_size = __pyx_state[24]; __pyx_result.input_values = __pyx_state[25]; __pyx_result.layer2_sent_values = __pyx_state[26]; __pyx_result.layer2_values = __pyx_state[27]; __pyx_result.learning_rate = __pyx_state[28]; __pyx_result.learning_rate_features = __pyx_state[29]; __pyx_result.learning_rate_trans = __pyx_state[30]; __pyx_result.max_indices = __pyx_state[31]; __pyx_result.net_gradients = __pyx_state[32]; __pyx_result.network_filename = __pyx_state[33]; __pyx_result.network_text_filename = __pyx_state[34]; __pyx_result.num_sentences = __pyx_state[35]; __pyx_result.num_targets = __pyx_state[36]; __pyx_result.num_tokens = __pyx_state[37]; __pyx_result.only_classify = __pyx_state[38]; __pyx_result.output_bias = __pyx_state[39]; __pyx_result.output_size = __pyx_state[40]; __pyx_result.output_weights = __pyx_state[41]; __pyx_result.padding_left = __pyx_state[42]; __pyx_result.padding_right = __pyx_state[43]; __pyx_result.pos_padding = __pyx_state[44]; __pyx_result.pre_padding = __pyx_state[45]; __pyx_result.pred_convolution_lookup = __pyx_state[46]; __pyx_result.pred_dist_deltas = __pyx_state[47]; __pyx_result.pred_dist_lookup = __pyx_state[48]; __pyx_result.pred_dist_offset = __pyx_state[49]; __pyx_result.pred_dist_table = __pyx_state[50]; __pyx_result.pred_dist_weights = __pyx_state[51]; __pyx_result.sentence_accuracy = __pyx_state[52]; __pyx_result.sentence_lookup = __pyx_state[53]; __pyx_result.skips = __pyx_state[54]; __pyx_result.target_convolution_lookup = __pyx_state[55]; __pyx_result.target_dist_deltas = __pyx_state[56]; __pyx_result.target_dist_lookup = __pyx_state[57]; __pyx_result.target_dist_offset = __pyx_state[58]; __pyx_result.target_dist_table = __pyx_state[59]; __pyx_result.target_dist_weights = __pyx_state[60]; __pyx_result.trans_gradients = __pyx_state[61]; __pyx_result.transitions = __pyx_state[62]; __pyx_result.use_learning_rate_decay = __pyx_state[63]; __pyx_result.validation_arguments = __pyx_state[64]; __pyx_result.validation_predicates = __pyx_state[65]; __pyx_result.validation_sentences = __pyx_state[66]; __pyx_result.validation_tags = __pyx_state[67]; __pyx_result.word_window_size = __pyx_state[68]
 *     if len(__pyx_state) > 69 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[69])             # <<<<<<<<<<<<<<
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 69, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ConvolutionalNetwork__set_state(ConvolutionalNetwork __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.error = __pyx_state[4]; __pyx_result.feature_tables = __pyx_state[5]; __pyx_result.features_per_token = __pyx_state[6]; __pyx_result.float_errors = __pyx_state[7]; __pyx_result.half_window = __pyx_state[8]; __pyx_result.hidden2_before_activation = __pyx_state[9]; __pyx_result.hidden2_bias = __pyx_state[10]; __pyx_result.hidden2_gradients = __pyx_state[11]; __pyx_result.hidden2_size = __pyx_state[12]; __pyx_result.hidden2_values = __pyx_state[13]; __pyx_result.hidden2_weights = __pyx_state[14]; __pyx_result.hidden_before_activation = __pyx_state[15]; __pyx_result.hidden_bias = __pyx_state[16]; __pyx_result.hidden_gradients = __pyx_state[17]; __pyx_result.hidden_sent_values = __pyx_state[18]; __pyx_result.hidden_size = __pyx_state[19]; __pyx_result.hidden_values = __pyx_state[20]; __pyx_result.hidden_weights = __pyx_state[21]; __pyx_result.input_deltas = __pyx_state[22]; __pyx_result.input_sent_values = __pyx_state[23]; __pyx_result.input_size = __pyx_state[24]; __pyx_result.input_values = __pyx_state[25]; __pyx_result.layer2_sent_values = __pyx_state[26]; __pyx_result.layer2_values = __pyx_state[27]; __pyx_result.learning_rate = __pyx_state[28]; __pyx_result.learning_rate_features = __pyx_state[29]; __pyx_result.learning_rate_trans = __pyx_state[30]; __pyx_result.max_indices = __pyx_state[31]; __pyx_result.net_gradients = __pyx_state[32]; __pyx_result.network_filename = __pyx_state[33]; __pyx_result.network_text_filename = __pyx_state[34]; __pyx_result.num_sentences = __pyx_state[35]; __pyx_result.num_targets = __pyx_state[36]; __pyx_result.num_tokens = __pyx_state[37]; __pyx_result.only_classify = __pyx_state[38]; __pyx_result.output_bias = __pyx_state[39]; __pyx_result.output_size = __pyx_state[40]; __pyx_result.output_weights = __pyx_state[41]; __pyx_result.padding_left = __pyx_state[42]; __pyx_result.padding_right = __pyx_state[43]; __pyx_result.pos_padding = __pyx_state[44]; __pyx_result.pre_padding = __pyx_state[45]; __pyx_result.pred_convolution_lookup = __pyx_state[46]; __pyx_result.pred_dist_deltas = __pyx_state[47]; __pyx_result.pred_dist_lookup = __pyx_state[48]; __pyx_result.pred_dist_offset = __pyx_state[49]; __pyx_result.pred_dist_table = __pyx_state[50]; __pyx_result.pred_dist_weights = __pyx_state[51]; __pyx_result.sentence_accuracy = __pyx_state[52]; __pyx_result.sentence_lookup = __pyx_state[53]; __pyx_result.skips = __pyx_state[54]; __pyx_result.target_convolution_lookup = __pyx_state[55]; __pyx_result.target_dist_deltas = __pyx_state[56]; __pyx_result.target_dist_lookup = __pyx_state[57]; __pyx_result.target_dist_offset = __pyx_state[58]; __pyx_result.target_dist_table = __pyx_state[59]; __pyx_result.target_dist_weights = __pyx_state[60]; __pyx_result.trans_gradients = __pyx_state[61]; __pyx_result.transitions = __pyx_state[62]; __pyx_result.use_learning_rate_decay = __pyx_state[63]; __pyx_result.validation_arguments = __pyx_state[64]; __pyx_result.validation_predicates = __pyx_state[65]; __pyx_result.validation_sentences = __pyx_state[66]; __pyx_result.validation_tags = __pyx_state[67]; __pyx_result.word_window_size = __pyx_state[68]
 *     if len(__pyx_state) > 69 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[69])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ConvolutionalNetwork__set_state(<ConvolutionalNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ConvolutionalNetwork__set_state(ConvolutionalNetwork __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.error = __pyx_state[4]; __pyx_result.feature_tables = __pyx_state[5]; __pyx_result.features_per_token = __pyx_state[6]; __pyx_result.float_errors = __pyx_state[7]; __pyx_result.half_window = __pyx_state[8]; __pyx_result.hidden2_before_activation = __pyx_state[9]; __pyx_result.hidden2_bias = __pyx_state[10]; __pyx_result.hidden2_gradients = __pyx_state[11]; __pyx_result.hidden2_size = __pyx_state[12]; __pyx_result.hidden2_values = __pyx_state[13]; __pyx_result.hidden2_weights = __pyx_state[14]; __pyx_result.hidden_before_activation = __pyx_state[15]; __pyx_result.hidden_bias = __pyx_state[16]; __pyx_result.hidden_gradients = __pyx_state[17]; __pyx_result.hidden_sent_values = __pyx_state[18]; __pyx_result.hidden_size = __pyx_state[19]; __pyx_result.hidden_values = __pyx_state[20]; __pyx_result.hidden_weights = __pyx_state[21]; __pyx_result.input_deltas = __pyx_state[22]; __pyx_result.input_sent_values = __pyx_state[23]; __pyx_result.input_size = __pyx_state[24]; __pyx_result.input_values = __pyx_state[25]; __pyx_result.layer2_sent_values = __pyx_state[26]; __pyx_result.layer2_values = __pyx_state[27]; __pyx_result.learning_rate = __pyx_state[28]; __pyx_result.learning_rate_features = __pyx_state[29]; __pyx_result.learning_rate_trans = __pyx_state[30]; __pyx_result.max_indices = __pyx_state[31]; __pyx_result.net_gradients = __pyx_state[32]; __pyx_result.network_filename = __pyx_state[33]; __pyx_result.network_text_filename = __pyx_state[34]; __pyx_result.num_sentences = __pyx_state[35]; __pyx_result.num_targets = __pyx_state[36]; __pyx_result.num_tokens = __pyx_state[37]; __pyx_result.only_classify = __pyx_state[38]; __pyx_result.output_bias = __pyx_state[39]; __pyx_result.output_size = __pyx_state[40]; __pyx_result.output_weights = __pyx_state[41]; __pyx_result.padding_left = __pyx_state[42]; __pyx_result.padding_right = __pyx_state[43]; __pyx_result.pos_padding = __pyx_state[44]; __pyx_result.pre_padding = __pyx_state[45]; __pyx_result.pred_convolution_lookup = __pyx_state[46]; __pyx_result.pred_dist_deltas = __pyx_state[47]; __pyx_result.pred_dist_lookup = __pyx_state[48]; __pyx_result.pred_dist_offset = __pyx_state[49]; __pyx_result.pred_dist_table = __pyx_state[50]; __pyx_result.pred_dist_weights = __pyx_state[51]; __pyx_result.sentence_accuracy = __pyx_state[52]; __pyx_result.sentence_lookup = __pyx_state[53]; __pyx_result.skips = __pyx_state[54]; __pyx_result.target_convolution_lookup = __pyx_state[55]; __pyx_result.target_dist_deltas = __pyx_state[56]; __pyx_result.target_dist_lookup = __pyx_state[57]; __pyx_result.target_dist_offset = __pyx_state[58]; __pyx_result.target_dist_table = __pyx_state[59]; __pyx_result.target_dist_weights = __pyx_state[60]; __pyx_result.trans_gradients = __pyx_state[61]; __pyx_result.transitions = __pyx_state[62]; __pyx_result.use_learning_rate_decay = __pyx_state[63]; __pyx_result.validation_arguments = __pyx_state[64]; __pyx_result.validation_predicates = __pyx_state[65]; __pyx_result.validation_sentences = __pyx_state[66]; __pyx_result.validation_tags = __pyx_state[67]; __pyx_result.word_window_size = __pyx_state[68]
 *     if len(__pyx_state) > 69 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_ConvolutionalNetwork__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":1
 * def __pyx_unpickle_ConvolutionalDependencyNetwork(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

/* Python wrapper */
static PyObject *__pyx_pw_4libs_7network_5__pyx_unpickle_ConvolutionalDependencyNetwork(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4libs_7network_4__pyx_unpickle_ConvolutionalDependencyNetwork[] = "__pyx_unpickle_ConvolutionalDependencyNetwork(__pyx_type, long __pyx_checksum, __pyx_state)";
static PyMethodDef __pyx_mdef_4libs_7network_5__pyx_unpickle_ConvolutionalDependencyNetwork = {"__pyx_unpickle_ConvolutionalDependencyNetwork", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_5__pyx_unpickle_ConvolutionalDependencyNetwork, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_4__pyx_unpickle_ConvolutionalDependencyNetwork};
static PyObject *__pyx_pw_4libs_7network_5__pyx_unpickle_ConvolutionalDependencyNetwork(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v___pyx_type = 0;
  long __pyx_v___pyx_checksum;
  PyObject *__pyx_v___pyx_state = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__pyx_unpickle_ConvolutionalDependencyNetwork (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ConvolutionalDependencyNetwork", 1, 3, 3, 1); __PYX_ERR(2, 1, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ConvolutionalDependencyNetwork", 1, 3, 3, 2); __PYX_ERR(2, 1, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_ConvolutionalDependencyNetwork") < 0)) __PYX_ERR(2, 1, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v___pyx_type = values[0];
    __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(2, 1, __pyx_L3_error)
    __pyx_v___pyx_state = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_ConvolutionalDependencyNetwork", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(2, 1, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_ConvolutionalDependencyNetwork", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4libs_7network_4__pyx_unpickle_ConvolutionalDependencyNetwork(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4libs_7network_4__pyx_unpickle_ConvolutionalDependencyNetwork(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_v___pyx_PickleError = 0;
  PyObject *__pyx_v___pyx_result = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceFrameInit(__pyx_codeobj__17)
  __Pyx_RefNannySetupContext("__pyx_unpickle_ConvolutionalDependencyNetwork", 0);
  __Pyx_TraceCall("__pyx_unpickle_ConvolutionalDependencyNetwork", __pyx_f[2], 1, 0, __PYX_ERR(2, 1, __pyx_L1_error));

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x1a87293, 0xca52c1e, 0x8b21fc2):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x1a87293, 0xca52c1e, 0x8b21fc2) = (accuracy, answer_score, convolution_lookup, decay_factor, dependency_weights, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_heads, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 */
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__18, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "(tree fragment)":5
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x1a87293, 0xca52c1e, 0x8b21fc2):
 *         from pickle import PickleError as __pyx_PickleError             # <<<<<<<<<<<<<<
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x1a87293, 0xca52c1e, 0x8b21fc2) = (accuracy, answer_score, convolution_lookup, decay_factor, dependency_weights, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_heads, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = ConvolutionalDependencyNetwork.__new__(__pyx_type)
 */
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_n_s_PickleError);
    __Pyx_GIVEREF(__pyx_n_s_PickleError);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError);
    __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 5, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_v___pyx_PickleError = __pyx_t_1;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":6
 *     if __pyx_checksum not in (0x1a87293, 0xca52c1e, 0x8b21fc2):
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x1a87293, 0xca52c1e, 0x8b21fc2) = (accuracy, answer_score, convolution_lookup, decay_factor, dependency_weights, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_heads, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)             # <<<<<<<<<<<<<<
 *     __pyx_result = ConvolutionalDependencyNetwork.__new__(__pyx_type)
 *     if __pyx_state is not None:
 */
    __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_v___pyx_PickleError);
    __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 6, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(2, 6, __pyx_L1_error)

    /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0x1a87293, 0xca52c1e, 0x8b21fc2):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x1a87293, 0xca52c1e, 0x8b21fc2) = (accuracy, answer_score, convolution_lookup, decay_factor, dependency_weights, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_heads, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 */
  }

  /* "(tree fragment)":7
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x1a87293, 0xca52c1e, 0x8b21fc2) = (accuracy, answer_score, convolution_lookup, decay_factor, dependency_weights, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_heads, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = ConvolutionalDependencyNetwork.__new__(__pyx_type)             # <<<<<<<<<<<<<<
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(<ConvolutionalDependencyNetwork> __pyx_result, __pyx_state)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x1a87293, 0xca52c1e, 0x8b21fc2) = (accuracy, answer_score, convolution_lookup, decay_factor, dependency_weights, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_heads, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = ConvolutionalDependencyNetwork.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(<ConvolutionalDependencyNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  __pyx_t_3 = (__pyx_v___pyx_state != Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "(tree fragment)":9
 *     __pyx_result = ConvolutionalDependencyNetwork.__new__(__pyx_type)
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(<ConvolutionalDependencyNetwork> __pyx_result, __pyx_state)             # <<<<<<<<<<<<<<
 *     return __pyx_result
 * cdef __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(ConvolutionalDependencyNetwork __pyx_result, tuple __pyx_state):
 */
    if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(2, 9, __pyx_L1_error)
    __pyx_t_4 = __pyx_f_4libs_7network___pyx_unpickle_ConvolutionalDependencyNetwork__set_state(((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(2, 9, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "(tree fragment)":8
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0x1a87293, 0xca52c1e, 0x8b21fc2) = (accuracy, answer_score, convolution_lookup, decay_factor, dependency_weights, error, feature_tables, features_per_token, float_errors, half_window, hidden2_before_activation, hidden2_bias, hidden2_gradients, hidden2_size, hidden2_values, hidden2_weights, hidden_before_activation, hidden_bias, hidden_gradients, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_deltas, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, max_indices, net_gradients, network_filename, network_text_filename, num_sentences, num_targets, num_tokens, only_classify, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, pred_convolution_lookup, pred_dist_deltas, pred_dist_lookup, pred_dist_offset, pred_dist_table, pred_dist_weights, sentence_accuracy, sentence_lookup, skips, target_convolution_lookup, target_dist_deltas, target_dist_lookup, target_dist_offset, target_dist_table, target_dist_weights, trans_gradients, transitions, use_learning_rate_decay, validation_arguments, validation_heads, validation_predicates, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 *     __pyx_result = ConvolutionalDependencyNetwork.__new__(__pyx_type)
 *     if __pyx_state is not None:             # <<<<<<<<<<<<<<
 *         __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(<ConvolutionalDependencyNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result
 */
  }

  /* "(tree fragment)":10
 *     if __pyx_state is not None:
 *         __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(<ConvolutionalDependencyNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result             # <<<<<<<<<<<<<<
 * cdef __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(ConvolutionalDependencyNetwork __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.dependency_weights = __pyx_state[4]; __pyx_result.error = __pyx_state[5]; __pyx_result.feature_tables = __pyx_state[6]; __pyx_result.features_per_token = __pyx_state[7]; __pyx_result.float_errors = __pyx_state[8]; __pyx_result.half_window = __pyx_state[9]; __pyx_result.hidden2_before_activation = __pyx_state[10]; __pyx_result.hidden2_bias = __pyx_state[11]; __pyx_result.hidden2_gradients = __pyx_state[12]; __pyx_result.hidden2_size = __pyx_state[13]; __pyx_result.hidden2_values = __pyx_state[14]; __pyx_result.hidden2_weights = __pyx_state[15]; __pyx_result.hidden_before_activation = __pyx_state[16]; __pyx_result.hidden_bias = __pyx_state[17]; __pyx_result.hidden_gradients = __pyx_state[18]; __pyx_result.hidden_sent_values = __pyx_state[19]; __pyx_result.hidden_size = __pyx_state[20]; __pyx_result.hidden_values = __pyx_state[21]; __pyx_result.hidden_weights = __pyx_state[22]; __pyx_result.input_deltas = __pyx_state[23]; __pyx_result.input_sent_values = __pyx_state[24]; __pyx_result.input_size = __pyx_state[25]; __pyx_result.input_values = __pyx_state[26]; __pyx_result.layer2_sent_values = __pyx_state[27]; __pyx_result.layer2_values = __pyx_state[28]; __pyx_result.learning_rate = __pyx_state[29]; __pyx_result.learning_rate_features = __pyx_state[30]; __pyx_result.learning_rate_trans = __pyx_state[31]; __pyx_result.max_indices = __pyx_state[32]; __pyx_result.net_gradients = __pyx_state[33]; __pyx_result.network_filename = __pyx_state[34]; __pyx_result.network_text_filename = __pyx_state[35]; __pyx_result.num_sentences = __pyx_state[36]; __pyx_result.num_targets = __pyx_state[37]; __pyx_result.num_tokens = __pyx_state[38]; __pyx_result.only_classify = __pyx_state[39]; __pyx_result.output_bias = __pyx_state[40]; __pyx_result.output_size = __pyx_state[41]; __pyx_result.output_weights = __pyx_state[42]; __pyx_result.padding_left = __pyx_state[43]; __pyx_result.padding_right = __pyx_state[44]; __pyx_result.pos_padding = __pyx_state[45]; __pyx_result.pre_padding = __pyx_state[46]; __pyx_result.pred_convolution_lookup = __pyx_state[47]; __pyx_result.pred_dist_deltas = __pyx_state[48]; __pyx_result.pred_dist_lookup = __pyx_state[49]; __pyx_result.pred_dist_offset = __pyx_state[50]; __pyx_result.pred_dist_table = __pyx_state[51]; __pyx_result.pred_dist_weights = __pyx_state[52]; __pyx_result.sentence_accuracy = __pyx_state[53]; __pyx_result.sentence_lookup = __pyx_state[54]; __pyx_result.skips = __pyx_state[55]; __pyx_result.target_convolution_lookup = __pyx_state[56]; __pyx_result.target_dist_deltas = __pyx_state[57]; __pyx_result.target_dist_lookup = __pyx_state[58]; __pyx_result.target_dist_offset = __pyx_state[59]; __pyx_result.target_dist_table = __pyx_state[60]; __pyx_result.target_dist_weights = __pyx_state[61]; __pyx_result.trans_gradients = __pyx_state[62]; __pyx_result.transitions = __pyx_state[63]; __pyx_result.use_learning_rate_decay = __pyx_state[64]; __pyx_result.validation_arguments = __pyx_state[65]; __pyx_result.validation_heads = __pyx_state[66]; __pyx_result.validation_predicates = __pyx_state[67]; __pyx_result.validation_sentences = __pyx_state[68]; __pyx_result.validation_tags = __pyx_state[69]; __pyx_result.word_window_size = __pyx_state[70]
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v___pyx_result);
  __pyx_r = __pyx_v___pyx_result;
  goto __pyx_L0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ConvolutionalDependencyNetwork(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_ConvolutionalDependencyNetwork", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v___pyx_PickleError);
  __Pyx_XDECREF(__pyx_v___pyx_result);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "(tree fragment)":11
 *         __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(<ConvolutionalDependencyNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(ConvolutionalDependencyNetwork __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.dependency_weights = __pyx_state[4]; __pyx_result.error = __pyx_state[5]; __pyx_result.feature_tables = __pyx_state[6]; __pyx_result.features_per_token = __pyx_state[7]; __pyx_result.float_errors = __pyx_state[8]; __pyx_result.half_window = __pyx_state[9]; __pyx_result.hidden2_before_activation = __pyx_state[10]; __pyx_result.hidden2_bias = __pyx_state[11]; __pyx_result.hidden2_gradients = __pyx_state[12]; __pyx_result.hidden2_size = __pyx_state[13]; __pyx_result.hidden2_values = __pyx_state[14]; __pyx_result.hidden2_weights = __pyx_state[15]; __pyx_result.hidden_before_activation = __pyx_state[16]; __pyx_result.hidden_bias = __pyx_state[17]; __pyx_result.hidden_gradients = __pyx_state[18]; __pyx_result.hidden_sent_values = __pyx_state[19]; __pyx_result.hidden_size = __pyx_state[20]; __pyx_result.hidden_values = __pyx_state[21]; __pyx_result.hidden_weights = __pyx_state[22]; __pyx_result.input_deltas = __pyx_state[23]; __pyx_result.input_sent_values = __pyx_state[24]; __pyx_result.input_size = __pyx_state[25]; __pyx_result.input_values = __pyx_state[26]; __pyx_result.layer2_sent_values = __pyx_state[27]; __pyx_result.layer2_values = __pyx_state[28]; __pyx_result.learning_rate = __pyx_state[29]; __pyx_result.learning_rate_features = __pyx_state[30]; __pyx_result.learning_rate_trans = __pyx_state[31]; __pyx_result.max_indices = __pyx_state[32]; __pyx_result.net_gradients = __pyx_state[33]; __pyx_result.network_filename = __pyx_state[34]; __pyx_result.network_text_filename = __pyx_state[35]; __pyx_result.num_sentences = __pyx_state[36]; __pyx_result.num_targets = __pyx_state[37]; __pyx_result.num_tokens = __pyx_state[38]; __pyx_result.only_classify = __pyx_state[39]; __pyx_result.output_bias = __pyx_state[40]; __pyx_result.output_size = __pyx_state[41]; __pyx_result.output_weights = __pyx_state[42]; __pyx_result.padding_left = __pyx_state[43]; __pyx_result.padding_right = __pyx_state[44]; __pyx_result.pos_padding = __pyx_state[45]; __pyx_result.pre_padding = __pyx_state[46]; __pyx_result.pred_convolution_lookup = __pyx_state[47]; __pyx_result.pred_dist_deltas = __pyx_state[48]; __pyx_result.pred_dist_lookup = __pyx_state[49]; __pyx_result.pred_dist_offset = __pyx_state[50]; __pyx_result.pred_dist_table = __pyx_state[51]; __pyx_result.pred_dist_weights = __pyx_state[52]; __pyx_result.sentence_accuracy = __pyx_state[53]; __pyx_result.sentence_lookup = __pyx_state[54]; __pyx_result.skips = __pyx_state[55]; __pyx_result.target_convolution_lookup = __pyx_state[56]; __pyx_result.target_dist_deltas = __pyx_state[57]; __pyx_result.target_dist_lookup = __pyx_state[58]; __pyx_result.target_dist_offset = __pyx_state[59]; __pyx_result.target_dist_table = __pyx_state[60]; __pyx_result.target_dist_weights = __pyx_state[61]; __pyx_result.trans_gradients = __pyx_state[62]; __pyx_result.transitions = __pyx_state[63]; __pyx_result.use_learning_rate_decay = __pyx_state[64]; __pyx_result.validation_arguments = __pyx_state[65]; __pyx_result.validation_heads = __pyx_state[66]; __pyx_result.validation_predicates = __pyx_state[67]; __pyx_result.validation_sentences = __pyx_state[68]; __pyx_result.validation_tags = __pyx_state[69]; __pyx_result.word_window_size = __pyx_state[70]
 *     if len(__pyx_state) > 71 and hasattr(__pyx_result, '__dict__'):
 */

static PyObject *__pyx_f_4libs_7network___pyx_unpickle_ConvolutionalDependencyNetwork__set_state(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  float __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__pyx_unpickle_ConvolutionalDependencyNetwork__set_state", 0);
  __Pyx_TraceCall("__pyx_unpickle_ConvolutionalDependencyNetwork__set_state", __pyx_f[2], 11, 0, __PYX_ERR(2, 11, __pyx_L1_error));

  /* "(tree fragment)":12
 *     return __pyx_result
 * cdef __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(ConvolutionalDependencyNetwork __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.dependency_weights = __pyx_state[4]; __pyx_result.error = __pyx_state[5]; __pyx_result.feature_tables = __pyx_state[6]; __pyx_result.features_per_token = __pyx_state[7]; __pyx_result.float_errors = __pyx_state[8]; __pyx_result.half_window = __pyx_state[9]; __pyx_result.hidden2_before_activation = __pyx_state[10]; __pyx_result.hidden2_bias = __pyx_state[11]; __pyx_result.hidden2_gradients = __pyx_state[12]; __pyx_result.hidden2_size = __pyx_state[13]; __pyx_result.hidden2_values = __pyx_state[14]; __pyx_result.hidden2_weights = __pyx_state[15]; __pyx_result.hidden_before_activation = __pyx_state[16]; __pyx_result.hidden_bias = __pyx_state[17]; __pyx_result.hidden_gradients = __pyx_state[18]; __pyx_result.hidden_sent_values = __pyx_state[19]; __pyx_result.hidden_size = __pyx_state[20]; __pyx_result.hidden_values = __pyx_state[21]; __pyx_result.hidden_weights = __pyx_state[22]; __pyx_result.input_deltas = __pyx_state[23]; __pyx_result.input_sent_values = __pyx_state[24]; __pyx_result.input_size = __pyx_state[25]; __pyx_result.input_values = __pyx_state[26]; __pyx_result.layer2_sent_values = __pyx_state[27]; __pyx_result.layer2_values = __pyx_state[28]; __pyx_result.learning_rate = __pyx_state[29]; __pyx_result.learning_rate_features = __pyx_state[30]; __pyx_result.learning_rate_trans = __pyx_state[31]; __pyx_result.max_indices = __pyx_state[32]; __pyx_result.net_gradients = __pyx_state[33]; __pyx_result.network_filename = __pyx_state[34]; __pyx_result.network_text_filename = __pyx_state[35]; __pyx_result.num_sentences = __pyx_state[36]; __pyx_result.num_targets = __pyx_state[37]; __pyx_result.num_tokens = __pyx_state[38]; __pyx_result.only_classify = __pyx_state[39]; __pyx_result.output_bias = __pyx_state[40]; __pyx_result.output_size = __pyx_state[41]; __pyx_result.output_weights = __pyx_state[42]; __pyx_result.padding_left = __pyx_state[43]; __pyx_result.padding_right = __pyx_state[44]; __pyx_result.pos_padding = __pyx_state[45]; __pyx_result.pre_padding = __pyx_state[46]; __pyx_result.pred_convolution_lookup = __pyx_state[47]; __pyx_result.pred_dist_deltas = __pyx_state[48]; __pyx_result.pred_dist_lookup = __pyx_state[49]; __pyx_result.pred_dist_offset = __pyx_state[50]; __pyx_result.pred_dist_table = __pyx_state[51]; __pyx_result.pred_dist_weights = __pyx_state[52]; __pyx_result.sentence_accuracy = __pyx_state[53]; __pyx_result.sentence_lookup = __pyx_state[54]; __pyx_result.skips = __pyx_state[55]; __pyx_result.target_convolution_lookup = __pyx_state[56]; __pyx_result.target_dist_deltas = __pyx_state[57]; __pyx_result.target_dist_lookup = __pyx_state[58]; __pyx_result.target_dist_offset = __pyx_state[59]; __pyx_result.target_dist_table = __pyx_state[60]; __pyx_result.target_dist_weights = __pyx_state[61]; __pyx_result.trans_gradients = __pyx_state[62]; __pyx_result.transitions = __pyx_state[63]; __pyx_result.use_learning_rate_decay = __pyx_state[64]; __pyx_result.validation_arguments = __pyx_state[65]; __pyx_result.validation_heads = __pyx_state[66]; __pyx_result.validation_predicates = __pyx_state[67]; __pyx_result.validation_sentences = __pyx_state[68]; __pyx_result.validation_tags = __pyx_state[69]; __pyx_result.word_window_size = __pyx_state[70]             # <<<<<<<<<<<<<<
 *     if len(__pyx_state) > 71 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[71])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.accuracy = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.answer_score = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.convolution_lookup));
  __pyx_v___pyx_result->__pyx_base.convolution_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.decay_factor = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->dependency_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->dependency_weights));
  __pyx_v___pyx_result->dependency_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.error = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 6, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.feature_tables);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.feature_tables);
  __pyx_v___pyx_result->__pyx_base.__pyx_base.feature_tables = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 7, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.features_per_token = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 8, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.float_errors = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 9, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.half_window = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 10, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden2_before_activation);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden2_before_activation));
  __pyx_v___pyx_result->__pyx_base.hidden2_before_activation = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 11, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden2_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden2_bias));
  __pyx_v___pyx_result->__pyx_base.hidden2_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 12, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden2_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden2_gradients));
  __pyx_v___pyx_result->__pyx_base.hidden2_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 13, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.hidden2_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 14, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden2_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden2_values));
  __pyx_v___pyx_result->__pyx_base.hidden2_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 15, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden2_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden2_weights));
  __pyx_v___pyx_result->__pyx_base.hidden2_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 16, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden_before_activation);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden_before_activation));
  __pyx_v___pyx_result->__pyx_base.hidden_before_activation = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 17, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_bias));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 18, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.hidden_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.hidden_gradients));
  __pyx_v___pyx_result->__pyx_base.hidden_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 19, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_sent_values));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 20, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 21, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_values));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 22, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_weights));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.hidden_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 23, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.input_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.input_deltas));
  __pyx_v___pyx_result->__pyx_base.input_deltas = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 24, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.input_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.input_sent_values));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.input_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 25, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.input_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 26, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.input_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.input_values));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.input_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 27, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.layer2_sent_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.layer2_sent_values));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.layer2_sent_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 28, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.layer2_values);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.layer2_values));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.layer2_values = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 29, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.learning_rate = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 30, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.learning_rate_features = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 31, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.learning_rate_trans = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 32, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.max_indices);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.max_indices));
  __pyx_v___pyx_result->__pyx_base.max_indices = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 33, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.net_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.net_gradients));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.net_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 34, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.network_filename);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.network_filename);
  __pyx_v___pyx_result->__pyx_base.__pyx_base.network_filename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 35, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "unicode", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.network_text_filename);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.network_text_filename);
  __pyx_v___pyx_result->__pyx_base.__pyx_base.network_text_filename = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 36, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.num_sentences = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 37, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.num_targets = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 38, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.num_tokens = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 39, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.only_classify);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.only_classify));
  __pyx_v___pyx_result->__pyx_base.only_classify = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 40, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.output_bias);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.output_bias));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.output_bias = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 41, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.output_size = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 42, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.output_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.output_weights));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.output_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 43, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.padding_left);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.padding_left));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.padding_left = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 44, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.padding_right);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.padding_right));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.padding_right = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 45, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.pos_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.pos_padding));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.pos_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 46, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.pre_padding);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.pre_padding));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.pre_padding = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 47, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.pred_convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.pred_convolution_lookup));
  __pyx_v___pyx_result->__pyx_base.pred_convolution_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 48, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.pred_dist_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.pred_dist_deltas));
  __pyx_v___pyx_result->__pyx_base.pred_dist_deltas = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 49, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.pred_dist_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.pred_dist_lookup));
  __pyx_v___pyx_result->__pyx_base.pred_dist_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 50, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.pred_dist_offset = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 51, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.pred_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.pred_dist_table));
  __pyx_v___pyx_result->__pyx_base.pred_dist_table = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 52, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.pred_dist_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.pred_dist_weights));
  __pyx_v___pyx_result->__pyx_base.pred_dist_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 53, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.sentence_accuracy = __pyx_t_2;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 54, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.sentence_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.sentence_lookup));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.sentence_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 55, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.skips = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 56, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.target_convolution_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.target_convolution_lookup));
  __pyx_v___pyx_result->__pyx_base.target_convolution_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 57, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.target_dist_deltas);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.target_dist_deltas));
  __pyx_v___pyx_result->__pyx_base.target_dist_deltas = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 58, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.target_dist_lookup);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.target_dist_lookup));
  __pyx_v___pyx_result->__pyx_base.target_dist_lookup = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 59, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.target_dist_offset = __pyx_t_3;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 60, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.target_dist_table);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.target_dist_table));
  __pyx_v___pyx_result->__pyx_base.target_dist_table = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 61, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.target_dist_weights);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.target_dist_weights));
  __pyx_v___pyx_result->__pyx_base.target_dist_weights = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 62, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.trans_gradients);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.trans_gradients));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.trans_gradients = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 63, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.transitions);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.transitions));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.transitions = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 64, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_4bool_bool))))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.use_learning_rate_decay);
  __Pyx_DECREF(((PyObject *)__pyx_v___pyx_result->__pyx_base.__pyx_base.use_learning_rate_decay));
  __pyx_v___pyx_result->__pyx_base.__pyx_base.use_learning_rate_decay = ((PyBoolObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 65, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.validation_arguments);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.validation_arguments);
  __pyx_v___pyx_result->__pyx_base.validation_arguments = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 66, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->validation_heads);
  __Pyx_DECREF(__pyx_v___pyx_result->validation_heads);
  __pyx_v___pyx_result->validation_heads = __pyx_t_1;
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 67, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.validation_predicates);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.validation_predicates);
  __pyx_v___pyx_result->__pyx_base.validation_predicates = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 68, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.validation_sentences);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.validation_sentences);
  __pyx_v___pyx_result->__pyx_base.__pyx_base.validation_sentences = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 69, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.validation_tags);
  __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.__pyx_base.validation_tags);
  __pyx_v___pyx_result->__pyx_base.__pyx_base.validation_tags = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    __PYX_ERR(2, 12, __pyx_L1_error)
  }
  __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 70, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(2, 12, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v___pyx_result->__pyx_base.__pyx_base.word_window_size = __pyx_t_3;

  /* "(tree fragment)":13
 * cdef __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(ConvolutionalDependencyNetwork __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.dependency_weights = __pyx_state[4]; __pyx_result.error = __pyx_state[5]; __pyx_result.feature_tables = __pyx_state[6]; __pyx_result.features_per_token = __pyx_state[7]; __pyx_result.float_errors = __pyx_state[8]; __pyx_result.half_window = __pyx_state[9]; __pyx_result.hidden2_before_activation = __pyx_state[10]; __pyx_result.hidden2_bias = __pyx_state[11]; __pyx_result.hidden2_gradients = __pyx_state[12]; __pyx_result.hidden2_size = __pyx_state[13]; __pyx_result.hidden2_values = __pyx_state[14]; __pyx_result.hidden2_weights = __pyx_state[15]; __pyx_result.hidden_before_activation = __pyx_state[16]; __pyx_result.hidden_bias = __pyx_state[17]; __pyx_result.hidden_gradients = __pyx_state[18]; __pyx_result.hidden_sent_values = __pyx_state[19]; __pyx_result.hidden_size = __pyx_state[20]; __pyx_result.hidden_values = __pyx_state[21]; __pyx_result.hidden_weights = __pyx_state[22]; __pyx_result.input_deltas = __pyx_state[23]; __pyx_result.input_sent_values = __pyx_state[24]; __pyx_result.input_size = __pyx_state[25]; __pyx_result.input_values = __pyx_state[26]; __pyx_result.layer2_sent_values = __pyx_state[27]; __pyx_result.layer2_values = __pyx_state[28]; __pyx_result.learning_rate = __pyx_state[29]; __pyx_result.learning_rate_features = __pyx_state[30]; __pyx_result.learning_rate_trans = __pyx_state[31]; __pyx_result.max_indices = __pyx_state[32]; __pyx_result.net_gradients = __pyx_state[33]; __pyx_result.network_filename = __pyx_state[34]; __pyx_result.network_text_filename = __pyx_state[35]; __pyx_result.num_sentences = __pyx_state[36]; __pyx_result.num_targets = __pyx_state[37]; __pyx_result.num_tokens = __pyx_state[38]; __pyx_result.only_classify = __pyx_state[39]; __pyx_result.output_bias = __pyx_state[40]; __pyx_result.output_size = __pyx_state[41]; __pyx_result.output_weights = __pyx_state[42]; __pyx_result.padding_left = __pyx_state[43]; __pyx_result.padding_right = __pyx_state[44]; __pyx_result.pos_padding = __pyx_state[45]; __pyx_result.pre_padding = __pyx_state[46]; __pyx_result.pred_convolution_lookup = __pyx_state[47]; __pyx_result.pred_dist_deltas = __pyx_state[48]; __pyx_result.pred_dist_lookup = __pyx_state[49]; __pyx_result.pred_dist_offset = __pyx_state[50]; __pyx_result.pred_dist_table = __pyx_state[51]; __pyx_result.pred_dist_weights = __pyx_state[52]; __pyx_result.sentence_accuracy = __pyx_state[53]; __pyx_result.sentence_lookup = __pyx_state[54]; __pyx_result.skips = __pyx_state[55]; __pyx_result.target_convolution_lookup = __pyx_state[56]; __pyx_result.target_dist_deltas = __pyx_state[57]; __pyx_result.target_dist_lookup = __pyx_state[58]; __pyx_result.target_dist_offset = __pyx_state[59]; __pyx_result.target_dist_table = __pyx_state[60]; __pyx_result.target_dist_weights = __pyx_state[61]; __pyx_result.trans_gradients = __pyx_state[62]; __pyx_result.transitions = __pyx_state[63]; __pyx_result.use_learning_rate_decay = __pyx_state[64]; __pyx_result.validation_arguments = __pyx_state[65]; __pyx_result.validation_heads = __pyx_state[66]; __pyx_result.validation_predicates = __pyx_state[67]; __pyx_result.validation_sentences = __pyx_state[68]; __pyx_result.validation_tags = __pyx_state[69]; __pyx_result.word_window_size = __pyx_state[70]
 *     if len(__pyx_state) > 71 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[71])
 */
  if (unlikely(__pyx_v___pyx_state == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    __PYX_ERR(2, 13, __pyx_L1_error)
  }
  __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_6 = ((__pyx_t_5 > 71) != 0);
  if (__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(2, 13, __pyx_L1_error)
  __pyx_t_7 = (__pyx_t_6 != 0);
  __pyx_t_4 = __pyx_t_7;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "(tree fragment)":14
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.dependency_weights = __pyx_state[4]; __pyx_result.error = __pyx_state[5]; __pyx_result.feature_tables = __pyx_state[6]; __pyx_result.features_per_token = __pyx_state[7]; __pyx_result.float_errors = __pyx_state[8]; __pyx_result.half_window = __pyx_state[9]; __pyx_result.hidden2_before_activation = __pyx_state[10]; __pyx_result.hidden2_bias = __pyx_state[11]; __pyx_result.hidden2_gradients = __pyx_state[12]; __pyx_result.hidden2_size = __pyx_state[13]; __pyx_result.hidden2_values = __pyx_state[14]; __pyx_result.hidden2_weights = __pyx_state[15]; __pyx_result.hidden_before_activation = __pyx_state[16]; __pyx_result.hidden_bias = __pyx_state[17]; __pyx_result.hidden_gradients = __pyx_state[18]; __pyx_result.hidden_sent_values = __pyx_state[19]; __pyx_result.hidden_size = __pyx_state[20]; __pyx_result.hidden_values = __pyx_state[21]; __pyx_result.hidden_weights = __pyx_state[22]; __pyx_result.input_deltas = __pyx_state[23]; __pyx_result.input_sent_values = __pyx_state[24]; __pyx_result.input_size = __pyx_state[25]; __pyx_result.input_values = __pyx_state[26]; __pyx_result.layer2_sent_values = __pyx_state[27]; __pyx_result.layer2_values = __pyx_state[28]; __pyx_result.learning_rate = __pyx_state[29]; __pyx_result.learning_rate_features = __pyx_state[30]; __pyx_result.learning_rate_trans = __pyx_state[31]; __pyx_result.max_indices = __pyx_state[32]; __pyx_result.net_gradients = __pyx_state[33]; __pyx_result.network_filename = __pyx_state[34]; __pyx_result.network_text_filename = __pyx_state[35]; __pyx_result.num_sentences = __pyx_state[36]; __pyx_result.num_targets = __pyx_state[37]; __pyx_result.num_tokens = __pyx_state[38]; __pyx_result.only_classify = __pyx_state[39]; __pyx_result.output_bias = __pyx_state[40]; __pyx_result.output_size = __pyx_state[41]; __pyx_result.output_weights = __pyx_state[42]; __pyx_result.padding_left = __pyx_state[43]; __pyx_result.padding_right = __pyx_state[44]; __pyx_result.pos_padding = __pyx_state[45]; __pyx_result.pre_padding = __pyx_state[46]; __pyx_result.pred_convolution_lookup = __pyx_state[47]; __pyx_result.pred_dist_deltas = __pyx_state[48]; __pyx_result.pred_dist_lookup = __pyx_state[49]; __pyx_result.pred_dist_offset = __pyx_state[50]; __pyx_result.pred_dist_table = __pyx_state[51]; __pyx_result.pred_dist_weights = __pyx_state[52]; __pyx_result.sentence_accuracy = __pyx_state[53]; __pyx_result.sentence_lookup = __pyx_state[54]; __pyx_result.skips = __pyx_state[55]; __pyx_result.target_convolution_lookup = __pyx_state[56]; __pyx_result.target_dist_deltas = __pyx_state[57]; __pyx_result.target_dist_lookup = __pyx_state[58]; __pyx_result.target_dist_offset = __pyx_state[59]; __pyx_result.target_dist_table = __pyx_state[60]; __pyx_result.target_dist_weights = __pyx_state[61]; __pyx_result.trans_gradients = __pyx_state[62]; __pyx_result.transitions = __pyx_state[63]; __pyx_result.use_learning_rate_decay = __pyx_state[64]; __pyx_result.validation_arguments = __pyx_state[65]; __pyx_result.validation_heads = __pyx_state[66]; __pyx_result.validation_predicates = __pyx_state[67]; __pyx_result.validation_sentences = __pyx_state[68]; __pyx_result.validation_tags = __pyx_state[69]; __pyx_result.word_window_size = __pyx_state[70]
 *     if len(__pyx_state) > 71 and hasattr(__pyx_result, '__dict__'):
 *         __pyx_result.__dict__.update(__pyx_state[71])             # <<<<<<<<<<<<<<
 */
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(__pyx_v___pyx_state == Py_None)) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
      __PYX_ERR(2, 14, __pyx_L1_error)
    }
    __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 71, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 14, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "(tree fragment)":13
 * cdef __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(ConvolutionalDependencyNetwork __pyx_result, tuple __pyx_state):
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.dependency_weights = __pyx_state[4]; __pyx_result.error = __pyx_state[5]; __pyx_result.feature_tables = __pyx_state[6]; __pyx_result.features_per_token = __pyx_state[7]; __pyx_result.float_errors = __pyx_state[8]; __pyx_result.half_window = __pyx_state[9]; __pyx_result.hidden2_before_activation = __pyx_state[10]; __pyx_result.hidden2_bias = __pyx_state[11]; __pyx_result.hidden2_gradients = __pyx_state[12]; __pyx_result.hidden2_size = __pyx_state[13]; __pyx_result.hidden2_values = __pyx_state[14]; __pyx_result.hidden2_weights = __pyx_state[15]; __pyx_result.hidden_before_activation = __pyx_state[16]; __pyx_result.hidden_bias = __pyx_state[17]; __pyx_result.hidden_gradients = __pyx_state[18]; __pyx_result.hidden_sent_values = __pyx_state[19]; __pyx_result.hidden_size = __pyx_state[20]; __pyx_result.hidden_values = __pyx_state[21]; __pyx_result.hidden_weights = __pyx_state[22]; __pyx_result.input_deltas = __pyx_state[23]; __pyx_result.input_sent_values = __pyx_state[24]; __pyx_result.input_size = __pyx_state[25]; __pyx_result.input_values = __pyx_state[26]; __pyx_result.layer2_sent_values = __pyx_state[27]; __pyx_result.layer2_values = __pyx_state[28]; __pyx_result.learning_rate = __pyx_state[29]; __pyx_result.learning_rate_features = __pyx_state[30]; __pyx_result.learning_rate_trans = __pyx_state[31]; __pyx_result.max_indices = __pyx_state[32]; __pyx_result.net_gradients = __pyx_state[33]; __pyx_result.network_filename = __pyx_state[34]; __pyx_result.network_text_filename = __pyx_state[35]; __pyx_result.num_sentences = __pyx_state[36]; __pyx_result.num_targets = __pyx_state[37]; __pyx_result.num_tokens = __pyx_state[38]; __pyx_result.only_classify = __pyx_state[39]; __pyx_result.output_bias = __pyx_state[40]; __pyx_result.output_size = __pyx_state[41]; __pyx_result.output_weights = __pyx_state[42]; __pyx_result.padding_left = __pyx_state[43]; __pyx_result.padding_right = __pyx_state[44]; __pyx_result.pos_padding = __pyx_state[45]; __pyx_result.pre_padding = __pyx_state[46]; __pyx_result.pred_convolution_lookup = __pyx_state[47]; __pyx_result.pred_dist_deltas = __pyx_state[48]; __pyx_result.pred_dist_lookup = __pyx_state[49]; __pyx_result.pred_dist_offset = __pyx_state[50]; __pyx_result.pred_dist_table = __pyx_state[51]; __pyx_result.pred_dist_weights = __pyx_state[52]; __pyx_result.sentence_accuracy = __pyx_state[53]; __pyx_result.sentence_lookup = __pyx_state[54]; __pyx_result.skips = __pyx_state[55]; __pyx_result.target_convolution_lookup = __pyx_state[56]; __pyx_result.target_dist_deltas = __pyx_state[57]; __pyx_result.target_dist_lookup = __pyx_state[58]; __pyx_result.target_dist_offset = __pyx_state[59]; __pyx_result.target_dist_table = __pyx_state[60]; __pyx_result.target_dist_weights = __pyx_state[61]; __pyx_result.trans_gradients = __pyx_state[62]; __pyx_result.transitions = __pyx_state[63]; __pyx_result.use_learning_rate_decay = __pyx_state[64]; __pyx_result.validation_arguments = __pyx_state[65]; __pyx_result.validation_heads = __pyx_state[66]; __pyx_result.validation_predicates = __pyx_state[67]; __pyx_result.validation_sentences = __pyx_state[68]; __pyx_result.validation_tags = __pyx_state[69]; __pyx_result.word_window_size = __pyx_state[70]
 *     if len(__pyx_state) > 71 and hasattr(__pyx_result, '__dict__'):             # <<<<<<<<<<<<<<
 *         __pyx_result.__dict__.update(__pyx_state[71])
 */
  }

  /* "(tree fragment)":11
 *         __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(<ConvolutionalDependencyNetwork> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_ConvolutionalDependencyNetwork__set_state(ConvolutionalDependencyNetwork __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.convolution_lookup = __pyx_state[2]; __pyx_result.decay_factor = __pyx_state[3]; __pyx_result.dependency_weights = __pyx_state[4]; __pyx_result.error = __pyx_state[5]; __pyx_result.feature_tables = __pyx_state[6]; __pyx_result.features_per_token = __pyx_state[7]; __pyx_result.float_errors = __pyx_state[8]; __pyx_result.half_window = __pyx_state[9]; __pyx_result.hidden2_before_activation = __pyx_state[10]; __pyx_result.hidden2_bias = __pyx_state[11]; __pyx_result.hidden2_gradients = __pyx_state[12]; __pyx_result.hidden2_size = __pyx_state[13]; __pyx_result.hidden2_values = __pyx_state[14]; __pyx_result.hidden2_weights = __pyx_state[15]; __pyx_result.hidden_before_activation = __pyx_state[16]; __pyx_result.hidden_bias = __pyx_state[17]; __pyx_result.hidden_gradients = __pyx_state[18]; __pyx_result.hidden_sent_values = __pyx_state[19]; __pyx_result.hidden_size = __pyx_state[20]; __pyx_result.hidden_values = __pyx_state[21]; __pyx_result.hidden_weights = __pyx_state[22]; __pyx_result.input_deltas = __pyx_state[23]; __pyx_result.input_sent_values = __pyx_state[24]; __pyx_result.input_size = __pyx_state[25]; __pyx_result.input_values = __pyx_state[26]; __pyx_result.layer2_sent_values = __pyx_state[27]; __pyx_result.layer2_values = __pyx_state[28]; __pyx_result.learning_rate = __pyx_state[29]; __pyx_result.learning_rate_features = __pyx_state[30]; __pyx_result.learning_rate_trans = __pyx_state[31]; __pyx_result.max_indices = __pyx_state[32]; __pyx_result.net_gradients = __pyx_state[33]; __pyx_result.network_filename = __pyx_state[34]; __pyx_result.network_text_filename = __pyx_state[35]; __pyx_result.num_sentences = __pyx_state[36]; __pyx_result.num_targets = __pyx_state[37]; __pyx_result.num_tokens = __pyx_state[38]; __pyx_result.only_classify = __pyx_state[39]; __pyx_result.output_bias = __pyx_state[40]; __pyx_result.output_size = __pyx_state[41]; __pyx_result.output_weights = __pyx_state[42]; __pyx_result.padding_left = __pyx_state[43]; __pyx_result.padding_right = __pyx_state[44]; __pyx_result.pos_padding = __pyx_state[45]; __pyx_result.pre_padding = __pyx_state[46]; __pyx_result.pred_convolution_lookup = __pyx_state[47]; __pyx_result.pred_dist_deltas = __pyx_state[48]; __pyx_result.pred_dist_lookup = __pyx_state[49]; __pyx_result.pred_dist_offset = __pyx_state[50]; __pyx_result.pred_dist_table = __pyx_state[51]; __pyx_result.pred_dist_weights = __pyx_state[52]; __pyx_result.sentence_accuracy = __pyx_state[53]; __pyx_result.sentence_lookup = __pyx_state[54]; __pyx_result.skips = __pyx_state[55]; __pyx_result.target_convolution_lookup = __pyx_state[56]; __pyx_result.target_dist_deltas = __pyx_state[57]; __pyx_result.target_dist_lookup = __pyx_state[58]; __pyx_result.target_dist_offset = __pyx_state[59]; __pyx_result.target_dist_table = __pyx_state[60]; __pyx_result.target_dist_weights = __pyx_state[61]; __pyx_result.trans_gradients = __pyx_state[62]; __pyx_result.transitions = __pyx_state[63]; __pyx_result.use_learning_rate_decay = __pyx_state[64]; __pyx_result.validation_arguments = __pyx_state[65]; __pyx_result.validation_heads = __pyx_state[66]; __pyx_result.validation_predicates = __pyx_state[67]; __pyx_result.validation_sentences = __pyx_state[68]; __pyx_result.validation_tags = __pyx_state[69]; __pyx_result.word_window_size = __pyx_state[70]
 *     if len(__pyx_state) > 71 and hasattr(__pyx_result, '__dict__'):
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("libs.network.__pyx_unpickle_ConvolutionalDependencyNetwork__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":734
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew1", __pyx_f[4], 734, 0, __PYX_ERR(4, 734, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":735
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 735, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":734
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":737
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew2", __pyx_f[4], 737, 0, __PYX_ERR(4, 737, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":738
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 738, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":737
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":740
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew3", __pyx_f[4], 740, 0, __PYX_ERR(4, 740, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":741
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 741, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":740
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":743
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew4", __pyx_f[4], 743, 0, __PYX_ERR(4, 743, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":744
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 744, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":743
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":746
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew5", __pyx_f[4], 746, 0, __PYX_ERR(4, 746, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":747
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 747, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":746
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":749
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyDataType_SHAPE(PyArray_Descr *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("PyDataType_SHAPE", 0);
  __Pyx_TraceCall("PyDataType_SHAPE", __pyx_f[4], 749, 0, __PYX_ERR(4, 749, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":750
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
 *         return <tuple>d.subarray.shape
 *     else:
 */
  __pyx_t_1 = (PyDataType_HASSUBARRAY(__pyx_v_d) != 0);
  if (__pyx_t_1) {

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":751
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape             # <<<<<<<<<<<<<<
 *     else:
 *         return ()
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject*)__pyx_v_d->subarray->shape));
    __pyx_r = ((PyObject*)__pyx_v_d->subarray->shape);
    goto __pyx_L0;

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":750
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):
 *     if PyDataType_HASSUBARRAY(d):             # <<<<<<<<<<<<<<
 *         return <tuple>d.subarray.shape
 *     else:
 */
  }

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":753
 *         return <tuple>d.subarray.shape
 *     else:
 *         return ()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_empty_tuple);
    __pyx_r = __pyx_empty_tuple;
    goto __pyx_L0;
  }

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":749
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline tuple PyDataType_SHAPE(dtype d):             # <<<<<<<<<<<<<<
 *     if PyDataType_HASSUBARRAY(d):
 *         return <tuple>d.subarray.shape
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("numpy.PyDataType_SHAPE", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":928
 *     int _import_umath() except -1
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_array_base", 0);
  __Pyx_TraceCall("set_array_base", __pyx_f[4], 928, 0, __PYX_ERR(4, 928, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":929
 * 
 * cdef inline void set_array_base(ndarray arr, object base):
 *     Py_INCREF(base) # important to do this before stealing the reference below!             # <<<<<<<<<<<<<<
 *     PyArray_SetBaseObject(arr, base)
 * 
 */
  Py_INCREF(__pyx_v_base);

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":930
 * cdef inline void set_array_base(ndarray arr, object base):
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  (void)(PyArray_SetBaseObject(__pyx_v_arr, __pyx_v_base));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":928
 *     int _import_umath() except -1
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *     Py_INCREF(base) # important to do this before stealing the reference below!
 *     PyArray_SetBaseObject(arr, base)
 */

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("numpy.set_array_base", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":932
 *     PyArray_SetBaseObject(arr, base)
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_v_base;
  PyObject *__pyx_r = NULL;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_array_base", 0);
  __Pyx_TraceCall("get_array_base", __pyx_f[4], 932, 0, __PYX_ERR(4, 932, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":933
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)             # <<<<<<<<<<<<<<
 *     if base is NULL:
 *         return None
 */
  __pyx_v_base = PyArray_BASE(__pyx_v_arr);

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":934
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)
 *     if base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     return <object>base
 */
  __pyx_t_1 = ((__pyx_v_base == NULL) != 0);
  if (__pyx_t_1) {

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":935
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     return <object>base
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":934
 * cdef inline object get_array_base(ndarray arr):
 *     base = PyArray_BASE(arr)
 *     if base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     return <object>base
 */
  }

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":936
 *     if base is NULL:
 *         return None
 *     return <object>base             # <<<<<<<<<<<<<<
 * 
 * # Versions of the import_* functions which are more suitable for
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_base));
  __pyx_r = ((PyObject *)__pyx_v_base);
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":932
 *     PyArray_SetBaseObject(arr, base)
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     base = PyArray_BASE(arr)
 *     if base is NULL:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("numpy.get_array_base", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":940
 * # Versions of the import_* functions which are more suitable for
 * # Cython code.
 * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         __pyx_import_array()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_array(void) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("import_array", 0);
  __Pyx_TraceCall("import_array", __pyx_f[4], 940, 0, __PYX_ERR(4, 940, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":941
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         __pyx_import_array()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":942
 * cdef inline int import_array() except -1:
 *     try:
 *         __pyx_import_array()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")
 */
      __pyx_t_4 = _import_array(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(4, 942, __pyx_L3_error)

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":941
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         __pyx_import_array()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":943
 *     try:
 *         __pyx_import_array()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(4, 943, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":944
 *         __pyx_import_array()
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_umath() except -1:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 944, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(4, 944, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":941
 * # Cython code.
 * cdef inline int import_array() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         __pyx_import_array()
 *     except Exception:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":940
 * # Versions of the import_* functions which are more suitable for
 * # Cython code.
 * cdef inline int import_array() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         __pyx_import_array()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.import_array", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":946
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_umath(void) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("import_umath", 0);
  __Pyx_TraceCall("import_umath", __pyx_f[4], 946, 0, __PYX_ERR(4, 946, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":947
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":948
 * cdef inline int import_umath() except -1:
 *     try:
 *         _import_umath()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")
 */
      __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(4, 948, __pyx_L3_error)

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":947
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":949
 *     try:
 *         _import_umath()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(4, 949, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":950
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_ufunc() except -1:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 950, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(4, 950, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":947
 * 
 * cdef inline int import_umath() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":946
 *         raise ImportError("numpy.core.multiarray failed to import")
 * 
 * cdef inline int import_umath() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.import_umath", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":952
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

static CYTHON_INLINE int __pyx_f_5numpy_import_ufunc(void) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("import_ufunc", 0);
  __Pyx_TraceCall("import_ufunc", __pyx_f[4], 952, 0, __PYX_ERR(4, 952, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":953
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":954
 * cdef inline int import_ufunc() except -1:
 *     try:
 *         _import_umath()             # <<<<<<<<<<<<<<
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")
 */
      __pyx_t_4 = _import_umath(); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(4, 954, __pyx_L3_error)

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":953
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":955
 *     try:
 *         _import_umath()
 *     except Exception:             # <<<<<<<<<<<<<<
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 */
    __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])));
    if (__pyx_t_4) {
      __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(4, 955, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_7);

      /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":956
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef extern from *:
 */
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(4, 956, __pyx_L5_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(4, 956, __pyx_L5_except_error)
    }
    goto __pyx_L5_except_error;
    __pyx_L5_except_error:;

    /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":953
 * 
 * cdef inline int import_ufunc() except -1:
 *     try:             # <<<<<<<<<<<<<<
 *         _import_umath()
 *     except Exception:
 */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_end:;
  }

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":952
 *         raise ImportError("numpy.core.umath failed to import")
 * 
 * cdef inline int import_ufunc() except -1:             # <<<<<<<<<<<<<<
 *     try:
 *         _import_umath()
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.import_ufunc", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline bint is_timedelta64_object(object obj):             # <<<<<<<<<<<<<<
 *     """
 *     Cython equivalent of `isinstance(obj, np.timedelta64)`
 */

static CYTHON_INLINE int __pyx_f_5numpy_is_timedelta64_object(PyObject *__pyx_v_obj) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_timedelta64_object", 0);
  __Pyx_TraceCall("is_timedelta64_object", __pyx_f[4], 966, 0, __PYX_ERR(4, 966, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":978
 *     bool
 *     """
 *     return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyTimedeltaArrType_Type));
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline bint is_timedelta64_object(object obj):             # <<<<<<<<<<<<<<
 *     """
 *     Cython equivalent of `isinstance(obj, np.timedelta64)`
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("numpy.is_timedelta64_object", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":981
 * 
 * 
 * cdef inline bint is_datetime64_object(object obj):             # <<<<<<<<<<<<<<
 *     """
 *     Cython equivalent of `isinstance(obj, np.datetime64)`
 */

static CYTHON_INLINE int __pyx_f_5numpy_is_datetime64_object(PyObject *__pyx_v_obj) {
  int __pyx_r;
  __Pyx_TraceDeclarations
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_datetime64_object", 0);
  __Pyx_TraceCall("is_datetime64_object", __pyx_f[4], 981, 0, __PYX_ERR(4, 981, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":993
 *     bool
 *     """
 *     return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = PyObject_TypeCheck(__pyx_v_obj, (&PyDatetimeArrType_Type));
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":981
 * 
 * 
 * cdef inline bint is_datetime64_object(object obj):             # <<<<<<<<<<<<<<
 *     """
 *     Cython equivalent of `isinstance(obj, np.datetime64)`
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("numpy.is_datetime64_object", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 0);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":996
 * 
 * 
 * cdef inline npy_datetime get_datetime64_value(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the int64 value underlying scalar numpy datetime64 object
 */

static CYTHON_INLINE npy_datetime __pyx_f_5numpy_get_datetime64_value(PyObject *__pyx_v_obj) {
  npy_datetime __pyx_r;
  __Pyx_TraceDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceCall("get_datetime64_value", __pyx_f[4], 996, 1, __PYX_ERR(4, 996, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":1003
 *     also needed.  That can be found using `get_datetime64_unit`.
 *     """
 *     return (<PyDatetimeScalarObject*>obj).obval             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((PyDatetimeScalarObject *)__pyx_v_obj)->obval;
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":996
 * 
 * 
 * cdef inline npy_datetime get_datetime64_value(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the int64 value underlying scalar numpy datetime64 object
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("numpy.get_datetime64_value", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 1);
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":1006
 * 
 * 
 * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the int64 value underlying scalar numpy timedelta64 object
 */

static CYTHON_INLINE npy_timedelta __pyx_f_5numpy_get_timedelta64_value(PyObject *__pyx_v_obj) {
  npy_timedelta __pyx_r;
  __Pyx_TraceDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceCall("get_timedelta64_value", __pyx_f[4], 1006, 1, __PYX_ERR(4, 1006, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":1010
 *     returns the int64 value underlying scalar numpy timedelta64 object
 *     """
 *     return (<PyTimedeltaScalarObject*>obj).obval             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((PyTimedeltaScalarObject *)__pyx_v_obj)->obval;
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":1006
 * 
 * 
 * cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the int64 value underlying scalar numpy timedelta64 object
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("numpy.get_timedelta64_value", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 1);
  return __pyx_r;
}

/* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":1013
 * 
 * 
 * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the unit part of the dtype for a numpy datetime64 object.
 */

static CYTHON_INLINE NPY_DATETIMEUNIT __pyx_f_5numpy_get_datetime64_unit(PyObject *__pyx_v_obj) {
  NPY_DATETIMEUNIT __pyx_r;
  __Pyx_TraceDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceCall("get_datetime64_unit", __pyx_f[4], 1013, 1, __PYX_ERR(4, 1013, __pyx_L1_error));

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":1017
 *     returns the unit part of the dtype for a numpy datetime64 object.
 *     """
 *     return <NPY_DATETIMEUNIT>(<PyDatetimeScalarObject*>obj).obmeta.base             # <<<<<<<<<<<<<<
 */
  __pyx_r = ((NPY_DATETIMEUNIT)((PyDatetimeScalarObject *)__pyx_v_obj)->obmeta.base);
  goto __pyx_L0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":1013
 * 
 * 
 * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the unit part of the dtype for a numpy datetime64 object.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("numpy.get_datetime64_unit", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 1);
  __pyx_r = (NPY_DATETIMEUNIT) 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None, 1);
  return __pyx_r;
}

static PyObject *__pyx_tp_new_4libs_7network_Network(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4libs_7network_Network *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4libs_7network_Network *)o);
  p->use_learning_rate_decay = ((PyBoolObject *)Py_None); Py_INCREF(Py_None);
  p->sentence_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->padding_left = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->padding_right = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->pre_padding = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->pos_padding = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->output_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden_bias = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->output_bias = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->input_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->layer2_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->feature_tables = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->transitions = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->net_gradients = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->trans_gradients = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->input_sent_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden_sent_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->layer2_sent_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->network_filename = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->network_text_filename = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->validation_sentences = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->validation_tags = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4libs_7network_Network(PyObject *o) {
  struct __pyx_obj_4libs_7network_Network *p = (struct __pyx_obj_4libs_7network_Network *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->use_learning_rate_decay);
  Py_CLEAR(p->sentence_lookup);
  Py_CLEAR(p->padding_left);
  Py_CLEAR(p->padding_right);
  Py_CLEAR(p->pre_padding);
  Py_CLEAR(p->pos_padding);
  Py_CLEAR(p->hidden_weights);
  Py_CLEAR(p->output_weights);
  Py_CLEAR(p->hidden_bias);
  Py_CLEAR(p->output_bias);
  Py_CLEAR(p->input_values);
  Py_CLEAR(p->hidden_values);
  Py_CLEAR(p->layer2_values);
  Py_CLEAR(p->feature_tables);
  Py_CLEAR(p->transitions);
  Py_CLEAR(p->net_gradients);
  Py_CLEAR(p->trans_gradients);
  Py_CLEAR(p->input_sent_values);
  Py_CLEAR(p->hidden_sent_values);
  Py_CLEAR(p->layer2_sent_values);
  Py_CLEAR(p->network_filename);
  Py_CLEAR(p->network_text_filename);
  Py_CLEAR(p->validation_sentences);
  Py_CLEAR(p->validation_tags);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4libs_7network_Network(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network_Network *p = (struct __pyx_obj_4libs_7network_Network *)o;
  if (p->use_learning_rate_decay) {
    e = (*v)(((PyObject *)p->use_learning_rate_decay), a); if (e) return e;
  }
  if (p->sentence_lookup) {
    e = (*v)(((PyObject *)p->sentence_lookup), a); if (e) return e;
  }
  if (p->padding_left) {
    e = (*v)(((PyObject *)p->padding_left), a); if (e) return e;
  }
  if (p->padding_right) {
    e = (*v)(((PyObject *)p->padding_right), a); if (e) return e;
  }
  if (p->pre_padding) {
    e = (*v)(((PyObject *)p->pre_padding), a); if (e) return e;
  }
  if (p->pos_padding) {
    e = (*v)(((PyObject *)p->pos_padding), a); if (e) return e;
  }
  if (p->hidden_weights) {
    e = (*v)(((PyObject *)p->hidden_weights), a); if (e) return e;
  }
  if (p->output_weights) {
    e = (*v)(((PyObject *)p->output_weights), a); if (e) return e;
  }
  if (p->hidden_bias) {
    e = (*v)(((PyObject *)p->hidden_bias), a); if (e) return e;
  }
  if (p->output_bias) {
    e = (*v)(((PyObject *)p->output_bias), a); if (e) return e;
  }
  if (p->input_values) {
    e = (*v)(((PyObject *)p->input_values), a); if (e) return e;
  }
  if (p->hidden_values) {
    e = (*v)(((PyObject *)p->hidden_values), a); if (e) return e;
  }
  if (p->layer2_values) {
    e = (*v)(((PyObject *)p->layer2_values), a); if (e) return e;
  }
  if (p->feature_tables) {
    e = (*v)(p->feature_tables, a); if (e) return e;
  }
  if (p->transitions) {
    e = (*v)(((PyObject *)p->transitions), a); if (e) return e;
  }
  if (p->net_gradients) {
    e = (*v)(((PyObject *)p->net_gradients), a); if (e) return e;
  }
  if (p->trans_gradients) {
    e = (*v)(((PyObject *)p->trans_gradients), a); if (e) return e;
  }
  if (p->input_sent_values) {
    e = (*v)(((PyObject *)p->input_sent_values), a); if (e) return e;
  }
  if (p->hidden_sent_values) {
    e = (*v)(((PyObject *)p->hidden_sent_values), a); if (e) return e;
  }
  if (p->layer2_sent_values) {
    e = (*v)(((PyObject *)p->layer2_sent_values), a); if (e) return e;
  }
  if (p->validation_sentences) {
    e = (*v)(p->validation_sentences, a); if (e) return e;
  }
  if (p->validation_tags) {
    e = (*v)(p->validation_tags, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4libs_7network_Network(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4libs_7network_Network *p = (struct __pyx_obj_4libs_7network_Network *)o;
  tmp = ((PyObject*)p->use_learning_rate_decay);
  p->use_learning_rate_decay = ((PyBoolObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->sentence_lookup);
  p->sentence_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->padding_left);
  p->padding_left = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->padding_right);
  p->padding_right = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pre_padding);
  p->pre_padding = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pos_padding);
  p->pos_padding = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden_weights);
  p->hidden_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->output_weights);
  p->output_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden_bias);
  p->hidden_bias = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->output_bias);
  p->output_bias = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->input_values);
  p->input_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden_values);
  p->hidden_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->layer2_values);
  p->layer2_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->feature_tables);
  p->feature_tables = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->transitions);
  p->transitions = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->net_gradients);
  p->net_gradients = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->trans_gradients);
  p->trans_gradients = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->input_sent_values);
  p->input_sent_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden_sent_values);
  p->hidden_sent_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->layer2_sent_values);
  p->layer2_sent_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->validation_sentences);
  p->validation_sentences = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->validation_tags);
  p->validation_tags = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4libs_7network_7Network_padding_left(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_12padding_left_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_padding_left(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_12padding_left_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_padding_right(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_13padding_right_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_padding_right(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_13padding_right_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_word_window_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_16word_window_size_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_input_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_10input_size_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_hidden_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_11hidden_size_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_output_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_11output_size_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_learning_rate(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_13learning_rate_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_learning_rate(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_13learning_rate_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_learning_rate_features(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_22learning_rate_features_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_learning_rate_features(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_22learning_rate_features_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_decay_factor(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_12decay_factor_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_decay_factor(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_12decay_factor_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_use_learning_rate_decay(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_use_learning_rate_decay(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_7Network_23use_learning_rate_decay_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_features_per_token(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_18features_per_token_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_pre_padding(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_11pre_padding_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_pre_padding(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_11pre_padding_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_7Network_11pre_padding_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_pos_padding(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_11pos_padding_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_pos_padding(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_11pos_padding_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_7Network_11pos_padding_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_hidden_weights(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_14hidden_weights_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_output_weights(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_14output_weights_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_hidden_bias(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_11hidden_bias_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_output_bias(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_11output_bias_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_input_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_12input_values_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_hidden_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_13hidden_values_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_layer2_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_13layer2_values_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_feature_tables(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_14feature_tables_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_feature_tables(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_14feature_tables_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_7Network_14feature_tables_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_learning_rate_trans(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_19learning_rate_trans_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_learning_rate_trans(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_19learning_rate_trans_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_transitions(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_11transitions_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_transitions(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_11transitions_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_7Network_11transitions_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_answer_score(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_12answer_score_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_net_gradients(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_13net_gradients_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_trans_gradients(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_15trans_gradients_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_input_sent_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_17input_sent_values_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_hidden_sent_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_18hidden_sent_values_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_layer2_sent_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_18layer2_sent_values_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_7Network_network_filename(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_16network_filename_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_network_filename(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_16network_filename_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_7Network_16network_filename_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4libs_7network_7Network_network_text_filename(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_7Network_21network_text_filename_1__get__(o);
}

static int __pyx_setprop_4libs_7network_7Network_network_text_filename(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_7Network_21network_text_filename_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_7Network_21network_text_filename_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_4libs_7network_Network[] = {
  {"create_new", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_7Network_1create_new, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_7Network_create_new},
  {"description", (PyCFunction)__pyx_pw_4libs_7network_7Network_5description, METH_NOARGS, __pyx_doc_4libs_7network_7Network_4description},
  {"_create_sentence_lookup", (PyCFunction)__pyx_pw_4libs_7network_7Network_7_create_sentence_lookup, METH_O, __pyx_doc_4libs_7network_7Network_6_create_sentence_lookup},
  {"tag_sentence", (PyCFunction)__pyx_pw_4libs_7network_7Network_9tag_sentence, METH_O, __pyx_doc_4libs_7network_7Network_8tag_sentence},
  {"_tag_sentence", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_7Network_11_tag_sentence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_7Network_10_tag_sentence},
  {"_calculate_delta", (PyCFunction)__pyx_pw_4libs_7network_7Network_13_calculate_delta, METH_O, __pyx_doc_4libs_7network_7Network_12_calculate_delta},
  {"_calculate_gradients_sll", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_7Network_15_calculate_gradients_sll, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_7Network_14_calculate_gradients_sll},
  {"_calculate_gradients_wll", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_7Network_17_calculate_gradients_wll, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_7Network_16_calculate_gradients_wll},
  {"_viterbi", (PyCFunction)__pyx_pw_4libs_7network_7Network_19_viterbi, METH_O, __pyx_doc_4libs_7network_7Network_18_viterbi},
  {"set_validation_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_7Network_21set_validation_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_7Network_20set_validation_data},
  {"set_learning_rate_decay", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_7Network_23set_learning_rate_decay, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_7Network_22set_learning_rate_decay},
  {"decrease_learning_rates", (PyCFunction)__pyx_pw_4libs_7network_7Network_25decrease_learning_rates, METH_O, __pyx_doc_4libs_7network_7Network_24decrease_learning_rates},
  {"train", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_7Network_27train, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_7Network_26train},
  {"_print_epoch_report", (PyCFunction)__pyx_pw_4libs_7network_7Network_29_print_epoch_report, METH_O, __pyx_doc_4libs_7network_7Network_28_print_epoch_report},
  {"_train_epoch", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_7Network_31_train_epoch, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_7Network_30_train_epoch},
  {"_validate", (PyCFunction)__pyx_pw_4libs_7network_7Network_33_validate, METH_NOARGS, __pyx_doc_4libs_7network_7Network_32_validate},
  {"_backpropagate", (PyCFunction)__pyx_pw_4libs_7network_7Network_35_backpropagate, METH_O, __pyx_doc_4libs_7network_7Network_34_backpropagate},
  {"_load_parameters", (PyCFunction)__pyx_pw_4libs_7network_7Network_37_load_parameters, METH_NOARGS, __pyx_doc_4libs_7network_7Network_36_load_parameters},
  {"save", (PyCFunction)__pyx_pw_4libs_7network_7Network_39save, METH_NOARGS, __pyx_doc_4libs_7network_7Network_38save},
  {"load_from_file", (PyCFunction)__pyx_pw_4libs_7network_7Network_41load_from_file, METH_O, __pyx_doc_4libs_7network_7Network_40load_from_file},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4libs_7network_7Network_43__reduce_cython__, METH_NOARGS, __pyx_doc_4libs_7network_7Network_42__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4libs_7network_7Network_45__setstate_cython__, METH_O, __pyx_doc_4libs_7network_7Network_44__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4libs_7network_Network[] = {
  {(char *)"padding_left", __pyx_getprop_4libs_7network_7Network_padding_left, __pyx_setprop_4libs_7network_7Network_padding_left, (char *)"\n        The padding element filling the \"void\" before the beginning\n        of the sentence.\n        ", 0},
  {(char *)"padding_right", __pyx_getprop_4libs_7network_7Network_padding_right, __pyx_setprop_4libs_7network_7Network_padding_right, (char *)"\n        The padding element filling the \"void\" after the end\n        of the sentence.\n        ", 0},
  {(char *)"word_window_size", __pyx_getprop_4libs_7network_7Network_word_window_size, 0, (char *)0, 0},
  {(char *)"input_size", __pyx_getprop_4libs_7network_7Network_input_size, 0, (char *)0, 0},
  {(char *)"hidden_size", __pyx_getprop_4libs_7network_7Network_hidden_size, 0, (char *)0, 0},
  {(char *)"output_size", __pyx_getprop_4libs_7network_7Network_output_size, 0, (char *)0, 0},
  {(char *)"learning_rate", __pyx_getprop_4libs_7network_7Network_learning_rate, __pyx_setprop_4libs_7network_7Network_learning_rate, (char *)"learning_rate: 'float'", 0},
  {(char *)"learning_rate_features", __pyx_getprop_4libs_7network_7Network_learning_rate_features, __pyx_setprop_4libs_7network_7Network_learning_rate_features, (char *)"learning_rate_features: 'float'", 0},
  {(char *)"decay_factor", __pyx_getprop_4libs_7network_7Network_decay_factor, __pyx_setprop_4libs_7network_7Network_decay_factor, (char *)"decay_factor: 'float'", 0},
  {(char *)"use_learning_rate_decay", __pyx_getprop_4libs_7network_7Network_use_learning_rate_decay, __pyx_setprop_4libs_7network_7Network_use_learning_rate_decay, (char *)"use_learning_rate_decay: __builtin__.bool", 0},
  {(char *)"features_per_token", __pyx_getprop_4libs_7network_7Network_features_per_token, 0, (char *)0, 0},
  {(char *)"pre_padding", __pyx_getprop_4libs_7network_7Network_pre_padding, __pyx_setprop_4libs_7network_7Network_pre_padding, (char *)"pre_padding: numpy.ndarray", 0},
  {(char *)"pos_padding", __pyx_getprop_4libs_7network_7Network_pos_padding, __pyx_setprop_4libs_7network_7Network_pos_padding, (char *)"pos_padding: numpy.ndarray", 0},
  {(char *)"hidden_weights", __pyx_getprop_4libs_7network_7Network_hidden_weights, 0, (char *)0, 0},
  {(char *)"output_weights", __pyx_getprop_4libs_7network_7Network_output_weights, 0, (char *)0, 0},
  {(char *)"hidden_bias", __pyx_getprop_4libs_7network_7Network_hidden_bias, 0, (char *)0, 0},
  {(char *)"output_bias", __pyx_getprop_4libs_7network_7Network_output_bias, 0, (char *)0, 0},
  {(char *)"input_values", __pyx_getprop_4libs_7network_7Network_input_values, 0, (char *)0, 0},
  {(char *)"hidden_values", __pyx_getprop_4libs_7network_7Network_hidden_values, 0, (char *)0, 0},
  {(char *)"layer2_values", __pyx_getprop_4libs_7network_7Network_layer2_values, 0, (char *)0, 0},
  {(char *)"feature_tables", __pyx_getprop_4libs_7network_7Network_feature_tables, __pyx_setprop_4libs_7network_7Network_feature_tables, (char *)"feature_tables: list", 0},
  {(char *)"learning_rate_trans", __pyx_getprop_4libs_7network_7Network_learning_rate_trans, __pyx_setprop_4libs_7network_7Network_learning_rate_trans, (char *)"learning_rate_trans: 'float'", 0},
  {(char *)"transitions", __pyx_getprop_4libs_7network_7Network_transitions, __pyx_setprop_4libs_7network_7Network_transitions, (char *)"transitions: numpy.ndarray", 0},
  {(char *)"answer_score", __pyx_getprop_4libs_7network_7Network_answer_score, 0, (char *)0, 0},
  {(char *)"net_gradients", __pyx_getprop_4libs_7network_7Network_net_gradients, 0, (char *)0, 0},
  {(char *)"trans_gradients", __pyx_getprop_4libs_7network_7Network_trans_gradients, 0, (char *)0, 0},
  {(char *)"input_sent_values", __pyx_getprop_4libs_7network_7Network_input_sent_values, 0, (char *)0, 0},
  {(char *)"hidden_sent_values", __pyx_getprop_4libs_7network_7Network_hidden_sent_values, 0, (char *)0, 0},
  {(char *)"layer2_sent_values", __pyx_getprop_4libs_7network_7Network_layer2_sent_values, 0, (char *)0, 0},
  {(char *)"network_filename", __pyx_getprop_4libs_7network_7Network_network_filename, __pyx_setprop_4libs_7network_7Network_network_filename, (char *)"network_filename: unicode", 0},
  {(char *)"network_text_filename", __pyx_getprop_4libs_7network_7Network_network_text_filename, __pyx_setprop_4libs_7network_7Network_network_text_filename, (char *)"network_text_filename: unicode", 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4libs_7network_Network = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.Network", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network_Network), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network_Network, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "Network(word_window, input_size, hidden_size, output_size, hidden_weights, hidden_bias, output_weights, output_bias, transitions=None)", /*tp_doc*/
  __pyx_tp_traverse_4libs_7network_Network, /*tp_traverse*/
  __pyx_tp_clear_4libs_7network_Network, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4libs_7network_Network, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4libs_7network_Network, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4libs_7network_7Network_3__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network_Network, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork __pyx_vtable_4libs_7network_ConvolutionalNetwork;

static PyObject *__pyx_tp_new_4libs_7network_ConvolutionalNetwork(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4libs_7network_ConvolutionalNetwork *p;
  PyObject *o = __pyx_tp_new_4libs_7network_Network(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)o);
  p->__pyx_vtab = __pyx_vtabptr_4libs_7network_ConvolutionalNetwork;
  p->target_dist_table = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->pred_dist_table = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->target_dist_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->pred_dist_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->target_dist_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->pred_dist_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->target_convolution_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->pred_convolution_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->target_dist_deltas = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->pred_dist_deltas = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden2_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden2_bias = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden2_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden2_before_activation = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden_before_activation = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->convolution_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->max_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->only_classify = ((PyBoolObject *)Py_None); Py_INCREF(Py_None);
  p->hidden_gradients = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->hidden2_gradients = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->input_deltas = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->validation_predicates = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->validation_arguments = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4libs_7network_ConvolutionalNetwork(PyObject *o) {
  struct __pyx_obj_4libs_7network_ConvolutionalNetwork *p = (struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->target_dist_table);
  Py_CLEAR(p->pred_dist_table);
  Py_CLEAR(p->target_dist_weights);
  Py_CLEAR(p->pred_dist_weights);
  Py_CLEAR(p->target_dist_lookup);
  Py_CLEAR(p->pred_dist_lookup);
  Py_CLEAR(p->target_convolution_lookup);
  Py_CLEAR(p->pred_convolution_lookup);
  Py_CLEAR(p->target_dist_deltas);
  Py_CLEAR(p->pred_dist_deltas);
  Py_CLEAR(p->hidden2_weights);
  Py_CLEAR(p->hidden2_bias);
  Py_CLEAR(p->hidden2_values);
  Py_CLEAR(p->hidden2_before_activation);
  Py_CLEAR(p->hidden_before_activation);
  Py_CLEAR(p->convolution_lookup);
  Py_CLEAR(p->max_indices);
  Py_CLEAR(p->only_classify);
  Py_CLEAR(p->hidden_gradients);
  Py_CLEAR(p->hidden2_gradients);
  Py_CLEAR(p->input_deltas);
  Py_CLEAR(p->validation_predicates);
  Py_CLEAR(p->validation_arguments);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_4libs_7network_Network(o);
}

static int __pyx_tp_traverse_4libs_7network_ConvolutionalNetwork(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network_ConvolutionalNetwork *p = (struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)o;
  e = __pyx_tp_traverse_4libs_7network_Network(o, v, a); if (e) return e;
  if (p->target_dist_table) {
    e = (*v)(((PyObject *)p->target_dist_table), a); if (e) return e;
  }
  if (p->pred_dist_table) {
    e = (*v)(((PyObject *)p->pred_dist_table), a); if (e) return e;
  }
  if (p->target_dist_weights) {
    e = (*v)(((PyObject *)p->target_dist_weights), a); if (e) return e;
  }
  if (p->pred_dist_weights) {
    e = (*v)(((PyObject *)p->pred_dist_weights), a); if (e) return e;
  }
  if (p->target_dist_lookup) {
    e = (*v)(((PyObject *)p->target_dist_lookup), a); if (e) return e;
  }
  if (p->pred_dist_lookup) {
    e = (*v)(((PyObject *)p->pred_dist_lookup), a); if (e) return e;
  }
  if (p->target_convolution_lookup) {
    e = (*v)(((PyObject *)p->target_convolution_lookup), a); if (e) return e;
  }
  if (p->pred_convolution_lookup) {
    e = (*v)(((PyObject *)p->pred_convolution_lookup), a); if (e) return e;
  }
  if (p->target_dist_deltas) {
    e = (*v)(((PyObject *)p->target_dist_deltas), a); if (e) return e;
  }
  if (p->pred_dist_deltas) {
    e = (*v)(((PyObject *)p->pred_dist_deltas), a); if (e) return e;
  }
  if (p->hidden2_weights) {
    e = (*v)(((PyObject *)p->hidden2_weights), a); if (e) return e;
  }
  if (p->hidden2_bias) {
    e = (*v)(((PyObject *)p->hidden2_bias), a); if (e) return e;
  }
  if (p->hidden2_values) {
    e = (*v)(((PyObject *)p->hidden2_values), a); if (e) return e;
  }
  if (p->hidden2_before_activation) {
    e = (*v)(((PyObject *)p->hidden2_before_activation), a); if (e) return e;
  }
  if (p->hidden_before_activation) {
    e = (*v)(((PyObject *)p->hidden_before_activation), a); if (e) return e;
  }
  if (p->convolution_lookup) {
    e = (*v)(((PyObject *)p->convolution_lookup), a); if (e) return e;
  }
  if (p->max_indices) {
    e = (*v)(((PyObject *)p->max_indices), a); if (e) return e;
  }
  if (p->only_classify) {
    e = (*v)(((PyObject *)p->only_classify), a); if (e) return e;
  }
  if (p->hidden_gradients) {
    e = (*v)(((PyObject *)p->hidden_gradients), a); if (e) return e;
  }
  if (p->hidden2_gradients) {
    e = (*v)(((PyObject *)p->hidden2_gradients), a); if (e) return e;
  }
  if (p->input_deltas) {
    e = (*v)(((PyObject *)p->input_deltas), a); if (e) return e;
  }
  if (p->validation_predicates) {
    e = (*v)(p->validation_predicates, a); if (e) return e;
  }
  if (p->validation_arguments) {
    e = (*v)(p->validation_arguments, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4libs_7network_ConvolutionalNetwork(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4libs_7network_ConvolutionalNetwork *p = (struct __pyx_obj_4libs_7network_ConvolutionalNetwork *)o;
  __pyx_tp_clear_4libs_7network_Network(o);
  tmp = ((PyObject*)p->target_dist_table);
  p->target_dist_table = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pred_dist_table);
  p->pred_dist_table = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->target_dist_weights);
  p->target_dist_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pred_dist_weights);
  p->pred_dist_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->target_dist_lookup);
  p->target_dist_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pred_dist_lookup);
  p->pred_dist_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->target_convolution_lookup);
  p->target_convolution_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pred_convolution_lookup);
  p->pred_convolution_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->target_dist_deltas);
  p->target_dist_deltas = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->pred_dist_deltas);
  p->pred_dist_deltas = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden2_weights);
  p->hidden2_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden2_bias);
  p->hidden2_bias = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden2_values);
  p->hidden2_values = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden2_before_activation);
  p->hidden2_before_activation = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden_before_activation);
  p->hidden_before_activation = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->convolution_lookup);
  p->convolution_lookup = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->max_indices);
  p->max_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->only_classify);
  p->only_classify = ((PyBoolObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden_gradients);
  p->hidden_gradients = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->hidden2_gradients);
  p->hidden2_gradients = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->input_deltas);
  p->input_deltas = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->validation_predicates);
  p->validation_predicates = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->validation_arguments);
  p->validation_arguments = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_table(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_1__get__(o);
}

static int __pyx_setprop_4libs_7network_20ConvolutionalNetwork_target_dist_table(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_20ConvolutionalNetwork_17target_dist_table_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_table(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_1__get__(o);
}

static int __pyx_setprop_4libs_7network_20ConvolutionalNetwork_pred_dist_table(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_3__set__(o, v);
  }
  else {
    return __pyx_pw_4libs_7network_20ConvolutionalNetwork_15pred_dist_table_5__del__(o);
  }
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_weights(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_19target_dist_weights_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_weights(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_17pred_dist_weights_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_offset(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_offset_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_offset(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_offset_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_lookup(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_lookup_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_lookup(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_lookup_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_convolution_lookup(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_25target_convolution_lookup_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_convolution_lookup(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_23pred_convolution_lookup_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_deltas(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_18target_dist_deltas_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_deltas(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_16pred_dist_deltas_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_12hidden2_size_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_weights(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_15hidden2_weights_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_bias(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_12hidden2_bias_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_values(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_14hidden2_values_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_before_activation(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_25hidden2_before_activation_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden_before_activation(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_24hidden_before_activation_1__get__(o);
}

static PyObject *__pyx_getprop_4libs_7network_20ConvolutionalNetwork_max_indices(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_20ConvolutionalNetwork_11max_indices_1__get__(o);
}

static PyMethodDef __pyx_methods_4libs_7network_ConvolutionalNetwork[] = {
  {"create_new", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_1create_new, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_create_new},
  {"description", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_3description, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_2description},
  {"_generate_save_dict", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_7_generate_save_dict, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_6_generate_save_dict},
  {"save", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_9save, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_8save},
  {"_load_from_file", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_11_load_from_file, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_10_load_from_file},
  {"load_from_file", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_13load_from_file, METH_O, __pyx_doc_4libs_7network_20ConvolutionalNetwork_12load_from_file},
  {"_load_parameters", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_15_load_parameters, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_14_load_parameters},
  {"set_validation_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_17set_validation_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_16set_validation_data},
  {"train", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_19train, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_18train},
  {"_reset_counters", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_21_reset_counters, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_20_reset_counters},
  {"_shuffle_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_23_shuffle_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_22_shuffle_data},
  {"_train_epoch", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_25_train_epoch, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_24_train_epoch},
  {"tag_sentence", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_27tag_sentence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_26tag_sentence},
  {"_sentence_convolution", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_29_sentence_convolution, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_28_sentence_convolution},
  {"_pre_tagging_setup", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_31_pre_tagging_setup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_30_pre_tagging_setup},
  {"_tag_sentence", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_33_tag_sentence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_32_tag_sentence},
  {"_validate", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_35_validate, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_34_validate},
  {"_calculate_gradients", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_37_calculate_gradients, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_36_calculate_gradients},
  {"_calculate_gradients_classify", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_39_calculate_gradients_classify, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_38_calculate_gradients_classify},
  {"_backpropagate", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_41_backpropagate, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_40_backpropagate},
  {"_adjust_weights", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_43_adjust_weights, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_42_adjust_weights},
  {"_calculate_input_deltas", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_45_calculate_input_deltas, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_44_calculate_input_deltas},
  {"_adjust_features", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_47_adjust_features, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_46_adjust_features},
  {"_viterbi", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_49_viterbi, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_48_viterbi},
  {"_create_target_lookup", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_51_create_target_lookup, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_50_create_target_lookup},
  {"_create_pred_lookup", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_53_create_pred_lookup, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_52_create_pred_lookup},
  {"_create_convolution_lookup", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_20ConvolutionalNetwork_55_create_convolution_lookup, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_54_create_convolution_lookup},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_57__reduce_cython__, METH_NOARGS, __pyx_doc_4libs_7network_20ConvolutionalNetwork_56__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4libs_7network_20ConvolutionalNetwork_59__setstate_cython__, METH_O, __pyx_doc_4libs_7network_20ConvolutionalNetwork_58__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4libs_7network_ConvolutionalNetwork[] = {
  {(char *)"target_dist_table", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_table, __pyx_setprop_4libs_7network_20ConvolutionalNetwork_target_dist_table, (char *)"target_dist_table: numpy.ndarray", 0},
  {(char *)"pred_dist_table", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_table, __pyx_setprop_4libs_7network_20ConvolutionalNetwork_pred_dist_table, (char *)"pred_dist_table: numpy.ndarray", 0},
  {(char *)"target_dist_weights", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_weights, 0, (char *)0, 0},
  {(char *)"pred_dist_weights", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_weights, 0, (char *)0, 0},
  {(char *)"target_dist_offset", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_offset, 0, (char *)0, 0},
  {(char *)"pred_dist_offset", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_offset, 0, (char *)0, 0},
  {(char *)"target_dist_lookup", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_lookup, 0, (char *)0, 0},
  {(char *)"pred_dist_lookup", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_lookup, 0, (char *)0, 0},
  {(char *)"target_convolution_lookup", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_convolution_lookup, 0, (char *)0, 0},
  {(char *)"pred_convolution_lookup", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_convolution_lookup, 0, (char *)0, 0},
  {(char *)"target_dist_deltas", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_target_dist_deltas, 0, (char *)0, 0},
  {(char *)"pred_dist_deltas", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_pred_dist_deltas, 0, (char *)0, 0},
  {(char *)"hidden2_size", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_size, 0, (char *)0, 0},
  {(char *)"hidden2_weights", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_weights, 0, (char *)0, 0},
  {(char *)"hidden2_bias", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_bias, 0, (char *)0, 0},
  {(char *)"hidden2_values", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_values, 0, (char *)0, 0},
  {(char *)"hidden2_before_activation", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden2_before_activation, 0, (char *)0, 0},
  {(char *)"hidden_before_activation", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_hidden_before_activation, 0, (char *)0, 0},
  {(char *)"max_indices", __pyx_getprop_4libs_7network_20ConvolutionalNetwork_max_indices, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4libs_7network_ConvolutionalNetwork = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.ConvolutionalNetwork", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network_ConvolutionalNetwork), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network_ConvolutionalNetwork, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "ConvolutionalNetwork(word_window, input_size, hidden1_size, hidden2_size, output_size, hidden1_weights, hidden1_bias, target_dist_weights, pred_dist_weights, hidden2_weights, hidden2_bias, output_weights, output_bias)", /*tp_doc*/
  __pyx_tp_traverse_4libs_7network_ConvolutionalNetwork, /*tp_traverse*/
  __pyx_tp_clear_4libs_7network_ConvolutionalNetwork, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4libs_7network_ConvolutionalNetwork, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4libs_7network_ConvolutionalNetwork, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4libs_7network_20ConvolutionalNetwork_5__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network_ConvolutionalNetwork, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};
static struct __pyx_vtabstruct_4libs_7network_ConvolutionalDependencyNetwork __pyx_vtable_4libs_7network_ConvolutionalDependencyNetwork;

static PyObject *__pyx_tp_new_4libs_7network_ConvolutionalDependencyNetwork(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *p;
  PyObject *o = __pyx_tp_new_4libs_7network_ConvolutionalNetwork(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4libs_7network_ConvolutionalNetwork*)__pyx_vtabptr_4libs_7network_ConvolutionalDependencyNetwork;
  p->dependency_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->validation_heads = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4libs_7network_ConvolutionalDependencyNetwork(PyObject *o) {
  struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *p = (struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->dependency_weights);
  Py_CLEAR(p->validation_heads);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_4libs_7network_ConvolutionalNetwork(o);
}

static int __pyx_tp_traverse_4libs_7network_ConvolutionalDependencyNetwork(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *p = (struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)o;
  e = __pyx_tp_traverse_4libs_7network_ConvolutionalNetwork(o, v, a); if (e) return e;
  if (p->dependency_weights) {
    e = (*v)(((PyObject *)p->dependency_weights), a); if (e) return e;
  }
  if (p->validation_heads) {
    e = (*v)(p->validation_heads, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4libs_7network_ConvolutionalDependencyNetwork(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *p = (struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork *)o;
  __pyx_tp_clear_4libs_7network_ConvolutionalNetwork(o);
  tmp = ((PyObject*)p->dependency_weights);
  p->dependency_weights = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->validation_heads);
  p->validation_heads = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4libs_7network_30ConvolutionalDependencyNetwork_dependency_weights(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_18dependency_weights_1__get__(o);
}

static PyMethodDef __pyx_methods_4libs_7network_ConvolutionalDependencyNetwork[] = {
  {"save", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_1save, METH_NOARGS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_save},
  {"load_from_file", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_3load_from_file, METH_O, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_2load_from_file},
  {"train", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_5train, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_4train},
  {"set_validation_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_7set_validation_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_6set_validation_data},
  {"_tag_sentence", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_9_tag_sentence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_8_tag_sentence},
  {"_tag_sentence_unlabeled_dependency", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_11_tag_sentence_unlabeled_dependency, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_10_tag_sentence_unlabeled_dependency},
  {"_tag_sentence_labeled_dependency", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_13_tag_sentence_labeled_dependency, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_12_tag_sentence_labeled_dependency},
  {"_calculate_gradients", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_15_calculate_gradients, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_14_calculate_gradients},
  {"_validate", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_17_validate, METH_NOARGS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_16_validate},
  {"_average_error", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_19_average_error, METH_NOARGS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_18_average_error},
  {"_print_epoch_report", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_21_print_epoch_report, METH_O, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_20_print_epoch_report},
  {"tag_sentence", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_23tag_sentence, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_22tag_sentence},
  {"_find_cycles", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_25_find_cycles, METH_O, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_24_find_cycles},
  {"_find_cycle_recursive", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_27_find_cycle_recursive, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_26_find_cycle_recursive},
  {"_contract_cycle", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_29_contract_cycle, METH_VARARGS|METH_KEYWORDS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_28_contract_cycle},
  {"_find_maximum_spanning_tree", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_31_find_maximum_spanning_tree, METH_NOARGS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_30_find_maximum_spanning_tree},
  {"__reduce_cython__", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_33__reduce_cython__, METH_NOARGS, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_32__reduce_cython__},
  {"__setstate_cython__", (PyCFunction)__pyx_pw_4libs_7network_30ConvolutionalDependencyNetwork_35__setstate_cython__, METH_O, __pyx_doc_4libs_7network_30ConvolutionalDependencyNetwork_34__setstate_cython__},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4libs_7network_ConvolutionalDependencyNetwork[] = {
  {(char *)"dependency_weights", __pyx_getprop_4libs_7network_30ConvolutionalDependencyNetwork_dependency_weights, 0, (char *)0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4libs_7network_ConvolutionalDependencyNetwork = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.ConvolutionalDependencyNetwork", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network_ConvolutionalDependencyNetwork), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network_ConvolutionalDependencyNetwork, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network_ConvolutionalDependencyNetwork, /*tp_traverse*/
  __pyx_tp_clear_4libs_7network_ConvolutionalDependencyNetwork, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4libs_7network_ConvolutionalDependencyNetwork, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4libs_7network_ConvolutionalDependencyNetwork, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  #if CYTHON_COMPILING_IN_PYPY
  __pyx_pw_4libs_7network_20ConvolutionalNetwork_5__init__, /*tp_init*/
  #else
  0, /*tp_init*/
  #endif
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network_ConvolutionalDependencyNetwork, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *__pyx_freelist_4libs_7network___pyx_scope_struct__create_new[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct__create_new = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct__create_new(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct__create_new > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct__create_new[--__pyx_freecount_4libs_7network___pyx_scope_struct__create_new];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct__create_new(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_feature_tables);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct__create_new < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct__create_new[__pyx_freecount_4libs_7network___pyx_scope_struct__create_new++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct__create_new(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *)o;
  if (p->__pyx_v_feature_tables) {
    e = (*v)(p->__pyx_v_feature_tables, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4libs_7network___pyx_scope_struct__create_new(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new *)o;
  tmp = ((PyObject*)p->__pyx_v_feature_tables);
  p->__pyx_v_feature_tables = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct__create_new = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct__create_new", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct__create_new), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct__create_new, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct__create_new, /*tp_traverse*/
  __pyx_tp_clear_4libs_7network___pyx_scope_struct__create_new, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct__create_new, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *__pyx_freelist_4libs_7network___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_1_genexpr[--__pyx_freecount_4libs_7network___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_table);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_1_genexpr[__pyx_freecount_4libs_7network___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_table) {
    e = (*v)(p->__pyx_v_table, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_1_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_1_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *__pyx_freelist_4libs_7network___pyx_scope_struct_2_train[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_2_train = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_2_train(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_2_train > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_2_train[--__pyx_freecount_4libs_7network___pyx_scope_struct_2_train];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_2_train(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_sentences);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_2_train < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_2_train[__pyx_freecount_4libs_7network___pyx_scope_struct_2_train++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_2_train(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *)o;
  if (p->__pyx_v_sentences) {
    e = (*v)(p->__pyx_v_sentences, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4libs_7network___pyx_scope_struct_2_train(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train *)o;
  tmp = ((PyObject*)p->__pyx_v_sentences);
  p->__pyx_v_sentences = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_2_train = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_2_train", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_2_train), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_2_train, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_2_train, /*tp_traverse*/
  __pyx_tp_clear_4libs_7network___pyx_scope_struct_2_train, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_2_train, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *__pyx_freelist_4libs_7network___pyx_scope_struct_3_genexpr[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_3_genexpr = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_3_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_3_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_3_genexpr[--__pyx_freecount_4libs_7network___pyx_scope_struct_3_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_3_genexpr(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_sent);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_3_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_3_genexpr[__pyx_freecount_4libs_7network___pyx_scope_struct_3_genexpr++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_3_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_sent) {
    e = (*v)(p->__pyx_v_sent, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_3_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_3_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_3_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_3_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_3_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_3_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *__pyx_freelist_4libs_7network___pyx_scope_struct_4__validate[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_4__validate = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_4__validate(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_4__validate > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_4__validate[--__pyx_freecount_4libs_7network___pyx_scope_struct_4__validate];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_4__validate(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_4__validate < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_4__validate[__pyx_freecount_4libs_7network___pyx_scope_struct_4__validate++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_4__validate(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *)o;
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject *)p->__pyx_v_self), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4libs_7network___pyx_scope_struct_4__validate(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate *)o;
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_4libs_7network_Network *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_4__validate = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_4__validate", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_4__validate), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_4__validate, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_4__validate, /*tp_traverse*/
  __pyx_tp_clear_4libs_7network___pyx_scope_struct_4__validate, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_4__validate, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *__pyx_freelist_4libs_7network___pyx_scope_struct_5_genexpr[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_5_genexpr = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_5_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_5_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_5_genexpr[--__pyx_freecount_4libs_7network___pyx_scope_struct_5_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_5_genexpr(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_sent);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_5_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_5_genexpr[__pyx_freecount_4libs_7network___pyx_scope_struct_5_genexpr++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_5_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_sent) {
    e = (*v)(p->__pyx_v_sent, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_5_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_5_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_5_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_5_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_5_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_5_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *__pyx_freelist_4libs_7network___pyx_scope_struct_6_create_new[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_6_create_new = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_6_create_new(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_6_create_new > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_6_create_new[--__pyx_freecount_4libs_7network___pyx_scope_struct_6_create_new];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_6_create_new(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_feature_tables);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_6_create_new < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_6_create_new[__pyx_freecount_4libs_7network___pyx_scope_struct_6_create_new++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_6_create_new(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *)o;
  if (p->__pyx_v_feature_tables) {
    e = (*v)(p->__pyx_v_feature_tables, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4libs_7network___pyx_scope_struct_6_create_new(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new *)o;
  tmp = ((PyObject*)p->__pyx_v_feature_tables);
  p->__pyx_v_feature_tables = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_6_create_new = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_6_create_new", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_6_create_new), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_6_create_new, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_6_create_new, /*tp_traverse*/
  __pyx_tp_clear_4libs_7network___pyx_scope_struct_6_create_new, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_6_create_new, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *__pyx_freelist_4libs_7network___pyx_scope_struct_7_genexpr[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_7_genexpr = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_7_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_7_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_7_genexpr[--__pyx_freecount_4libs_7network___pyx_scope_struct_7_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_7_genexpr(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_table);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_7_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_7_genexpr[__pyx_freecount_4libs_7network___pyx_scope_struct_7_genexpr++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_7_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_table) {
    e = (*v)(p->__pyx_v_table, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_7_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_7_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_7_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_7_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_7_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_7_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *__pyx_freelist_4libs_7network___pyx_scope_struct_8_train[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_8_train = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_8_train(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_8_train > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_8_train[--__pyx_freecount_4libs_7network___pyx_scope_struct_8_train];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_8_train(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_sentences);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_8_train < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_8_train[__pyx_freecount_4libs_7network___pyx_scope_struct_8_train++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_8_train(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *)o;
  if (p->__pyx_v_sentences) {
    e = (*v)(p->__pyx_v_sentences, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4libs_7network___pyx_scope_struct_8_train(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train *)o;
  tmp = ((PyObject*)p->__pyx_v_sentences);
  p->__pyx_v_sentences = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_8_train = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_8_train", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_8_train), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_8_train, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_8_train, /*tp_traverse*/
  __pyx_tp_clear_4libs_7network___pyx_scope_struct_8_train, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_8_train, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *__pyx_freelist_4libs_7network___pyx_scope_struct_9_genexpr[8];
static int __pyx_freecount_4libs_7network___pyx_scope_struct_9_genexpr = 0;

static PyObject *__pyx_tp_new_4libs_7network___pyx_scope_struct_9_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_4libs_7network___pyx_scope_struct_9_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr)))) {
    o = (PyObject*)__pyx_freelist_4libs_7network___pyx_scope_struct_9_genexpr[--__pyx_freecount_4libs_7network___pyx_scope_struct_9_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_9_genexpr(PyObject *o) {
  struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_sent);
  Py_CLEAR(p->__pyx_t_0);
  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_4libs_7network___pyx_scope_struct_9_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr)))) {
    __pyx_freelist_4libs_7network___pyx_scope_struct_9_genexpr[__pyx_freecount_4libs_7network___pyx_scope_struct_9_genexpr++] = ((struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_4libs_7network___pyx_scope_struct_9_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *p = (struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_sent) {
    e = (*v)(p->__pyx_v_sent, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static PyTypeObject __pyx_type_4libs_7network___pyx_scope_struct_9_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "libs.network.__pyx_scope_struct_9_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_4libs_7network___pyx_scope_struct_9_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4libs_7network___pyx_scope_struct_9_genexpr, /*tp_dealloc*/
  #if PY_VERSION_HEX < 0x030800b4
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4
  0, /*tp_vectorcall_offset*/
  #endif
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #endif
  #if PY_MAJOR_VERSION >= 3
  0, /*tp_as_async*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_4libs_7network___pyx_scope_struct_9_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4libs_7network___pyx_scope_struct_9_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
  0, /*tp_vectorcall*/
  #endif
  #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
  0, /*tp_print*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
  0, /*tp_pypy_flags*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_network(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_network},
  {0, NULL}
};
#endif

static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    "network",
    __pyx_k_A_neural_network_for_NLP_taggin, /* m_doc */
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    0, /* m_size */
  #else
    -1, /* m_size */
  #endif
    __pyx_methods /* m_methods */,
  #if CYTHON_PEP489_MULTI_PHASE_INIT
    __pyx_moduledef_slots, /* m_slots */
  #else
    NULL, /* m_reload */
  #endif
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
  {&__pyx_kp_u_Accuracy, __pyx_k_Accuracy, sizeof(__pyx_k_Accuracy), 0, 1, 0, 0},
  {&__pyx_kp_u_Confidence_measure_not_implement, __pyx_k_Confidence_measure_not_implement, sizeof(__pyx_k_Confidence_measure_not_implement), 0, 1, 0, 0},
  {&__pyx_kp_u_Convolution_layer_size, __pyx_k_Convolution_layer_size, sizeof(__pyx_k_Convolution_layer_size), 0, 1, 0, 0},
  {&__pyx_n_s_ConvolutionalDependencyNetwork, __pyx_k_ConvolutionalDependencyNetwork, sizeof(__pyx_k_ConvolutionalDependencyNetwork), 0, 0, 1, 1},
  {&__pyx_n_s_ConvolutionalNetwork, __pyx_k_ConvolutionalNetwork, sizeof(__pyx_k_ConvolutionalNetwork), 0, 0, 1, 1},
  {&__pyx_kp_u_Distance_table_sizes_target_and, __pyx_k_Distance_table_sizes_target_and, sizeof(__pyx_k_Distance_table_sizes_target_and), 0, 1, 0, 0},
  {&__pyx_kp_u_Feature_table_sizes, __pyx_k_Feature_table_sizes, sizeof(__pyx_k_Feature_table_sizes), 0, 1, 0, 0},
  {&__pyx_n_s_FloatingPointError, __pyx_k_FloatingPointError, sizeof(__pyx_k_FloatingPointError), 0, 0, 1, 1},
  {&__pyx_kp_u_Hidden_layer_size, __pyx_k_Hidden_layer_size, sizeof(__pyx_k_Hidden_layer_size), 0, 1, 0, 0},
  {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_k_Incompatible_checksums_0x_x_vs_0, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_2, __pyx_k_Incompatible_checksums_0x_x_vs_0_2, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_2), 0, 0, 1, 0},
  {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0_3, __pyx_k_Incompatible_checksums_0x_x_vs_0_3, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0_3), 0, 0, 1, 0},
  {&__pyx_n_s_Infinity, __pyx_k_Infinity, sizeof(__pyx_k_Infinity), 0, 0, 1, 1},
  {&__pyx_kp_u_Input_layer_size, __pyx_k_Input_layer_size, sizeof(__pyx_k_Input_layer_size), 0, 1, 0, 0},
  {&__pyx_n_u_Logger, __pyx_k_Logger, sizeof(__pyx_k_Logger), 0, 1, 0, 1},
  {&__pyx_n_s_Network, __pyx_k_Network, sizeof(__pyx_k_Network), 0, 0, 1, 1},
  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
  {&__pyx_kp_u_Output_size, __pyx_k_Output_size, sizeof(__pyx_k_Output_size), 0, 1, 0, 0},
  {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
  {&__pyx_kp_u_Saved_model, __pyx_k_Saved_model, sizeof(__pyx_k_Saved_model), 0, 1, 0, 0},
  {&__pyx_kp_u_Second_hidden_layer_size, __pyx_k_Second_hidden_layer_size, sizeof(__pyx_k_Second_hidden_layer_size), 0, 1, 0, 0},
  {&__pyx_kp_u_Sentence_accuracy, __pyx_k_Sentence_accuracy, sizeof(__pyx_k_Sentence_accuracy), 0, 1, 0, 0},
  {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1},
  {&__pyx_kp_u_Token_accuracy, __pyx_k_Token_accuracy, sizeof(__pyx_k_Token_accuracy), 0, 1, 0, 0},
  {&__pyx_kp_u_Training_for_up_to_d_epochs, __pyx_k_Training_for_up_to_d_epochs, sizeof(__pyx_k_Training_for_up_to_d_epochs), 0, 1, 0, 0},
  {&__pyx_kp_u_Word_window_size, __pyx_k_Word_window_size, sizeof(__pyx_k_Word_window_size), 0, 1, 0, 0},
  {&__pyx_kp_u__12, __pyx_k__12, sizeof(__pyx_k__12), 0, 1, 0, 0},
  {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0},
  {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0},
  {&__pyx_n_s_add, __pyx_k_add, sizeof(__pyx_k_add), 0, 0, 1, 1},
  {&__pyx_n_s_adjust_features, __pyx_k_adjust_features, sizeof(__pyx_k_adjust_features), 0, 0, 1, 1},
  {&__pyx_n_s_adjust_weights, __pyx_k_adjust_weights, sizeof(__pyx_k_adjust_weights), 0, 0, 1, 1},
  {&__pyx_n_s_allow_pickle, __pyx_k_allow_pickle, sizeof(__pyx_k_allow_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_allow_repeats, __pyx_k_allow_repeats, sizeof(__pyx_k_allow_repeats), 0, 0, 1, 1},
  {&__pyx_n_s_arange, __pyx_k_arange, sizeof(__pyx_k_arange), 0, 0, 1, 1},
  {&__pyx_n_s_argmax, __pyx_k_argmax, sizeof(__pyx_k_argmax), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_argument_blocks, __pyx_k_argument_blocks, sizeof(__pyx_k_argument_blocks), 0, 0, 1, 1},
  {&__pyx_n_s_arguments, __pyx_k_arguments, sizeof(__pyx_k_arguments), 0, 0, 1, 1},
  {&__pyx_n_s_array, __pyx_k_array, sizeof(__pyx_k_array), 0, 0, 1, 1},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1},
  {&__pyx_n_s_backpropagate, __pyx_k_backpropagate, sizeof(__pyx_k_backpropagate), 0, 0, 1, 1},
  {&__pyx_n_s_bincount, __pyx_k_bincount, sizeof(__pyx_k_bincount), 0, 0, 1, 1},
  {&__pyx_n_s_calculate_all_scores, __pyx_k_calculate_all_scores, sizeof(__pyx_k_calculate_all_scores), 0, 0, 1, 1},
  {&__pyx_n_s_calculate_delta, __pyx_k_calculate_delta, sizeof(__pyx_k_calculate_delta), 0, 0, 1, 1},
  {&__pyx_n_s_calculate_gradients, __pyx_k_calculate_gradients, sizeof(__pyx_k_calculate_gradients), 0, 0, 1, 1},
  {&__pyx_n_s_calculate_gradients_classify, __pyx_k_calculate_gradients_classify, sizeof(__pyx_k_calculate_gradients_classify), 0, 0, 1, 1},
  {&__pyx_n_s_calculate_gradients_sll, __pyx_k_calculate_gradients_sll, sizeof(__pyx_k_calculate_gradients_sll), 0, 0, 1, 1},
  {&__pyx_n_s_calculate_input_deltas, __pyx_k_calculate_input_deltas, sizeof(__pyx_k_calculate_input_deltas), 0, 0, 1, 1},
  {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_clip, __pyx_k_clip, sizeof(__pyx_k_clip), 0, 0, 1, 1},
  {&__pyx_n_u_clip, __pyx_k_clip, sizeof(__pyx_k_clip), 0, 1, 0, 1},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_concatenate, __pyx_k_concatenate, sizeof(__pyx_k_concatenate), 0, 0, 1, 1},
  {&__pyx_n_s_contract_cycle, __pyx_k_contract_cycle, sizeof(__pyx_k_contract_cycle), 0, 0, 1, 1},
  {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1},
  {&__pyx_kp_u_corrections_skipped_Learning_ra, __pyx_k_corrections_skipped_Learning_ra, sizeof(__pyx_k_corrections_skipped_Learning_ra), 0, 1, 0, 0},
  {&__pyx_kp_u_corrections_skipped_learning_ra, __pyx_k_corrections_skipped_learning_ra, sizeof(__pyx_k_corrections_skipped_learning_ra), 0, 1, 0, 0},
  {&__pyx_n_s_count_nonzero, __pyx_k_count_nonzero, sizeof(__pyx_k_count_nonzero), 0, 0, 1, 1},
  {&__pyx_n_s_create_convolution_lookup, __pyx_k_create_convolution_lookup, sizeof(__pyx_k_create_convolution_lookup), 0, 0, 1, 1},
  {&__pyx_n_s_create_new, __pyx_k_create_new, sizeof(__pyx_k_create_new), 0, 0, 1, 1},
  {&__pyx_n_s_create_new_locals_genexpr, __pyx_k_create_new_locals_genexpr, sizeof(__pyx_k_create_new_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_create_pred_lookup, __pyx_k_create_pred_lookup, sizeof(__pyx_k_create_pred_lookup), 0, 0, 1, 1},
  {&__pyx_n_s_create_sentence_lookup, __pyx_k_create_sentence_lookup, sizeof(__pyx_k_create_sentence_lookup), 0, 0, 1, 1},
  {&__pyx_n_s_create_target_lookup, __pyx_k_create_target_lookup, sizeof(__pyx_k_create_target_lookup), 0, 0, 1, 1},
  {&__pyx_n_s_cycle, __pyx_k_cycle, sizeof(__pyx_k_cycle), 0, 0, 1, 1},
  {&__pyx_n_u_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 1, 0, 1},
  {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  {&__pyx_n_s_decay_factor, __pyx_k_decay_factor, sizeof(__pyx_k_decay_factor), 0, 0, 1, 1},
  {&__pyx_n_s_decrease_learning_rates, __pyx_k_decrease_learning_rates, sizeof(__pyx_k_decrease_learning_rates), 0, 0, 1, 1},
  {&__pyx_n_s_desired_accuracy, __pyx_k_desired_accuracy, sizeof(__pyx_k_desired_accuracy), 0, 0, 1, 1},
  {&__pyx_n_s_diagonal, __pyx_k_diagonal, sizeof(__pyx_k_diagonal), 0, 0, 1, 1},
  {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
  {&__pyx_n_s_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1},
  {&__pyx_n_s_empty_like, __pyx_k_empty_like, sizeof(__pyx_k_empty_like), 0, 0, 1, 1},
  {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
  {&__pyx_n_s_epochs, __pyx_k_epochs, sizeof(__pyx_k_epochs), 0, 0, 1, 1},
  {&__pyx_kp_u_epochs_Error, __pyx_k_epochs_Error, sizeof(__pyx_k_epochs_Error), 0, 1, 0, 0},
  {&__pyx_n_s_epochs_between_reports, __pyx_k_epochs_between_reports, sizeof(__pyx_k_epochs_between_reports), 0, 0, 1, 1},
  {&__pyx_n_s_exp, __pyx_k_exp, sizeof(__pyx_k_exp), 0, 0, 1, 1},
  {&__pyx_n_u_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 1, 0, 1},
  {&__pyx_n_s_feature_tables, __pyx_k_feature_tables, sizeof(__pyx_k_feature_tables), 0, 0, 1, 1},
  {&__pyx_n_u_feature_tables, __pyx_k_feature_tables, sizeof(__pyx_k_feature_tables), 0, 1, 0, 1},
  {&__pyx_n_s_filename, __pyx_k_filename, sizeof(__pyx_k_filename), 0, 0, 1, 1},
  {&__pyx_n_s_fill_diagonal, __pyx_k_fill_diagonal, sizeof(__pyx_k_fill_diagonal), 0, 0, 1, 1},
  {&__pyx_n_s_find_cycle_recursive, __pyx_k_find_cycle_recursive, sizeof(__pyx_k_find_cycle_recursive), 0, 0, 1, 1},
  {&__pyx_n_s_find_cycles, __pyx_k_find_cycles, sizeof(__pyx_k_find_cycles), 0, 0, 1, 1},
  {&__pyx_n_s_find_maximum_spanning_tree, __pyx_k_find_maximum_spanning_tree, sizeof(__pyx_k_find_maximum_spanning_tree), 0, 0, 1, 1},
  {&__pyx_n_s_flatten, __pyx_k_flatten, sizeof(__pyx_k_flatten), 0, 0, 1, 1},
  {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
  {&__pyx_n_s_generate_save_dict, __pyx_k_generate_save_dict, sizeof(__pyx_k_generate_save_dict), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
  {&__pyx_n_s_get_state, __pyx_k_get_state, sizeof(__pyx_k_get_state), 0, 0, 1, 1},
  {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
  {&__pyx_n_s_gold_head, __pyx_k_gold_head, sizeof(__pyx_k_gold_head), 0, 0, 1, 1},
  {&__pyx_n_s_graph, __pyx_k_graph, sizeof(__pyx_k_graph), 0, 0, 1, 1},
  {&__pyx_n_s_greater, __pyx_k_greater, sizeof(__pyx_k_greater), 0, 0, 1, 1},
  {&__pyx_n_s_heads, __pyx_k_heads, sizeof(__pyx_k_heads), 0, 0, 1, 1},
  {&__pyx_n_s_hidden1_bias, __pyx_k_hidden1_bias, sizeof(__pyx_k_hidden1_bias), 0, 0, 1, 1},
  {&__pyx_n_s_hidden1_size, __pyx_k_hidden1_size, sizeof(__pyx_k_hidden1_size), 0, 0, 1, 1},
  {&__pyx_n_s_hidden1_weights, __pyx_k_hidden1_weights, sizeof(__pyx_k_hidden1_weights), 0, 0, 1, 1},
  {&__pyx_n_s_hidden2_bias, __pyx_k_hidden2_bias, sizeof(__pyx_k_hidden2_bias), 0, 0, 1, 1},
  {&__pyx_n_u_hidden2_bias, __pyx_k_hidden2_bias, sizeof(__pyx_k_hidden2_bias), 0, 1, 0, 1},
  {&__pyx_n_s_hidden2_size, __pyx_k_hidden2_size, sizeof(__pyx_k_hidden2_size), 0, 0, 1, 1},
  {&__pyx_n_u_hidden2_size, __pyx_k_hidden2_size, sizeof(__pyx_k_hidden2_size), 0, 1, 0, 1},
  {&__pyx_n_s_hidden2_weights, __pyx_k_hidden2_weights, sizeof(__pyx_k_hidden2_weights), 0, 0, 1, 1},
  {&__pyx_n_u_hidden2_weights, __pyx_k_hidden2_weights, sizeof(__pyx_k_hidden2_weights), 0, 1, 0, 1},
  {&__pyx_n_s_hidden_bias, __pyx_k_hidden_bias, sizeof(__pyx_k_hidden_bias), 0, 0, 1, 1},
  {&__pyx_n_u_hidden_bias, __pyx_k_hidden_bias, sizeof(__pyx_k_hidden_bias), 0, 1, 0, 1},
  {&__pyx_n_s_hidden_size, __pyx_k_hidden_size, sizeof(__pyx_k_hidden_size), 0, 0, 1, 1},
  {&__pyx_n_u_hidden_size, __pyx_k_hidden_size, sizeof(__pyx_k_hidden_size), 0, 1, 0, 1},
  {&__pyx_n_s_hidden_weights, __pyx_k_hidden_weights, sizeof(__pyx_k_hidden_weights), 0, 0, 1, 1},
  {&__pyx_n_u_hidden_weights, __pyx_k_hidden_weights, sizeof(__pyx_k_hidden_weights), 0, 1, 0, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  {&__pyx_n_s_input_size, __pyx_k_input_size, sizeof(__pyx_k_input_size), 0, 0, 1, 1},
  {&__pyx_n_u_input_size, __pyx_k_input_size, sizeof(__pyx_k_input_size), 0, 1, 0, 1},
  {&__pyx_n_s_labels, __pyx_k_labels, sizeof(__pyx_k_labels), 0, 0, 1, 1},
  {&__pyx_n_s_less, __pyx_k_less, sizeof(__pyx_k_less), 0, 0, 1, 1},
  {&__pyx_n_s_libs_network, __pyx_k_libs_network, sizeof(__pyx_k_libs_network), 0, 0, 1, 1},
  {&__pyx_n_s_load, __pyx_k_load, sizeof(__pyx_k_load), 0, 0, 1, 1},
  {&__pyx_n_s_load_from_file, __pyx_k_load_from_file, sizeof(__pyx_k_load_from_file), 0, 0, 1, 1},
  {&__pyx_n_s_load_from_file_2, __pyx_k_load_from_file_2, sizeof(__pyx_k_load_from_file_2), 0, 0, 1, 1},
  {&__pyx_n_s_load_parameters, __pyx_k_load_parameters, sizeof(__pyx_k_load_parameters), 0, 0, 1, 1},
  {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
  {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  {&__pyx_n_s_logical_and, __pyx_k_logical_and, sizeof(__pyx_k_logical_and), 0, 0, 1, 1},
  {&__pyx_n_s_logical_not, __pyx_k_logical_not, sizeof(__pyx_k_logical_not), 0, 0, 1, 1},
  {&__pyx_n_s_logprob, __pyx_k_logprob, sizeof(__pyx_k_logprob), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  {&__pyx_n_s_network_filename, __pyx_k_network_filename, sizeof(__pyx_k_network_filename), 0, 0, 1, 1},
  {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_kp_u_numpy_core_multiarray_failed_to, __pyx_k_numpy_core_multiarray_failed_to, sizeof(__pyx_k_numpy_core_multiarray_failed_to), 0, 1, 0, 0},
  {&__pyx_kp_u_numpy_core_umath_failed_to_impor, __pyx_k_numpy_core_umath_failed_to_impor, sizeof(__pyx_k_numpy_core_umath_failed_to_impor), 0, 1, 0, 0},
  {&__pyx_n_s_output_bias, __pyx_k_output_bias, sizeof(__pyx_k_output_bias), 0, 0, 1, 1},
  {&__pyx_n_u_output_bias, __pyx_k_output_bias, sizeof(__pyx_k_output_bias), 0, 1, 0, 1},
  {&__pyx_n_s_output_size, __pyx_k_output_size, sizeof(__pyx_k_output_size), 0, 0, 1, 1},
  {&__pyx_n_u_output_size, __pyx_k_output_size, sizeof(__pyx_k_output_size), 0, 1, 0, 1},
  {&__pyx_n_s_output_weights, __pyx_k_output_weights, sizeof(__pyx_k_output_weights), 0, 0, 1, 1},
  {&__pyx_n_u_output_weights, __pyx_k_output_weights, sizeof(__pyx_k_output_weights), 0, 1, 0, 1},
  {&__pyx_n_s_padding_left, __pyx_k_padding_left, sizeof(__pyx_k_padding_left), 0, 0, 1, 1},
  {&__pyx_n_u_padding_left, __pyx_k_padding_left, sizeof(__pyx_k_padding_left), 0, 1, 0, 1},
  {&__pyx_n_s_padding_right, __pyx_k_padding_right, sizeof(__pyx_k_padding_right), 0, 0, 1, 1},
  {&__pyx_n_u_padding_right, __pyx_k_padding_right, sizeof(__pyx_k_padding_right), 0, 1, 0, 1},
  {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
  {&__pyx_n_s_pos_padding, __pyx_k_pos_padding, sizeof(__pyx_k_pos_padding), 0, 0, 1, 1},
  {&__pyx_n_s_pre_padding, __pyx_k_pre_padding, sizeof(__pyx_k_pre_padding), 0, 0, 1, 1},
  {&__pyx_n_s_pre_tagging_setup, __pyx_k_pre_tagging_setup, sizeof(__pyx_k_pre_tagging_setup), 0, 0, 1, 1},
  {&__pyx_n_s_pred_dist_table, __pyx_k_pred_dist_table, sizeof(__pyx_k_pred_dist_table), 0, 0, 1, 1},
  {&__pyx_n_u_pred_dist_table, __pyx_k_pred_dist_table, sizeof(__pyx_k_pred_dist_table), 0, 1, 0, 1},
  {&__pyx_n_s_pred_dist_weights, __pyx_k_pred_dist_weights, sizeof(__pyx_k_pred_dist_weights), 0, 0, 1, 1},
  {&__pyx_n_u_pred_dist_weights, __pyx_k_pred_dist_weights, sizeof(__pyx_k_pred_dist_weights), 0, 1, 0, 1},
  {&__pyx_n_s_predicate, __pyx_k_predicate, sizeof(__pyx_k_predicate), 0, 0, 1, 1},
  {&__pyx_n_s_predicates, __pyx_k_predicates, sizeof(__pyx_k_predicates), 0, 0, 1, 1},
  {&__pyx_n_s_print_epoch_report, __pyx_k_print_epoch_report, sizeof(__pyx_k_print_epoch_report), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ConvolutionalDepe, __pyx_k_pyx_unpickle_ConvolutionalDepe, sizeof(__pyx_k_pyx_unpickle_ConvolutionalDepe), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_ConvolutionalNetw, __pyx_k_pyx_unpickle_ConvolutionalNetw, sizeof(__pyx_k_pyx_unpickle_ConvolutionalNetw), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_unpickle_Network, __pyx_k_pyx_unpickle_Network, sizeof(__pyx_k_pyx_unpickle_Network), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_random, __pyx_k_random, sizeof(__pyx_k_random), 0, 0, 1, 1},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_ravel, __pyx_k_ravel, sizeof(__pyx_k_ravel), 0, 0, 1, 1},
  {&__pyx_n_s_reachable, __pyx_k_reachable, sizeof(__pyx_k_reachable), 0, 0, 1, 1},
  {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
  {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
  {&__pyx_n_s_reset_counters, __pyx_k_reset_counters, sizeof(__pyx_k_reset_counters), 0, 0, 1, 1},
  {&__pyx_n_s_reshape, __pyx_k_reshape, sizeof(__pyx_k_reshape), 0, 0, 1, 1},
  {&__pyx_n_s_rollaxis, __pyx_k_rollaxis, sizeof(__pyx_k_rollaxis), 0, 0, 1, 1},
  {&__pyx_n_s_save, __pyx_k_save, sizeof(__pyx_k_save), 0, 0, 1, 1},
  {&__pyx_n_s_savez, __pyx_k_savez, sizeof(__pyx_k_savez), 0, 0, 1, 1},
  {&__pyx_n_s_scores, __pyx_k_scores, sizeof(__pyx_k_scores), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_sentence, __pyx_k_sentence, sizeof(__pyx_k_sentence), 0, 0, 1, 1},
  {&__pyx_n_s_sentence_convolution, __pyx_k_sentence_convolution, sizeof(__pyx_k_sentence_convolution), 0, 0, 1, 1},
  {&__pyx_n_s_sentences, __pyx_k_sentences, sizeof(__pyx_k_sentences), 0, 0, 1, 1},
  {&__pyx_n_s_set_state, __pyx_k_set_state, sizeof(__pyx_k_set_state), 0, 0, 1, 1},
  {&__pyx_n_s_set_validation_data, __pyx_k_set_validation_data, sizeof(__pyx_k_set_validation_data), 0, 0, 1, 1},
  {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
  {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
  {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
  {&__pyx_n_s_shuffle, __pyx_k_shuffle, sizeof(__pyx_k_shuffle), 0, 0, 1, 1},
  {&__pyx_n_s_shuffle_data, __pyx_k_shuffle_data, sizeof(__pyx_k_shuffle_data), 0, 0, 1, 1},
  {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1},
  {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
  {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1},
  {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
  {&__pyx_n_s_tag_sentence, __pyx_k_tag_sentence, sizeof(__pyx_k_tag_sentence), 0, 0, 1, 1},
  {&__pyx_n_s_tag_sentence_2, __pyx_k_tag_sentence_2, sizeof(__pyx_k_tag_sentence_2), 0, 0, 1, 1},
  {&__pyx_n_s_tag_sentence_labeled_dependency, __pyx_k_tag_sentence_labeled_dependency, sizeof(__pyx_k_tag_sentence_labeled_dependency), 0, 0, 1, 1},
  {&__pyx_n_s_tag_sentence_unlabeled_dependen, __pyx_k_tag_sentence_unlabeled_dependen, sizeof(__pyx_k_tag_sentence_unlabeled_dependen), 0, 0, 1, 1},
  {&__pyx_n_s_tags, __pyx_k_tags, sizeof(__pyx_k_tags), 0, 0, 1, 1},
  {&__pyx_n_s_take, __pyx_k_take, sizeof(__pyx_k_take), 0, 0, 1, 1},
  {&__pyx_n_s_target_dist_table, __pyx_k_target_dist_table, sizeof(__pyx_k_target_dist_table), 0, 0, 1, 1},
  {&__pyx_n_u_target_dist_table, __pyx_k_target_dist_table, sizeof(__pyx_k_target_dist_table), 0, 1, 0, 1},
  {&__pyx_n_s_target_dist_weights, __pyx_k_target_dist_weights, sizeof(__pyx_k_target_dist_weights), 0, 0, 1, 1},
  {&__pyx_n_u_target_dist_weights, __pyx_k_target_dist_weights, sizeof(__pyx_k_target_dist_weights), 0, 1, 0, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_tile, __pyx_k_tile, sizeof(__pyx_k_tile), 0, 0, 1, 1},
  {&__pyx_n_s_train, __pyx_k_train, sizeof(__pyx_k_train), 0, 0, 1, 1},
  {&__pyx_n_s_train_epoch, __pyx_k_train_epoch, sizeof(__pyx_k_train_epoch), 0, 0, 1, 1},
  {&__pyx_n_s_train_locals_genexpr, __pyx_k_train_locals_genexpr, sizeof(__pyx_k_train_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_training, __pyx_k_training, sizeof(__pyx_k_training), 0, 0, 1, 1},
  {&__pyx_n_s_transitions, __pyx_k_transitions, sizeof(__pyx_k_transitions), 0, 0, 1, 1},
  {&__pyx_n_u_transitions, __pyx_k_transitions, sizeof(__pyx_k_transitions), 0, 1, 0, 1},
  {&__pyx_n_s_uniform, __pyx_k_uniform, sizeof(__pyx_k_uniform), 0, 0, 1, 1},
  {&__pyx_n_s_unreachable, __pyx_k_unreachable, sizeof(__pyx_k_unreachable), 0, 0, 1, 1},
  {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
  {&__pyx_n_s_validate, __pyx_k_validate, sizeof(__pyx_k_validate), 0, 0, 1, 1},
  {&__pyx_n_s_validate_locals_genexpr, __pyx_k_validate_locals_genexpr, sizeof(__pyx_k_validate_locals_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_validation_arguments, __pyx_k_validation_arguments, sizeof(__pyx_k_validation_arguments), 0, 0, 1, 1},
  {&__pyx_n_s_validation_predicates, __pyx_k_validation_predicates, sizeof(__pyx_k_validation_predicates), 0, 0, 1, 1},
  {&__pyx_n_s_validation_sentences, __pyx_k_validation_sentences, sizeof(__pyx_k_validation_sentences), 0, 0, 1, 1},
  {&__pyx_n_s_validation_tags, __pyx_k_validation_tags, sizeof(__pyx_k_validation_tags), 0, 0, 1, 1},
  {&__pyx_n_s_vertex, __pyx_k_vertex, sizeof(__pyx_k_vertex), 0, 0, 1, 1},
  {&__pyx_n_s_visited, __pyx_k_visited, sizeof(__pyx_k_visited), 0, 0, 1, 1},
  {&__pyx_n_s_viterbi, __pyx_k_viterbi, sizeof(__pyx_k_viterbi), 0, 0, 1, 1},
  {&__pyx_n_s_vstack, __pyx_k_vstack, sizeof(__pyx_k_vstack), 0, 0, 1, 1},
  {&__pyx_n_s_where, __pyx_k_where, sizeof(__pyx_k_where), 0, 0, 1, 1},
  {&__pyx_n_s_word_window, __pyx_k_word_window, sizeof(__pyx_k_word_window), 0, 0, 1, 1},
  {&__pyx_n_s_word_window_size, __pyx_k_word_window_size, sizeof(__pyx_k_word_window_size), 0, 0, 1, 1},
  {&__pyx_n_u_word_window_size, __pyx_k_word_window_size, sizeof(__pyx_k_word_window_size), 0, 1, 0, 1},
  {&__pyx_n_s_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 0, 0, 1, 1},
  {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
  {&__pyx_n_s_zeros_like, __pyx_k_zeros_like, sizeof(__pyx_k_zeros_like), 0, 0, 1, 1},
  {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_n_s_sum); if (!__pyx_builtin_sum) __PYX_ERR(0, 133, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 233, __pyx_L1_error)
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 303, __pyx_L1_error)
  #if PY_MAJOR_VERSION >= 3
  __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) __PYX_ERR(0, 345, __pyx_L1_error)
  #else
  __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) __PYX_ERR(0, 345, __pyx_L1_error)
  #endif
  __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 370, __pyx_L1_error)
  __pyx_builtin_FloatingPointError = __Pyx_GetBuiltinName(__pyx_n_s_FloatingPointError); if (!__pyx_builtin_FloatingPointError) __PYX_ERR(0, 689, __pyx_L1_error)
  __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(1, 126, __pyx_L1_error)
  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(1, 564, __pyx_L1_error)
  __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(4, 944, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "libs/network.pyx":237
 *             ind_to = ind_from + num_dims
 * 
 *             token_indices = padded_sentence[:, i]             # <<<<<<<<<<<<<<
 *             embeddings = table.take(token_indices, axis=0)
 *             self.sentence_lookup[:, ind_from:ind_to] = embeddings
 */
  __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 237, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__3);
  __Pyx_GIVEREF(__pyx_slice__3);

  /* "libs/network.pyx":343
 *         # delta_t(k) = ftheta_k,t + logadd_i(delta_t-1(i) + A_i,k)
 *         #            = ftheta_k,t + log(Sum_i(exp(delta_t-1(i) + A_i,k)))
 *         transitions = self.transitions[:-1].T # A_k,i             # <<<<<<<<<<<<<<
 * 
 *         for token in xrange(1, len(delta)):
 */
  __pyx_slice__4 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__4)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__4);
  __Pyx_GIVEREF(__pyx_slice__4);

  /* "libs/network.pyx":370
 *         correct_path_score = 0
 *         last_tag = self.output_size
 *         for tag, net_scores in zip(tags[:-2], scores[:-2]):             # <<<<<<<<<<<<<<
 *             #print(tags, last_tag, tag, self.transitions)
 *             trans = 0 if self.transitions is None else self.transitions[last_tag, tag]
 */
  __pyx_slice__5 = PySlice_New(Py_None, __pyx_int_neg_2, Py_None); if (unlikely(!__pyx_slice__5)) __PYX_ERR(0, 370, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__5);
  __Pyx_GIVEREF(__pyx_slice__5);

  /* "libs/network.pyx":450
 *             grad_times_softmax = self.net_gradients[t + 1] * delta_softmax
 *             # dC / dA_i,j
 *             self.trans_gradients[:-1, :] += grad_times_softmax             # <<<<<<<<<<<<<<
 * 
 *             # sum all transition gradients by row to find the network gradients
 */
  __pyx_tuple__6 = PyTuple_Pack(2, __pyx_slice__4, __pyx_slice__3); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 450, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "networkconv.pyx":564
 *             if logprob:
 *                 if self.only_classify:
 *                     raise NotImplementedError('Confidence measure not implemented for argument classifying')             # <<<<<<<<<<<<<<
 * 
 *                 all_scores = self._calculate_all_scores(token_scores)
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_u_Confidence_measure_not_implement); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 564, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "networkconv.pyx":830
 *             pre_deltas = dist_deltas.take(np.arange(pre_dist), 0).sum(0)
 *             pos_deltas = dist_deltas.take(np.arange(-pos_dist, 0), 0).sum(0)
 *             self.target_dist_table[1:-1, :] += dist_deltas[pre_dist : -pos_dist]             # <<<<<<<<<<<<<<
 *             self.target_dist_table[0] += pre_deltas
 *             self.target_dist_table[-1] += pos_deltas
 */
  __pyx_slice__9 = PySlice_New(__pyx_int_1, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__9)) __PYX_ERR(1, 830, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__9);
  __Pyx_GIVEREF(__pyx_slice__9);
  __pyx_tuple__10 = PyTuple_Pack(2, __pyx_slice__9, __pyx_slice__3); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 830, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "networkconv.pyx":899
 *         path_scores[0] = scores[0] + self.transitions[-1]
 * 
 *         for i, token in enumerate(scores[1:], 1):             # <<<<<<<<<<<<<<
 * 
 *             # each line contains the score until each tag t plus the transition to each other tag t'
 */
  __pyx_slice__11 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__11)) __PYX_ERR(1, 899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__11);
  __Pyx_GIVEREF(__pyx_slice__11);

  /* "(tree fragment)":4
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 *     if __pyx_checksum not in (0xc0e08fa, 0x72479d4, 0xd248f0d):             # <<<<<<<<<<<<<<
 *         from pickle import PickleError as __pyx_PickleError
 *         raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xc0e08fa, 0x72479d4, 0xd248f0d) = (accuracy, answer_score, decay_factor, error, feature_tables, features_per_token, float_errors, hidden_bias, hidden_sent_values, hidden_size, hidden_values, hidden_weights, input_sent_values, input_size, input_values, layer2_sent_values, layer2_values, learning_rate, learning_rate_features, learning_rate_trans, net_gradients, network_filename, network_text_filename, num_tokens, output_bias, output_size, output_weights, padding_left, padding_right, pos_padding, pre_padding, sentence_accuracy, sentence_lookup, skips, trans_gradients, transitions, use_learning_rate_decay, validation_sentences, validation_tags, word_window_size))" % __pyx_checksum)
 */
  __pyx_tuple__14 = PyTuple_Pack(3, __pyx_int_202246394, __pyx_int_119830996, __pyx_int_220499725); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);
  __pyx_tuple__16 = PyTuple_Pack(3, __pyx_int_149446146, __pyx_int_49696698, __pyx_int_148123145); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);
  __pyx_tuple__18 = PyTuple_Pack(3, __pyx_int_27816595, __pyx_int_212151326, __pyx_int_145891266); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(2, 4, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":944
 *         __pyx_import_array()
 *     except Exception:
 *         raise ImportError("numpy.core.multiarray failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_umath() except -1:
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_multiarray_failed_to); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(4, 944, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":950
 *         _import_umath()
 *     except Exception:
 *         raise ImportError("numpy.core.umath failed to import")             # <<<<<<<<<<<<<<
 * 
 * cdef inline int import_ufunc() except -1:
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_u_numpy_core_umath_failed_to_impor); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(4, 950, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "(tree fragment)":1
 * def __pyx_unpickle_Network(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_tuple__21 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);
  __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Network, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__22 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);
  __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ConvolutionalNetw, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) __PYX_ERR(2, 1, __pyx_L1_error)
  __pyx_tuple__23 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);
  __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_ConvolutionalDepe, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  __pyx_umethod_PySet_Type_update.type = (PyObject*)&PySet_Type;
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_0_01 = PyFloat_FromDouble(0.01); if (unlikely(!__pyx_float_0_01)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_2_38 = PyFloat_FromDouble(2.38); if (unlikely(!__pyx_float_2_38)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_float_neg_1_0 = PyFloat_FromDouble(-1.0); if (unlikely(!__pyx_float_neg_1_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_27816595 = PyInt_FromLong(27816595L); if (unlikely(!__pyx_int_27816595)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_49696698 = PyInt_FromLong(49696698L); if (unlikely(!__pyx_int_49696698)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_119830996 = PyInt_FromLong(119830996L); if (unlikely(!__pyx_int_119830996)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_145891266 = PyInt_FromLong(145891266L); if (unlikely(!__pyx_int_145891266)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_148123145 = PyInt_FromLong(148123145L); if (unlikely(!__pyx_int_148123145)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_149446146 = PyInt_FromLong(149446146L); if (unlikely(!__pyx_int_149446146)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_202246394 = PyInt_FromLong(202246394L); if (unlikely(!__pyx_int_202246394)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_212151326 = PyInt_FromLong(212151326L); if (unlikely(!__pyx_int_212151326)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_220499725 = PyInt_FromLong(220499725L); if (unlikely(!__pyx_int_220499725)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_int_neg_1000 = PyInt_FromLong(-1000); if (unlikely(!__pyx_int_neg_1000)) __PYX_ERR(0, 1, __pyx_L1_error)
  return 0;
  __pyx_L1_error:;
  return -1;
}

static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/

static int __Pyx_modinit_global_init_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(void) {
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_4libs_7network_Network) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network_Network.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network_Network.tp_dictoffset && __pyx_type_4libs_7network_Network.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network_Network.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  #if CYTHON_UPDATE_DESCRIPTOR_DOC
  {
    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_4libs_7network_Network, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 79, __pyx_L1_error)
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_4libs_7network_7Network_2__init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_4libs_7network_7Network_2__init__.doc = __pyx_doc_4libs_7network_7Network_2__init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_4libs_7network_7Network_2__init__;
    }
  }
  #endif
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Network, (PyObject *)&__pyx_type_4libs_7network_Network) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4libs_7network_Network) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
  __pyx_ptype_4libs_7network_Network = &__pyx_type_4libs_7network_Network;
  __pyx_vtabptr_4libs_7network_ConvolutionalNetwork = &__pyx_vtable_4libs_7network_ConvolutionalNetwork;
  __pyx_vtable_4libs_7network_ConvolutionalNetwork.argument_distances = (PyArrayObject *(*)(struct __pyx_obj_4libs_7network_ConvolutionalNetwork *, PyObject *, PyObject *))__pyx_f_4libs_7network_20ConvolutionalNetwork_argument_distances;
  __pyx_type_4libs_7network_ConvolutionalNetwork.tp_base = __pyx_ptype_4libs_7network_Network;
  if (PyType_Ready(&__pyx_type_4libs_7network_ConvolutionalNetwork) < 0) __PYX_ERR(1, 11, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network_ConvolutionalNetwork.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network_ConvolutionalNetwork.tp_dictoffset && __pyx_type_4libs_7network_ConvolutionalNetwork.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network_ConvolutionalNetwork.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4libs_7network_ConvolutionalNetwork.tp_dict, __pyx_vtabptr_4libs_7network_ConvolutionalNetwork) < 0) __PYX_ERR(1, 11, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ConvolutionalNetwork, (PyObject *)&__pyx_type_4libs_7network_ConvolutionalNetwork) < 0) __PYX_ERR(1, 11, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4libs_7network_ConvolutionalNetwork) < 0) __PYX_ERR(1, 11, __pyx_L1_error)
  __pyx_ptype_4libs_7network_ConvolutionalNetwork = &__pyx_type_4libs_7network_ConvolutionalNetwork;
  __pyx_vtabptr_4libs_7network_ConvolutionalDependencyNetwork = &__pyx_vtable_4libs_7network_ConvolutionalDependencyNetwork;
  __pyx_vtable_4libs_7network_ConvolutionalDependencyNetwork.__pyx_base = *__pyx_vtabptr_4libs_7network_ConvolutionalNetwork;
  __pyx_type_4libs_7network_ConvolutionalDependencyNetwork.tp_base = __pyx_ptype_4libs_7network_ConvolutionalNetwork;
  if (PyType_Ready(&__pyx_type_4libs_7network_ConvolutionalDependencyNetwork) < 0) __PYX_ERR(3, 11, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network_ConvolutionalDependencyNetwork.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network_ConvolutionalDependencyNetwork.tp_dictoffset && __pyx_type_4libs_7network_ConvolutionalDependencyNetwork.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network_ConvolutionalDependencyNetwork.tp_getattro = __Pyx_PyObject_GenericGetAttr;
  }
  if (__Pyx_SetVtable(__pyx_type_4libs_7network_ConvolutionalDependencyNetwork.tp_dict, __pyx_vtabptr_4libs_7network_ConvolutionalDependencyNetwork) < 0) __PYX_ERR(3, 11, __pyx_L1_error)
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_ConvolutionalDependencyNetwork, (PyObject *)&__pyx_type_4libs_7network_ConvolutionalDependencyNetwork) < 0) __PYX_ERR(3, 11, __pyx_L1_error)
  if (__Pyx_setup_reduce((PyObject*)&__pyx_type_4libs_7network_ConvolutionalDependencyNetwork) < 0) __PYX_ERR(3, 11, __pyx_L1_error)
  __pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork = &__pyx_type_4libs_7network_ConvolutionalDependencyNetwork;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct__create_new) < 0) __PYX_ERR(0, 127, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct__create_new.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct__create_new.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct__create_new.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct__create_new.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct__create_new = &__pyx_type_4libs_7network___pyx_scope_struct__create_new;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_1_genexpr) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_1_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_1_genexpr.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_1_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_1_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_1_genexpr = &__pyx_type_4libs_7network___pyx_scope_struct_1_genexpr;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_2_train) < 0) __PYX_ERR(0, 595, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_2_train.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_2_train.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_2_train.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_2_train.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_2_train = &__pyx_type_4libs_7network___pyx_scope_struct_2_train;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_3_genexpr) < 0) __PYX_ERR(0, 617, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_3_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_3_genexpr.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_3_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_3_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_3_genexpr = &__pyx_type_4libs_7network___pyx_scope_struct_3_genexpr;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_4__validate) < 0) __PYX_ERR(0, 693, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_4__validate.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_4__validate.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_4__validate.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_4__validate.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_4__validate = &__pyx_type_4libs_7network___pyx_scope_struct_4__validate;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_5_genexpr) < 0) __PYX_ERR(0, 702, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_5_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_5_genexpr.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_5_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_5_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_5_genexpr = &__pyx_type_4libs_7network___pyx_scope_struct_5_genexpr;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_6_create_new) < 0) __PYX_ERR(1, 52, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_6_create_new.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_6_create_new.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_6_create_new.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_6_create_new.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_6_create_new = &__pyx_type_4libs_7network___pyx_scope_struct_6_create_new;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_7_genexpr) < 0) __PYX_ERR(1, 56, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_7_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_7_genexpr.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_7_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_7_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_7_genexpr = &__pyx_type_4libs_7network___pyx_scope_struct_7_genexpr;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_8_train) < 0) __PYX_ERR(1, 275, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_8_train.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_8_train.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_8_train.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_8_train.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_8_train = &__pyx_type_4libs_7network___pyx_scope_struct_8_train;
  if (PyType_Ready(&__pyx_type_4libs_7network___pyx_scope_struct_9_genexpr) < 0) __PYX_ERR(1, 288, __pyx_L1_error)
  #if PY_VERSION_HEX < 0x030800B1
  __pyx_type_4libs_7network___pyx_scope_struct_9_genexpr.tp_print = 0;
  #endif
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_4libs_7network___pyx_scope_struct_9_genexpr.tp_dictoffset && __pyx_type_4libs_7network___pyx_scope_struct_9_genexpr.tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_type_4libs_7network___pyx_scope_struct_9_genexpr.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
  }
  __pyx_ptype_4libs_7network___pyx_scope_struct_9_genexpr = &__pyx_type_4libs_7network___pyx_scope_struct_9_genexpr;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(void) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", 
  #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(5, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(6, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(6, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(7, 15, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(7, 15, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyImport_ImportModule("numpy"); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType(__pyx_t_1, "numpy", "dtype", sizeof(PyArray_Descr), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_dtype) __PYX_ERR(4, 199, __pyx_L1_error)
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType(__pyx_t_1, "numpy", "flatiter", sizeof(PyArrayIterObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_flatiter) __PYX_ERR(4, 222, __pyx_L1_error)
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType(__pyx_t_1, "numpy", "broadcast", sizeof(PyArrayMultiIterObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_broadcast) __PYX_ERR(4, 226, __pyx_L1_error)
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType(__pyx_t_1, "numpy", "ndarray", sizeof(PyArrayObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_ndarray) __PYX_ERR(4, 238, __pyx_L1_error)
  __pyx_ptype_5numpy_generic = __Pyx_ImportType(__pyx_t_1, "numpy", "generic", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_generic) __PYX_ERR(4, 770, __pyx_L1_error)
  __pyx_ptype_5numpy_number = __Pyx_ImportType(__pyx_t_1, "numpy", "number", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_number) __PYX_ERR(4, 772, __pyx_L1_error)
  __pyx_ptype_5numpy_integer = __Pyx_ImportType(__pyx_t_1, "numpy", "integer", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_integer) __PYX_ERR(4, 774, __pyx_L1_error)
  __pyx_ptype_5numpy_signedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "signedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_signedinteger) __PYX_ERR(4, 776, __pyx_L1_error)
  __pyx_ptype_5numpy_unsignedinteger = __Pyx_ImportType(__pyx_t_1, "numpy", "unsignedinteger", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_unsignedinteger) __PYX_ERR(4, 778, __pyx_L1_error)
  __pyx_ptype_5numpy_inexact = __Pyx_ImportType(__pyx_t_1, "numpy", "inexact", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_inexact) __PYX_ERR(4, 780, __pyx_L1_error)
  __pyx_ptype_5numpy_floating = __Pyx_ImportType(__pyx_t_1, "numpy", "floating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_floating) __PYX_ERR(4, 782, __pyx_L1_error)
  __pyx_ptype_5numpy_complexfloating = __Pyx_ImportType(__pyx_t_1, "numpy", "complexfloating", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_complexfloating) __PYX_ERR(4, 784, __pyx_L1_error)
  __pyx_ptype_5numpy_flexible = __Pyx_ImportType(__pyx_t_1, "numpy", "flexible", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_flexible) __PYX_ERR(4, 786, __pyx_L1_error)
  __pyx_ptype_5numpy_character = __Pyx_ImportType(__pyx_t_1, "numpy", "character", sizeof(PyObject), __Pyx_ImportType_CheckSize_Warn);
   if (!__pyx_ptype_5numpy_character) __PYX_ERR(4, 788, __pyx_L1_error)
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType(__pyx_t_1, "numpy", "ufunc", sizeof(PyUFuncObject), __Pyx_ImportType_CheckSize_Ignore);
   if (!__pyx_ptype_5numpy_ufunc) __PYX_ERR(4, 826, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_variable_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}


#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#elif PY_MAJOR_VERSION < 3
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" void
#else
#define __Pyx_PyMODINIT_FUNC void
#endif
#else
#ifdef __cplusplus
#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif


#if PY_MAJOR_VERSION < 3
__Pyx_PyMODINIT_FUNC initnetwork(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC initnetwork(void)
#else
__Pyx_PyMODINIT_FUNC PyInit_network(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_network(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    #if PY_VERSION_HEX >= 0x030700A1
    static PY_INT64_T main_interpreter_id = -1;
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return (unlikely(current_id == -1)) ? -1 : 0;
    } else if (unlikely(main_interpreter_id != current_id))
    #else
    static PyInterpreterState *main_interpreter = NULL;
    PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
    if (!main_interpreter) {
        main_interpreter = current_interpreter;
    } else if (unlikely(main_interpreter != current_interpreter))
    #endif
    {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    if (__Pyx_check_single_interpreter())
        return NULL;
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_network(PyObject *__pyx_pyinit_module)
#endif
#endif
{
  __Pyx_TraceDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'network' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #elif PY_MAJOR_VERSION >= 3
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  #if CYTHON_REFNANNY
__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
if (!__Pyx_RefNanny) {
  PyErr_Clear();
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  if (!__Pyx_RefNanny)
      Py_FatalError("failed to import 'refnanny' module");
}
#endif
  __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_network(void)", 0);
  if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pxy_PyFrame_Initialize_Offsets
  __Pxy_PyFrame_Initialize_Offsets();
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  #ifdef __Pyx_CyFunction_USED
  if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Coroutine_USED
  if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_AsyncGen_USED
  if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #ifdef __Pyx_StopAsyncIteration_USED
  if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  PyEval_InitThreads();
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_m = __pyx_pyinit_module;
  Py_INCREF(__pyx_m);
  #else
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4("network", __pyx_methods, __pyx_k_A_neural_network_for_NLP_taggin, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_b);
  __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_cython_runtime);
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  if (__pyx_module_is_main_libs__network) {
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "libs.network")) {
      if (unlikely(PyDict_SetItemString(modules, "libs.network", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code();
  (void)__Pyx_modinit_variable_export_code();
  (void)__Pyx_modinit_function_export_code();
  if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_variable_import_code();
  (void)__Pyx_modinit_function_import_code();
  /*--- Execution code ---*/
  #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  __Pyx_TraceCall("__Pyx_PyMODINIT_FUNC PyInit_network(void)", __pyx_f[0], 1, 0, __PYX_ERR(0, 1, __pyx_L1_error));

  /* "libs/network.pyx":11
 * """
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":17
 * 
 * #from itertools import izip
 * import logging             # <<<<<<<<<<<<<<
 * 
 * #ctypedef float FLOAT_t
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":127
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, int word_window, int hidden_size,             # <<<<<<<<<<<<<<
 *                  int output_size):
 *         """
 */
  __Pyx_GetNameInClass(__pyx_t_1, (PyObject *)__pyx_ptype_4libs_7network_Network, __pyx_n_s_create_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "libs/network.pyx":126
 *     cdef list validation_tags
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def create_new(cls, feature_tables, int word_window, int hidden_size,
 *                  int output_size):
 */
  __pyx_t_2 = __Pyx_Method_ClassMethod(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4libs_7network_Network->tp_dict, __pyx_n_s_create_new, __pyx_t_2) < 0) __PYX_ERR(0, 127, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4libs_7network_Network);

  /* "libs/network.pyx":838
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_4libs_7network_Network, __pyx_n_s_load_from_file_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 838, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "libs/network.pyx":837
 * 
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def load_from_file(cls, filename):
 *         """
 */
  __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 837, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4libs_7network_Network->tp_dict, __pyx_n_s_load_from_file_2, __pyx_t_1) < 0) __PYX_ERR(0, 838, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4libs_7network_Network);

  /* "networkconv.pyx":8
 * """
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(1, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "networkconv.pyx":52
 * 
 *     @classmethod
 *     def create_new(cls, feature_tables, target_dist_table, pred_dist_table,             # <<<<<<<<<<<<<<
 *                    int word_window, int hidden1_size, int hidden2_size, int output_size):
 *         """Creates a new convolutional neural network."""
 */
  __Pyx_GetNameInClass(__pyx_t_1, (PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork, __pyx_n_s_create_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 52, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "networkconv.pyx":51
 *     cdef list validation_predicates, validation_arguments
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def create_new(cls, feature_tables, target_dist_table, pred_dist_table,
 *                    int word_window, int hidden1_size, int hidden2_size, int output_size):
 */
  __pyx_t_2 = __Pyx_Method_ClassMethod(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork->tp_dict, __pyx_n_s_create_new, __pyx_t_2) < 0) __PYX_ERR(1, 52, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4libs_7network_ConvolutionalNetwork);

  /* "networkconv.pyx":179
 * 
 *     @classmethod
 *     def _load_from_file(cls, data, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Internal method for setting data read from a npz file.
 */
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork, __pyx_n_s_load_from_file); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "networkconv.pyx":178
 *         np.savez(self.network_filename, **data)
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def _load_from_file(cls, data, filename):
 *         """
 */
  __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork->tp_dict, __pyx_n_s_load_from_file, __pyx_t_1) < 0) __PYX_ERR(1, 179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4libs_7network_ConvolutionalNetwork);

  /* "networkconv.pyx":225
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */
  __Pyx_GetNameInClass(__pyx_t_1, (PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork, __pyx_n_s_load_from_file_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 225, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "networkconv.pyx":224
 *         return nn
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def load_from_file(cls, filename):
 *         """
 */
  __pyx_t_2 = __Pyx_Method_ClassMethod(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalNetwork->tp_dict, __pyx_n_s_load_from_file_2, __pyx_t_2) < 0) __PYX_ERR(1, 225, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4libs_7network_ConvolutionalNetwork);

  /* "networkdependencyconv.pyx":8
 * """
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * 
 */
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(3, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "networkdependencyconv.pyx":30
 * 
 *     @classmethod
 *     def load_from_file(cls, filename):             # <<<<<<<<<<<<<<
 *         """
 *         Loads the neural network from a file.
 */
  __Pyx_GetNameInClass(__pyx_t_2, (PyObject *)__pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork, __pyx_n_s_load_from_file_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(3, 30, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "networkdependencyconv.pyx":29
 *         np.savez(self.network_filename, **data)
 * 
 *     @classmethod             # <<<<<<<<<<<<<<
 *     def load_from_file(cls, filename):
 *         """
 */
  __pyx_t_1 = __Pyx_Method_ClassMethod(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 29, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork->tp_dict, __pyx_n_s_load_from_file_2, __pyx_t_1) < 0) __PYX_ERR(3, 30, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_4libs_7network_ConvolutionalDependencyNetwork);

  /* "(tree fragment)":1
 * def __pyx_unpickle_Network(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4libs_7network_1__pyx_unpickle_Network, NULL, __pyx_n_s_libs_network); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Network, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":11
 *         __pyx_unpickle_Network__set_state(<Network> __pyx_result, __pyx_state)
 *     return __pyx_result
 * cdef __pyx_unpickle_Network__set_state(Network __pyx_result, tuple __pyx_state):             # <<<<<<<<<<<<<<
 *     __pyx_result.accuracy = __pyx_state[0]; __pyx_result.answer_score = __pyx_state[1]; __pyx_result.decay_factor = __pyx_state[2]; __pyx_result.error = __pyx_state[3]; __pyx_result.feature_tables = __pyx_state[4]; __pyx_result.features_per_token = __pyx_state[5]; __pyx_result.float_errors = __pyx_state[6]; __pyx_result.hidden_bias = __pyx_state[7]; __pyx_result.hidden_sent_values = __pyx_state[8]; __pyx_result.hidden_size = __pyx_state[9]; __pyx_result.hidden_values = __pyx_state[10]; __pyx_result.hidden_weights = __pyx_state[11]; __pyx_result.input_sent_values = __pyx_state[12]; __pyx_result.input_size = __pyx_state[13]; __pyx_result.input_values = __pyx_state[14]; __pyx_result.layer2_sent_values = __pyx_state[15]; __pyx_result.layer2_values = __pyx_state[16]; __pyx_result.learning_rate = __pyx_state[17]; __pyx_result.learning_rate_features = __pyx_state[18]; __pyx_result.learning_rate_trans = __pyx_state[19]; __pyx_result.net_gradients = __pyx_state[20]; __pyx_result.network_filename = __pyx_state[21]; __pyx_result.network_text_filename = __pyx_state[22]; __pyx_result.num_tokens = __pyx_state[23]; __pyx_result.output_bias = __pyx_state[24]; __pyx_result.output_size = __pyx_state[25]; __pyx_result.output_weights = __pyx_state[26]; __pyx_result.padding_left = __pyx_state[27]; __pyx_result.padding_right = __pyx_state[28]; __pyx_result.pos_padding = __pyx_state[29]; __pyx_result.pre_padding = __pyx_state[30]; __pyx_result.sentence_accuracy = __pyx_state[31]; __pyx_result.sentence_lookup = __pyx_state[32]; __pyx_result.skips = __pyx_state[33]; __pyx_result.trans_gradients = __pyx_state[34]; __pyx_result.transitions = __pyx_state[35]; __pyx_result.use_learning_rate_decay = __pyx_state[36]; __pyx_result.validation_sentences = __pyx_state[37]; __pyx_result.validation_tags = __pyx_state[38]; __pyx_result.word_window_size = __pyx_state[39]
 *     if len(__pyx_state) > 40 and hasattr(__pyx_result, '__dict__'):
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4libs_7network_3__pyx_unpickle_ConvolutionalNetwork, NULL, __pyx_n_s_libs_network); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ConvolutionalNetw, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "(tree fragment)":1
 * def __pyx_unpickle_ConvolutionalDependencyNetwork(__pyx_type, long __pyx_checksum, __pyx_state):             # <<<<<<<<<<<<<<
 *     cdef object __pyx_PickleError
 *     cdef object __pyx_result
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4libs_7network_5__pyx_unpickle_ConvolutionalDependencyNetwork, NULL, __pyx_n_s_libs_network); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_ConvolutionalDepe, __pyx_t_1) < 0) __PYX_ERR(2, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "libs/network.pyx":1
 * # -*- coding: utf-8 -*-             # <<<<<<<<<<<<<<
 * #cython: embedsignature=True
 * #cython: profile=True
 */
  __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "../../../Library/Python/3.9/lib/python/site-packages/numpy/__init__.pxd":1013
 * 
 * 
 * cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:             # <<<<<<<<<<<<<<
 *     """
 *     returns the unit part of the dtype for a numpy datetime64 object.
 */
  __Pyx_TraceReturn(Py_None, 0);

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__pyx_m) {
    if (__pyx_d) {
      __Pyx_AddTraceback("init libs.network", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    Py_CLEAR(__pyx_m);
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init libs.network");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #elif PY_MAJOR_VERSION >= 3
  return __pyx_m;
  #else
  return;
  #endif
}

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyObjectGetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

/* PyErrFetchRestore */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}
#endif

/* Profile */
#if CYTHON_PROFILE
static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
                                   PyFrameObject** frame,
                                   PyThreadState* tstate,
                                   const char *funcname,
                                   const char *srcfile,
                                   int firstlineno) {
    PyObject *type, *value, *traceback;
    int retval;
    if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
        if (*code == NULL) {
            *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
            if (*code == NULL) return 0;
        }
        *frame = PyFrame_New(
            tstate,                          /*PyThreadState *tstate*/
            *code,                           /*PyCodeObject *code*/
            __pyx_d,                  /*PyObject *globals*/
            0                                /*PyObject *locals*/
        );
        if (*frame == NULL) return 0;
        if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
            Py_INCREF(Py_None);
            (*frame)->f_trace = Py_None;
        }
#if PY_VERSION_HEX < 0x030400B1
    } else {
        (*frame)->f_tstate = tstate;
#endif
    }
    __Pyx_PyFrame_SetLineNumber(*frame, firstlineno);
    retval = 1;
    __Pyx_EnterTracing(tstate);
    __Pyx_ErrFetchInState(tstate, &type, &value, &traceback);
    #if CYTHON_TRACE
    if (tstate->c_tracefunc)
        retval = tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL) == 0;
    if (retval && tstate->c_profilefunc)
    #endif
        retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
    __Pyx_LeaveTracing(tstate);
    if (retval) {
        __Pyx_ErrRestoreInState(tstate, type, value, traceback);
        return __Pyx_IsTracing(tstate, 0, 0) && retval;
    } else {
        Py_XDECREF(type);
        Py_XDECREF(value);
        Py_XDECREF(traceback);
        return -1;
    }
}
static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
    PyCodeObject *py_code = 0;
#if PY_MAJOR_VERSION >= 3
    py_code = PyCode_NewEmpty(srcfile, funcname, firstlineno);
    if (likely(py_code)) {
        py_code->co_flags |= CO_OPTIMIZED | CO_NEWLOCALS;
    }
#else
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    py_funcname = PyString_FromString(funcname);
    if (unlikely(!py_funcname)) goto bad;
    py_srcfile = PyString_FromString(srcfile);
    if (unlikely(!py_srcfile)) goto bad;
    py_code = PyCode_New(
        0,
        0,
        0,
        CO_OPTIMIZED | CO_NEWLOCALS,
        __pyx_empty_bytes,     /*PyObject *code,*/
        __pyx_empty_tuple,     /*PyObject *consts,*/
        __pyx_empty_tuple,     /*PyObject *names,*/
        __pyx_empty_tuple,     /*PyObject *varnames,*/
        __pyx_empty_tuple,     /*PyObject *freevars,*/
        __pyx_empty_tuple,     /*PyObject *cellvars,*/
        py_srcfile,       /*PyObject *filename,*/
        py_funcname,      /*PyObject *name,*/
        firstlineno,
        __pyx_empty_bytes      /*PyObject *lnotab*/
    );
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
#endif
    return py_code;
}
#endif

/* PyFunctionFastCall */
#if CYTHON_FAST_PYCALL
static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
                                               PyObject *globals) {
    PyFrameObject *f;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject **fastlocals;
    Py_ssize_t i;
    PyObject *result;
    assert(globals != NULL);
    /* XXX Perhaps we should create a specialized
       PyFrame_New() that doesn't take locals, but does
       take builtins without sanity checking them.
       */
    assert(tstate != NULL);
    f = PyFrame_New(tstate, co, globals, NULL);
    if (f == NULL) {
        return NULL;
    }
    fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
    for (i = 0; i < na; i++) {
        Py_INCREF(*args);
        fastlocals[i] = *args++;
    }
    result = PyEval_EvalFrameEx(f,0);
    ++tstate->recursion_depth;
    Py_DECREF(f);
    --tstate->recursion_depth;
    return result;
}
#if 1 || PY_VERSION_HEX < 0x030600B1
static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
    PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
    PyObject *globals = PyFunction_GET_GLOBALS(func);
    PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
    PyObject *closure;
#if PY_MAJOR_VERSION >= 3
    PyObject *kwdefs;
#endif
    PyObject *kwtuple, **k;
    PyObject **d;
    Py_ssize_t nd;
    Py_ssize_t nk;
    PyObject *result;
    assert(kwargs == NULL || PyDict_Check(kwargs));
    nk = kwargs ? PyDict_Size(kwargs) : 0;
    if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
        return NULL;
    }
    if (
#if PY_MAJOR_VERSION >= 3
            co->co_kwonlyargcount == 0 &&
#endif
            likely(kwargs == NULL || nk == 0) &&
            co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
        if (argdefs == NULL && co->co_argcount == nargs) {
            result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
            goto done;
        }
        else if (nargs == 0 && argdefs != NULL
                 && co->co_argcount == Py_SIZE(argdefs)) {
            /* function called with no arguments, but all parameters have
               a default value: use default values as arguments .*/
            args = &PyTuple_GET_ITEM(argdefs, 0);
            result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
            goto done;
        }
    }
    if (kwargs != NULL) {
        Py_ssize_t pos, i;
        kwtuple = PyTuple_New(2 * nk);
        if (kwtuple == NULL) {
            result = NULL;
            goto done;
        }
        k = &PyTuple_GET_ITEM(kwtuple, 0);
        pos = i = 0;
        while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
            Py_INCREF(k[i]);
            Py_INCREF(k[i+1]);
            i += 2;
        }
        nk = i / 2;
    }
    else {
        kwtuple = NULL;
        k = NULL;
    }
    closure = PyFunction_GET_CLOSURE(func);
#if PY_MAJOR_VERSION >= 3
    kwdefs = PyFunction_GET_KW_DEFAULTS(func);
#endif
    if (argdefs != NULL) {
        d = &PyTuple_GET_ITEM(argdefs, 0);
        nd = Py_SIZE(argdefs);
    }
    else {
        d = NULL;
        nd = 0;
    }
#if PY_MAJOR_VERSION >= 3
    result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, kwdefs, closure);
#else
    result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
                               args, (int)nargs,
                               k, (int)nk,
                               d, (int)nd, closure);
#endif
    Py_XDECREF(kwtuple);
done:
    Py_LeaveRecursiveCall();
    return result;
}
#endif
#endif

/* PyObjectCall */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = Py_TYPE(func)->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallMethO */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = PyCFunction_GET_FUNCTION(func);
    self = PyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallNoArg */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, NULL, 0);
    }
#endif
#ifdef __Pyx_CyFunction_USED
    if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
#else
    if (likely(PyCFunction_Check(func)))
#endif
    {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
            return __Pyx_PyObject_CallMethO(func, NULL);
        }
    }
    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
}
#endif

/* PyCFunctionFastCall */
#if CYTHON_FAST_PYCCALL
static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
    PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    int flags = PyCFunction_GET_FLAGS(func);
    assert(PyCFunction_Check(func));
    assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
    assert(nargs >= 0);
    assert(nargs == 0 || args != NULL);
    /* _PyCFunction_FastCallDict() must not be called with an exception set,
       because it may clear it (directly or indirectly) and so the
       caller loses its exception */
    assert(!PyErr_Occurred());
    if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
        return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
    } else {
        return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
    }
}
#endif

/* PyObjectCallOneArg */
#if CYTHON_COMPILING_IN_CPYTHON
static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_New(1);
    if (unlikely(!args)) return NULL;
    Py_INCREF(arg);
    PyTuple_SET_ITEM(args, 0, arg);
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
#if CYTHON_FAST_PYCALL
    if (PyFunction_Check(func)) {
        return __Pyx_PyFunction_FastCall(func, &arg, 1);
    }
#endif
    if (likely(PyCFunction_Check(func))) {
        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
            return __Pyx_PyObject_CallMethO(func, arg);
#if CYTHON_FAST_PYCCALL
        } else if (__Pyx_PyFastCFunction_Check(func)) {
            return __Pyx_PyCFunction_FastCall(func, &arg, 1);
#endif
        }
    }
    return __Pyx__PyObject_CallOneArg(func, arg);
}
#else
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *result;
    PyObject *args = PyTuple_Pack(1, arg);
    if (unlikely(!args)) return NULL;
    result = __Pyx_PyObject_Call(func, args, NULL);
    Py_DECREF(args);
    return result;
}
#endif

/* ExtTypeTest */
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(__Pyx_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

/* PyDictVersioning */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if !CYTHON_AVOID_BORROWED_REFS
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
    result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    } else if (unlikely(PyErr_Occurred())) {
        return NULL;
    }
#else
    result = PyDict_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
#endif
#else
    result = PyObject_GetItem(__pyx_d, name);
    __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyObjectCall2Args */
static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args, *result = NULL;
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyFunction_FastCall(function, args, 2);
    }
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(function)) {
        PyObject *args[2] = {arg1, arg2};
        return __Pyx_PyCFunction_FastCall(function, args, 2);
    }
    #endif
    args = PyTuple_New(2);
    if (unlikely(!args)) goto done;
    Py_INCREF(arg1);
    PyTuple_SET_ITEM(args, 0, arg1);
    Py_INCREF(arg2);
    PyTuple_SET_ITEM(args, 1, arg2);
    Py_INCREF(function);
    result = __Pyx_PyObject_Call(function, args, NULL);
    Py_DECREF(args);
    Py_DECREF(function);
done:
    return result;
}

/* IsLittleEndian */
static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
{
  union {
    uint32_t u32;
    uint8_t u8[4];
  } S;
  S.u32 = 0x01020304;
  return S.u8[0] == 4;
}

/* BufferFormatCheck */
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->new_packmode = '@';
  ctx->enc_packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  ctx->is_valid_array = 0;
  ctx->struct_alignment = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t <= '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
    int number = __Pyx_BufFmt_ParseNumber(ts);
    if (number == -1)
        PyErr_Format(PyExc_ValueError,\
                     "Does not understand character buffer dtype format string ('%c')", **ts);
    return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  PyErr_Format(PyExc_ValueError,
               "Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case '?': return "'bool'";
    case 'c': return "'char'";
    case 'b': return "'signed char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 's': case 'p': return "a string";
    case 0: return "end";
    default: return "unparseable format string";
  }
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
/* These are for computing the padding at the end of the struct to align
   on the first member of the struct. This will probably the same as above,
   but we don't have any guarantees.
 */
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c':
        return 'H';
    case 'b': case 'h': case 'i':
    case 'l': case 'q': case 's': case 'p':
        return 'I';
    case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
        return 'U';
    case 'f': case 'd': case 'g':
        return (is_complex ? 'C' : 'R');
    case 'O':
        return 'O';
    case 'P':
        return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset, arraysize = 1;
  if (ctx->enc_type == 0) return 0;
  if (ctx->head->field->type->arraysize[0]) {
    int i, ndim = 0;
    if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
        ctx->is_valid_array = ctx->head->field->type->ndim == 1;
        ndim = 1;
        if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
            PyErr_Format(PyExc_ValueError,
                         "Expected a dimension of size %zu, got %zu",
                         ctx->head->field->type->arraysize[0], ctx->enc_count);
            return -1;
        }
    }
    if (!ctx->is_valid_array) {
      PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
                   ctx->head->field->type->ndim, ndim);
      return -1;
    }
    for (i = 0; i < ctx->head->field->type->ndim; i++) {
      arraysize *= ctx->head->field->type->arraysize[i];
    }
    ctx->is_valid_array = 0;
    ctx->enc_count = 1;
  }
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
    if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->enc_packmode == '@') {
      size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      size_t align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
      if (ctx->struct_alignment == 0)
          ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
                                                                 ctx->is_complex);
    }
    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
      if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
      } else {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
      }
    }
    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
                   (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
      return -1;
    }
    ctx->fmt_offset += size;
    if (arraysize)
      ctx->fmt_offset += (arraysize - 1) * size;
    --ctx->enc_count;
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break;
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue;
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;
}
static PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number, ndim;
    ++ts;
    if (ctx->new_count != 1) {
        PyErr_SetString(PyExc_ValueError,
                        "Cannot handle repeated arrays in format string");
        return NULL;
    }
    if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
    ndim = ctx->head->field->type->ndim;
    while (*ts && *ts != ')') {
        switch (*ts) {
            case ' ': case '\f': case '\r': case '\n': case '\t': case '\v':  continue;
            default:  break;
        }
        number = __Pyx_BufFmt_ExpectNumber(&ts);
        if (number == -1) return NULL;
        if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
            return PyErr_Format(PyExc_ValueError,
                        "Expected a dimension of size %zu, got %d",
                        ctx->head->field->type->arraysize[i], number);
        if (*ts != ',' && *ts != ')')
            return PyErr_Format(PyExc_ValueError,
                                "Expected a comma in format string, got '%c'", *ts);
        if (*ts == ',') ts++;
        i++;
    }
    if (i != ndim)
        return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
                            ctx->head->field->type->ndim, i);
    if (!*ts) {
        PyErr_SetString(PyExc_ValueError,
                        "Unexpected end of format string, expected ')'");
        return NULL;
    }
    ctx->is_valid_array = 1;
    ctx->new_count = 1;
    *tsp = ++ts;
    return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        return ts;
      case ' ':
      case '\r':
      case '\n':
        ++ts;
        break;
      case '<':
        if (!__Pyx_Is_Little_Endian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_Is_Little_Endian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        ctx->new_packmode = *ts++;
        break;
      case 'T':
        {
          const char* ts_after_sub;
          size_t i, struct_count = ctx->new_count;
          size_t struct_alignment = ctx->struct_alignment;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          ctx->enc_count = 0;
          ctx->struct_alignment = 0;
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
          if (struct_alignment) ctx->struct_alignment = struct_alignment;
        }
        break;
      case '}':
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0;
          if (alignment && ctx->fmt_offset % alignment) {
            ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
          }
        }
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ctx->enc_packmode = ctx->new_packmode;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }
        CYTHON_FALLTHROUGH;
      case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O': case 'p':
        if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
            (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
          ctx->enc_count += ctx->new_count;
          ctx->new_count = 1;
          got_Z = 0;
          ++ts;
          break;
        }
        CYTHON_FALLTHROUGH;
      case 's':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->enc_count = ctx->new_count;
        ctx->enc_packmode = ctx->new_packmode;
        ctx->enc_type = *ts;
        ctx->is_complex = got_Z;
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      case ':':
        ++ts;
        while(*ts != ':') ++ts;
        ++ts;
        break;
      case '(':
        if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
        break;
      default:
        {
          int number = __Pyx_BufFmt_ExpectNumber(&ts);
          if (number == -1) return NULL;
          ctx->new_count = (size_t)number;
        }
    }
  }
}

/* BufferGetAndValidate */
  static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (unlikely(info->buf == NULL)) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}
static void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}
static int __Pyx__GetBufferAndValidate(
        Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
        int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
  buf->buf = NULL;
  if (unlikely(__Pyx_GetBuffer(obj, buf, flags) == -1)) {
    __Pyx_ZeroBuffer(buf);
    return -1;
  }
  if (unlikely(buf->ndim != nd)) {
    PyErr_Format(PyExc_ValueError,
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
                 nd, buf->ndim);
    goto fail;
  }
  if (!cast) {
    __Pyx_BufFmt_Context ctx;
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  }
  if (unlikely((size_t)buf->itemsize != dtype->size)) {
    PyErr_Format(PyExc_ValueError,
      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
      dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
    goto fail;
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_SafeReleaseBuffer(buf);
  return -1;
}

/* RaiseArgTupleInvalid */
  static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* RaiseDoubleKeywords */
  static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

/* ParseKeywords */
  static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

/* None */
  static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

/* GetItemInt */
  static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyList_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              CYTHON_NCP_UNUSED int wraparound,
                                                              CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    Py_ssize_t wrapped_i = i;
    if (wraparound & unlikely(i < 0)) {
        wrapped_i += PyTuple_GET_SIZE(o);
    }
    if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                     CYTHON_NCP_UNUSED int wraparound,
                                                     CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return NULL;
                    PyErr_Clear();
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

/* PyFloatBinop */
  #if !CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(operand) if (unlikely(zerodivision_check && ((operand) == 0))) {\
    PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero");\
    return NULL;\
}
static PyObject* __Pyx_PyFloat_TrueDivideCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) {
    const double a = floatval;
    double b, result;
    (void)inplace;
    (void)zerodivision_check;
    if (likely(PyFloat_CheckExact(op2))) {
        b = PyFloat_AS_DOUBLE(op2);
        __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(b)
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        b = (double) PyInt_AS_LONG(op2);
        __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(b)
    } else
    #endif
    if (likely(PyLong_CheckExact(op2))) {
        #if CYTHON_USE_PYLONG_INTERNALS
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        switch (size) {
            case  0: __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(0) break;
            case -1: b = -(double) digits[0]; break;
            case  1: b = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -2)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -3)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -4)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            default:
        #else
        {
        #endif
            b = PyLong_AsDouble(op2);
            if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL;
            __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(b)
        }
    } else {
        return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
    }
        __Pyx_PyFloat_TrueDivideCObj_ZeroDivisionError(b)
        PyFPE_START_PROTECT("divide", return NULL)
        result = a / b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#endif

/* CIntToDigits */
    static const char DIGIT_PAIRS_10[2*10*10+1] = {
    "00010203040506070809"
    "10111213141516171819"
    "20212223242526272829"
    "30313233343536373839"
    "40414243444546474849"
    "50515253545556575859"
    "60616263646566676869"
    "70717273747576777879"
    "80818283848586878889"
    "90919293949596979899"
};
static const char DIGIT_PAIRS_8[2*8*8+1] = {
    "0001020304050607"
    "1011121314151617"
    "2021222324252627"
    "3031323334353637"
    "4041424344454647"
    "5051525354555657"
    "6061626364656667"
    "7071727374757677"
};
static const char DIGITS_HEX[2*16+1] = {
    "0123456789abcdef"
    "0123456789ABCDEF"
};

/* BuildPyUnicode */
    static PyObject* __Pyx_PyUnicode_BuildFromAscii(Py_ssize_t ulength, char* chars, int clength,
                                                int prepend_sign, char padding_char) {
    PyObject *uval;
    Py_ssize_t uoffset = ulength - clength;
#if CYTHON_USE_UNICODE_INTERNALS
    Py_ssize_t i;
#if CYTHON_PEP393_ENABLED
    void *udata;
    uval = PyUnicode_New(ulength, 127);
    if (unlikely(!uval)) return NULL;
    udata = PyUnicode_DATA(uval);
#else
    Py_UNICODE *udata;
    uval = PyUnicode_FromUnicode(NULL, ulength);
    if (unlikely(!uval)) return NULL;
    udata = PyUnicode_AS_UNICODE(uval);
#endif
    if (uoffset > 0) {
        i = 0;
        if (prepend_sign) {
            __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, 0, '-');
            i++;
        }
        for (; i < uoffset; i++) {
            __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, i, padding_char);
        }
    }
    for (i=0; i < clength; i++) {
        __Pyx_PyUnicode_WRITE(PyUnicode_1BYTE_KIND, udata, uoffset+i, chars[i]);
    }
#else
    {
        PyObject *sign = NULL, *padding = NULL;
        uval = NULL;
        if (uoffset > 0) {
            prepend_sign = !!prepend_sign;
            if (uoffset > prepend_sign) {
                padding = PyUnicode_FromOrdinal(padding_char);
                if (likely(padding) && uoffset > prepend_sign + 1) {
                    PyObject *tmp;
                    PyObject *repeat = PyInt_FromSsize_t(uoffset - prepend_sign);
                    if (unlikely(!repeat)) goto done_or_error;
                    tmp = PyNumber_Multiply(padding, repeat);
                    Py_DECREF(repeat);
                    Py_DECREF(padding);
                    padding = tmp;
                }
                if (unlikely(!padding)) goto done_or_error;
            }
            if (prepend_sign) {
                sign = PyUnicode_FromOrdinal('-');
                if (unlikely(!sign)) goto done_or_error;
            }
        }
        uval = PyUnicode_DecodeASCII(chars, clength, NULL);
        if (likely(uval) && padding) {
            PyObject *tmp = PyNumber_Add(padding, uval);
            Py_DECREF(uval);
            uval = tmp;
        }
        if (likely(uval) && sign) {
            PyObject *tmp = PyNumber_Add(sign, uval);
            Py_DECREF(uval);
            uval = tmp;
        }
done_or_error:
        Py_XDECREF(padding);
        Py_XDECREF(sign);
    }
#endif
    return uval;
}

/* CIntToPyUnicode */
    static CYTHON_INLINE PyObject* __Pyx_PyUnicode_From_int(int value, Py_ssize_t width, char padding_char, char format_char) {
    char digits[sizeof(int)*3+2];
    char *dpos, *end = digits + sizeof(int)*3+2;
    const char *hex_digits = DIGITS_HEX;
    Py_ssize_t length, ulength;
    int prepend_sign, last_one_off;
    int remaining;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (format_char == 'X') {
        hex_digits += 16;
        format_char = 'x';
    }
    remaining = value;
    last_one_off = 0;
    dpos = end;
    do {
        int digit_pos;
        switch (format_char) {
        case 'o':
            digit_pos = abs((int)(remaining % (8*8)));
            remaining = (int) (remaining / (8*8));
            dpos -= 2;
            memcpy(dpos, DIGIT_PAIRS_8 + digit_pos * 2, 2);
            last_one_off = (digit_pos < 8);
            break;
        case 'd':
            digit_pos = abs((int)(remaining % (10*10)));
            remaining = (int) (remaining / (10*10));
            dpos -= 2;
            memcpy(dpos, DIGIT_PAIRS_10 + digit_pos * 2, 2);
            last_one_off = (digit_pos < 10);
            break;
        case 'x':
            *(--dpos) = hex_digits[abs((int)(remaining % 16))];
            remaining = (int) (remaining / 16);
            break;
        default:
            assert(0);
            break;
        }
    } while (unlikely(remaining != 0));
    if (last_one_off) {
        assert(*dpos == '0');
        dpos++;
    }
    length = end - dpos;
    ulength = length;
    prepend_sign = 0;
    if (!is_unsigned && value <= neg_one) {
        if (padding_char == ' ' || width <= length + 1) {
            *(--dpos) = '-';
            ++length;
        } else {
            prepend_sign = 1;
        }
        ++ulength;
    }
    if (width > ulength) {
        ulength = width;
    }
    if (ulength == 1) {
        return PyUnicode_FromOrdinal(*dpos);
    }
    return __Pyx_PyUnicode_BuildFromAscii(ulength, dpos, (int) length, prepend_sign, padding_char);
}

/* PyObjectFormatAndDecref */
    static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
    if (unlikely(!s)) return NULL;
    if (likely(PyUnicode_CheckExact(s))) return s;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyString_CheckExact(s))) {
        PyObject *result = PyUnicode_FromEncodedObject(s, NULL, "strict");
        Py_DECREF(s);
        return result;
    }
    #endif
    return __Pyx_PyObject_FormatAndDecref(s, f);
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
    PyObject *result = PyObject_Format(s, f);
    Py_DECREF(s);
    return result;
}

/* JoinPyUnicode */
    static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength,
                                      CYTHON_UNUSED Py_UCS4 max_char) {
#if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    PyObject *result_uval;
    int result_ukind;
    Py_ssize_t i, char_pos;
    void *result_udata;
#if CYTHON_PEP393_ENABLED
    result_uval = PyUnicode_New(result_ulength, max_char);
    if (unlikely(!result_uval)) return NULL;
    result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
    result_udata = PyUnicode_DATA(result_uval);
#else
    result_uval = PyUnicode_FromUnicode(NULL, result_ulength);
    if (unlikely(!result_uval)) return NULL;
    result_ukind = sizeof(Py_UNICODE);
    result_udata = PyUnicode_AS_UNICODE(result_uval);
#endif
    char_pos = 0;
    for (i=0; i < value_count; i++) {
        int ukind;
        Py_ssize_t ulength;
        void *udata;
        PyObject *uval = PyTuple_GET_ITEM(value_tuple, i);
        if (unlikely(__Pyx_PyUnicode_READY(uval)))
            goto bad;
        ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
        if (unlikely(!ulength))
            continue;
        if (unlikely(char_pos + ulength < 0))
            goto overflow;
        ukind = __Pyx_PyUnicode_KIND(uval);
        udata = __Pyx_PyUnicode_DATA(uval);
        if (!CYTHON_PEP393_ENABLED || ukind == result_ukind) {
            memcpy((char *)result_udata + char_pos * result_ukind, udata, (size_t) (ulength * result_ukind));
        } else {
            #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters)
            _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
            #else
            Py_ssize_t j;
            for (j=0; j < ulength; j++) {
                Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
                __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
            }
            #endif
        }
        char_pos += ulength;
    }
    return result_uval;
overflow:
    PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
bad:
    Py_DECREF(result_uval);
    return NULL;
#else
    result_ulength++;
    value_count++;
    return PyUnicode_Join(__pyx_empty_unicode, value_tuple);
#endif
}

/* ArgTypeTest */
    static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (exact) {
        #if PY_MAJOR_VERSION == 2
        if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
        #endif
    }
    else {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

/* PyIntBinop */
    #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* ObjectGetItem */
    #if CYTHON_USE_TYPE_SLOTS
static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
    PyObject *runerr;
    Py_ssize_t key_value;
    PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
    if (unlikely(!(m && m->sq_item))) {
        PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
        return NULL;
    }
    key_value = __Pyx_PyIndex_AsSsize_t(index);
    if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
        return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
    }
    if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
        PyErr_Clear();
        PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
    }
    return NULL;
}
static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
    PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
    if (likely(m && m->mp_subscript)) {
        return m->mp_subscript(obj, key);
    }
    return __Pyx_PyObject_GetIndex(obj, key);
}
#endif

/* DivInt[long] */
    static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
    long q = a / b;
    long r = a - q*b;
    q -= ((r != 0) & ((r ^ b) < 0));
    return q;
}

/* SliceObject */
    static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
        Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_USE_TYPE_SLOTS
    PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3
    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
    if (likely(ms && ms->sq_slice)) {
        if (!has_cstart) {
            if (_py_start && (*_py_start != Py_None)) {
                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstart = 0;
        }
        if (!has_cstop) {
            if (_py_stop && (*_py_stop != Py_None)) {
                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
            } else
                cstop = PY_SSIZE_T_MAX;
        }
        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
            Py_ssize_t l = ms->sq_length(obj);
            if (likely(l >= 0)) {
                if (cstop < 0) {
                    cstop += l;
                    if (cstop < 0) cstop = 0;
                }
                if (cstart < 0) {
                    cstart += l;
                    if (cstart < 0) cstart = 0;
                }
            } else {
                if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                    goto bad;
                PyErr_Clear();
            }
        }
        return ms->sq_slice(obj, cstart, cstop);
    }
#endif
    mp = Py_TYPE(obj)->tp_as_mapping;
    if (likely(mp && mp->mp_subscript))
#endif
    {
        PyObject* result;
        PyObject *py_slice, *py_start, *py_stop;
        if (_py_slice) {
            py_slice = *_py_slice;
        } else {
            PyObject* owned_start = NULL;
            PyObject* owned_stop = NULL;
            if (_py_start) {
                py_start = *_py_start;
            } else {
                if (has_cstart) {
                    owned_start = py_start = PyInt_FromSsize_t(cstart);
                    if (unlikely(!py_start)) goto bad;
                } else
                    py_start = Py_None;
            }
            if (_py_stop) {
                py_stop = *_py_stop;
            } else {
                if (has_cstop) {
                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
                    if (unlikely(!py_stop)) {
                        Py_XDECREF(owned_start);
                        goto bad;
                    }
                } else
                    py_stop = Py_None;
            }
            py_slice = PySlice_New(py_start, py_stop, Py_None);
            Py_XDECREF(owned_start);
            Py_XDECREF(owned_stop);
            if (unlikely(!py_slice)) goto bad;
        }
#if CYTHON_USE_TYPE_SLOTS
        result = mp->mp_subscript(obj, py_slice);
#else
        result = PyObject_GetItem(obj, py_slice);
#endif
        if (!_py_slice) {
            Py_DECREF(py_slice);
        }
        return result;
    }
    PyErr_Format(PyExc_TypeError,
        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
bad:
    return NULL;
}

/* SetItemInt */
    static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
                                               CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                        return -1;
                    PyErr_Clear();
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
#else
    if (is_list || PySequence_Check(o))
#endif
    {
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

/* PyIntBinop */
    #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            x = (long)((unsigned long)a - b);
            if (likely((x^a) >= 0 || (x^~b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
            }
        }
                x = a - b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla - llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            PyFPE_START_PROTECT("subtract", return NULL)
            result = ((double)a) - (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
}
#endif

/* RaiseTooManyValuesToUnpack */
    static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

/* RaiseNeedMoreValuesToUnpack */
    static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

/* IterFinish */
    static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_FAST_THREAD_STATE
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

/* UnpackItemEndCheck */
    static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

/* BufferFallbackError */
    static void __Pyx_RaiseBufferFallbackError(void) {
  PyErr_SetString(PyExc_ValueError,
     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
}

/* PyIntCompare */
    static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
    if (op1 == op2) {
        Py_RETURN_TRUE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = Py_SIZE(op1);
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        if (intval == 0) {
            if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
        } else if (intval < 0) {
            if (size >= 0)
                Py_RETURN_FALSE;
            intval = -intval;
            size = -size;
        } else {
            if (size <= 0)
                Py_RETURN_FALSE;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
        if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    return (
        PyObject_RichCompare(op1, op2, Py_EQ));
}

/* PyFloatBinop */
    #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_AddCObj(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) {
    const double a = floatval;
    double b, result;
    (void)inplace;
    (void)zerodivision_check;
    if (likely(PyFloat_CheckExact(op2))) {
        b = PyFloat_AS_DOUBLE(op2);
        
    } else
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        b = (double) PyInt_AS_LONG(op2);
        
    } else
    #endif
    if (likely(PyLong_CheckExact(op2))) {
        #if CYTHON_USE_PYLONG_INTERNALS
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        switch (size) {
            case  0: b = 0.0; break;
            case -1: b = -(double) digits[0]; break;
            case  1: b = (double) digits[0]; break;
            case -2:
            case 2:
                if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                    b = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -2)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -3:
            case 3:
                if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -3)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            case -4:
            case 4:
                if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                    b = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (b < (double) ((PY_LONG_LONG)1 << 53))) {
                        if (size == -4)
                            b = -b;
                        break;
                    }
                }
                CYTHON_FALLTHROUGH;
            default:
        #else
        {
        #endif
            b = PyLong_AsDouble(op2);
            if (unlikely(b == -1.0 && PyErr_Occurred())) return NULL;
            
        }
    } else {
        return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
    }
        
        PyFPE_START_PROTECT("add", return NULL)
        result = a + b;
        PyFPE_END_PROTECT(result)
        return PyFloat_FromDouble(result);
}
#endif

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyInt_AddCObj(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op2))) {
        const long a = intval;
        long x;
        long b = PyInt_AS_LONG(op2);
            x = (long)((unsigned long)a + b);
            if (likely((x^a) >= 0 || (x^b) >= 0))
                return PyInt_FromLong(x);
            return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op2))) {
        const long a = intval;
        long b, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG lla = intval;
        PY_LONG_LONG llb, llx;
#endif
        const digit* digits = ((PyLongObject*)op2)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op2);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            b = likely(size) ? digits[0] : 0;
            if (size == -1) b = -b;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
            }
        }
                x = a + b;
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                llx = lla + llb;
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    if (PyFloat_CheckExact(op2)) {
        const long a = intval;
        double b = PyFloat_AS_DOUBLE(op2);
            double result;
            PyFPE_START_PROTECT("add", return NULL)
            result = ((double)a) + (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#endif

/* PyObjectFormat */
      #if CYTHON_USE_UNICODE_WRITER
static PyObject* __Pyx_PyObject_Format(PyObject* obj, PyObject* format_spec) {
    int ret;
    _PyUnicodeWriter writer;
    if (likely(PyFloat_CheckExact(obj))) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000
        _PyUnicodeWriter_Init(&writer, 0);
#else
        _PyUnicodeWriter_Init(&writer);
#endif
        ret = _PyFloat_FormatAdvancedWriter(
            &writer,
            obj,
            format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
    } else if (likely(PyLong_CheckExact(obj))) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x03040000
        _PyUnicodeWriter_Init(&writer, 0);
#else
        _PyUnicodeWriter_Init(&writer);
#endif
        ret = _PyLong_FormatAdvancedWriter(
            &writer,
            obj,
            format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
    } else {
        return PyObject_Format(obj, format_spec);
    }
    if (unlikely(ret == -1)) {
        _PyUnicodeWriter_Dealloc(&writer);
        return NULL;
    }
    return _PyUnicodeWriter_Finish(&writer);
}
#endif

/* GetTopmostException */
      #if CYTHON_USE_EXC_INFO_STACK
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
      #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    #endif
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}
#endif

/* PyErrExceptionMatches */
      #if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    PyObject *exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
    if (unlikely(PyTuple_Check(err)))
        return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
}
#endif

/* GetException */
      #if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
    #endif
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

/* BufferIndexError */
      static void __Pyx_RaiseBufferIndexError(int axis) {
  PyErr_Format(PyExc_IndexError,
     "Out of bounds on buffer access (axis %d)", axis);
}

/* DictGetItem */
      #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            if (unlikely(PyTuple_Check(key))) {
                PyObject* args = PyTuple_Pack(1, key);
                if (likely(args)) {
                    PyErr_SetObject(PyExc_KeyError, args);
                    Py_DECREF(args);
                }
            } else {
                PyErr_SetObject(PyExc_KeyError, key);
            }
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#endif

/* GetAttr */
      static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
#if CYTHON_USE_TYPE_SLOTS
#if PY_MAJOR_VERSION >= 3
    if (likely(PyUnicode_Check(n)))
#else
    if (likely(PyString_Check(n)))
#endif
        return __Pyx_PyObject_GetAttrStr(o, n);
#endif
    return PyObject_GetAttr(o, n);
}

/* GetAttr3 */
      static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r = __Pyx_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
}

/* PyObjectSetAttrStr */
      #if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_setattr))
        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
#endif
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* CIntToPyUnicode */
      static CYTHON_INLINE PyObject* __Pyx_PyUnicode_From_long(long value, Py_ssize_t width, char padding_char, char format_char) {
    char digits[sizeof(long)*3+2];
    char *dpos, *end = digits + sizeof(long)*3+2;
    const char *hex_digits = DIGITS_HEX;
    Py_ssize_t length, ulength;
    int prepend_sign, last_one_off;
    long remaining;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (format_char == 'X') {
        hex_digits += 16;
        format_char = 'x';
    }
    remaining = value;
    last_one_off = 0;
    dpos = end;
    do {
        int digit_pos;
        switch (format_char) {
        case 'o':
            digit_pos = abs((int)(remaining % (8*8)));
            remaining = (long) (remaining / (8*8));
            dpos -= 2;
            memcpy(dpos, DIGIT_PAIRS_8 + digit_pos * 2, 2);
            last_one_off = (digit_pos < 8);
            break;
        case 'd':
            digit_pos = abs((int)(remaining % (10*10)));
            remaining = (long) (remaining / (10*10));
            dpos -= 2;
            memcpy(dpos, DIGIT_PAIRS_10 + digit_pos * 2, 2);
            last_one_off = (digit_pos < 10);
            break;
        case 'x':
            *(--dpos) = hex_digits[abs((int)(remaining % 16))];
            remaining = (long) (remaining / 16);
            break;
        default:
            assert(0);
            break;
        }
    } while (unlikely(remaining != 0));
    if (last_one_off) {
        assert(*dpos == '0');
        dpos++;
    }
    length = end - dpos;
    ulength = length;
    prepend_sign = 0;
    if (!is_unsigned && value <= neg_one) {
        if (padding_char == ' ' || width <= length + 1) {
            *(--dpos) = '-';
            ++length;
        } else {
            prepend_sign = 1;
        }
        ++ulength;
    }
    if (width > ulength) {
        ulength = width;
    }
    if (ulength == 1) {
        return PyUnicode_FromOrdinal(*dpos);
    }
    return __Pyx_PyUnicode_BuildFromAscii(ulength, dpos, (int) length, prepend_sign, padding_char);
}

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_TrueDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b)
            if (8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53))) {
                return PyFloat_FromDouble((double)a / (double)b);
            }
            return PyInt_Type.tp_as_number->nb_true_divide(op1, op2);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
            }
        }
                __Pyx_PyInt_TrueDivideObjC_ZeroDivisionError(b)
                if ((8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53)))
                        || __Pyx_sst_abs(size) <= 52 / PyLong_SHIFT) {
                    return PyFloat_FromDouble((double)a / (double)b);
                }
                return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
            return PyLong_FromLong(x);
        
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
            double result;
            if (unlikely(zerodivision_check && b == 0)) {
                PyErr_SetString(PyExc_ZeroDivisionError, "float division by zero");
                return NULL;
            }
            PyFPE_START_PROTECT("divide", return NULL)
            result = ((double)a) / (double)b;
            PyFPE_END_PROTECT(result)
            return PyFloat_FromDouble(result);
    }
    return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
}
#endif

/* PyIntBinop */
      #if !CYTHON_COMPILING_IN_PYPY
#if PY_MAJOR_VERSION < 3 || CYTHON_USE_PYLONG_INTERNALS
#define __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(operand)\
    if (unlikely(zerodivision_check && ((operand) == 0))) {\
        PyErr_SetString(PyExc_ZeroDivisionError, "integer division by zero");\
        return NULL;\
    }
#endif
static PyObject* __Pyx_PyInt_FloorDivideObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
    (void)inplace;
    (void)zerodivision_check;
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long x;
        long a = PyInt_AS_LONG(op1);
            __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(b)
            if (unlikely(b == -1 && ((unsigned long)a) == 0-(unsigned long)a))
                return PyInt_Type.tp_as_number->nb_floor_divide(op1, op2);
            else {
                long q, r;
                q = a / b;
                r = a - q*b;
                q -= ((r != 0) & ((r ^ b) < 0));
                x = q;
            }
            return PyInt_FromLong(x);
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        const long b = intval;
        long a, x;
#ifdef HAVE_LONG_LONG
        const PY_LONG_LONG llb = intval;
        PY_LONG_LONG lla, llx;
#endif
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        const Py_ssize_t size = Py_SIZE(op1);
        if (likely(__Pyx_sst_abs(size) <= 1)) {
            a = likely(size) ? digits[0] : 0;
            if (size == -1) a = -a;
        } else {
            switch (size) {
                case -2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 2:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 3:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case -4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                case 4:
                    if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                        a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                        break;
#ifdef HAVE_LONG_LONG
                    } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                        lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                        goto long_long;
#endif
                    }
                    CYTHON_FALLTHROUGH;
                default: return PyLong_Type.tp_as_number->nb_floor_divide(op1, op2);
            }
        }
                __Pyx_PyInt_FloorDivideObjC_ZeroDivisionError(b)
                {
                    long q, r;
                    q = a / b;
                    r = a - q*b;
                    q -= ((r != 0) & ((r ^ b) < 0));
                    x = q;
                }
            return PyLong_FromLong(x);
#ifdef HAVE_LONG_LONG
        long_long:
                {
                    PY_LONG_LONG q, r;
                    q = lla / llb;
                    r = lla - q*llb;
                    q -= ((r != 0) & ((r ^ llb) < 0));
                    llx = q;
                }
            return PyLong_FromLongLong(llx);
#endif
        
        
    }
    #endif
    return (inplace ? PyNumber_InPlaceFloorDivide : PyNumber_FloorDivide)(op1, op2);
}
#endif

/* IterNext */
      static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
    PyObject* exc_type;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    exc_type = __Pyx_PyErr_Occurred();
    if (unlikely(exc_type)) {
        if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
            return NULL;
        __Pyx_PyErr_Clear();
        Py_INCREF(defval);
        return defval;
    }
    if (defval) {
        Py_INCREF(defval);
        return defval;
    }
    __Pyx_PyErr_SetNone(PyExc_StopIteration);
    return NULL;
}
static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
    PyErr_Format(PyExc_TypeError,
        "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
}
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
    PyObject* next;
    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
    if (likely(iternext)) {
#if CYTHON_USE_TYPE_SLOTS
        next = iternext(iterator);
        if (likely(next))
            return next;
        #if PY_VERSION_HEX >= 0x02070000
        if (unlikely(iternext == &_PyObject_NextNotImplemented))
            return NULL;
        #endif
#else
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
#endif
    } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) {
        __Pyx_PyIter_Next_ErrorNoIterator(iterator);
        return NULL;
    }
#if !CYTHON_USE_TYPE_SLOTS
    else {
        next = PyIter_Next(iterator);
        if (likely(next))
            return next;
    }
#endif
    return __Pyx_PyIter_Next2Default(defval);
}

/* None */
      static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

/* RaiseException */
      #if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    __Pyx_PyThreadState_declare
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    if (PyType_Check(type)) {
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if CYTHON_COMPILING_IN_PYPY
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#else
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

/* PyIntCompare */
      static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
    if (op1 == op2) {
        Py_RETURN_FALSE;
    }
    #if PY_MAJOR_VERSION < 3
    if (likely(PyInt_CheckExact(op1))) {
        const long b = intval;
        long a = PyInt_AS_LONG(op1);
        if (a != b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = Py_SIZE(op1);
        const digit* digits = ((PyLongObject*)op1)->ob_digit;
        if (intval == 0) {
            if (size != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
        } else if (intval < 0) {
            if (size >= 0)
                Py_RETURN_TRUE;
            intval = -intval;
            size = -size;
        } else {
            if (size <= 0)
                Py_RETURN_TRUE;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        if (unequal != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = PyFloat_AS_DOUBLE(op1);
        if ((double)a != (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
    }
    return (
        PyObject_RichCompare(op1, op2, Py_NE));
}

/* pyobject_as_double */
      static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
#if !CYTHON_USE_TYPE_SLOTS
    float_value = PyNumber_Float(obj);  if ((0)) goto bad;
#else
    PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
    if (likely(nb) && likely(nb->nb_float)) {
        float_value = nb->nb_float(obj);
        if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
            PyErr_Format(PyExc_TypeError,
                "__float__ returned non-float (type %.200s)",
                Py_TYPE(float_value)->tp_name);
            Py_DECREF(float_value);
            goto bad;
        }
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
#endif
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-1;
}

/* pyfrozenset_new */
      static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
    if (it) {
        PyObject* result;
#if CYTHON_COMPILING_IN_PYPY
        PyObject* args;
        args = PyTuple_Pack(1, it);
        if (unlikely(!args))
            return NULL;
        result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
        Py_DECREF(args);
        return result;
#else
        if (PyFrozenSet_CheckExact(it)) {
            Py_INCREF(it);
            return it;
        }
        result = PyFrozenSet_New(it);
        if (unlikely(!result))
            return NULL;
        if ((PY_VERSION_HEX >= 0x031000A1) || likely(PySet_GET_SIZE(result)))
            return result;
        Py_DECREF(result);
#endif
    }
#if CYTHON_USE_TYPE_SLOTS
    return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#else
    return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL);
#endif
}

/* PySetContains */
      static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
    int result = -1;
    if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
        PyObject *tmpkey;
        PyErr_Clear();
        tmpkey = __Pyx_PyFrozenSet_New(key);
        if (tmpkey != NULL) {
            result = PySet_Contains(set, tmpkey);
            Py_DECREF(tmpkey);
        }
    }
    return result;
}
static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
    int result = PySet_Contains(set, key);
    if (unlikely(result < 0)) {
        result = __Pyx_PySet_ContainsUnhashable(set, key);
    }
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* UnpackUnboundCMethod */
      static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    target->method = method;
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION >= 3
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    #endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    }
#endif
    return 0;
}

/* CallUnboundCMethod1 */
      #if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
    if (likely(cfunc->func)) {
        int flag = cfunc->flag;
        if (flag == METH_O) {
            return (*(cfunc->func))(self, arg);
        } else if (PY_VERSION_HEX >= 0x030600B1 && flag == METH_FASTCALL) {
            if (PY_VERSION_HEX >= 0x030700A0) {
                return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1);
            } else {
                return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
            }
        } else if (PY_VERSION_HEX >= 0x030700A0 && flag == (METH_FASTCALL | METH_KEYWORDS)) {
            return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL);
        }
    }
    return __Pyx__CallUnboundCMethod1(cfunc, self, arg);
}
#endif
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
    PyObject *args, *result = NULL;
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 0, arg);
        if (cfunc->flag & METH_KEYWORDS)
            result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL);
        else
            result = (*cfunc->func)(self, args);
    } else {
        args = PyTuple_New(2);
        if (unlikely(!args)) goto bad;
        Py_INCREF(self);
        PyTuple_SET_ITEM(args, 0, self);
        Py_INCREF(arg);
        PyTuple_SET_ITEM(args, 1, arg);
        result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
    }
#else
    args = PyTuple_Pack(2, self, arg);
    if (unlikely(!args)) goto bad;
    result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
#endif
bad:
    Py_XDECREF(args);
    return result;
}

/* Import */
      static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0;
        }
        #endif
        if (!module) {
            #if PY_MAJOR_VERSION < 3
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
bad:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* ImportFrom */
      static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

/* HasAttr */
      static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!__Pyx_PyBaseString_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_GetAttr(o, n);
    if (unlikely(!r)) {
        PyErr_Clear();
        return 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}

/* WriteUnraisableException */
      static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback, CYTHON_UNUSED int nogil) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_PyThreadState_declare
#ifdef WITH_THREAD
    PyGILState_STATE state;
    if (nogil)
        state = PyGILState_Ensure();
#ifdef _MSC_VER
    else state = (PyGILState_STATE)-1;
#endif
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
#ifdef WITH_THREAD
    if (nogil)
        PyGILState_Release(state);
#endif
}

/* PyObject_GenericGetAttrNoDict */
      #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, attr_name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(attr_name));
#endif
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
    PyObject *descr;
    PyTypeObject *tp = Py_TYPE(obj);
    if (unlikely(!PyString_Check(attr_name))) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    assert(!tp->tp_dictoffset);
    descr = _PyType_Lookup(tp, attr_name);
    if (unlikely(!descr)) {
        return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
    }
    Py_INCREF(descr);
    #if PY_MAJOR_VERSION < 3
    if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
    #endif
    {
        descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
        if (unlikely(f)) {
            PyObject *res = f(descr, obj, (PyObject *)tp);
            Py_DECREF(descr);
            return res;
        }
    }
    return descr;
}
#endif

/* PyObject_GenericGetAttr */
      #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
    if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
        return PyObject_GenericGetAttr(obj, attr_name);
    }
    return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
}
#endif

/* PyObjectGetAttrStrNoError */
      static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
}

/* SetupReduce */
      static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
  int ret;
  PyObject *name_attr;
  name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
  if (likely(name_attr)) {
      ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
  } else {
      ret = -1;
  }
  if (unlikely(ret < 0)) {
      PyErr_Clear();
      ret = 0;
  }
  Py_XDECREF(name_attr);
  return ret;
}
static int __Pyx_setup_reduce(PyObject* type_obj) {
    int ret = 0;
    PyObject *object_reduce = NULL;
    PyObject *object_getstate = NULL;
    PyObject *object_reduce_ex = NULL;
    PyObject *reduce = NULL;
    PyObject *reduce_ex = NULL;
    PyObject *reduce_cython = NULL;
    PyObject *setstate = NULL;
    PyObject *setstate_cython = NULL;
    PyObject *getstate = NULL;
#if CYTHON_USE_PYTYPE_LOOKUP
    getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate);
#else
    getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate);
    if (!getstate && PyErr_Occurred()) {
        goto __PYX_BAD;
    }
#endif
    if (getstate) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate);
#else
        object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate);
        if (!object_getstate && PyErr_Occurred()) {
            goto __PYX_BAD;
        }
#endif
        if (object_getstate != getstate) {
            goto __PYX_GOOD;
        }
    }
#if CYTHON_USE_PYTYPE_LOOKUP
    object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#else
    object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
#endif
    reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
    if (reduce_ex == object_reduce_ex) {
#if CYTHON_USE_PYTYPE_LOOKUP
        object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#else
        object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
#endif
        reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
        if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
            reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
            if (likely(reduce_cython)) {
                ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
            } else if (reduce == object_reduce || PyErr_Occurred()) {
                goto __PYX_BAD;
            }
            setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
            if (!setstate) PyErr_Clear();
            if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
                setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
                if (likely(setstate_cython)) {
                    ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                    ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
                } else if (!setstate || PyErr_Occurred()) {
                    goto __PYX_BAD;
                }
            }
            PyType_Modified((PyTypeObject*)type_obj);
        }
    }
    goto __PYX_GOOD;
__PYX_BAD:
    if (!PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
    ret = -1;
__PYX_GOOD:
#if !CYTHON_USE_PYTYPE_LOOKUP
    Py_XDECREF(object_reduce);
    Py_XDECREF(object_reduce_ex);
    Py_XDECREF(object_getstate);
    Py_XDECREF(getstate);
#endif
    Py_XDECREF(reduce);
    Py_XDECREF(reduce_ex);
    Py_XDECREF(reduce_cython);
    Py_XDECREF(setstate);
    Py_XDECREF(setstate_cython);
    return ret;
}

/* SetVTable */
      static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

/* TypeImport */
      #ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
    size_t size, enum __Pyx_ImportType_CheckSize check_size)
{
    PyObject *result = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    result = PyObject_GetAttrString(module, class_name);
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if ((size_t)basicsize < size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        goto bad;
    }
    else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility. "
            "Expected %zd from C header, got %zd from PyObject",
            module_name, class_name, size, basicsize);
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return NULL;
}
#endif

/* ClassMethod */
      static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
#if CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM <= 0x05080000
    if (PyObject_TypeCheck(method, &PyWrapperDescr_Type)) {
        return PyClassMethod_New(method);
    }
#else
#if CYTHON_COMPILING_IN_PYSTON || CYTHON_COMPILING_IN_PYPY
    if (PyMethodDescr_Check(method))
#else
    #if PY_MAJOR_VERSION == 2
    static PyTypeObject *methoddescr_type = NULL;
    if (methoddescr_type == NULL) {
       PyObject *meth = PyObject_GetAttrString((PyObject*)&PyList_Type, "append");
       if (!meth) return NULL;
       methoddescr_type = Py_TYPE(meth);
       Py_DECREF(meth);
    }
    #else
    PyTypeObject *methoddescr_type = &PyMethodDescr_Type;
    #endif
    if (__Pyx_TypeCheck(method, methoddescr_type))
#endif
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
        #if PY_VERSION_HEX < 0x03020000
        PyTypeObject *d_type = descr->d_type;
        #else
        PyTypeObject *d_type = descr->d_common.d_type;
        #endif
        return PyDescr_NewClassMethod(d_type, descr->d_method);
    }
#endif
    else if (PyMethod_Check(method)) {
        return PyClassMethod_New(PyMethod_GET_FUNCTION(method));
    }
    else {
        return PyClassMethod_New(method);
    }
}

/* GetNameInClass */
      static PyObject *__Pyx_GetGlobalNameAfterAttributeLookup(PyObject *name) {
    PyObject *result;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    __Pyx_GetModuleGlobalNameUncached(result, name);
    return result;
}
static PyObject *__Pyx__GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result) {
        result = __Pyx_GetGlobalNameAfterAttributeLookup(name);
    }
    return result;
}

/* CLineInTraceback */
      #ifndef CYTHON_CLINE_IN_TRACEBACK
static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
    PyObject *use_cline;
    PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject **cython_runtime_dict;
#endif
    if (unlikely(!__pyx_cython_runtime)) {
        return c_line;
    }
    __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
#if CYTHON_COMPILING_IN_CPYTHON
    cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
    if (likely(cython_runtime_dict)) {
        __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
            use_cline, *cython_runtime_dict,
            __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
    } else
#endif
    {
      PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
      if (use_cline_obj) {
        use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
        Py_DECREF(use_cline_obj);
      } else {
        PyErr_Clear();
        use_cline = NULL;
      }
    }
    if (!use_cline) {
        c_line = 0;
        (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
    }
    else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
        c_line = 0;
    }
    __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
    return c_line;
}
#endif

/* CodeObjectCache */
      static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = start + (end - start) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

/* AddTraceback */
      #include "compile.h"
#include "frameobject.h"
#include "traceback.h"
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = NULL;
    PyObject *py_funcname = NULL;
    #if PY_MAJOR_VERSION < 3
    PyObject *py_srcfile = NULL;
    py_srcfile = PyString_FromString(filename);
    if (!py_srcfile) goto bad;
    #endif
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        if (!py_funcname) goto bad;
        funcname = PyUnicode_AsUTF8(py_funcname);
        if (!funcname) goto bad;
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        if (!py_funcname) goto bad;
        #endif
    }
    #if PY_MAJOR_VERSION < 3
    py_code = __Pyx_PyCode_New(
        0,
        0,
        0,
        0,
        0,
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    #else
    py_code = PyCode_NewEmpty(filename, funcname, py_line);
    #endif
    Py_XDECREF(py_funcname);  // XDECREF since it's only set on Py3 if cline
    return py_code;
bad:
    Py_XDECREF(py_funcname);
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(py_srcfile);
    #endif
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    PyThreadState *tstate = __Pyx_PyThreadState_Current;
    PyObject *ptype, *pvalue, *ptraceback;
    if (c_line) {
        c_line = __Pyx_CLineForTraceback(tstate, c_line);
    }
    py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
    if (!py_code) {
        __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) {
            /* If the code object creation fails, then we should clear the
               fetched exception references and propagate the new exception */
            Py_XDECREF(ptype);
            Py_XDECREF(pvalue);
            Py_XDECREF(ptraceback);
            goto bad;
        }
        __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
        __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
    }
    py_frame = PyFrame_New(
        tstate,            /*PyThreadState *tstate,*/
        py_code,           /*PyCodeObject *code,*/
        __pyx_d,    /*PyObject *globals,*/
        0                  /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

/* CIntFromPyVerify */
      #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
    __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
    {\
        func_type value = func_value;\
        if (sizeof(target_type) < sizeof(func_type)) {\
            if (unlikely(value != (func_type) (target_type) value)) {\
                func_type zero = 0;\
                if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                    return (target_type) -1;\
                if (is_unsigned && unlikely(value < zero))\
                    goto raise_neg_overflow;\
                else\
                    goto raise_overflow;\
            }\
        }\
        return (target_type) value;\
    }

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
    if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
    PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
    return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
    PyObject *obj = view->obj;
    if (!obj) return;
    if (PyObject_CheckBuffer(obj)) {
        PyBuffer_Release(view);
        return;
    }
    if ((0)) {}
    view->obj = NULL;
    Py_DECREF(obj);
}
#endif


      /* Declarations */
      #if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* Arithmetic */
      #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sum_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_diff_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prod_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabsf(b.real) >= fabsf(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                float r = b.imag / b.real;
                float s = (float)(1.0) / (b.real + b.imag * r);
                return __pyx_t_float_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            float r = b.real / b.imag;
            float s = (float)(1.0) / (b.imag + b.real * r);
            return __pyx_t_float_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quot_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        if (b.imag == 0) {
            return __pyx_t_float_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            float denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_float_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_neg_float(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero_float(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conj_float(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_abs_float(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_pow_float(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        return __Pyx_c_prod_float(a, a);
                    case 3:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, a);
                    case 4:
                        z = __Pyx_c_prod_float(a, a);
                        return __Pyx_c_prod_float(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = powf(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2f(0.0, -1.0);
                }
            } else {
                r = __Pyx_c_abs_float(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

/* Declarations */
      #if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

/* Arithmetic */
      #if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    #if 1
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        if (b.imag == 0) {
            return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else if (fabs(b.real) >= fabs(b.imag)) {
            if (b.real == 0 && b.imag == 0) {
                return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
            } else {
                double r = b.imag / b.real;
                double s = (double)(1.0) / (b.real + b.imag * r);
                return __pyx_t_double_complex_from_parts(
                    (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
            }
        } else {
            double r = b.real / b.imag;
            double s = (double)(1.0) / (b.imag + b.real * r);
            return __pyx_t_double_complex_from_parts(
                (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
        }
    }
    #else
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        if (b.imag == 0) {
            return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
        } else {
            double denom = b.real * b.real + b.imag * b.imag;
            return __pyx_t_double_complex_from_parts(
                (a.real * b.real + a.imag * b.imag) / denom,
                (a.imag * b.real - a.real * b.imag) / denom);
        }
    }
    #endif
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrt(z.real*z.real + z.imag*z.imag);
          #else
            return hypot(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
            __pyx_t_double_complex z;
            double r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    double denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        return __Pyx_c_prod_double(a, a);
                    case 3:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(z, a);
                    case 4:
                        z = __Pyx_c_prod_double(a, a);
                        return __Pyx_c_prod_double(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                } else if (b.imag == 0) {
                    z.real = pow(a.real, b.real);
                    z.imag = 0;
                    return z;
                } else if (a.real > 0) {
                    r = a.real;
                    theta = 0;
                } else {
                    r = -a.real;
                    theta = atan2(0.0, -1.0);
                }
            } else {
                r = __Pyx_c_abs_double(a);
                theta = atan2(a.imag, a.real);
            }
            lnr = log(r);
            z_r = exp(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cos(z_theta);
            z.imag = z_r * sin(z_theta);
            return z;
        }
    #endif
#endif

/* CIntToPy */
      static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
      static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const int neg_one = (int) -1, const_zero = (int) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case  1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
                            return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
                            return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
                            return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (int) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (int) 0;
                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                            return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                            return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
                            return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to int");
    return (int) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to int");
    return (int) -1;
}

/* CIntFromPy */
      static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case  1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
                            return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
                            return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
                            return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (long) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (long) 0;
                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                            return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                            return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                            return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to long");
    return (long) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to long");
    return (long) -1;
}

/* CIntToPy */
      static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const long neg_one = (long) -1, const_zero = (long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
      static CYTHON_INLINE PyObject* __Pyx_PyInt_From_npy_long(npy_long value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const npy_long neg_one = (npy_long) -1, const_zero = (npy_long) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(npy_long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(npy_long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(npy_long) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(npy_long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(npy_long) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(npy_long),
                                     little, !is_unsigned);
    }
}

/* CIntToPy */
      static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(Py_intptr_t) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
#endif
        }
    } else {
        if (sizeof(Py_intptr_t) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
#ifdef HAVE_LONG_LONG
        } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
            return PyLong_FromLongLong((PY_LONG_LONG) value);
#endif
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t),
                                     little, !is_unsigned);
    }
}

/* CIntFromPy */
      static CYTHON_INLINE Py_intptr_t __Pyx_PyInt_As_Py_intptr_t(PyObject *x) {
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
    const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = (Py_intptr_t) 0;
#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(Py_intptr_t) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, PyInt_AS_LONG(x))
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                goto raise_neg_overflow;
            }
            return (Py_intptr_t) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Py_intptr_t) 0;
                case  1: __PYX_VERIFY_RETURN_INT(Py_intptr_t, digit, digits[0])
                case 2:
                    if (8 * sizeof(Py_intptr_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) >= 2 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0]));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Py_intptr_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) >= 3 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0]));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Py_intptr_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) >= 4 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | (Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0]));
                        }
                    }
                    break;
            }
#endif
#if CYTHON_COMPILING_IN_CPYTHON
            if (unlikely(Py_SIZE(x) < 0)) {
                goto raise_neg_overflow;
            }
#else
            {
                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
                if (unlikely(result < 0))
                    return (Py_intptr_t) -1;
                if (unlikely(result == 1))
                    goto raise_neg_overflow;
            }
#endif
            if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, unsigned long, PyLong_AsUnsignedLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(Py_intptr_t) <= sizeof(unsigned PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
#endif
            }
        } else {
#if CYTHON_USE_PYLONG_INTERNALS
            const digit* digits = ((PyLongObject*)x)->ob_digit;
            switch (Py_SIZE(x)) {
                case  0: return (Py_intptr_t) 0;
                case -1: __PYX_VERIFY_RETURN_INT(Py_intptr_t, sdigit, (sdigit) (-(sdigit)digits[0]))
                case  1: __PYX_VERIFY_RETURN_INT(Py_intptr_t,  digit, +digits[0])
                case -2:
                    if (8 * sizeof(Py_intptr_t) - 1 > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((Py_intptr_t)-1)*(((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
                        }
                    }
                    break;
                case 2:
                    if (8 * sizeof(Py_intptr_t) > 1 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
                            return (Py_intptr_t) ((((((Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
                        }
                    }
                    break;
                case -3:
                    if (8 * sizeof(Py_intptr_t) - 1 > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((Py_intptr_t)-1)*(((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
                        }
                    }
                    break;
                case 3:
                    if (8 * sizeof(Py_intptr_t) > 2 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
                            return (Py_intptr_t) ((((((((Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
                        }
                    }
                    break;
                case -4:
                    if (8 * sizeof(Py_intptr_t) - 1 > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 4 * PyLong_SHIFT) {
                            return (Py_intptr_t) (((Py_intptr_t)-1)*(((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | (Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
                        }
                    }
                    break;
                case 4:
                    if (8 * sizeof(Py_intptr_t) > 3 * PyLong_SHIFT) {
                        if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
                            __PYX_VERIFY_RETURN_INT(Py_intptr_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                        } else if (8 * sizeof(Py_intptr_t) - 1 > 4 * PyLong_SHIFT) {
                            return (Py_intptr_t) ((((((((((Py_intptr_t)digits[3]) << PyLong_SHIFT) | (Py_intptr_t)digits[2]) << PyLong_SHIFT) | (Py_intptr_t)digits[1]) << PyLong_SHIFT) | (Py_intptr_t)digits[0])));
                        }
                    }
                    break;
            }
#endif
            if (sizeof(Py_intptr_t) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, long, PyLong_AsLong(x))
#ifdef HAVE_LONG_LONG
            } else if (sizeof(Py_intptr_t) <= sizeof(PY_LONG_LONG)) {
                __PYX_VERIFY_RETURN_INT_EXC(Py_intptr_t, PY_LONG_LONG, PyLong_AsLongLong(x))
#endif
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            Py_intptr_t val;
            PyObject *v = __Pyx_PyNumber_IntOrLong(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (Py_intptr_t) -1;
        }
    } else {
        Py_intptr_t val;
        PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
        if (!tmp) return (Py_intptr_t) -1;
        val = __Pyx_PyInt_As_Py_intptr_t(tmp);
        Py_DECREF(tmp);
        return val;
    }
raise_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "value too large to convert to Py_intptr_t");
    return (Py_intptr_t) -1;
raise_neg_overflow:
    PyErr_SetString(PyExc_OverflowError,
        "can't convert negative value to Py_intptr_t");
    return (Py_intptr_t) -1;
}

/* FastTypeChecks */
      #if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = a->tp_base;
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
#if PY_MAJOR_VERSION == 2
static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
    PyObject *exception, *value, *tb;
    int res;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&exception, &value, &tb);
    res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
    if (unlikely(res == -1)) {
        PyErr_WriteUnraisable(err);
        res = 0;
    }
    if (!res) {
        res = PyObject_IsSubclass(err, exc_type2);
        if (unlikely(res == -1)) {
            PyErr_WriteUnraisable(err);
            res = 0;
        }
    }
    __Pyx_ErrRestore(exception, value, tb);
    return res;
}
#else
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
    if (!res) {
        res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
    return res;
}
#endif
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
#if PY_MAJOR_VERSION >= 3
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
#endif
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        #if PY_MAJOR_VERSION < 3
        if (likely(exc_type == t)) return 1;
        #endif
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* FetchCommonType */
      static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* SwapException */
      #if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
    #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* PyObjectGetMethod */
      static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if PY_MAJOR_VERSION >= 3
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
        #endif
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (descr != NULL) {
        *method = descr;
        return 0;
    }
    PyErr_Format(PyExc_AttributeError,
#if PY_MAJOR_VERSION >= 3
                 "'%.50s' object has no attribute '%U'",
                 tp->tp_name, name);
#else
                 "'%.50s' object has no attribute '%.400s'",
                 tp->tp_name, PyString_AS_STRING(name));
#endif
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}

/* PyObjectCallMethod1 */
      static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
}

/* CoroutineBase */
      #include <structmember.h>
#include <frameobject.h>
#if PY_VERSION_HEX >= 0x030b00a6
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
#define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
static int __Pyx_PyGen__FetchStopIterationValue(CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (!ev) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#if PY_VERSION_HEX >= 0x030300A0
        else if (Py_TYPE(ev) == (PyTypeObject*)PyExc_StopIteration) {
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            Py_DECREF(ev);
        }
#endif
        else if (unlikely(PyTuple_Check(ev))) {
            if (PyTuple_GET_SIZE(ev) >= 1) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                value = PyTuple_GET_ITEM(ev, 0);
                Py_INCREF(value);
#else
                value = PySequence_ITEM(ev, 0);
#endif
            } else {
                Py_INCREF(Py_None);
                value = Py_None;
            }
            Py_DECREF(ev);
        }
        else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PySequence_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *t, *v, *tb;
    t = exc_state->exc_type;
    v = exc_state->exc_value;
    tb = exc_state->exc_traceback;
    exc_state->exc_type = NULL;
    exc_state->exc_value = NULL;
    exc_state->exc_traceback = NULL;
    Py_XDECREF(t);
    Py_XDECREF(v);
    Py_XDECREF(tb);
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(CYTHON_UNUSED __pyx_CoroutineObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
#define __Pyx_Coroutine_NotStartedError(gen)  (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_NotStartedError(CYTHON_UNUSED PyObject *gen) {
    const char *msg;
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check(gen)) {
        msg = "can't send non-None value to a just-started coroutine";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact(gen)) {
        msg = "can't send non-None value to a just-started async generator";
    #endif
    } else {
        msg = "can't send non-None value to a just-started generator";
    }
    PyErr_SetString(PyExc_TypeError, msg);
}
#define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing)  (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyTerminatedError(CYTHON_UNUSED PyObject *gen, PyObject *value, CYTHON_UNUSED int closing) {
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_Check(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    __Pyx_ExcInfoStruct *exc_state;
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            return __Pyx_Coroutine_NotStartedError((PyObject*)self);
        }
    }
    if (unlikely(self->resume_label == -1)) {
        return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    exc_state = &self->gi_exc_state;
    if (exc_state->exc_type) {
        #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
        #else
        if (exc_state->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) exc_state->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            assert(f->f_back == NULL);
            #if PY_VERSION_HEX >= 0x030B00A1
            f->f_back = PyThreadState_GetFrame(tstate);
            #else
            Py_XINCREF(tstate->frame);
            f->f_back = tstate->frame;
            #endif
        }
        #endif
    }
#if CYTHON_USE_EXC_INFO_STACK
    exc_state->previous_item = tstate->exc_info;
    tstate->exc_info = exc_state;
#else
    if (exc_state->exc_type) {
        __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(exc_state);
        __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    }
#endif
    self->is_running = 1;
    retval = self->body((PyObject *) self, tstate, value);
    self->is_running = 0;
#if CYTHON_USE_EXC_INFO_STACK
    exc_state = &self->gi_exc_state;
    tstate->exc_info = exc_state->previous_item;
    exc_state->previous_item = NULL;
    __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
#endif
    return retval;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
    PyObject *exc_tb = exc_state->exc_traceback;
    if (likely(exc_tb)) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_PYSTON
#else
        PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
#endif
    }
}
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_MethodReturn(CYTHON_UNUSED PyObject* gen, PyObject *retval) {
    if (unlikely(!retval)) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        if (!__Pyx_PyErr_Occurred()) {
            PyObject *exc = PyExc_StopIteration;
            #ifdef __Pyx_AsyncGen_USED
            if (__Pyx_AsyncGen_CheckExact(gen))
                exc = __Pyx_PyExc_StopAsyncIteration;
            #endif
            __Pyx_PyErr_SetNone(exc);
        }
    }
    return retval;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
static CYTHON_INLINE
PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
#if PY_VERSION_HEX <= 0x030A00A1
    return _PyGen_Send(gen, arg);
#else
    PyObject *result;
    if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
        if (PyAsyncGen_CheckExact(gen)) {
            assert(result == Py_None);
            PyErr_SetNone(PyExc_StopAsyncIteration);
        }
        else if (result == Py_None) {
            PyErr_SetNone(PyExc_StopIteration);
        }
        else {
            _PyGen_SetStopIterationValue(result);
        }
        Py_CLEAR(result);
    }
    return result;
#endif
}
#endif
static CYTHON_INLINE
PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    ret = __Pyx_Coroutine_SendEx(gen, val, 0);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyCoro_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
        {
            if (value == Py_None)
                ret = Py_TYPE(yf)->tp_iternext(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        retval = __Pyx_Coroutine_FinishDelegation(gen);
    } else {
        retval = __Pyx_Coroutine_SendEx(gen, value, 0);
    }
    return __Pyx_Coroutine_MethodReturn(self, retval);
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(yf)) {
        retval = __Pyx_Coroutine_Close(yf);
        if (!retval)
            return -1;
    } else
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL);
        if (!retval)
            return -1;
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
    } else
    #endif
    {
        PyObject *meth;
        gen->is_running = 1;
        meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, Py_None);
        } else
        #endif
            ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Coroutine_FinishDelegation(gen);
    }
    return __Pyx_Coroutine_SendEx(gen, Py_None, 0);
}
static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, CYTHON_UNUSED PyObject *arg) {
    return __Pyx_Coroutine_Close(self);
}
static PyObject *__Pyx_Coroutine_Close(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    retval = __Pyx_Coroutine_SendEx(gen, NULL, 1);
    if (unlikely(retval)) {
        const char *msg;
        Py_DECREF(retval);
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_Check(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
#if PY_VERSION_HEX < 0x03060000
            msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)";
#else
            msg = "async generator ignored GeneratorExit";
#endif
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) {
        if (raised_exception) PyErr_Clear();
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(gen->is_running))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
            goto throw_here;
        }
        gen->is_running = 1;
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_Check(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            PyObject *meth = __Pyx_PyObject_GetAttrStr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Coroutine_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            if (likely(args)) {
                ret = PyObject_CallObject(meth, args);
            } else {
                ret = PyObject_CallFunctionObjArgs(meth, typ, val, tb, NULL);
            }
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Coroutine_FinishDelegation(gen);
        }
        return __Pyx_Coroutine_MethodReturn(self, ret);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0));
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
    Py_VISIT(exc_state->exc_type);
    Py_VISIT(exc_state->exc_value);
    Py_VISIT(exc_state->exc_traceback);
    return 0;
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_code);
    Py_CLEAR(gen->gi_frame);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label >= 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (Py_REFCNT(self) > 0)
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
#if !CYTHON_USE_TP_FINALIZE
    assert(self->ob_refcnt == 0);
    __Pyx_SET_REFCNT(self, 1);
#endif
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
#if PY_MAJOR_VERSION >= 3  || defined(PyErr_WarnFormat)
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
#else
        {PyObject *msg;
        char *cmsg;
        #if CYTHON_COMPILING_IN_PYPY
        msg = NULL;
        cmsg = (char*) "coroutine was never awaited";
        #else
        char *cname;
        PyObject *qualname;
        qualname = gen->gi_qualname;
        cname = PyString_AS_STRING(qualname);
        msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname);
        if (unlikely(!msg)) {
            PyErr_Clear();
            cmsg = (char*) "coroutine was never awaited";
        } else {
            cmsg = PyString_AS_STRING(msg);
        }
        #endif
        if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0))
            PyErr_WriteUnraisable(self);
        Py_XDECREF(msg);}
#endif
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *res = __Pyx_Coroutine_Close(self);
        if (unlikely(!res)) {
            if (PyErr_Occurred())
                PyErr_WriteUnraisable(self);
        } else {
            Py_DECREF(res);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if !CYTHON_USE_TP_FINALIZE
    assert(Py_REFCNT(self) > 0);
    if (--self->ob_refcnt == 0) {
        return;
    }
    {
        Py_ssize_t refcnt = Py_REFCNT(self);
        _Py_NewReference(self);
        __Pyx_SET_REFCNT(self, refcnt);
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(Py_TYPE(self)) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    _Py_DEC_REFTOTAL;
#endif
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_name;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_name;
    Py_INCREF(value);
    self->gi_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *name = self->gi_qualname;
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, CYTHON_UNUSED void *context)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value)))
#else
    if (unlikely(value == NULL || !PyString_Check(value)))
#endif
    {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, CYTHON_UNUSED void *context)
{
    PyObject *frame = self->gi_frame;
    if (!frame) {
        if (unlikely(!self->gi_code)) {
            Py_RETURN_NONE;
        }
        frame = (PyObject *) PyFrame_New(
            PyThreadState_Get(),            /*PyThreadState *tstate,*/
            (PyCodeObject*) self->gi_code,  /*PyCodeObject *code,*/
            __pyx_d,                 /*PyObject *globals,*/
            0                               /*PyObject *locals*/
        );
        if (unlikely(!frame))
            return NULL;
        self->gi_frame = frame;
    }
    Py_INCREF(frame);
    return frame;
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
            PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->gi_exc_state.exc_type = NULL;
    gen->gi_exc_state.exc_value = NULL;
    gen->gi_exc_state.exc_traceback = NULL;
#if CYTHON_USE_EXC_INFO_STACK
    gen->gi_exc_state.previous_item = NULL;
#endif
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    Py_XINCREF(module_name);
    gen->gi_modulename = module_name;
    Py_XINCREF(code);
    gen->gi_code = code;
    gen->gi_frame = NULL;
    PyObject_GC_Track(gen);
    return gen;
}

/* PatchModuleWithCoroutine */
      static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    int result;
    PyObject *globals, *result_obj;
    globals = PyDict_New();  if (unlikely(!globals)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_coroutine_type",
    #ifdef __Pyx_Coroutine_USED
        (PyObject*)__pyx_CoroutineType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    result = PyDict_SetItemString(globals, "_cython_generator_type",
    #ifdef __Pyx_Generator_USED
        (PyObject*)__pyx_GeneratorType);
    #else
        Py_None);
    #endif
    if (unlikely(result < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore;
    if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore;
    result_obj = PyRun_String(py_code, Py_file_input, globals, globals);
    if (unlikely(!result_obj)) goto ignore;
    Py_DECREF(result_obj);
    Py_DECREF(globals);
    return module;
ignore:
    Py_XDECREF(globals);
    PyErr_WriteUnraisable(module);
    if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) {
        Py_DECREF(module);
        module = NULL;
    }
#else
    py_code++;
#endif
    return module;
}

/* PatchGeneratorABC */
      #ifndef CYTHON_REGISTER_ABCS
#define CYTHON_REGISTER_ABCS 1
#endif
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
static PyObject* __Pyx_patch_abc_module(PyObject *module);
static PyObject* __Pyx_patch_abc_module(PyObject *module) {
    module = __Pyx_Coroutine_patch_module(
        module, ""
"if _cython_generator_type is not None:\n"
"    try: Generator = _module.Generator\n"
"    except AttributeError: pass\n"
"    else: Generator.register(_cython_generator_type)\n"
"if _cython_coroutine_type is not None:\n"
"    try: Coroutine = _module.Coroutine\n"
"    except AttributeError: pass\n"
"    else: Coroutine.register(_cython_coroutine_type)\n"
    );
    return module;
}
#endif
static int __Pyx_patch_abc(void) {
#if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
    static int abc_patched = 0;
    if (CYTHON_REGISTER_ABCS && !abc_patched) {
        PyObject *module;
        module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections");
        if (!module) {
            PyErr_WriteUnraisable(NULL);
            if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning,
                    ((PY_MAJOR_VERSION >= 3) ?
                        "Cython module failed to register with collections.abc module" :
                        "Cython module failed to register with collections module"), 1) < 0)) {
                return -1;
            }
        } else {
            module = __Pyx_patch_abc_module(module);
            abc_patched = 1;
            if (unlikely(!module))
                return -1;
            Py_DECREF(module);
        }
        module = PyImport_ImportModule("backports_abc");
        if (module) {
            module = __Pyx_patch_abc_module(module);
            Py_XDECREF(module);
        }
        if (!module) {
            PyErr_Clear();
        }
    }
#else
    if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL);
#endif
    return 0;
}

/* Generator */
      static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
     (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL},
    {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     (char*) PyDoc_STR("object being iterated by 'yield from', or None")},
    {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {(char *) "gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
     (char*) PyDoc_STR("Frame of the generator"), 0},
    {0, 0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",
    sizeof(__pyx_CoroutineObject),
    0,
    (destructor) __Pyx_Coroutine_dealloc,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
    0,
    (traverseproc) __Pyx_Coroutine_traverse,
    0,
    0,
    offsetof(__pyx_CoroutineObject, gi_weakreflist),
    0,
    (iternextfunc) __Pyx_Generator_Next,
    __pyx_Generator_methods,
    __pyx_Generator_memberlist,
    __pyx_Generator_getsets,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
#if CYTHON_USE_TP_FINALIZE
    0,
#else
    __Pyx_Coroutine_del,
#endif
    0,
#if CYTHON_USE_TP_FINALIZE
    __Pyx_Coroutine_del,
#elif PY_VERSION_HEX >= 0x030400a1
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
    0,
#endif
#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
    0,
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000
    0,
#endif
};
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (unlikely(!__pyx_GeneratorType)) {
        return -1;
    }
    return 0;
}

/* CheckBinaryVersion */
      static int __Pyx_check_binary_version(void) {
    char ctversion[5];
    int same=1, i, found_dot;
    const char* rt_from_call = Py_GetVersion();
    PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    found_dot = 0;
    for (i = 0; i < 4; i++) {
        if (!ctversion[i]) {
            same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
            break;
        }
        if (rt_from_call[i] != ctversion[i]) {
            same = 0;
            break;
        }
    }
    if (!same) {
        char rtversion[5] = {'\0'};
        char message[200];
        for (i=0; i<4; ++i) {
            if (rt_from_call[i] == '.') {
                if (found_dot) break;
                found_dot = 1;
            } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
                break;
            }
            rtversion[i] = rt_from_call[i];
        }
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        return PyErr_WarnEx(NULL, message, 1);
    }
    return 0;
}

/* InitStrings */
      static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        if (PyObject_Hash(*t->p) == -1)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
#if !CYTHON_PEP393_ENABLED
static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    char* defenc_c;
    PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
    if (!defenc) return NULL;
    defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    {
        char* end = defenc_c + PyBytes_GET_SIZE(defenc);
        char* c;
        for (c = defenc_c; c < end; c++) {
            if ((unsigned char) (*c) >= 128) {
                PyUnicode_AsASCIIString(o);
                return NULL;
            }
        }
    }
#endif
    *length = PyBytes_GET_SIZE(defenc);
    return defenc_c;
}
#else
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
}
#endif
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
#if PY_MAJOR_VERSION >= 3
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type %.200s).  "
                "The ability to return an instance of a strict subclass of int "
                "is deprecated, and may be removed in a future version of Python.",
                Py_TYPE(result)->tp_name)) {
            Py_DECREF(result);
            return NULL;
        }
        return result;
    }
#endif
    PyErr_Format(PyExc_TypeError,
                 "__%.4s__ returned non-%.4s (type %.200s)",
                 type_name, type_name, Py_TYPE(result)->tp_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_Check(x) || PyLong_Check(x)))
#else
  if (likely(PyLong_Check(x)))
#endif
    return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  #if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = m->nb_int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = m->nb_long(x);
  }
  #else
  if (likely(m && m->nb_int)) {
    name = "int";
    res = m->nb_int(x);
  }
  #endif
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
    res = PyNumber_Int(x);
  }
#endif
  if (likely(res)) {
#if PY_MAJOR_VERSION < 3
    if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
#else
    if (unlikely(!PyLong_CheckExact(res))) {
#endif
        return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b))) {
    if (sizeof(Py_ssize_t) >= sizeof(long))
        return PyInt_AS_LONG(b);
    else
        return PyInt_AsSsize_t(b);
  }
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    const digit* digits = ((PyLongObject*)b)->ob_digit;
    const Py_ssize_t size = Py_SIZE(b);
    if (likely(__Pyx_sst_abs(size) <= 1)) {
        ival = likely(size) ? digits[0] : 0;
        if (size == -1) ival = -ival;
        return ival;
    } else {
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
    return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
#if PY_MAJOR_VERSION < 3
  } else if (likely(PyInt_CheckExact(o))) {
    return PyInt_AS_LONG(o);
#endif
  } else {
    Py_ssize_t ival;
    PyObject *x;
    x = PyNumber_Index(o);
    if (!x) return -1;
    ival = PyInt_AsLong(x);
    Py_DECREF(x);
    return ival;
  }
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
    return PyInt_FromSize_t(ival);
}


#endif /* Py_PYTHON_H */
