<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, scalar, ignored_variables=None, ignored_interactions=None, ignore_offset=False):
 """Multiply by the specified scalar all the biases and offset of a binary quadratic model. Args: scalar (number):
 Value by which to scale the energy range of the binary quadratic model. ignored_variables (iterable, optional):
 Biases associated with these variables are not scaled. ignored_interactions (iterable[tuple], optional):
 As an iterable of 2-tuples. Biases associated with these interactions are not scaled. ignore_offset (bool, default=False):
 If True, the offset is not scaled. Examples: This example creates a binary quadratic model and then scales it to half the original energy range. -1.0 -0.5 0.5 """


        if ignored_variables is None:
            ignored_variables = set()
        elif not isinstance(ignored_variables, abc.Container):
            ignored_variables = set(ignored_variables)

        if ignored_interactions is None:
            ignored_interactions = set()
        elif not isinstance(ignored_interactions, abc.Container):
            ignored_interactions = set(ignored_interactions)

        linear = self.linear
        for v in linear:
            if v in ignored_variables:
                continue
            linear[v] *= scalar

        quadratic = self.quadratic
        for u, v in quadratic:
            if (u, v) in ignored_interactions or (v, u) in ignored_interactions:
                continue
            quadratic[(u, v)] *= scalar

        if not ignore_offset:
            self.offset *= scalar

        try:
            self._counterpart.scale(scalar, ignored_variables=ignored_variables,
                                    ignored_interactions=ignored_interactions)
        except AttributeError:
            pass