<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def scale(self, factor, inplace=True):
 """ Multiplies all branch lengths by factor. """

        if not inplace:
            t = self.copy()
        else:
            t = self
        t._tree.scale_edges(factor)
        t._dirty = True
        return t