def upload_custom_metric(func, func_file="metrics.py", func_name=None, class_name=None, source_provider=None):
    """
    Upload given metrics function into H2O cluster.

    The metrics can have different representation:
      - method
      - class: needs to inherit from water.udf.CFunc2 and implement method apply(actual, predict)
      returning double
      - string: the same as in class case, but the class is given as a string

    :param func:  metrics representation: string, class, function
    :param func_file:  internal name of file to save given metrics representation
    :param func_name:  name for h2o key under which the given metric is saved
    :param class_name: name of class wrapping the metrics function
    :param source_provider: a function which provides a source code for given function
    :return: reference to uploaded metrics function
    """
    import tempfile
    import inspect

    # Use default source provider
    if not source_provider:
        source_provider = _default_source_provider

    # The template wraps given metrics representation
    _CFUNC_CODE_TEMPLATE = """# Generated code