def dim_handling(inputs, dim=None, dims={}, broadcastables={}, keys=(), **kwargs):
 if dim:
  dims = dict(zip(inputs, ([dim] * len(inputs))))
 if dims:
  maxdim = max(dims.values())
  broadcastables = dict(((i, (((False,) * dims[i]) + ((True,) * (maxdim - dims[i])))) for i in inputs))
 return broadcastables

def dim_handling ( inputs , dim = None , dims = { } , broadcastables = { } , keys = ( ) , ** kwargs ) : if dim : dims = dict ( zip ( inputs , ( [ dim ] * len ( inputs ) ) ) ) if dims : maxdim = max ( dims . values ( ) ) broadcastables = dict ( ( ( i , ( ( ( False , ) * dims [ i ] ) + ( ( True , ) * ( maxdim - dims [ i ] ) ) ) ) for i in inputs ) ) return broadcastables
handle various input types for dimensions in tensor_wrap see also: tensor_wrap theano_funciton .