Question 2
When using Wav2Vec2Model to extract hidden states for a downstream task, you set in the model call. In PyTorch, what is the most efficient way to ensure the model does not calculate gradients or update weights during this feature extraction process, thereby saving memory and computation?
Use before passing the audio through the model.
Wrap the extraction code block with the : context manager.
Manually set each layer's attribute to False using a for loop before every forward pass.
Use the function on the output tensor to remove unnecessary dimensions.