docs: def _get_function(target):
      """Get target function.
  
      :param callable target: target from where get function.
  
      :return: depending on target type::
  
          - class: constructor.
          - method: method function.
          - function: function.
          - else: __call__ method.
  
      :raises: TypeError if target is not callable or is a class without a
          constructor.
      """
  
      result = None
  
      # raise TypeError if target is not callable
      if not callable(target):
          raise TypeError('target {0} must be callable'.format(target))
  
      # in case of class, final target is its constructor
      if isclass(target):
          constructor = getattr(
              target, '__init__',  # try to find __init__
              getattr(target, '__new__', None)
          )  # try to find __new__ | target
          # if no constructor exists
          if constructor is None:
              # create one
              def __init__(self):
                  pass
              if PY2:
                  target.__init__ = MethodType(__init__, None, target)
              else:
                  target.__init__ = __init__
              constructor = target.__init__
          # if constructor is a method, return function method
          if ismethod(constructor):
              result = constructor.__func__
          # else return constructor
          else:
              result = constructor
  
      elif ismethod(target):  # if target is a method, return function method
          result = target.__func__
  
      # return target if target is function or builtin
      elif isfunction(target) or isbuiltin(target) or isroutine(target):
          result = target
  
      else:  # otherwise, return __call__ method
          __call__ = getattr(target, '__call__')
  
          if ismethod(__call__):  # if __call__ is a method, return its function
              result = __call__.__func__
          else:  # otherwise return __call__
              result = __call__
  
      return result