Add a `FlexibleAlias` to `mypy_extensions` (#5436)

Currently there is no way to define generic type aliases that do not
depend on their type arguments or that are just directly a type
variable.

`FlexibleAlias[T, typ]` creates a type that depends on `T` but that is
expanded to `typ` during type alias expansion.

One target use case for this is in creating conditionally defined type
aliases that depend on their argument under certain configurations but
not under others, for example:
```
if BOGUS:
    Bogus = FlexibleAlias[T, Any]
else:
    Bogus = FlexibleAlias[T, T]
```
diff --git a/mypy_extensions.py b/mypy_extensions.py
index 0fc3b43..a05ea55 100644
--- a/mypy_extensions.py
+++ b/mypy_extensions.py
@@ -139,3 +139,23 @@
 
 def trait(cls):
     return cls
+
+
+# TODO: We may want to try to properly apply this to any type
+# variables left over...
+class _FlexibleAliasClsApplied:
+    def __init__(self, val):
+        self.val = val
+
+    def __getitem__(self, args):
+        return self.val
+
+
+class _FlexibleAliasCls:
+    def __getitem__(self, args):
+        return _FlexibleAliasClsApplied(args[-1])
+
+
+FlexibleAlias = _FlexibleAliasCls()
+
+Id = _FlexibleAliasCls()