old_contents: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  
  import keras
  from keras.datasets import mnist
  from keras import backend as K
  from sklearn.datasets import load_iris
  from sklearn.model_selection import train_test_split
  from sklearn.preprocessing import OneHotEncoder
  
  
  def get_mnist_data():
      img_rows, img_cols = 28, 28
      num_classes = 10
  
      # the data, split between train and test sets
      (x_train, y_train), (x_test, y_test) = mnist.load_data()
  
      if K.image_data_format() == "channels_first":
          x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
          x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
          input_shape = (1, img_rows, img_cols)
      else:
          x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
          x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
          input_shape = (img_rows, img_cols, 1)
  
      x_train = x_train.astype("float32")
      x_test = x_test.astype("float32")
      x_train /= 255
      x_test /= 255
  
      # convert class vectors to binary class matrices
      y_train = keras.utils.to_categorical(y_train, num_classes)
      y_test = keras.utils.to_categorical(y_test, num_classes)
  
      return x_train, y_train, x_test, y_test, input_shape
  
  
  def get_iris_data(test_size=0.2):
      iris_data = load_iris()
      x = iris_data.data
      y = iris_data.target.reshape(-1, 1)
      encoder = OneHotEncoder(sparse=False)
      y = encoder.fit_transform(y)
      train_x, test_x, train_y, test_y = train_test_split(x, y)
      return train_x, train_y, test_x, test_y
  
  
  def set_keras_threads(threads):
      # We set threads here to avoid contention, as Keras
      # is heavily parallelized across multiple cores.
      K.set_session(
          K.tf.Session(
              config=K.tf.ConfigProto(
                  intra_op_parallelism_threads=threads,
                  inter_op_parallelism_threads=threads)))
  
  
  def TuneKerasCallback(*args, **kwargs):
      raise DeprecationWarning("TuneKerasCallback is now "
                               "tune.integration.keras.TuneReporterCallback.")
  
new_contents: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  
  import tensorflow as tf
  import keras
  from keras.datasets import mnist
  from keras import backend as K
  from sklearn.datasets import load_iris
  from sklearn.model_selection import train_test_split
  from sklearn.preprocessing import OneHotEncoder
  
  
  def get_mnist_data():
      img_rows, img_cols = 28, 28
      num_classes = 10
  
      # the data, split between train and test sets
      (x_train, y_train), (x_test, y_test) = mnist.load_data()
  
      if K.image_data_format() == "channels_first":
          x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
          x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
          input_shape = (1, img_rows, img_cols)
      else:
          x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
          x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
          input_shape = (img_rows, img_cols, 1)
  
      x_train = x_train.astype("float32")
      x_test = x_test.astype("float32")
      x_train /= 255
      x_test /= 255
  
      # convert class vectors to binary class matrices
      y_train = keras.utils.to_categorical(y_train, num_classes)
      y_test = keras.utils.to_categorical(y_test, num_classes)
  
      return x_train, y_train, x_test, y_test, input_shape
  
  
  def get_iris_data(test_size=0.2):
      iris_data = load_iris()
      x = iris_data.data
      y = iris_data.target.reshape(-1, 1)
      encoder = OneHotEncoder(sparse=False)
      y = encoder.fit_transform(y)
      train_x, test_x, train_y, test_y = train_test_split(x, y)
      return train_x, train_y, test_x, test_y
  
  
  def set_keras_threads(threads):
      # We set threads here to avoid contention, as Keras
      # is heavily parallelized across multiple cores.
      K.set_session(
          tf.Session(
              config=tf.ConfigProto(
                  intra_op_parallelism_threads=threads,
                  inter_op_parallelism_threads=threads)))
  
  
  def TuneKerasCallback(*args, **kwargs):
      raise DeprecationWarning("TuneKerasCallback is now "
                               "tune.integration.keras.TuneReporterCallback.")
  
subject: Fix for keras threading (#5517)