parameters: (tp, tvars, subs)
return_statement: return tp.copy_with(tuple(new_args))
docstring: Substitute type variables 'tvars' with substitutions 'subs'.
      These two must have the same length.
docstring_summary: Substitute type variables 'tvars' with substitutions 'subs'.
      These two must have the same length.
docstring_tokens: Substitute type variables tvars with substitutions subs . These two must have the same length .
function: def _subs_tvars(tp, tvars, subs):
      """Substitute type variables 'tvars' with substitutions 'subs'.
      These two must have the same length.
      """
      if not isinstance(tp, _GenericAlias):
          return tp
      new_args = list(tp.__args__)
      for a, arg in enumerate(tp.__args__):
          if isinstance(arg, TypeVar):
              for i, tvar in enumerate(tvars):
                  if arg == tvar:
                      new_args[a] = subs[i]
          else:
              new_args[a] = _subs_tvars(arg, tvars, subs)
      if tp.__origin__ is Union:
          return Union[tuple(new_args)]
      return tp.copy_with(tuple(new_args))
function_tokens: def _subs_tvars ( tp , tvars , subs ) : if not isinstance ( tp , _GenericAlias ) : return tp new_args = list ( tp . __args__ ) for a , arg in enumerate ( tp . __args__ ) : if isinstance ( arg , TypeVar ) : for i , tvar in enumerate ( tvars ) : if arg == tvar : new_args [ a ] = subs [ i ] else : new_args [ a ] = _subs_tvars ( arg , tvars , subs ) if tp . __origin__ is Union : return Union [ tuple ( new_args ) ] return tp . copy_with ( tuple ( new_args ) )