<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def inject_long_nonspeech_fragments(self, pairs, replacement_string):
 """ Inject nonspeech fragments corresponding to the given intervals in this fragment list. It is assumed that ``pairs`` are consistent, e.g. they are produced by ``fragments_ending_inside_nonspeech_intervals``. :param list pairs: list of ``(TimeInterval, int)`` pairs, each identifying a nonspeech interval and the corresponding fragment index ending inside it :param string replacement_string: the string to be applied to the nonspeech intervals """

        self.log(u"Called inject_long_nonspeech_fragments")
        # set the appropriate fragment text
        if replacement_string in [None, gc.PPV_TASK_ADJUST_BOUNDARY_NONSPEECH_REMOVE]:
            self.log(u"  Remove long nonspeech")
            lines = []
        else:
            self.log([u"  Replace long nonspeech with '%s'", replacement_string])
            lines = [replacement_string]
        # first, make room for the nonspeech intervals
        self.log(u"  First pass: making room...")
        for nsi, index in pairs:
            self[index].interval.end = nsi.begin
            self[index + 1].interval.begin = nsi.end
        self.log(u"  First pass: making room... done")
        self.log(u"  Second pass: append nonspeech intervals...")
        for i, (nsi, index) in enumerate(pairs, 1):
            identifier = u"n%06d" % i
            self.add(SyncMapFragment(
                text_fragment=TextFragment(
                    identifier=identifier,
                    language=None,
                    lines=lines,
                    filtered_lines=lines
                ),
                interval=nsi,
                fragment_type=SyncMapFragment.NONSPEECH
            ), sort=False)
        self.log(u"  Second pass: append nonspeech intervals... done")
        self.log(u"  Third pass: sorting...")
        self.sort()
        self.log(u"  Third pass: sorting... done")