code: def sequences_to_onehot(sequences):
      """Convert DNA sequences into a one hot nucleotide encoding.
  
      Each nucleotide in each sequence is mapped as follows:
      A -> [1, 0, 0, 0]
      C -> [0, 1, 0, 0]
      G -> [0 ,0 ,1, 0]
      T -> [0, 0, 0, 1]
  
      If for some reason a non (A, T, C, G) character exists in the string, it is
      currently mapped to a error one hot encoding [1, 1, 1, 1].
  
      Args:
          sequences: A tf.string tensor where each string represents a DNA sequence
  
      Returns:
          tf.RaggedTensor: The output sequences with nucleotides one hot encoded.
      """
      all_onehot_nucleotides = tf.TensorArray(
          dtype=tf.int32, size=0, dynamic_size=True
      )
      sequence_splits = tf.TensorArray(
          dtype=tf.int32, size=0, dynamic_size=True
      )
  
      global_nucleotide_idx = 0
      sequence_splits = sequence_splits.write(
          sequence_splits.size(), global_nucleotide_idx
      )
  
      for sequence in sequences:
          for nucleotide in tf.strings.bytes_split(sequence):
              all_onehot_nucleotides = all_onehot_nucleotides.write(
                  global_nucleotide_idx,
                  _nucleotide_to_onehot(nucleotide),
              )
              global_nucleotide_idx += 1
          sequence_splits = sequence_splits.write(
              sequence_splits.size(), global_nucleotide_idx
          )
      return tf.RaggedTensor.from_row_splits(
          values=all_onehot_nucleotides.stack(),
          row_splits=tf.cast(sequence_splits.stack(), tf.int64),
      )
  
file_path: io/tensorflow_io/python/ops/genome_ops.py
imports: import tensorflow
  from tensorflow_io.python.ops import core_ops
label_desc: Use image node_id 3 for calling a global function with example usage: sequences_to_onehot(sequences) and returns: tf