def _get_name(f):
  """Gets the name of underlying objects."""
  if hasattr(f, '__name__'):
    return f.__name__
  # Next clause handles functools.partial objects.
  if hasattr(f, 'func') and hasattr(f.func, '__name__'):
    return f.func.__name__
  return repr(f)