title: how to use try-resources in kotlin?
body: <p>I am trying to use kotlin instead of Java, I cannot find a good way to do with try resource:</p>
  
  <p>Java Code like this:</p>
  
  <pre><code>import org.tensorflow.Graph;
  import org.tensorflow.Session;
  import org.tensorflow.Tensor;
  import org.tensorflow.TensorFlow;
  
  public class HelloTensorFlow {
    public static void main(String[] args) throws Exception {
      try (Graph g = new Graph()) {
        final String value = "Hello from " + TensorFlow.version();
  
        // Construct the computation graph with a single operation, a constant
        // named "MyConst" with a value "value".
        try (Tensor t = Tensor.create(value.getBytes("UTF-8"))) {
          // The Java API doesn't yet include convenience functions for adding operations.
          g.opBuilder("Const", "MyConst").setAttr("dtype", t.dataType()).setAttr("value", t).build();
        }
  
        // Execute the "MyConst" operation in a Session.
        try (Session s = new Session(g);
            // Generally, there may be multiple output tensors,
            // all of them must be closed to prevent resource leaks.
            Tensor output = s.runner().fetch("MyConst").run().get(0)) {
          System.out.println(new String(output.bytesValue(), "UTF-8"));
        }
      }
    }
  }
  </code></pre>
  
  <p>I do it in kotlin, I have to do this: </p>
  
  <pre><code>fun main(args: Array&lt;String&gt;) {
      val g = Graph();
      try {
          val value = "Hello from ${TensorFlow.version()}"
          val t = Tensor.create(value.toByteArray(Charsets.UTF_8))
          try {
              g.opBuilder("Const", "MyConst").setAttr("dtype", t.dataType()).setAttr("value", t).build()
          } finally {
              t.close()
          }
  
          var sess = Session(g)
          try {
              val output = sess.runner().fetch("MyConst").run().get(0)
              println(String(output.bytesValue(), Charsets.UTF_8))
          } finally {
              sess?.close()
          }
      } finally {
          g.close()
      }
  
  }
  </code></pre>
  
  <p>I have try to use <code>use</code> like this:</p>
  
  <pre><code>Graph().use {
      it -&gt; ....
  }
  </code></pre>
  
  <p>I got error like this:</p>
  
  <pre><code>Error:(16, 20) Kotlin: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
  </code></pre>
  
  <p>@InlineOnly public inline fun  ???.use(block: (???) -> ???): ??? defined in kotlin.io</p>