#NEWLINE# def get_idx_list( inputs , idx_list , get_count = False ) : #NEWLINE# #INDENT# '\n    Given a list of inputs to the subtensor and its idx_list reorders\n    the inputs according to the idx list to get the right values.\n\n    If get_counts=True, instead returns the number of inputs consumed\n    during this process.\n\n    ' #NEWLINE# n = ( len ( inputs ) - 1 ) #NEWLINE# if ( n == 0 ) : #NEWLINE# #INDENT# return tuple ( idx_list ) #NEWLINE# #UNINDENT# indices = list ( reversed ( list ( inputs [ 1 : ] ) ) ) #NEWLINE# def convert( entry ) : #NEWLINE# #INDENT# if isinstance ( entry , gof . Type ) : #NEWLINE# #INDENT# return indices . pop ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( entry , slice ) : #NEWLINE# #INDENT# return slice ( convert ( entry . start ) , convert ( entry . stop ) , convert ( entry . step ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return entry #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# cdata = tuple ( map ( convert , idx_list ) ) #NEWLINE# if get_count : #NEWLINE# #INDENT# return ( n - len ( indices ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return cdata