def permute_dimensions(x, pattern):
 pattern = tuple(pattern)
 return x.dimshuffle(pattern)

def permute_dimensions ( x , pattern ) : pattern = tuple ( pattern ) return x . dimshuffle ( pattern )
permutes axes in a tensor .