def expand_empty(tensor_var, size):
 if (size == 0):
  return tensor_var
 shapes = [tensor_var.shape[x] for x in xrange(tensor_var.ndim)]
 new_shape = ([(size + shapes[0])] + shapes[1:])
 empty = tensor.AllocEmpty(tensor_var.dtype)(*new_shape)
 ret = tensor.set_subtensor(empty[:shapes[0]], tensor_var)
 ret.tag.nan_guard_mode_check = False
 return ret

def expand_empty ( tensor_var , size ) : if ( size == 0 ) : return tensor_var shapes = [ tensor_var . shape [ x ] for x in xrange ( tensor_var . ndim ) ] new_shape = ( [ ( size + shapes [ 0 ] ) ] + shapes [ 1 : ] ) empty = tensor . AllocEmpty ( tensor_var . dtype ) ( * new_shape ) ret = tensor . set_subtensor ( empty [ : shapes [ 0 ] ] , tensor_var ) ret . tag . nan_guard_mode_check = False return ret
transforms the shape of a tensor from to by adding uninitialized memory at the end of the tensor .