def _type_from_subscripted_value(root: Optional[Value], members: Sequence[Value], ctx: Context, is_typeddict: bool=False) -> Value:
    if isinstance(root, GenericValue):
        if (len(root.args) == len(members)):
            return GenericValue(root.typ, [_type_from_value(member, ctx) for member in members])
    if isinstance(root, _SubscriptedValue):
        root_type = _type_from_value(root, ctx)
        return _type_from_subscripted_value(root_type, members, ctx)
    elif isinstance(root, MultiValuedValue):
        return unite_values(*[_type_from_subscripted_value(subval, members, ctx, is_typeddict) for subval in root.vals])
    if (isinstance(root, SubclassValue) and root.exactly and isinstance(root.typ, TypedValue)):
        return GenericValue(root.typ.typ, [_type_from_value(elt, ctx) for elt in members])
    if (isinstance(root, TypedValue) and isinstance(root.typ, str)):
        return GenericValue(root.typ, [_type_from_value(elt, ctx) for elt in members])
    if (not isinstance(root, KnownValue)):
        if (root != AnyValue(AnySource.error)):
            ctx.show_error(f'Cannot resolve subscripted annotation: {root}')
        return AnyValue(AnySource.error)
    root = root.val
    if (root is typing.Union):
        return unite_values(*[_type_from_value(elt, ctx) for elt in members])
    elif is_typing_name(root, 'Literal'):
        if all((isinstance(elt, KnownValue) for elt in members)):
            return unite_values(*members)
        else:
            ctx.show_error(f'Arguments to Literal[] must be literals, not {members}')
            return AnyValue(AnySource.error)
    elif ((root is typing.Tuple) or (root is tuple)):
        if ((len(members) == 2) and (members[1] == KnownValue(Ellipsis))):
            return GenericValue(tuple, [_type_from_value(members[0], ctx)])
        elif ((len(members) == 1) and (members[0] == KnownValue(()))):
            return SequenceIncompleteValue(tuple, [])
        else:
            return SequenceIncompleteValue(tuple, [_type_from_value(arg, ctx) for arg in members])
    elif (root is typing.Optional):
        if (len(members) != 1):
            ctx.show_error('Optional[] takes only one argument')
            return AnyValue(AnySource.error)
        return unite_values(KnownValue(None), _type_from_value(members[0], ctx))
    elif ((root is typing.Type) or (root is type)):
        if (len(members) != 1):
            ctx.show_error('Type[] takes only one argument')
            return AnyValue(AnySource.error)
        argument = _type_from_value(members[0], ctx)
        return SubclassValue.make(argument)
    elif is_typing_name(root, 'Annotated'):
        (origin, *metadata) = members
        return _make_annotated(_type_from_value(origin, ctx), metadata, ctx)
    elif is_typing_name(root, 'TypeGuard'):
        if (len(members) != 1):
            ctx.show_error('TypeGuard requires a single argument')
            return AnyValue(AnySource.error)
        return AnnotatedValue(TypedValue(bool), [TypeGuardExtension(_type_from_value(members[0], ctx))])
    elif is_typing_name(root, 'Required'):
        if (not is_typeddict):
            ctx.show_error('Required[] used in unsupported context')
            return AnyValue(AnySource.error)
        if (len(members) != 1):
            ctx.show_error('Required[] requires a single argument')
            return AnyValue(AnySource.error)
        return Pep655Value(True, _type_from_value(members[0], ctx))
    elif is_typing_name(root, 'NotRequired'):
        if (not is_typeddict):
            ctx.show_error('NotRequired[] used in unsupported context')
            return AnyValue(AnySource.error)
        if (len(members) != 1):
            ctx.show_error('NotRequired[] requires a single argument')
            return AnyValue(AnySource.error)
        return Pep655Value(False, _type_from_value(members[0], ctx))
    elif ((root is Callable) or (root is typing.Callable)):
        if (len(members) == 2):
            (args, return_value) = members
            return _make_callable_from_value(args, return_value, ctx)
        ctx.show_error('Callable requires exactly two arguments')
        return AnyValue(AnySource.error)
    elif (root is AsynqCallable):
        if (len(members) == 2):
            (args, return_value) = members
            return _make_callable_from_value(args, return_value, ctx, is_asynq=True)
        ctx.show_error('AsynqCallable requires exactly two arguments')
        return AnyValue(AnySource.error)
    elif typing_inspect.is_generic_type(root):
        origin = typing_inspect.get_origin(root)
        if (origin is None):
            origin = root
        origin = _maybe_get_extra(origin)
        return GenericValue(origin, [_type_from_value(elt, ctx) for elt in members])
    elif isinstance(root, type):
        return GenericValue(root, [_type_from_value(elt, ctx) for elt in members])
    else:
        origin = get_origin(root)
        if isinstance(origin, type):
            return GenericValue(origin, [_type_from_value(elt, ctx) for elt in members])
        ctx.show_error(f'Unrecognized subscripted annotation: {root}')
        return AnyValue(AnySource.error)
