'Utility function for processing arguments that are singletons or lists.
Args:
x: either a list of self.n elements, or not a list.
Returns:
a list of self.n elements.'

def _MaybeRepeat(self, x):

    if isinstance(x, list):
        assert (len(x) == self.n)
        return x
    else:
        return ([x] * self.n)
