<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def round(self, contract=False):
 """Round this flag to integer segments. Parameters contract : `bool`, optional if `False` (default) expand each segment to the containing integer boundaries, otherwise contract each segment to the contained boundaries Returns ------- roundedflag : `DataQualityFlag` A copy of the original flag with the `active` and `known` segments padded out to integer boundaries. """

        def _round(seg):
            if contract:  # round inwards
                a = type(seg[0])(ceil(seg[0]))
                b = type(seg[1])(floor(seg[1]))
            else:  # round outwards
                a = type(seg[0])(floor(seg[0]))
                b = type(seg[1])(ceil(seg[1]))
            if a >= b:  # if segment is too short, return 'null' segment
                return type(seg)(0, 0)  # will get coalesced away
            return type(seg)(a, b)

        new = self.copy()
        new.active = type(new.active)(map(_round, new.active))
        new.known = type(new.known)(map(_round, new.known))
        return new.coalesce()