
    Vh                         d Z ddlZddlZddlmZ  ej
                         adefdZej                  ded   fd       Z
y)a  
Provides thread-local scope identification for SubgraphTracer instances.

This module implements a thread-safe mechanism for tracking nested tracing contexts,
which is essential when multiple SubgraphTracer instances are active. The scope ID
helps identify which tracer context is currently active when direct access to the
InstructionTranslator is difficult.

Key components:
- Thread-local scope ID storage (_current_scope_id)
- Getter function (current_scope_id) to safely access the current scope
- Context manager (enter_new_scope) for managing nested scope transitions

The scope ID increments when entering a new context and decrements when exiting,
allowing proper tracking of nested tracing operations across different threads.
    N)	Generatorreturnc                  X    t        t        d      sdt        _        t        j                  S )Nvalue   )hasattr_current_scope_idr        N/home/dcms/DCMS/lib/python3.12/site-packages/torch/_dynamo/current_scope_id.pycurrent_scope_idr      s"    $g."#"""r   )NNNc               #      K   	 t               dz   t        _        d  t               dz
  t        _        y # t               dz
  t        _        w xY ww)Nr   )r   r	   r   r
   r   r   enter_new_scoper   #   sB     9"2"4q"8"2"4q"8"2"4q"8s   A5 AAA)__doc__
contextlib	threadingcollections.abcr   localr	   intr   contextmanagerr   r
   r   r   <module>r      sY   "   %
 $IOO% ## # 9#34 9 9r   