<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def visdom_send_metrics(vis, metrics, update='replace'):
 """ Send set of metrics to visdom """

    visited = {}

    sorted_metrics = sorted(metrics.columns, key=_column_original_name)
    for metric_basename, metric_list in it.groupby(sorted_metrics, key=_column_original_name):
        metric_list = list(metric_list)

        for metric in metric_list:
            if vis.win_exists(metric_basename) and (not visited.get(metric, False)):
                update = update
            elif not vis.win_exists(metric_basename):
                update = None
            else:
                update = 'append'

            vis.line(
                metrics[metric].values,
                metrics.index.values,
                win=metric_basename,
                name=metric,
                opts={
                    'title': metric_basename,
                    'showlegend': True
                },
                update=update
            )

            if metric_basename != metric and len(metric_list) > 1:
                if vis.win_exists(metric):
                    update = update
                else:
                    update = None

                vis.line(
                    metrics[metric].values,
                    metrics.index.values,
                    win=metric,
                    name=metric,
                    opts={
                        'title': metric,
                        'showlegend': True
                    },
                    update=update
                )