code: def encode_example(self, example_data):
      
      np_dtype = np.dtype(self._dtype.as_numpy_dtype)
      # Convert to numpy if possible
      if not isinstance(example_data, np.ndarray):
        example_data = np.array(example_data, dtype=np_dtype)
      # Ensure the shape and dtype match
      if example_data.dtype != np_dtype:
        raise ValueError('Dtype {} do not match {}'.format(
            example_data.dtype, np_dtype))
      utils.assert_shape_match(example_data.shape, self._shape)
      # For booleans, convert to integer (tf.train.Example does not support bool)
      if example_data.dtype == np.bool_:
        example_data = example_data.astype(int)
      return example_data
docs: See base class for details.