# Path: dsenser/nnbase.py
# MAX = 1e10
# INF = float('inf')
# UNK_PROB = lambda: np.random.binomial(1, 0.05)
# DIG_RE = re.compile(r"^[\d.]*\d[\d.]*$")
# def _norm_vec(a_x):
# def _norm_word(a_word):
#     def __init__(self, a_w2v=False, a_lstsq=False, a_max_iters=MAX_ITERS):
#     def train(self, a_train_data, a_dev_data=None, a_n_y=-1,
#               a_i=-1, a_train_out=None, a_dev_out=None):
#     def _init_nn(self):
#     def predict(self, a_rel, a_data, a_ret, a_i):
#     def _predict(self, a_args, a_ret, a_i):
#     def _free(self):
#     def _cleanup(self, a_vars):
#     def _generate_ts(self, a_data, a_get_w_emb_i, a_get_c_emb_i):
#     def _rel2x(self, a_rel, a_parses, a_get_w_emb_i, a_get_c_emb_i):
#     def _arg2emb_idx(self, a_parses, a_rel, a_arg, a_get_emb_i):
#     def _init_w_emb(self):
#     def _init_w2v_emb(self):
#     def _init_w2emb(self):
#     def _get_train_w_emb_i(self, a_word):
#     def _get_test_w_emb_i(self, a_word):
#     def _get_train_w2v_emb_i(self, a_word):
#     def _get_test_w2v_emb_i(self, a_word):
#     def _get_test_w2v_lstsq_emb_i(self, a_word):
#     def _init_conn_emb(self):
#     def get_train_c_emb_i(self, a_conn):
#     def get_test_c_emb_i(self, a_conn):
#     def _init_dropout(self, a_input):
#     def _init_funcs(self, a_grads=None):
#     def _init_wemb_funcs(self):
#     def _reset_funcs(self):
#     def _compute_w_stat(self, a_parses):
# class NNBaseSenser(BaseSenser):
# 
# Path: dsenser/constants.py
# CONNECTIVE = "Connective"
# 
# WORDS = "words"
# 
# SENTENCES = "sentences"
# 
# RAW_TEXT = "RawText"


from dsenser.nnbase import _norm_vec, _norm_word, NNBaseSenser, DFLT_VDIM
from dsenser.constants import CONNECTIVE, WORDS, SENTENCES, RAW_TEXT
from pytest import fixture
from mock import patch, MagicMock, Mock
from unittest import TestCase
import dsenser
import dsenser.nnbase
import numpy as np
import pytest
import theano
            return np.array([[0, 0, 1, 0],
                             [0, 0, 0, 1],
                             [0, 0, 1, 0],
                             [1, 0, 0, 0],
                             ])

        with patch.multiple(self.nnbs,
                            _predict_func=_predict_func_mock,
                            get_test_w_emb_i=None,
                            _init_wemb_funcs=MagicMock(),
                            _rel2x=MagicMock(return_value=x)):
            ret = np.array([[0] * 4])
            self.nnbs.predict(None, (None, None), ret, 0)
            assert np.allclose(ret[0], y)

    def test_cleanup(self):
        a = theano.shared(np.ones((10, 30)).astype(theano.config.floatX))
        assert np.allclose(a.get_value(), 1)
        self.nnbs._cleanup([[a]])
        assert np.allclose(a.get_value(), 0)

    def test_rel2x_0(self):
        with patch.object(self.nnbs,
                          "_arg2emb_idx", MagicMock(return_value=None)):
            assert self.nnbs._rel2x(REL1, PARSE1, lambda: None, lambda: None) \
                is None

    def test_rel2x_1(self):
        W2I = {}
        i = 0

# Path: dsenser/nnbase.py
# MAX = 1e10
# INF = float('inf')
# UNK_PROB = lambda: np.random.binomial(1, 0.05)
# DIG_RE = re.compile(r"^[\d.]*\d[\d.]*$")
# def _norm_vec(a_x):
# def _norm_word(a_word):
#     def __init__(self, a_w2v=False, a_lstsq=False, a_max_iters=MAX_ITERS):
#     def train(self, a_train_data, a_dev_data=None, a_n_y=-1,
#               a_i=-1, a_train_out=None, a_dev_out=None):
#     def _init_nn(self):
#     def predict(self, a_rel, a_data, a_ret, a_i):
#     def _predict(self, a_args, a_ret, a_i):
#     def _free(self):
#     def _cleanup(self, a_vars):
#     def _generate_ts(self, a_data, a_get_w_emb_i, a_get_c_emb_i):
#     def _rel2x(self, a_rel, a_parses, a_get_w_emb_i, a_get_c_emb_i):
#     def _arg2emb_idx(self, a_parses, a_rel, a_arg, a_get_emb_i):
#     def _init_w_emb(self):
#     def _init_w2v_emb(self):
#     def _init_w2emb(self):
#     def _get_train_w_emb_i(self, a_word):
#     def _get_test_w_emb_i(self, a_word):
#     def _get_train_w2v_emb_i(self, a_word):
#     def _get_test_w2v_emb_i(self, a_word):
#     def _get_test_w2v_lstsq_emb_i(self, a_word):
#     def _init_conn_emb(self):
#     def get_train_c_emb_i(self, a_conn):
#     def get_test_c_emb_i(self, a_conn):
#     def _init_dropout(self, a_input):
#     def _init_funcs(self, a_grads=None):
#     def _init_wemb_funcs(self):
#     def _reset_funcs(self):
#     def _compute_w_stat(self, a_parses):
# class NNBaseSenser(BaseSenser):
# 
# Path: dsenser/constants.py
# CONNECTIVE = "Connective"
# 
# WORDS = "words"
# 
# SENTENCES = "sentences"
# 
# RAW_TEXT = "RawText"


# Path: tests/test_nnbase.py
from dsenser.nnbase import _norm_vec, _norm_word, NNBaseSenser, DFLT_VDIM
from dsenser.constants import CONNECTIVE, WORDS, SENTENCES, RAW_TEXT
from pytest import fixture
from mock import patch, MagicMock, Mock
from unittest import TestCase
import dsenser
import dsenser.nnbase
import numpy as np
import pytest
import theano

            return np.array([[0, 0, 1, 0],
                             [0, 0, 0, 1],
                             [0, 0, 1, 0],
                             [1, 0, 0, 0],
                             ])

        with patch.multiple(self.nnbs,
                            _predict_func=_predict_func_mock,
                            get_test_w_emb_i=None,
                            _init_wemb_funcs=MagicMock(),
                            _rel2x=MagicMock(return_value=x)):
            ret = np.array([[0] * 4])
            self.nnbs.predict(None, (None, None), ret, 0)
            assert np.allclose(ret[0], y)

    def test_cleanup(self):
        a = theano.shared(np.ones((10, 30)).astype(theano.config.floatX))
        assert np.allclose(a.get_value(), 1)
        self.nnbs._cleanup([[a]])
        assert np.allclose(a.get_value(), 0)

    def test_rel2x_0(self):
        with patch.object(self.nnbs,
                          "_arg2emb_idx", MagicMock(return_value=None)):
            assert self.nnbs._rel2x(REL1, PARSE1, lambda: None, lambda: None) \
                is None

    def test_rel2x_1(self):
        W2I = {}
        i = 0

        for w in PARSE1[DOC_ID][SENTENCES][2][WORDS]: