class_docstr: Test the utility function _generate_tapes_and_coeffs.
class_docstr_tok: ["Test","the","utility","function","_generate_tapes_and_coeffs","."]
docstr: Check that a cache equals an expected cache.
docstr_tok: ["Check","that","a","cache","equals","an","expected","cache","."]
code: def check_cache_equality(self, cache, expected):
      """Check that a cache equals an expected cache."""
      assert list(cache.keys()) == list(expected.keys())
      # "total_num_tapes" always is a key in the caches
      assert cache["total_num_tapes"] == expected["total_num_tapes"]
      for k, v in cache.items():
          if k == "total_num_tapes":
              # We already checked "total_num_tapes", so skip this entry
              continue
          expected_value = expected[k]
          # values of the cache should be three-tuples with format (int, int, tuple[tensor_like])
          assert isinstance(v, tuple) and len(v) == 3
          # first two entries (integers) are start and end pointers into the list of
          # tapes (or equivalently into the list of results later on in the gradient transfom)
          assert v[:2] == expected_value[:2]
          # last entry is a tuple of coefficients, so we iterate over the outer-most axis
          # (the tuple axis) and compare the tensors one after the other
          for _v, e in zip(v[2], expected_value[2]):
              assert qml.math.allclose(_v, e, atol=self.atol)
  
imports: import copy
  import pytest
  import numpy
  import pennylane
  from pennylane import numpy
  from pennylane.ops.qubit.special_unitary import pauli_basis_matrices, pauli_basis_strings
  from pennylane.math import expand_matrix
  from pennylane.gradients.pulse_gradient_odegen import _generate_tapes_and_coeffs, pulse_odegen, _insert_op, _nonzero_coeffs_and_words, _one_parameter_generators, _one_parameter_paulirot_coeffs, _parshift_and_contract
label_desc: Use image node_id 2 for calling the TestGenerateTapesAndCoeffs obj's underlying member method code with example usage: obj.check_cache_equality(cache, expected) without return types