class_docstr: F0 estimation with dio + stonemask algorithm.
  
  This is f0 extractor based on dio + stonmask algorithm introduced in `WORLD:
  a vocoder-based high-quality speech synthesis system for real-time applications`_.
  
  .. _`WORLD: a vocoder-based high-quality speech synthesis system for real-time
      applications`: https://doi.org/10.1587/transinf.2015EDP7457
  
  Note:
      This module is based on NumPy implementation. Therefore, the computational graph
      is not connected.
  
  Todo:
      Replace this module with PyTorch-based implementation.
class_docstr_tok: ["F0","estimation","with","dio","+","stonemask","algorithm",".","This","is","f0","extractor","based","on","dio","+","stonmask","algorithm","introduced","in","`","WORLD",":","a","vocoder-based","high-quality","speech","synthesis","system","for","real-time","applications","`","_",".","..","_","`","WORLD",":","a","vocoder-based","high-quality","speech","synthesis","system","for","real-time","applications","`",":","https",":","\/\/doi.org\/10.1587\/transinf.2015EDP7457","Note",":","This","module","is","based","on","NumPy","implementation",".","Therefore",",","the","computational","graph","is","not","connected",".","Todo",":","Replace","this","module","with","PyTorch-based","implementation","."]
code: def forward(
      self,
      input: torch.Tensor,
      input_lengths: torch.Tensor = None,
      feats_lengths: torch.Tensor = None,
      durations: torch.Tensor = None,
      durations_lengths: torch.Tensor = None,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      # If not provide, we assume that the inputs have the same length
      if input_lengths is None:
          input_lengths = (
              input.new_ones(input.shape[0], dtype=torch.long)
              * input.shape[1]
          )
  
      # F0 extraction
      pitch = [
          self._calculate_f0(x[:xl])
          for x, xl in zip(input, input_lengths)
      ]
  
      # (Optional): Adjust length to match with the mel-spectrogram
      if feats_lengths is not None:
          pitch = [
              self._adjust_num_frames(p, fl).view(-1)
              for p, fl in zip(pitch, feats_lengths)
          ]
  
      # (Optional): Average by duration to calculate token-wise f0
      if self.use_token_averaged_f0:
          durations = durations * self.reduction_factor
          pitch = [
              self._average_by_duration(p, d).view(-1)
              for p, d in zip(pitch, durations)
          ]
          pitch_lengths = durations_lengths
      else:
          pitch_lengths = input.new_tensor(
              [len(p) for p in pitch], dtype=torch.long
          )
  
      # Padding
      pitch = pad_list(pitch, 0.0)
  
      # Return with the shape (B, T, 1)
      return pitch.unsqueeze(-1), pitch_lengths
  
imports: import logging
  from typing import Any, Dict, Tuple, Union
  import humanfriendly
  import numpy
  import pyworld
  import torch
  import torch.nn.functional
  from scipy.interpolate import interp1d
  from typeguard import check_argument_types
  from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract
  from espnet.nets.pytorch_backend.nets_utils import pad_list
label_desc: Use image node_id 4 for calling the Dio obj's underlying member method code with example usage: obj.forward(input, input_lengths, feats_lengths, durations, durations_lengths) and returns: pitch,  pitch_lengths