from typing import Iterable
from typing import Callable
from typing import Tuple
from typing import Any


def min_key(it: Iterable, key: Callable) -> Tuple[Any, Any]:
  """Minimum value and corresponding argument

  Args:
    it (iterable): Iterable of function arguments
    key (callable): Function

  Returns:
    Argmin and min of :data:`key(i) for i in it`"""
  i_ = None
  x_ = None
  for i in it:
    x = key(i)
    if x_ is None or x < x_:
      i_ = i
      x_ = x
  return i_, x_