class_docstr: Length Regulator
docstr: Expand input mel-spectrogram based on the predicted duration.
  
  Args:
      batch (Tensor): Input tensor (T, dim).
      predicted (Tensor): Predicted duration tensor (T,).
      use_state_info (bool, optional): Whether to use position information or not.
  
  Returns:
      Tensor: Output tensor (D_frame, dim).
code: def expand(self, batch, predicted, use_state_info=False):
      """Expand input mel-spectrogram based on the predicted duration.
  
      Args:
          batch (Tensor): Input tensor (T, dim).
          predicted (Tensor): Predicted duration tensor (T,).
          use_state_info (bool, optional): Whether to use position information or not.
  
      Returns:
          Tensor: Output tensor (D_frame, dim).
      """
      out = list()
  
      for i, vec in enumerate(batch):
          expand_size = predicted[i].item()
          if use_state_info:
              state_info_index = torch.unsqueeze(
                  torch.arange(0, expand_size), 1
              ).float()
              state_info_length = torch.unsqueeze(
                  torch.Tensor([expand_size] * expand_size), 1
              ).float()
              state_info = torch.cat(
                  [state_info_index, state_info_length], 1
              ).to(vec.device)
          new_vec = vec.expand(max(int(expand_size), 0), -1)
          if use_state_info:
              new_vec = torch.cat([new_vec, state_info], 1)
  
          out.append(new_vec)
      out = torch.cat(out, 0)
  
      return out
  
file_path: espnet/espnet2/gan_svs/vits/length_regulator.py
imports: import logging
  import torch
  from espnet.nets.pytorch_backend.nets_utils import pad_list
label_desc: Use image node_id 3 for calling the LengthRegulator obj's underlying member method code with example usage: obj.expand(batch, predicted, use_state_info) and returns: out