def splice_signatures(*sigs):
  """Creates a new signature by splicing together any number of signatures.

  The splicing effectively flattens the top level input signatures. For
  instance, it would perform the following mapping:

    - `*sigs: sd1, (sd2, sd3, sd4), (), sd5`
    - return: `(sd1, sd2, sd3, sd4, sd5)`

  Args:
    *sigs: Any number of signatures. A signature is either a `ShapeDtype`
        instance or a tuple of `ShapeDtype` instances.

  Returns:
    A single `ShapeDtype` instance if the spliced signature has one element,
    else a tuple of `ShapeDtype` instances.
  """
  result_sigs = []
  for sig in sigs:
    if isinstance(sig, (list, tuple)):
      result_sigs.extend(sig)
    else:
      result_sigs.append(sig)
  return result_sigs[0] if len(result_sigs) == 1 else tuple(result_sigs)
Creates a new signature by splicing together any number of signatures.

  The splicing effectively flattens the top level input signatures. For
  instance, it would perform the following mapping:

    - `*sigs: sd1, (sd2, sd3, sd4), (), sd5`
    - return: `(sd1, sd2, sd3, sd4, sd5)`

  Args:
    *sigs: Any number of signatures. A signature is either a `ShapeDtype`
        instance or a tuple of `ShapeDtype` instances.

  Returns:
    A single `ShapeDtype` instance if the spliced signature has one element,
    else a tuple of `ShapeDtype` instances.
  
trax/shapes.py