class_docstr: Registry for DslContexts and associated BaseNodes of a pipeline DSL.
  
  DslContextRegistry manages the active DslContexts, their orders, BaseNodes,
  and association between DslContext and BaseNodes during the pipeline DSL
  definition. DslContext and BaseNode always belong to exactly one
  DslContextRegistry (1:n relationship).
class_docstr_tok: ["Registry","for","DslContexts","and","associated","BaseNodes","of","a","pipeline","DSL",".","DslContextRegistry","manages","the","active","DslContexts",",","their","orders",",","BaseNodes",",","and","association","between","DslContext","and","BaseNodes","during","the","pipeline","DSL","definition",".","DslContext","and","BaseNode","always","belong","to","exactly","one","DslContextRegistry","(","1",":","n","relationship",")","."]
code: def __init__(self):
      super().__init__()
      # Frame of currently active DSL context. Ordered by parent -> child.
      self._active_contexts: List[dsl_context.DslContext] = []
      # All DSL contexts that have ever been defined so far.
      self._all_contexts: List[dsl_context.DslContext] = []
      self._all_nodes: List[_BaseNode] = []
      # Mapping from Context ID to a list of nodes that belong to each context.
      # Each list of node is sorted chronologically.
      self._nodes_by_context = collections.defaultdict(list)
      self._finalized = False
  
imports: import collections
  import contextlib
  import threading
  from typing import Any, List, Optional, Iterator
  from tfx.dsl.context_managers import dsl_context
label_desc: Use image node_id 1 to create a new DslContextRegistry object  with example: obj = DslContextRegistry()