from typing import Union
from typing import List
from typing import Tuple


def _tupleize_compound_value(
    v: Union[List, bool, str, int, float]) -> Union[List, Tuple]:
  """ list of lists -> list of tuples
      list of primitives -> tuple of primitives
      single primitive -> length-1 tuple of that primitive

  E.g., [[0,1],[3,4]] -> [(0,1),(3,4)]
        [0,1] -> (0,1)
        0 -> (0, )
  """
  if isinstance(v, list):
    if isinstance(v[0], list):
      # v is list of lists
      return [tuple(vi) for vi in v]
    else:
      # v is list of primitives
      return tuple(v)
  else:
    # v is a single primitive (bool, str, int, float)
    return tuple([v])