class_docstr: Constructs a Pop2Piano feature extractor.
  
  This feature extractor inherits from [`~feature_extraction_sequence_utils.SequenceFeatureExtractor`] which contains
  most of the main methods. Users should refer to this superclass for more information regarding those methods.
  
  This class extracts rhythm and preprocesses the audio before it is passed to the model. First the audio is passed
  to `RhythmExtractor2013` algorithm which extracts the beat_times, beat positions and estimates their confidence as
  well as tempo in bpm, then beat_times is interpolated and to get beatsteps. Later we calculate
  extrapolated_beatsteps from it to be used in tokenizer. On the other hand audio is resampled to self.sampling_rate
  and preprocessed and then log mel spectogram is computed from that to be used in our transformer model.
  
  Args:
      sampling_rate (`int`, *optional*, defaults to 22050):
          Target Sampling rate of audio signal. It's the sampling rate that we forward to the model.
      padding_value (`int`, *optional*, defaults to 0):
          Padding value used to pad the audio. Should correspond to silences.
      window_size (`int`, *optional*, defaults to 4096):
          Length of the window in samples to which the Fourier transform is applied.
      hop_length (`int`, *optional*, defaults to 1024):
          Step size between each window of the waveform, in samples.
      min_frequency (`float`, *optional*, defaults to 10.0):
          Lowest frequency that will be used in the log-mel spectrogram.
      feature_size (`int`, *optional*, defaults to 512):
          The feature dimension of the extracted features.
      num_bars (`int`, *optional*, defaults to 2):
          Determines interval between each sequence.
class_docstr_tok: ["Constructs","a","Pop2Piano","feature","extractor",".","This","feature","extractor","inherits","from","[","`","~feature_extraction_sequence_utils.SequenceFeatureExtractor","`","]","which","contains","most","of","the","main","methods",".","Users","should","refer","to","this","superclass","for","more","information","regarding","those","methods",".","This","class","extracts","rhythm","and","preprocesses","the","audio","before","it","is","passed","to","the","model",".","First","the","audio","is","passed","to","`","RhythmExtractor2013","`","algorithm","which","extracts","the","beat_times",",","beat","positions","and","estimates","their","confidence","as","well","as","tempo","in","bpm",",","then","beat_times","is","interpolated","and","to","get","beatsteps",".","Later","we","calculate","extrapolated_beatsteps","from","it","to","be","used","in","tokenizer",".","On","the","other","hand","audio","is","resampled","to","self.sampling_rate","and","preprocessed","and","then","log","mel","spectogram","is","computed","from","that","to","be","used","in","our","transformer","model",".","Args",":","sampling_rate","(","`","int","`",",","*","optional","*",",","defaults","to","22050",")",":","Target","Sampling","rate","of","audio","signal",".","It","'s","the","sampling","rate","that","we","forward","to","the","model",".","padding_value","(","`","int","`",",","*","optional","*",",","defaults","to","0",")",":","Padding","value","used","to","pad","the","audio",".","Should","correspond","to","silences",".","window_size","(","`","int","`",",","*","optional","*",",","defaults","to","4096",")",":","Length","of","the","window","in","samples","to","which","the","Fourier","transform","is","applied",".","hop_length","(","`","int","`",",","*","optional","*",",","defaults","to","1024",")",":","Step","size","between","each","window","of","the","waveform",",","in","samples",".","min_frequency","(","`","float","`",",","*","optional","*",",","defaults","to","10.0",")",":","Lowest","frequency","that","will","be","used","in","the","log-mel","spectrogram",".","feature_size","(","`","int","`",",","*","optional","*",",","defaults","to","512",")",":","The","feature","dimension","of","the","extracted","features",".","num_bars","(","`","int","`",",","*","optional","*",",","defaults","to","2",")",":","Determines","interval","between","each","sequence","."]
docstr: Main method to featurize and prepare for the model.
  
  Args:
      audio (`np.ndarray`, `List`):
          The audio or batch of audio to be processed. Each audio can be a numpy array, a list of float values, a
          list of numpy arrays or a list of list of float values.
      sampling_rate (`int`):
          The sampling rate at which the `audio` input was sampled. It is strongly recommended to pass
          `sampling_rate` at the forward call to prevent silent errors.
      steps_per_beat (`int`, *optional*, defaults to 2):
          This is used in interpolating `beat_times`.
      resample (`bool`, *optional*, defaults to `True`):
          Determines whether to resample the audio to `sampling_rate` or not before processing. Must be True
          during inference.
      return_attention_mask (`bool` *optional*, defaults to `False`):
          Denotes if attention_mask for input_features, beatsteps and extrapolated_beatstep will be given as
          output or not. Automatically set to True for batched inputs.
      return_tensors (`str` or [`~utils.TensorType`], *optional*):
          If set, will return tensors instead of list of python integers. Acceptable values are:
          - `'pt'`: Return PyTorch `torch.Tensor` objects.
          - `'np'`: Return Numpy `np.ndarray` objects.
          If nothing is specified, it will return list of `np.ndarray` arrays.
