code: def parse_example(
      example: tf.train.Example, input_shape: Tuple[int, int, int]
  ) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]:
      """Parses a serialized tf.Example, preprocesses the image, and one-hot encodes the label."""
      proto_features = {
          "image/encoded": tf.io.FixedLenFeature((), tf.string),
          "variant/encoded": tf.io.FixedLenFeature((), tf.string),
          "alt_allele_indices/encoded": tf.io.FixedLenFeature(
              (), tf.string
          ),
          "label": tf.io.FixedLenFeature((1), tf.int64),
      }
      proto_features_denovo = {
          "denovo_label": tf.io.FixedLenFeature((1), tf.int64),
      } | proto_features
  
      if FLAGS.train_config.denovo_enabled:
          parsed_features = tf.io.parse_single_example(
              serialized=example, features=proto_features_denovo
          )
      else:
          parsed_features = tf.io.parse_single_example(
              serialized=example, features=proto_features
          )
      image = tf.io.decode_raw(
          parsed_features["image/encoded"], tf.uint8
      )
      image = tf.reshape(image, input_shape)
      image = tf.cast(image, tf.float32)
  
      # Image preprocessing and one-hot encoding were previously done inside the
      # TF Estimator API's model_fn. Though we can subclass the Keras InceptionV3
      # class and do it in the forward pass, it seems more fitting to do it during
      # dataset loading along with the above image loading steps.
      image = dv_utils.preprocess_images(image)
      label = tf.keras.layers.CategoryEncoding(
          num_tokens=dv_constants.NUM_CLASSES, output_mode="one_hot"
      )(parsed_features["label"])
  
      if (
          FLAGS.train_config.denovo_enabled
          and parsed_features["denovo_label"][0] == 1
      ):
          # If the example is denovo then set the denovo example weights for this.
          sample_weight = tf.constant(
              FLAGS.train_config.denovo_weight, dtype=tf.float32
          )
      else:
          sample_weight = tf.constant(1.0, dtype=tf.float32)
  
      return image, label, sample_weight
  
imports: import gc
  import os
  import re
  from typing import Any, Dict, Optional, Tuple
  import warnings
  from absl import app
  from absl import flags
  from absl import logging
  from ml_collections.config_flags import config_flags
  import tensorflow
  import tensorflow_addons
  from deepvariant import data_providers
  from deepvariant import dv_constants
  from deepvariant import dv_utils
  from deepvariant import keras_modeling
  from deepvariant.average_model_checkpoint_patched import AverageModelCheckpointPatched
  from third_party.nucleus.io import sharded_file_utils
  from official.modeling import optimization
label_desc: Use image node_id 1 for calling a global function with example usage: parse_example(example, input_shape) and returns: image,  label,  sample_weight