
    sg                     L    d dl Z d dlZdej                  j                  ddfdZy)    Ngraphreturnc                    | j                   D ]v  }|j                  t        j                  k(  s"|j                  \  }}|j
                  s>t        |j
                  d      r|j
                  j                  }|j
                  j                  dk(  rNt        |      dk(  r#t        |d   t        d            r|d   |_        t        |      |kD  sJ ||   }||_        |j
                  j                  dk(  st        |      dk(  sJ |d   |_        t        |j
                  d      s|j
                  t        j                  k(  r>|j
                  j                  }|j
                  j                  |   }||   |_        y y	)
a  
    Annotate the type of getitem nodes, inferred from the type of sequence node.
    If sequence node is not annotated with a type, do nothing.
    Currently support getitem nodes from Tuple, List, and NamedTuple sequence node.

    This is helpful since annotations on local names within function are lost during FX transforms.
    Adding back known type annotation for getitem nodes to improve jit scriptability.

    Args:
        graph (Graph): The graph to be annotated
    _nameTuple      .r   List__annotations__N)nodestargetoperatorgetitemargstypehasattr__args__r   len
isinstancetorchTensorr   _fields)r   nodesequence_node
index_nodeparameterized_types	node_typesequence_node_field_types
field_names           Y/var/www/html/venv/lib/python3.12/site-packages/torch/fx/passes/annotate_getitem_nodes.pyannotate_getitem_nodesr!      s_     B;;(***(,		%M: %%}))73&3&8&8&A&A# %%++w6./14+A.S	: %8$:	"#67*DDD$7
$C	$-	"''--723q888 3A 6DI++->? %%5,9,>,>,N,N)*//77
C
5jA	5B    )r   r   fxGraphr!    r"   r    <module>r&      s)     &B%((.. &BT &Br"   