docstr: Distributed TF cluster w/ InputMode.SPARK
docstr_tok: ["Distributed","TF","cluster","w\/","InputMode.SPARK"]
code: def test_inputmode_spark(self):
      """Distributed TF cluster w/ InputMode.SPARK"""
  
      def _map_fun(args, ctx):
          import tensorflow as tf
  
          tf_feed = TFNode.DataFeed(ctx.mgr, False)
          while not tf_feed.should_stop():
              batch = tf_feed.next_batch(batch_size=10)
              print("batch: {}".format(batch))
              squares = tf.math.square(batch)
              print("squares: {}".format(squares))
              tf_feed.batch_results(squares.numpy())
  
      input = [
          [x] for x in range(1000)
      ]  # set up input as tensors of shape [1] to match placeholder
      rdd = self.sc.parallelize(input, 10)
      cluster = TFCluster.run(
          self.sc,
          _map_fun,
          tf_args={},
          num_executors=self.num_workers,
          num_ps=0,
          input_mode=TFCluster.InputMode.SPARK,
      )
      rdd_out = cluster.inference(rdd)
      rdd_sum = rdd_out.sum()
      self.assertEqual(rdd_sum, sum([x * x for x in range(1000)]))
      cluster.shutdown()
  
file_path: TensorFlowOnSpark/tests/test_TFCluster.py
imports: import unittest
  import test
  import time
  from tensorflowonspark import TFCluster, TFNode
label_desc: Use image node_id 4 for calling the TFClusterTest obj's underlying member method code with example usage: obj.test_inputmode_spark() without return types