code: def energy(signal):
      """
      Compute the energy of a (framed) signal.
  
      Parameters
      ----------
      signal : numpy array
          Signal.
  
      Returns
      -------
      energy : float
          Energy of the signal.
  
      Notes
      -----
      If `signal` is a `FramedSignal`, the energy is computed for each frame
      individually.
  
      """
      # compute the energy for every frame of the signal
      if isinstance(signal, FramedSignal):
          return np.array([energy(frame) for frame in signal])
      # make sure the signal is a numpy array
      if not isinstance(signal, np.ndarray):
          raise TypeError(
              "Invalid type for signal, must be a numpy array."
          )
      # take the abs if the signal is complex
      if np.iscomplex(signal).any():
          signal = np.abs(signal)
      # Note: type conversion needed because of integer overflows
      if signal.dtype != float:
          signal = signal.astype(float)
      # return energy
      return np.dot(signal.flatten(), signal.flatten())
  
imports: from __future__ import absolute_import, division, print_function
  import warnings
  import numpy
  from ..processors import BufferProcessor, Processor
  from ..utils import integer_types
label_desc: Use image node_id 9 for calling a global function with example usage: energy(signal) and returns: np, np