from typing import List
from typing import Tuple
from typing import Any
from typing import Dict


def _find_self(param_names: List[str], args: Tuple[Any, ...], kwargs: Dict[str, Any]) -> Any:
    """Find the instance of ``self`` in the arguments."""
    instance_i = None
    try:
        instance_i = param_names.index("self")
    except ValueError:
        pass

    if instance_i is not None and instance_i < len(args):
        return args[instance_i]

    return kwargs["self"]