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 subsequence out of a tensor of probabilities
  
  Arguments
  ---------
  p_seq: torch.Tensor
      a tensor of phoneme probabilities
      (batch x sequence index x phoneme index)
  target_word_indexes: torch.Tensor
      a tensor of word indexes to extract, zero-based
      (e.g.) torch.IntTensor([2, 3])  means extracting
      the third word from the first sample and the
      fourth word from the second sample
  longest_subsequence: int
      the length of the longest subsequence
  edge: int
      the index of the "edge" of the sequence
  
  Returns
  -------
  p_seq_subsequence: torch.Tensor
      a probability tensor composed of the phoneme
      probabilities for target words only
docstr_tok: ["Extracts","a","subsequence","out","of","a","tensor","of","probabilities","Arguments","--","--","--","--","-","p_seq",":","torch.Tensor","a","tensor","of","phoneme","probabilities","(","batch","x","sequence","index","x","phoneme","index",")","target_word_indexes",":","torch.Tensor","a","tensor","of","word","indexes","to","extract",",","zero-based","(","e.g",".",")","torch.IntTensor","(","[","2",",","3","]",")","means","extracting","the","third","word","from","the","first","sample","and","the","fourth","word","from","the","second","sample","longest_subsequence",":","int","the","length","of","the","longest","subsequence","edge",":","int","the","index","of","the","``","edge","''","of","the","sequence","Returns","--","--","--","-","p_seq_subsequence",":","torch.Tensor","a","probability","tensor","composed","of","the","phoneme","probabilities","for","target","words","only"]
code: def _get_p_seq_subsequence(
      self, p_seq, target_word_indexes, longest_subsequence, edge
  ):
      """Extracts a subsequence out of a tensor of probabilities
  
      Arguments
      ---------
      p_seq: torch.Tensor
          a tensor of phoneme probabilities
          (batch x sequence index x phoneme index)
      target_word_indexes: torch.Tensor
          a tensor of word indexes to extract, zero-based
          (e.g.) torch.IntTensor([2, 3])  means extracting
          the third word from the first sample and the
          fourth word from the second sample
      longest_subsequence: int
          the length of the longest subsequence
      edge: int
          the index of the "edge" of the sequence
  
      Returns
      -------
      p_seq_subsequence: torch.Tensor
          a probability tensor composed of the phoneme
          probabilities for target words only
      """
      # Determine where the predicted subsequences start and end
      word_start, word_end = self._get_word_boundaries(
          p_seq, target_word_indexes, edge
      )
      p_seq_range = (
          torch.arange(p_seq.size(1), device=p_seq.device)
          .unsqueeze(0)
          .unsqueeze(-1)
          .expand_as(p_seq)
      )
      word_start_unsq = word_start.unsqueeze(-1).unsqueeze(-1)
      word_end_unsq = word_end.unsqueeze(-1).unsqueeze(-1)
      phn_match = (p_seq_range >= word_start_unsq) & (
          p_seq_range < word_start_unsq + longest_subsequence
      )
      p_seq_subsequence = p_seq[phn_match].view(
          p_seq.size(0), longest_subsequence, p_seq.size(-1)
      )
      p_seq_subsequence_range = (
          torch.arange(
              p_seq_subsequence.size(1), device=p_seq_subsequence.device
          )
          .unsqueeze(0)
          .unsqueeze(-1)
          .expand_as(p_seq_subsequence)
      )
      p_seq_subsequence[
          p_seq_subsequence_range >= (word_end_unsq - word_start_unsq)
      ] = 0.0
      return p_seq_subsequence
  
imports: import torch
  from torch import nn
label_desc: Use image node_id 6 for calling the SubsequenceExtractor obj's underlying member method code with example usage: obj._get_p_seq_subsequence(p_seq, target_word_indexes, longest_subsequence, edge) and returns: p_seq_subsequence