class_docstr: A utility class to help extract subsequences out of a batch
  of sequences
  
  Arguments
  ---------
  word_separator: int
      the index of the word separator (used in p_seq)
  word_separator_base int
      the index of word separators used in unprocessed
      targets (if different)
  
  Example
  -------
  >>> import torch
  >>> from speechbrain.lobes.models.g2p.homograph import SubsequenceExtractor
  >>> extractor = SubsequenceExtractor()
  >>> phns = torch.Tensor(
  ...     [[1, 2, 0, 1, 3, 0, 2, 1, 0],
  ...      [2, 1, 3, 0, 1, 2, 0, 3, 2]]
  ... )
  >>> phn_lens = torch.IntTensor([8, 9])
  >>> subsequence_phn_start = torch.IntTensor([3, 4])
  >>> subsequence_phn_end = torch.IntTensor([5, 7])
  >>> p_seq = torch.Tensor([
  ...     [[0., 1., 0., 0.],
  ...      [0., 0., 1., 0.],
  ...      [1., 0., 0., 0.],
  ...      [0., 1., 0., 0.],
  ...      [0., 0., 0., 1.],
  ...      [1., 0., 0., 0.],
  ...      [0., 0., 1., 0.],
  ...      [0., 1., 0., 0.],
  ...      [1., 0., 0., 0.]],
  ...     [[0., 0., 1., 0.],
  ...      [0., 1., 0., 0.],
  ...      [0., 0., 0., 1.],
  ...      [1., 0., 0., 0.],
  ...      [0., 1., 0., 0.],
  ...      [0., 0., 1., 0.],
  ...      [1., 0., 0., 0.],
  ...      [0., 0., 0., 1.],
  ...      [0., 0., 1., 0.]]
  ... ])
  >>> extractor.extract_seq(
  ...    phns,
  ...    phn_lens,
  ...    p_seq,
  ...    subsequence_phn_start,
  ...    subsequence_phn_end
  ... )
  (tensor([[[0., 1., 0., 0.],
           [0., 0., 0., 1.],
           [0., 0., 0., 0.]],
  <BLANKLINE>
          [[0., 1., 0., 0.],
           [0., 0., 1., 0.],
           [0., 0., 0., 0.]]]), tensor([[1., 3., 0.],
          [1., 2., 0.]]), tensor([0.6667, 1.0000]))
docstr: Extracts a subsequnce from hypotheses (e.g. the result of a beam
  search) based on a refernece sequence, which can be either a sequence of phonemes (the target during training)
  Arguments
  ---------
  ref_seq: torch.Tensor
      a reference sequence (e.g. phoneme targets)
  hyps: list
      a batch of hypotheses, a list of list of
      integer indices (usually of phonemes)
  subsequence_phn_start: torch.tensor
      the index of the beginning of the subsequence to
  use_base: bool
      whether to use the raw (token) space for word separators
docstr_tok: ["Extracts","a","subsequnce","from","hypotheses","(","e.g",".","the","result","of","a","beam","search",")","based","on","a","refernece","sequence",",","which","can","be","either","a","sequence","of","phonemes","(","the","target","during","training",")","Arguments","--","--","--","--","-","ref_seq",":","torch.Tensor","a","reference","sequence","(","e.g",".","phoneme","targets",")","hyps",":","list","a","batch","of","hypotheses",",","a","list","of","list","of","integer","indices","(","usually","of","phonemes",")","subsequence_phn_start",":","torch.tensor","the","index","of","the","beginning","of","the","subsequence","to","use_base",":","bool","whether","to","use","the","raw","(","token",")","space","for","word","separators"]
code: def extract_hyps(
      self, ref_seq, hyps, subsequence_phn_start, use_base=False
  ):
      """Extracts a subsequnce from hypotheses (e.g. the result of a beam
      search) based on a refernece sequence, which can be either a sequence of phonemes (the target during training)
      Arguments
      ---------
      ref_seq: torch.Tensor
          a reference sequence (e.g. phoneme targets)
      hyps: list
          a batch of hypotheses, a list of list of
          integer indices (usually of phonemes)
      subsequence_phn_start: torch.tensor
          the index of the beginning of the subsequence to
      use_base: bool
          whether to use the raw (token) space for word separators
      """
      range_phns = torch.arange(
          ref_seq.size(1), device=ref_seq.device
      ).expand_as(ref_seq)
      target_word_indexes = self._get_target_word_indexes(
          ref_seq,
          range_phns,
          subsequence_phn_start.unsqueeze(-1),
          self.word_separator_base if use_base else self.word_separator,
      )
      separator_indexes = [
          [-1]
          + [
              idx
              for idx, phn in enumerate(item_hyps)
              if phn == self.word_separator
          ]
          + [None]
          for item_hyps in hyps
      ]
      result = [
          self._extract_hyp_word(
              item_hyps, item_separtaor_indexes, word_index
          )
          for item_hyps, item_separtaor_indexes, word_index in zip(
              hyps, separator_indexes, target_word_indexes
          )
      ]
      return result
  
imports: import torch
  from torch import nn
label_desc: Use image node_id 10 for calling the SubsequenceExtractor obj's underlying member method code with example usage: obj.extract_hyps(ref_seq, hyps, subsequence_phn_start, use_base) and returns: result