def transform(self, code, *, name=None, filename=None):
        """Transform a codetransformer.Code object applying the transforms.

        Parameters
        ----------
        code : Code
            The code object to transform.
        name : str, optional
            The new name for this code object.
        filename : str, optional
            The new filename for this code object.

        Returns
        -------
        new_code : Code
            The transformed code object.
        """
        # reverse lookups from for constants and names.
        reversed_consts = {}
        reversed_names = {}
        reversed_varnames = {}
        for instr in code:
            if isinstance(instr, LOAD_CONST):
                reversed_consts[instr] = instr.arg
            if instr.uses_name:
                reversed_names[instr] = instr.arg
            if isinstance(instr, (STORE_FAST, LOAD_FAST)):
                reversed_varnames[instr] = instr.arg

        instrs, consts = tuple(zip(*reversed_consts.items())) or ((), ())
        for instr, const in zip(instrs, self.transform_consts(consts)):
            instr.arg = const

        instrs, names = tuple(zip(*reversed_names.items())) or ((), ())
        for instr, name_ in zip(instrs, self.transform_names(names)):
            instr.arg = name_

        instrs, varnames = tuple(zip(*reversed_varnames.items())) or ((), ())
        for instr, varname in zip(instrs, self.transform_varnames(varnames)):
            instr.arg = varname

        with self._new_context(code):
            post_transform = self.patterndispatcher(code)

            return Code(
                post_transform,
                code.argnames,
                cellvars=self.transform_cellvars(code.cellvars),
                freevars=self.transform_freevars(code.freevars),
                name=name if name is not None else code.name,
                filename=filename if filename is not None else code.filename,
                firstlineno=code.firstlineno,
                lnotab=_new_lnotab(post_transform, code.lnotab),
                flags=code.flags,
            )
Transform a codetransformer.Code object applying the transforms.

        Parameters
        ----------
        code : Code
            The code object to transform.
        name : str, optional
            The new name for this code object.
        filename : str, optional
            The new filename for this code object.

        Returns
        -------
        new_code : Code
            The transformed code object.