'Return the simplest possible composite unit(s) that represent
the given unit.  Since there may be multiple equally simple
compositions of the unit, a list of units is always returned.
Parameters
equivalencies : list of equivalence pairs, optional
A list of equivalence pairs to also list.  See
:ref:`unit_equivalencies`.
This list is in addition to possible global defaults set by, e.g.,
`set_enabled_equivalencies`.
Use `None` to turn off all equivalencies.
units : set of units to compose to, optional
If not provided, any known units may be used to compose
into.  Otherwise, ``units`` is a dict, module or sequence
containing the units to compose into.
max_depth : int, optional
The maximum recursion depth to use when composing into
composite units.
include_prefix_units : bool, optional
When `True`, include prefixed units in the result.
Default is `False`.
Returns
units : list of `CompositeUnit`
A list of candidate compositions.  These will all be
equally simple, but it may not be possible to
automatically determine which of the candidates are
better.'

def compose(self, equivalencies=[], units=None, max_depth=2, include_prefix_units=False):

    equivalencies = self._normalize_equivalencies(equivalencies)
    def has_bases_in_common(a, b):
        if ((len(a.bases) == 0) and (len(b.bases) == 0)):
            return True
        for ab in a.bases:
            for bb in b.bases:
                if (ab == bb):
                    return True
        return False
    def has_bases_in_common_with_equiv(unit, other):
        if has_bases_in_common(unit, other):
            return True
        for (funit, tunit, a, b) in equivalencies:
            if (tunit is not None):
                if unit._is_equivalent(funit):
                    if has_bases_in_common(tunit.decompose(), other):
                        return True
                elif unit._is_equivalent(tunit):
                    if has_bases_in_common(funit.decompose(), other):
                        return True
            elif unit._is_equivalent(funit):
                if has_bases_in_common(dimensionless_unscaled, other):
                    return True
        return False
    def filter_units(units):
        filtered_namespace = set()
        for tunit in units:
            if (isinstance(tunit, UnitBase) and (include_prefix_units or (not isinstance(tunit, PrefixUnit))) and has_bases_in_common_with_equiv(decomposed, tunit.decompose())):
                filtered_namespace.add(tunit)
        return filtered_namespace
    decomposed = self.decompose()
    if (units is None):
        units = filter_units(self._get_units_with_same_physical_type(equivalencies=equivalencies))
        if (len(units) == 0):
            units = get_current_unit_registry().non_prefix_units
    elif isinstance(units, dict):
        units = set(filter_units(six.itervalues(units)))
    elif inspect.ismodule(units):
        units = filter_units(six.itervalues(vars(units)))
    else:
        units = filter_units(_flatten_units_collection(units))
    def sort_results(results):
        if (not len(results)):
            return []
        results = list(results)
        results.sort(key=(lambda x: np.abs(x.scale)))
        results.sort(key=(lambda x: np.sum(np.abs(x.powers))))
        results.sort(key=(lambda x: (np.sum(x.powers) < 0.0)))
        results.sort(key=(lambda x: (not is_effectively_unity(x.scale))))
        last_result = results[0]
        filtered = [last_result]
        for result in results[1:]:
            if (str(result) != str(last_result)):
                filtered.append(result)
            last_result = result
        return filtered
    return sort_results(self._compose(equivalencies=equivalencies, namespace=units, max_depth=max_depth, depth=0, cached_results={}))
