### Question:
Scope { public Scope withName(String opName) { return new Scope(env, nameScope.withName(opName), controlDependencies); } Scope(ExecutionEnvironment env); private  Scope(
      ExecutionEnvironment env, NameScope nameScope, Iterable<Op> controlDependencies); ExecutionEnvironment env(); Scope withSubScope(String childScopeName); Scope withName(String opName); String makeOpName(String defaultName); Scope withControlDependencies(Iterable<Op> controls); OperationBuilder applyControlDependencies(OperationBuilder builder);  }### Answer:
@Test public void basic() { try (Graph g = new Graph()) { Scope s = new Scope(g); Const<TInt32> c1 = Const.create(s, 42); assertEquals("Const", c1.output().op().name()); Const<TInt32> c2 = Const.create(s, 7); assertEquals("Const_1", c2.output().op().name()); Const<TInt32> c3 = Const.create(s.withName("four"), 4); assertEquals("four", c3.output().op().name()); Const<TInt32> c4 = Const.create(s.withName("four"), 4); assertEquals("four_1", c4.output().op().name()); } }
@Test public void composite() { try (Graph g = new Graph(); Session sess = new Session(g)) { Scope s = new Scope(g); Output<TInt32> data = Const.create(s.withName("data"), new int[] {600, 470, 170, 430, 300}).output(); Variance<TInt32> var1 = Variance.create(s.withName("example"), data); assertEquals("example/variance", var1.output().op().name()); assertNotNull(g.operation("example/squared_deviation")); assertNotNull(g.operation("example/Mean")); Variance<TInt32> var2 = Variance.create(s, data); assertEquals("variance/variance", var2.output().op().name()); assertNotNull(g.operation("variance/squared_deviation")); assertNotNull(g.operation("variance/Mean")); Tensor<TInt32> result = sess.runner().fetch(var1.output()).run().get(0).expect(TInt32.DTYPE); assertEquals(21704, result.data().getInt()); result = sess.runner().fetch(var2.output()).run().get(0).expect(TInt32.DTYPE); assertEquals(21704, result.data().getInt()); } }