def _make_singleitem_or_original(xs):
  """Returns a single element if possible, or the original list/tuple if not."""
  if isinstance(xs, (list, tuple)) and len(xs) == 1:
    return xs[0]
  else:
    return xs
Returns a single element if possible, or the original list/tuple if not.
trax/layers/combinators.py