class_docstr: Base class for generator of stats proto from TF data.
class_docstr_tok: ["Base","class","for","generator","of","stats","proto","from","TF","data","."]
docstr: Parses data from an example, populating a dictionary of feature values.
  
  Args:
    example_features: A map of strings to tf.Features from the example.
    example_feature_lists: A map of strings to tf.FeatureLists from the
      example.
    entries: A dictionary of all features parsed thus far and arrays of their
        values. This is mutated by the function.
    index: The index of the example to parse from a list of examples.
  Raises:
    TypeError: Raises an exception when a feature has inconsistent types
    across
        examples.
docstr_tok: ["Parses","data","from","an","example",",","populating","a","dictionary","of","feature","values",".","Args",":","example_features",":","A","map","of","strings","to","tf.Features","from","the","example",".","example_feature_lists",":","A","map","of","strings","to","tf.FeatureLists","from","the","example",".","entries",":","A","dictionary","of","all","features","parsed","thus","far","and","arrays","of","their","values",".","This","is","mutated","by","the","function",".","index",":","The","index","of","the","example","to","parse","from","a","list","of","examples",".","Raises",":","TypeError",":","Raises","an","exception","when","a","feature","has","inconsistent","types","across","examples","."]
code: def _ParseExample(
      self, example_features, example_feature_lists, entries, index
  ):
      """Parses data from an example, populating a dictionary of feature values.
  
      Args:
        example_features: A map of strings to tf.Features from the example.
        example_feature_lists: A map of strings to tf.FeatureLists from the
          example.
        entries: A dictionary of all features parsed thus far and arrays of their
            values. This is mutated by the function.
        index: The index of the example to parse from a list of examples.
      Raises:
        TypeError: Raises an exception when a feature has inconsistent types
        across
            examples.
      """
      features_seen = set()
  
      for feature_list, is_feature in zip(
          [example_features, example_feature_lists], [True, False]
      ):
          sequence_length = None
          for feature_name in feature_list:
              # If this feature has not been seen in previous examples, then
              # initialize its entry into the entries dictionary.
              if feature_name not in entries:
                  entries[feature_name] = {
                      "vals": [],
                      "counts": [],
                      "feat_lens": [],
                      "missing": index,
                  }
  
              feature_entry = entries[feature_name]
              feature = feature_list[feature_name]
  
              value_type = None
              value_list = []
              if is_feature:
                  # If parsing a tf.Feature, extract the type and values simply.
                  if feature.HasField("float_list"):
                      value_list = feature.float_list.value
                      value_type = self.fs_proto.FLOAT
                  elif feature.HasField("bytes_list"):
                      value_list = feature.bytes_list.value
                      value_type = self.fs_proto.STRING
                  elif feature.HasField("int64_list"):
                      value_list = feature.int64_list.value
                      value_type = self.fs_proto.INT
              else:
                  # If parsing a tf.FeatureList, get the type and values by iterating
                  # over all Features in the FeatureList.
                  sequence_length = len(feature.feature)
                  if sequence_length != 0 and feature.feature[
                      0
                  ].HasField("float_list"):
                      for feat in feature.feature:
                          for value in feat.float_list.value:
                              value_list.append(value)
                      value_type = self.fs_proto.FLOAT
                  elif sequence_length != 0 and feature.feature[
                      0
                  ].HasField("bytes_list"):
                      for feat in feature.feature:
                          for value in feat.bytes_list.value:
                              value_list.append(value)
                      value_type = self.fs_proto.STRING
                  elif sequence_length != 0 and feature.feature[
                      0
                  ].HasField("int64_list"):
                      for feat in feature.feature:
                          for value in feat.int64_list.value:
                              value_list.append(value)
                      value_type = self.fs_proto.INT
              if value_type is not None:
                  if "type" not in feature_entry:
                      feature_entry["type"] = value_type
                  elif feature_entry["type"] != value_type:
                      raise TypeError(
                          "type mismatch for feature " + feature_name
                      )
              feature_entry["counts"].append(len(value_list))
              feature_entry["vals"].extend(value_list)
              if sequence_length is not None:
                  feature_entry["feat_lens"].append(sequence_length)
              if value_list:
                  features_seen.add(feature_name)
  
      # For all previously-seen features not found in this example, update the
      # feature's missing value.
      for f in entries:
          fv = entries[f]
          if f not in features_seen:
              fv["missing"] += 1
  
file_path: facets/facets_overview/python/base_feature_statistics_generator.py
imports: from functools import partial
  import warnings
  from base_generic_feature_statistics_generator import BaseGenericFeatureStatisticsGenerator
  import tensorflow
label_desc: Use image node_id 3 for calling the BaseFeatureStatisticsGenerator obj's underlying member method code with example usage: obj._ParseExample(example_features, example_feature_lists, entries, index) without return types