def __init__(
            self,
            inference_func: Callable,
            sample_rate: int = 16000,
            max_segment_length: int = '30s',
            max_inference_tokens: int = 100,
            *,
            steps: str = 'se',
            rel_prob_decrease: float = .03,
            abs_prob_decrease: float = .05,
            rel_rel_prob_decrease: Optional[float] = None,
            prob_threshold: float = .5,
            rel_dur_change: Optional[float] = .5,
            abs_dur_change: Optional[float] = None,
            word_level: bool = True,
            precision: float = None,
            **options
    ):
        """
        Improve existing timestamps with any compatible ASR models.

        This function iteratively muting portions of the audio and monitoring token probabilities to find the most
        precise timestamps. This "most precise" in this case means the latest start and earliest end of a word that
        maintains an acceptable probability determined by the specified arguments.

        This is useful readjusting timestamps when they start too early or end too late.

        Parameters
        ----------
        inference_func : Callable
            Function that computes confidence score of tokens for an audio segment.
            The function takes two argument: two audio segment as a torch.Tensor and tokens as a list of int.
            The function must return a torch.Tensor of token confidence scores of the audio segments.
        sample_rate : int, default 16000
            The sampling of the audio ``inference_func`` expects.
        max_segment_length : int, default '30s'
            Maximum samples of audio segment ``inference_func`` expects. Use string for seconds followed by 's'.
        max_inference_tokens : int, default 100
            Maximum number of tokens ``inference_func`` expects.
        steps : str, default 'se'
            Instructions for refinement. A 's' means refine start-timestamps. An 'e' means refine end-timestamps.
        rel_prob_decrease : float, default 0.3
            Maximum percent decrease in probability relative to original probability which is the probability from
            muting according initial timestamps.
        abs_prob_decrease : float, default 0.05
            Maximum decrease in probability from original probability.
        rel_rel_prob_decrease : float, optional
            Maximum percent decrease in probability relative to previous probability which is the probability from
            previous iteration of muting.
        prob_threshold : float, default 0.5
            Stop refining the timestamp if the probability of its token goes below this value.
        rel_dur_change : float, default 0.5
            Maximum percent change in duration of a word relative to its original duration.
        abs_dur_change : float, optional
            Maximum seconds a word is allowed deviate from its original duration.
        word_level : bool, default True
            Whether to refine timestamps on word-level. If ``False``, only refine start/end timestamps of each segment.
        precision : float, default 0.1
            Precision of refined timestamps in seconds. The lowest precision is 0.02 second.
        single_batch : bool, default False
            Whether to process in only batch size of one to reduce memory usage.
        inplace : bool, default True
            Whether to alter timestamps in-place. Return a deepcopy of ``result`` if ``False``.
        denoiser : str, optional
            String of the denoiser to use for preprocessing ``audio``.
            See ``stable_whisper.audio.SUPPORTED_DENOISERS`` for supported denoisers.
        denoiser_options : dict, optional
            Options to use for ``denoiser``.
        only_voice_freq : bool, default False
            Whether to only use sound between 200 - 5000 Hz, where majority of human speech are.
        verbose : bool or None, default False
            Whether to display the text being decoded to the console.
            Displays all the details if ``True``. Displays progressbar if ``False``. Display nothing if ``None``.

        Notes
        -----
        The lower the ``precision``, the longer the processing time.
        """

        if not steps:
            steps = 'se'
        if invalid_steps := steps.replace('s', '').replace('e', ''):
            raise ValueError(f'Invalid step(s): {", ".join(invalid_steps)}')
        if precision is None:
            precision = 0.1

        if isinstance(max_segment_length, str):
            if not max_segment_length.endswith('s'):
                raise ValueError(f'expect string ``max_segment_length`` to end with "s" but got "{max_segment_length}"')
            self.max_segment_seconds = float(max_segment_length[:-1])
        else:
            self.max_segment_seconds = max_segment_length / sample_rate

        self.options = AllOptions(options, silence=False, align=False)
        self.steps = steps
        self.precision = precision
        self.sample_rate = sample_rate

        self.max_inference_tokens = max_inference_tokens
        self.sample_precision = max(round(self.precision * self.sample_rate), 2)

        self.inference_func = inference_func

        self.rel_prob_decrease = rel_prob_decrease
        self.abs_prob_decrease = abs_prob_decrease
        self.rel_rel_prob_decrease = rel_rel_prob_decrease
        self.prob_threshold = prob_threshold
        self.rel_dur_change = rel_dur_change
        self.abs_dur_change = abs_dur_change
        self.word_level = word_level

        self._prev_ts = 0
        self._pbar_step = 0
        self._step_count = 0
        self._tqdm_pbar = None
        self._audio = torch.tensor([])

        Improve existing timestamps with any compatible ASR models.

        This function iteratively muting portions of the audio and monitoring token probabilities to find the most
        precise timestamps. This "most precise" in this case means the latest start and earliest end of a word that
        maintains an acceptable probability determined by the specified arguments.

        This is useful readjusting timestamps when they start too early or end too late.

        Parameters
        ----------
        inference_func : Callable
            Function that computes confidence score of tokens for an audio segment.
            The function takes two argument: two audio segment as a torch.Tensor and tokens as a list of int.
            The function must return a torch.Tensor of token confidence scores of the audio segments.
        sample_rate : int, default 16000
            The sampling of the audio ``inference_func`` expects.
        max_segment_length : int, default '30s'
            Maximum samples of audio segment ``inference_func`` expects. Use string for seconds followed by 's'.
        max_inference_tokens : int, default 100
            Maximum number of tokens ``inference_func`` expects.
        steps : str, default 'se'
            Instructions for refinement. A 's' means refine start-timestamps. An 'e' means refine end-timestamps.
        rel_prob_decrease : float, default 0.3
            Maximum percent decrease in probability relative to original probability which is the probability from
            muting according initial timestamps.
        abs_prob_decrease : float, default 0.05
            Maximum decrease in probability from original probability.
        rel_rel_prob_decrease : float, optional
            Maximum percent decrease in probability relative to previous probability which is the probability from
            previous iteration of muting.
        prob_threshold : float, default 0.5
            Stop refining the timestamp if the probability of its token goes below this value.
        rel_dur_change : float, default 0.5
            Maximum percent change in duration of a word relative to its original duration.
        abs_dur_change : float, optional
            Maximum seconds a word is allowed deviate from its original duration.
        word_level : bool, default True
            Whether to refine timestamps on word-level. If ``False``, only refine start/end timestamps of each segment.
        precision : float, default 0.1
            Precision of refined timestamps in seconds. The lowest precision is 0.02 second.
        single_batch : bool, default False
            Whether to process in only batch size of one to reduce memory usage.
        inplace : bool, default True
            Whether to alter timestamps in-place. Return a deepcopy of ``result`` if ``False``.
        denoiser : str, optional
            String of the denoiser to use for preprocessing ``audio``.
            See ``stable_whisper.audio.SUPPORTED_DENOISERS`` for supported denoisers.
        denoiser_options : dict, optional
            Options to use for ``denoiser``.
        only_voice_freq : bool, default False
            Whether to only use sound between 200 - 5000 Hz, where majority of human speech are.
        verbose : bool or None, default False
            Whether to display the text being decoded to the console.
            Displays all the details if ``True``. Displays progressbar if ``False``. Display nothing if ``None``.

        Notes
        -----
        The lower the ``precision``, the longer the processing time.
        
stable_whisper/non_whisper/refinement.py