Keras model throwing AttributeError: 'NoneType' object has no attribute '_inbound_nodes'

I am trying to create a keras network based on partially connected layers. I am using two custom layers I wrote, Outer() and Inner().

def pcsm(depth=5,batch_shape=(5,128,128)):
    inputs = Input(batch_shape=batch_shape, dtype='float', name='inputs')

    front_L = Outer()
    middle_L = Inner()
    back_L = Outer()
    front_old = inputs
    # middle_old = Lambda(lambda: tf.random.normal(batch_shape)
    # back_old = Lambda(lambda: tf.random.normal(batch_shape)
    middle_old = tf.random.normal(batch_shape)
    back_old = tf.random.normal(batch_shape)

    for _ in range(0,depth):
        front = front_L([front_old,middle_old])
        middle = middle_L([front_old,middle_old,back_old])
        back = back_L([middle_old,back_old])
        front_old=front
        middle_old = middle
        back_old = back


    pcsm = Model(input=inputs,output=back)
    pcsm.compile(optimizer=Adam(lr=1e-4), loss='binary_crossentropy')

    return pcsm

When trying to create the model it throws AttributeError: 'NoneType' object has no attribute '_inbound_nodes'. When looking for a solution, I found that this error occurs mainly when the model contains non-keraslayer operations. It is suggested to instead use keras lambda layers to wrap the operations. So I tried to replace the lines in my code that might cause problems middle_old = tf.random.normal(batch_shape) and back_old = tf.random.normal(batch_shape) with their keras lambda counterparts. Now there's another issue ValueError: Layer outer_1 was called with an input that isn't a symbolic tensor. suggesting that my previous attempt not using lambda layers was correct, which makes sense as all the ..._old values are used as the tensor outputs of the layers in my model. So now I do not have a clue why the AttributeError is thrown in the first place; other than those two lines there are no non-keras operations present in my model.