def _hash_example(states: List[State], action: Text, tracker: DialogueStateTracker) -> int: """Hash states for efficient deduplication.""" frozen_states = tuple( s if s is None else tracker.freeze_current_state(s) for s in states) frozen_actions = (action, ) return hash((frozen_states, frozen_actions))
def _hash_example(states: List[State], labels: Optional[List[Text]] = None) -> int: """Hashes states (and optionally label). Produces a hash of the tracker state sequence (and optionally the labels). If `labels` is `None`, labels don't get hashed. Args: states: The tracker state sequence to hash. labels: Label strings associated with this state sequence. Returns: The hash of the states and (optionally) the label. """ frozen_states = tuple( s if s is None else DialogueStateTracker.freeze_current_state(s) for s in states) if labels is not None: frozen_labels = tuple(labels) return hash((frozen_states, frozen_labels)) else: return hash(frozen_states)