code: def _convert_to_example(
      filename: str,
      image_buffer: str,
      label: int,
      synset: str,
      height: int,
      width: int,
  ) -> tf.train.Example:
      """
      Builds an Example proto for an ImageNet example.
  
      Args:
      filename: string, path to an image file, e.g., '/path/to/example.JPG'
      image_buffer: string, JPEG encoding of RGB image
      label: integer, identifier for the ground truth for the network
      synset: string, unique WordNet ID specifying the label, e.g., 'n02323233'
      height: integer, image height in pixels
      width: integer, image width in pixels
      Returns:
      Example proto
  
      """
      colorspace = "RGB"
      channels = 3
      image_format = "JPEG"
  
      example = tf.train.Example(
          features=tf.train.Features(
              feature={
                  "image/height": _int64_feature(height),
                  "image/width": _int64_feature(width),
                  "image/colorspace": _bytes_feature(colorspace),
                  "image/channels": _int64_feature(channels),
                  "image/class/label": _int64_feature(label),
                  "image/class/synset": _bytes_feature(synset),
                  "image/format": _bytes_feature(image_format),
                  "image/filename": _bytes_feature(
                      os.path.basename(filename)
                  ),
                  "image/encoded": _bytes_feature(image_buffer),
              }
          )
      )
      return example
  
imports: from datetime import datetime
  import math
  import os
  import random
  from typing import Iterable, List, Mapping, Union, Tuple
  import sys
  import threading
  import numpy
  import tensorflow
label_desc: Use image node_id 8 for calling a global function with example usage: _convert_to_example(filename, image_buffer, label, synset, height, width) and returns: example