code: def _prep_data_fn(
      has_sparse_col,
      sample_weight_col,
      feature_columns,
      label_columns,
      input_shapes,
      label_shapes,
      output_names,
  ):
      def _get_from_dict(row, col):
          return row[col]
  
      def _get_from_named_tuple(row, col):
          return getattr(row, col)
  
      if has_sparse_col:
          get_col_from_row_fn = _get_from_dict
      else:
          get_col_from_row_fn = _get_from_named_tuple
  
      num_inputs = len(feature_columns)
      num_labels = len(label_columns)
  
      def as_tuple(v):
          return tuple(v) if len(v) > 1 else v[0]
  
      def prep(row):
          if sample_weight_col:
              sample_weight = get_col_from_row_fn(
                  row, sample_weight_col
              )
              return (
                  tuple(
                      tf.reshape(
                          get_col_from_row_fn(row, feature_columns[i]),
                          input_shapes[i],
                      )
                      for i in range(num_inputs)
                  ),
                  as_tuple(
                      [
                          tf.reshape(
                              get_col_from_row_fn(
                                  row, label_columns[j]
                              ),
                              label_shapes[j],
                          )
                          for j in range(num_labels)
                      ]
                  ),
                  {
                      name: tf.reshape(sample_weight, [-1])
                      for name in output_names
                  },
              )
          else:
              return (
                  tuple(
                      tf.reshape(
                          get_col_from_row_fn(row, feature_columns[i]),
                          input_shapes[i],
                      )
                      for i in range(num_inputs)
                  ),
                  as_tuple(
                      [
                          tf.reshape(
                              get_col_from_row_fn(
                                  row, label_columns[j]
                              ),
                              label_shapes[j],
                          )
                          for j in range(num_labels)
                      ]
                  ),
              )
  
      return prep
  
imports: import io
  from packaging import version
  import h5py
  import numpy
  import tensorflow
  from horovod.runner.common.util import codec
  from horovod.spark.common import constants, params
  from horovod.spark.keras import optimizer, remote
label_desc: Use image node_id 13 for calling the TFKerasUtil obj's underlying member method code with example usage: obj._prep_data_fn(has_sparse_col, sample_weight_col, feature_columns, label_columns, input_shapes, label_shapes, output_names) and returns: prep, row, getattr, unknown, tuple,  as_tuple,  unknown, tuple,  as_tuple