code: def test_timestretch(rate, jam_fixture):
      D = muda.deformers.TimeStretch(rate=rate)
  
      jam_orig = deepcopy(jam_fixture)
  
      for jam_new in D.transform(jam_orig):
          # Verify that the original jam reference hasn't changed
          assert jam_new is not jam_fixture
          __test_time(jam_orig, jam_fixture, 1.0)
  
          # Verify that the state and history objects are intact
          __test_deformer_history(D, jam_new.sandbox.muda.history[-1])
  
          d_state = jam_new.sandbox.muda.history[-1]["state"]
          d_rate = d_state["rate"]
          if isinstance(rate, list):
              assert d_rate in rate
          else:
              assert d_rate == rate
  
          __test_time(jam_orig, jam_new, d_rate)
  
      # Serialization test
      D2 = muda.deserialize(muda.serialize(D))
      __test_params(D, D2)
  
imports: from copy import deepcopy
  import re
  import six
  import numpy
  import soundfile
  import jams
  import librosa
  import muda
  import pytest
  import scipy
  from contextlib import contextmanager
label_desc: Use image node_id 9 for calling a global function with example usage: test_timestretch(rate, jam_fixture) without return types