def _type_from_subscripted_value(root: Optional[Value], members: Sequence[Value], ctx: Context, is_typeddict: bool=False) -> Value:
    if isinstance(root, GenericValue):
        if (len(root.args) == len(members)):
            return GenericValue(root.typ, [_type_from_value(member, ctx) for member in members])
    if isinstance(root, _SubscriptedValue):
        root_type = _type_from_value(root, ctx)
        return _type_from_subscripted_value(root_type, members, ctx)
    elif isinstance(root, MultiValuedValue):
        return unite_values(*[_type_from_subscripted_value(subval, members, ctx, is_typeddict) for subval in root.vals])
    if (isinstance(root, SubclassValue) and root.exactly and isinstance(root.typ, TypedValue)):
        return GenericValue(root.typ.typ, [_type_from_value(elt, ctx) for elt in members])
    if (isinstance(root, TypedValue) and isinstance(root.typ, str)):
        return GenericValue(root.typ, [_type_from_value(elt, ctx) for elt in members])
    if (not isinstance(root, KnownValue)):
        if (root != AnyValue(AnySource.error)):
            ctx.show_error(f'Cannot resolve subscripted annotation: {root}')
        return AnyValue(AnySource.error)
    root = root.val
    if (root is typing.Union):
        return unite_values(*[_type_from_value(elt, ctx) for elt in members])
    elif is_typing_name(root, 'Literal'):
        if all((isinstance(elt, KnownValue) for elt in members)):
            return unite_values(*members)
        else:
            ctx.show_error(f'Arguments to Literal[] must be literals, not {members}')
            return AnyValue(AnySource.error)
    elif ((root is typing.Tuple) or (root is tuple)):
        if ((len(members) == 2) and (members[1] == KnownValue(Ellipsis))):
            return GenericValue(tuple, [_type_from_value(members[0], ctx)])
        elif ((len(members) == 1) and (members[0] == KnownValue(()))):
            return SequenceIncompleteValue(tuple, [])
        else:
            return SequenceIncompleteValue(tuple, [_type_from_value(arg, ctx) for arg in members])
    elif (root is typing.Optional):
        if (len(members) != 1):
            ctx.show_error('Optional[] takes only one argument')
            return AnyValue(AnySource.error)
        return unite_values(KnownValue(None), _type_from_value(members[0], ctx))
    elif ((root is typing.Type) or (root is type)):
        if (len(members) != 1):
            ctx.show_error('Type[] takes only one argument')
            return AnyValue(AnySource.error)
        argument = _type_from_value(members[0], ctx)
        return SubclassValue.make(argument)
    elif is_typing_name(root, 'Annotated'):
        (origin, *metadata) = members
        return _make_annotated(_type_from_value(origin, ctx), metadata, ctx)
    elif is_typing_name(root, 'TypeGuard'):
        if (len(members) != 1):
            ctx.show_error('TypeGuard requires a single argument')
            return AnyValue(AnySource.error)
        return AnnotatedValue(TypedValue(bool), [TypeGuardExtension(_type_from_value(members[0], ctx))])
    elif is_typing_name(root, 'Required'):
        if (not is_typeddict):
            ctx.show_error('Required[] used in unsupported context')
            return AnyValue(AnySource.error)
        if (len(members) != 1):
            ctx.show_error('Required[] requires a single argument')
            return AnyValue(AnySource.error)
        return Pep655Value(True, _type_from_value(members[0], ctx))
    elif is_typing_name(root, 'NotRequired'):
        if (not is_typeddict):
            ctx.show_error('NotRequired[] used in unsupported context')
            return AnyValue(AnySource.error)
        if (len(members) != 1):
            ctx.show_error('NotRequired[] requires a single argument')
            return AnyValue(AnySource.error)
        return Pep655Value(False, _type_from_value(members[0], ctx))
    elif ((root is Callable) or (root is typing.Callable)):
        if (len(members) == 2):
            (args, return_value) = members
            return _make_callable_from_value(args, return_value, ctx)
        ctx.show_error('Callable requires exactly two arguments')
        return AnyValue(AnySource.error)
    elif (root is AsynqCallable):
        if (len(members) == 2):
            (args, return_value) = members
            return _make_callable_from_value(args, return_value, ctx, is_asynq=True)
        ctx.show_error('AsynqCallable requires exactly two arguments')
        return AnyValue(AnySource.error)
    elif typing_inspect.is_generic_type(root):
        origin = typing_inspect.get_origin(root)
        if (origin is None):
            origin = root
        origin = _maybe_get_extra(origin)
        return GenericValue(origin, [_type_from_value(elt, ctx) for elt in members])
    elif isinstance(root, type):
        return GenericValue(root, [_type_from_value(elt, ctx) for elt in members])
    else:
        origin = get_origin(root)
        if isinstance(origin, type):
            return GenericValue(origin, [_type_from_value(elt, ctx) for elt in members])
        ctx.show_error(f'Unrecognized subscripted annotation: {root}')
        return AnyValue(AnySource.error)