def _column_schema_from_json(feature_dict):
  """Translate a JSON feature dict into a feature spec."""
  dtype = _dtype_from_json(feature_dict['domain'])
  tf_options = feature_dict['parsingOptions']['tfOptions']
  if tf_options.get('fixedLenFeature') is not None:
    default_value = None
    try:
      # int() is needed because protobuf JSON encodes int64 as string
      default_value = _convert_scalar_or_list(
          int, tf_options['fixedLenFeature']['intDefaultValue'])
    except KeyError:
      try:
        default_value = tf_options['fixedLenFeature']['stringDefaultValue']
      except KeyError:
        try:
          default_value = tf_options['fixedLenFeature']['floatDefaultValue']
        except KeyError:
          pass
    axes = feature_dict['fixedShape'].get('axis', [])
    shape = [int(axis['size']) for axis in axes]
    return tf.io.FixedLenFeature(shape, dtype, default_value)
  elif tf_options.get('varLenFeature') is not None:
    return tf.io.VarLenFeature(dtype)
  else:
    raise ValueError('Could not interpret tfOptions: {}'.format(tf_options))
Translate a JSON feature dict into a feature spec.
tensorflow_transform/tf_metadata/metadata_io.py