def get_idx_list(inputs, idx_list, get_count=False):
 n = (len(inputs) - 1)
 if (n == 0):
  return tuple(idx_list)
 indices = list(reversed(list(inputs[1:])))
 def convert(entry):
  if isinstance(entry, gof.Type):
   return indices.pop()
  elif isinstance(entry, slice):
   return slice(convert(entry.start), convert(entry.stop), convert(entry.step))
  else:
   return entry
 cdata = tuple(map(convert, idx_list))
 if get_count:
  return (n - len(indices))
 else:
  return cdata

def get_idx_list ( inputs , idx_list , get_count = False ) : n = ( len ( inputs ) - 1 ) if ( n == 0 ) : return tuple ( idx_list ) indices = list ( reversed ( list ( inputs [ 1 : ] ) ) ) def convert ( entry ) : if isinstance ( entry , gof . Type ) : return indices . pop ( ) elif isinstance ( entry , slice ) : return slice ( convert ( entry . start ) , convert ( entry . stop ) , convert ( entry . step ) ) else : return entry cdata = tuple ( map ( convert , idx_list ) ) if get_count : return ( n - len ( indices ) ) else : return cdata
given a list of inputs to the subtensor and its idx_list reorders the inputs according to the idx list to get the right values .