def set_transformer_in_out(transformer, inputCol, outputCol):
    """Set input and output column(s) of a transformer instance."""
    transformer = transformer.copy()
    try:
        transformer.setInputCol(inputCol)
    except AttributeError:
        try:
            transformer.setInputCols([inputCol])
        except AttributeError:
            message = (
                "Invalid transformer (doesn't have setInputCol or setInputCols): "
                , str(transformer.__class__))
            raise ValueError(message)
    try:
        transformer.setOutputCol(outputCol)
    except AttributeError:
        try:
            transformer.setOutputCols([outputCol])
        except AttributeError:
            pass
    return transformer
