### Question:
DifferentiableChecker { public static boolean isDifferentiableWrtLatents(Collection<Vertex> vertices) { if (!allProbabilisticAreDoubleOrObserved(vertices)) { return false; } Set<Vertex> allParents = allParentsOf(vertices); Set<Vertex> constantValueVerticesCache = new HashSet<>(); return diffableOrConstantUptoNextRV(allParents, constantValueVerticesCache); }  static boolean isDifferentiableWrtLatents(Collection<Vertex> vertices);  }### Answer:
@Test public void constantVerticesAreCached() { GaussianVertex baseVertex = new GaussianVertex(1., 1.); DoubleVertex addVertex = baseVertex.plus(new ConstantDoubleVertex(1.)); DoubleVertex mockedVertex = Mockito.spy(addVertex); DoubleVertex nonDiffable = mockedVertex.floor(); GaussianVertex gaussianA = new GaussianVertex(nonDiffable, new ConstantDoubleVertex(3.)); GaussianVertex gaussianB = new GaussianVertex(nonDiffable, new ConstantDoubleVertex(3.)); DifferentiableChecker.isDifferentiableWrtLatents(gaussianB.getConnectedGraph()); verify(mockedVertex, times(1)).isObserved(); }