code: def spectral_magnitude(
      stft, power: int = 1, log: bool = False, eps: float = 1e-14
  ):
      """Returns the magnitude of a complex spectrogram.
  
      Arguments
      ---------
      stft : torch.Tensor
          A tensor, output from the stft function.
      power : int
          What power to use in computing the magnitude.
          Use power=1 for the power spectrogram.
          Use power=0.5 for the magnitude spectrogram.
      log : bool
          Whether to apply log to the spectral features.
  
      Example
      -------
      >>> a = torch.Tensor([[3, 4]])
      >>> spectral_magnitude(a, power=0.5)
      tensor([5.])
      """
      spectr = stft.pow(2).sum(-1)
  
      # Add eps avoids NaN when spectr is zero
      if power < 1:
          spectr = spectr + eps
      spectr = spectr.pow(power)
  
      if log:
          return torch.log(spectr + eps)
      return spectr
  
imports: import math
  import torch
  import logging
  from speechbrain.utils.checkpoints import mark_as_saver, mark_as_loader, mark_as_transfer, register_checkpoint_hooks
  from speechbrain.dataio.dataio import length_to_mask
label_desc: Use image node_id 1 for calling a global function with example usage: spectral_magnitude(stft, power, log, eps) and returns: spectr, torch