docstr_tok: ["Main","method","to","featurize","and","prepare","for","the","model",".","Args",":","audio","(","`","np.ndarray","`",",","`","List","`",")",":","The","audio","or","batch","of","audio","to","be","processed",".","Each","audio","can","be","a","numpy","array",",","a","list","of","float","values",",","a","list","of","numpy","arrays","or","a","list","of","list","of","float","values",".","sampling_rate","(","`","int","`",")",":","The","sampling","rate","at","which","the","`","audio","`","input","was","sampled",".","It","is","strongly","recommended","to","pass","`","sampling_rate","`","at","the","forward","call","to","prevent","silent","errors",".","steps_per_beat","(","`","int","`",",","*","optional","*",",","defaults","to","2",")",":","This","is","used","in","interpolating","`","beat_times","`",".","resample","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Determines","whether","to","resample","the","audio","to","`","sampling_rate","`","or","not","before","processing",".","Must","be","True","during","inference",".","return_attention_mask","(","`","bool","`","*","optional","*",",","defaults","to","`","False","`",")",":","Denotes","if","attention_mask","for","input_features",",","beatsteps","and","extrapolated_beatstep","will","be","given","as","output","or","not",".","Automatically","set","to","True","for","batched","inputs",".","return_tensors","(","`","str","`","or","[","`","~utils.TensorType","`","]",",","*","optional","*",")",":","If","set",",","will","return","tensors","instead","of","list","of","python","integers",".","Acceptable","values","are",":","-","`","'pt","'","`",":","Return","PyTorch","`","torch.Tensor","`","objects",".","-","`","'np","'","`",":","Return","Numpy","`","np.ndarray","`","objects",".","If","nothing","is","specified",",","it","will","return","list","of","`","np.ndarray","`","arrays","."]
code: def __call__(
      self,
      audio: Union[
          np.ndarray, List[float], List[np.ndarray], List[List[float]]
      ],
      sampling_rate: Union[int, List[int]],
      steps_per_beat: int = 2,
      resample: Optional[bool] = True,
      return_attention_mask: Optional[bool] = False,
      return_tensors: Optional[Union[str, TensorType]] = None,
      **kwargs,
  ) -> BatchFeature:
      """
      Main method to featurize and prepare for the model.
  
      Args:
          audio (`np.ndarray`, `List`):
              The audio or batch of audio to be processed. Each audio can be a numpy array, a list of float values, a
              list of numpy arrays or a list of list of float values.
          sampling_rate (`int`):
              The sampling rate at which the `audio` input was sampled. It is strongly recommended to pass
              `sampling_rate` at the forward call to prevent silent errors.
          steps_per_beat (`int`, *optional*, defaults to 2):
              This is used in interpolating `beat_times`.
          resample (`bool`, *optional*, defaults to `True`):
              Determines whether to resample the audio to `sampling_rate` or not before processing. Must be True
              during inference.
          return_attention_mask (`bool` *optional*, defaults to `False`):
              Denotes if attention_mask for input_features, beatsteps and extrapolated_beatstep will be given as
              output or not. Automatically set to True for batched inputs.
          return_tensors (`str` or [`~utils.TensorType`], *optional*):
              If set, will return tensors instead of list of python integers. Acceptable values are:
              - `'pt'`: Return PyTorch `torch.Tensor` objects.
              - `'np'`: Return Numpy `np.ndarray` objects.
              If nothing is specified, it will return list of `np.ndarray` arrays.
      """
  
      requires_backends(self, ["librosa"])
      is_batched = bool(
          isinstance(audio, (list, tuple))
          and isinstance(audio[0], (np.ndarray, tuple, list))
      )
      if is_batched:
          # This enables the user to process files of different sampling_rate at same time
          if not isinstance(sampling_rate, list):
              raise ValueError(
                  "Please give sampling_rate of each audio separately when you are passing multiple raw_audios at the same time. "
                  f"Received {sampling_rate}, expected [audio_1_sr, ..., audio_n_sr]."
              )
          return_attention_mask = (
              True
              if return_attention_mask is None
              else return_attention_mask
          )
      else:
          audio = [audio]
          sampling_rate = [sampling_rate]
          return_attention_mask = (
              False
              if return_attention_mask is None
              else return_attention_mask
          )
  
      batch_input_features, batch_beatsteps, batch_ext_beatstep = (
          [],
          [],
          [],
      )
      for single_raw_audio, single_sampling_rate in zip(
          audio, sampling_rate
      ):
          (
              bpm,
              beat_times,
              confidence,
              estimates,
              essentia_beat_intervals,
          ) = self.extract_rhythm(audio=single_raw_audio)
          beatsteps = self.interpolate_beat_times(
              beat_times=beat_times,
              steps_per_beat=steps_per_beat,
              n_extend=1,
          )
  
          if (
              self.sampling_rate != single_sampling_rate
              and self.sampling_rate is not None
          ):
              if resample:
                  # Change sampling_rate to self.sampling_rate
                  single_raw_audio = librosa.core.resample(
                      single_raw_audio,
                      orig_sr=single_sampling_rate,
                      target_sr=self.sampling_rate,
                      res_type="kaiser_best",
                  )
              else:
                  warnings.warn(
                      f"The sampling_rate of the provided audio is different from the target sampling_rate "
                      f"of the Feature Extractor, {self.sampling_rate} vs {single_sampling_rate}. "
                      f"In these cases it is recommended to use `resample=True` in the `__call__` method to "
                      f"get the optimal behaviour."
                  )
  
          single_sampling_rate = self.sampling_rate
          start_sample = int(beatsteps[0] * single_sampling_rate)
          end_sample = int(beatsteps[-1] * single_sampling_rate)
  
          input_features, extrapolated_beatstep = self.preprocess_mel(
              single_raw_audio[start_sample:end_sample],
              beatsteps - beatsteps[0],
          )
  
          mel_specs = self.mel_spectrogram(
              input_features.astype(np.float32)
          )
  
          # apply np.log to get log mel-spectrograms
          log_mel_specs = np.log(
              np.clip(mel_specs, a_min=1e-6, a_max=None)
          )
  
          input_features = np.transpose(log_mel_specs, (0, -1, -2))
  
          batch_input_features.append(input_features)
          batch_beatsteps.append(beatsteps)
          batch_ext_beatstep.append(extrapolated_beatstep)
  
      output = BatchFeature(
          {
              "input_features": batch_input_features,
              "beatsteps": batch_beatsteps,
              "extrapolated_beatstep": batch_ext_beatstep,
          }
      )
  
      output = self.pad(
          output,
          is_batched=is_batched,
          return_attention_mask=return_attention_mask,
          return_tensors=return_tensors,
      )
  
      return output
  
file_path: transformers/src/transformers/models/pop2piano/feature_extraction_pop2piano.py
imports: import warnings
  from typing import List, Optional, Union
  import numpy
  import numpy
  from ...audio_utils import mel_filter_bank, spectrogram
  from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
  from ...feature_extraction_utils import BatchFeature
  from ...utils import TensorType, is_essentia_available, is_librosa_available, is_scipy_available, logging, requires_backends
label_desc: Use image node_id 8 for calling the Pop2PianoFeatureExtractor obj's underlying member method code with example usage: obj.__call__(audio, sampling_rate, steps_per_beat, resample, return_attention_mask, return_tensors) and returns: output