Modified trainable to avoid the use of large Lua tables