code: def gradients(
      Xs: OptionalList[Tensor],
      Ys: OptionalList[Tensor],
      known_Ys: OptionalList[Tensor],
  ) -> list[Tensor]:
      if len(Ys) != len(known_Ys):
          raise ValueError(
              "Gradient computation failesd, Ys and known_Ys not of same length"
          )
  
      grad = tf.gradients(Ys, Xs, grad_ys=known_Ys, stop_gradients=Xs)
      if grad is None:
          raise TypeError("Gradient computation failed, returned None.")
      return to_list(grad)
  
imports: from __future__ import annotations
  from typing import TypeVar
  import numpy
  import tensorflow
  import tensorflow.keras.backend
  from innvestigate.backend.types import Layer, OptionalList, ShapeTuple, Tensor
label_desc: Use image node_id 6 for calling a global function with example usage: gradients(Xs, Ys, known_Ys) and returns: to_list