message: [tf.data] Fixes leak of `OptimizeDatasetOp::Dataset` if optimization fails.
  Previously, we were not calling `dataset->Unref()` when optimization failed, and the `Dataset` object would leak. If we *had* called `Unref()` we would have attempted to call `optimized_input_->Unref()`, but `optimized_input_` was uninitialized in the case that optimization fails.
diff: @@ -29,6 +29,7 @@ limitations under the License.
  #include "tensorflow/core/grappler/grappler_item_builder.h"
  #include "tensorflow/core/grappler/optimizers/data/graph_utils.h"
  #include "tensorflow/core/grappler/optimizers/meta_optimizer.h"
  +#include "tensorflow/core/lib/core/refcount.h"
  #include "tensorflow/core/lib/random/random.h"
  #include "tensorflow/core/protobuf/meta_graph.pb.h"
  #include "tensorflow/core/protobuf/rewriter_config.pb.h"
  @@ -56,8 +57,13 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel {
  ctx, ParseVectorArgument<string>(ctx, "optimizations", &optimizations));
  Dataset* dataset =
  new Dataset(ctx, input, optimizations, output_types_, output_shapes_);
  - OP_REQUIRES_OK(ctx, dataset->Optimize(ctx));
  + Status s = dataset->Optimize(ctx);
  + if (s.ok()) {
  *output = dataset;
  + } else {
  + dataset->Unref();
  + OP_REQUIRES_OK(ctx, s);
  + }
  }
  private:
  @@ -68,6 +74,7 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel {
  const DataTypeVector& output_types,
  const std::vector<PartialTensorShape>& output_shapes)
  : DatasetBase(DatasetContext(ctx)),
  + optimized_input_(nullptr),
  input_(input),
  optimizations_(optimizations),
  output_types_(output_types),
  @@ -77,8 +84,10 @@ class OptimizeDatasetOp : public UnaryDatasetOpKernel {
  ~Dataset() override {
  input_->Unref();
  + if (optimized_input_) {
  optimized_input_->Unref();
  }
  + }
  std::unique_ptr<IteratorBase> MakeIteratorInternal(
  const string& prefix) const override {
  