def _rotate_last_dim(x, rotate_right=False):
    'Rotate the last dimension either left or right.'
    ndims = array_ops.rank(x)
    if rotate_right:
        transpose_perm = array_ops.concat([[(ndims - 1)], math_ops.range(0, (ndims - 1))], axis=0)
    else:
        transpose_perm = array_ops.concat([math_ops.range(1, ndims), [0]], axis=0)
    return array_ops.transpose(x, transpose_perm)
Rotate the last dimension either left or right.
def _rotate_last_dim(x, rotate_right=False):
    
    ndims = array_ops.rank(x)
    if rotate_right:
        transpose_perm = array_ops.concat([[(ndims - 1)], math_ops.range(0, (ndims - 1))], axis=0)
    else:
        transpose_perm = array_ops.concat([math_ops.range(1, ndims), [0]], axis=0)
    return array_ops.transpose(x, transpose_perm)