code: def test_energy_correctness(data_format):
      frame_length = 4
      hop_length = frame_length // 2
      n_ch = 1
      src_mono, batch_src, input_shape = get_audio(
          data_format=data_format, n_ch=n_ch, length=frame_length * 2
      )
  
      sr = 22050
      ref_duration = 0.1
      model = tf.keras.Sequential()
      model.add(
          Energy(
              sample_rate=sr,
              ref_duration=ref_duration,
              frame_length=frame_length,
              hop_length=hop_length,
              pad_end=False,
              data_format=data_format,
              input_shape=input_shape,
          )
      )
  
      energies_kapre = model.predict(batch_src)[0]
  
      frames_ref = librosa.util.frame(
          src_mono, frame_length, hop_length
      ).T  # (time, frame_length)
      nor_coeff = ref_duration / (frame_length / sr)
      energies_ref = nor_coeff * np.sum(
          frames_ref**2, axis=1
      )  # (time, )
  
      if data_format in (_CH_DEFAULT_STR, _CH_LAST_STR):
          energies_ref = np.expand_dims(energies_ref, axis=1)
      else:
          energies_ref = np.expand_dims(energies_ref, axis=0)
  
      np.testing.assert_allclose(
          energies_kapre, energies_ref, atol=1e-5
      )
  
file_path: kapre/tests/test_signal.py
imports: import pytest
  import numpy
  import tensorflow
  import librosa
  from kapre import Frame, Energy, MuLawEncoding, MuLawDecoding, LogmelToMFCC
  from kapre.backend import _CH_FIRST_STR, _CH_LAST_STR, _CH_DEFAULT_STR
  from utils import get_audio, save_load_compare
label_desc: Use image node_id 2 for calling a global function with example usage: test_energy_correctness(data_format) without return types