def create_element_id(features: Dict[str, Any]): """Hash the element id to compute a unique id.""" assert "element_id" not in features, \ "`element_id` should not be already present in the feature set." fingerprint_feature = features[self._fingerprint_key] features["element_id"] = ops.fingerprint_int64(fingerprint_feature) return features
def _create_element_id(self, features: types.Features) -> types.Features: """Hash element id for a unique id per data element (NOT per-step).""" if 'element_id' in features: raise ValueError( '`element_id` should not be already present in the feature set.') fingerprint_feature = features[self._fingerprint_key] features['element_id'] = ops.fingerprint_int64(fingerprint_feature) return features
def _create_element_id(self, features: types.Features) -> types.Features: """Hash the element id to compute a unique id.""" if 'element_id' in features: raise ValueError( '`element_id` should not be already present in the feature set.') fingerprint_feature = features[self._fingerprint_key] features['element_id'] = ops.fingerprint_int64(fingerprint_feature) return features
def _make_element_id_unique(dataset_tag: str): """We make element_id differ in the in- and out-of-distribution datasets.""" dataset_fingerprint = ops.fingerprint_int64(dataset_tag) def _make_element_id_unique_fn(feature): fingerprint = (feature["metadata"]["element_id"], dataset_fingerprint) feature["metadata"]["element_id"] = ops.fingerprint_int64(fingerprint) return feature return _make_element_id_unique_fn
def _make_element_id_unique_fn(feature): fingerprint = (feature["metadata"]["element_id"], dataset_fingerprint) feature["metadata"]["element_id"] = ops.fingerprint_int64(fingerprint) return feature
def _compute_element_id(self, features: Dict[str, Any]): """Hash the element id to compute a unique id.""" assert_msg = "`element_id` should not be present in the feature set." assert "element_id" not in features, assert_msg fingerprint_feature = features[self._fingerprint_key] return ops.fingerprint_int64(fingerprint_feature)