def _get_external_source_param(input_name, input_value, name_es_map, param_name):
    """Get value of the parameter `param_name` specified for the External Source node
       named `input_name`. It can be specified either via `input_value` or in the op instance
       passed in `name_es_map`.
       Not `None` value in `input_value` overwrites the one specified in the Operator instances.
       Otherwise, the one from pipeline definition (the op instance) is used.

    Parameters
    ----------
    input_name : str
        Name of the input
    input_value : Input, optional
        Description of the input
    name_es_map : dict[str, ExternalSource]
        Mapping from the External Source names to operator nodes.
    param_name : str
        name of the parameter we want to access
    """
    def get_param_from_pipe(input_name, name_es_map, param_name):
        es_op = name_es_map[input_name]
        # Check the OpInstance and the `_op`
        try:
            return getattr(es_op, "_" + param_name)
        except AttributeError:
            return getattr(es_op._op, "_" + param_name, None)

    # We didn't get input through input_datasets
    if input_value is None or getattr(input_value, param_name) is None:
        return get_param_from_pipe(input_name, name_es_map, param_name)
    else:
        return getattr(input_value, param_name)