def test_may_share_memory():
    a = numpy.random.rand(5, 4)
    b = numpy.random.rand(5, 4)
    va = a.view()
    vb = b.view()
    ra = a.reshape((4, 5))
    rb = b.reshape((4, 5))
    ta = a.T
    tb = b.T

    for a_, b_, rep in [(a, a, True), (b, b, True), (a, b, False),
                      (a, a[0], True), (a, a[:, 0], True), (a, a.T, True),
                      (a, (0,), False), (a, 1, False), (a, None, False),
                      (a, va, True), (b, vb, True), (va, b, False), (a, vb, False),
                      (a, ra, True), (b, rb, True), (ra, b, False), (a, rb, False),
                      (a, ta, True), (b, tb, True), (ta, b, False), (a, tb, False),
                      ]:

        assert may_share_memory(a_, b_, False) == rep
        assert may_share_memory(b_, a_, False) == rep

    # test that it raise error when needed.
    for a_, b_, rep in [(a, (0,), False), (a, 1, False), (a, None, False), ]:
        assert may_share_memory(a_, b_, False) == rep
        assert may_share_memory(b_, a_, False) == rep
        try:
            may_share_memory(a_, b_)
            raise Exception("An error was expected")
        except TypeError:
            pass
        try:
            may_share_memory(b_, a_)
            raise Exception("An error was expected")
        except __HOLE__:
            pass
dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/misc/tests/test_may_share_memory.py/test_may_share_memory