title: How to use apply and map function on tf dataset with custom function
body: <p>I am trying to understand how to use map and apply function in TensorFlow. Objective is to use all the basic data pre-processing step while reading the data into TensorFlow as map gives an option to parallelize the operation.</p>
  
  <pre><code>a_list = [b"THis is for Testing"]
  </code></pre>
  
  <h1>converting a_list into tf dataset format</h1>
  
  <pre><code>a_dataset = tf.data.Dataset.from_tensors(a_list)
  
  print(list(a_dataset.as_numpy_iterator()))
  [array([b'THis is for Testing'], dtype=object)]
  </code></pre>
  
  <h1>Applying map to calculate len of list</h1>
  
  <pre><code>a_dataset_len = a_dataset.map(lambda x: len(x))
  
  print(list(a_dataset_len.as_numpy_iterator()))
  
  [1]
  </code></pre>
  
  <h1>Applying map to convert all strings into lowercase</h1>
  
  <pre><code>a_dataset_lower = a_dataset.map(lambda x: x.lower())
  AttributeError: 'Tensor' object has no attribute 'lower'
  </code></pre>
  
  <h1>Using apply function on a_list</h1>
  
  <pre><code>a_dataset.apply(lambda x:len(x))
  TypeError: object of type 'TensorDataset' has no len()
  </code></pre>
  
  <p>Please help me to understand </p>
  
  <ol>
  <li>Why I am failing to use apply function using len(x) while map is
  able to execute ?  </li>
  <li>How to create own custom function and use the pre-built one to pass it during Dataset.map and Dataset.apply?</li>
  </ol>