code: def _gen_unzip(it, elem_len):
      """Helper for unzip which checks the lengths of each element in it.
      Parameters
      ----------
      it : iterable[tuple]
          An iterable of tuples. ``unzip`` should map ensure that these are
          already tuples.
      elem_len : int or None
          The expected element length. If this is None it is infered from the
          length of the first element.
      Yields
      ------
      elem : tuple
          Each element of ``it``.
      Raises
      ------
      ValueError
          Raised when the lengths do not match the ``elem_len``.
      """
      elem = next(it)
      first_elem_len = len(elem)
  
      if elem_len is not None and elem_len != first_elem_len:
          raise ValueError(
              "element at index 0 was length %d, expected %d"
              % (
                  first_elem_len,
                  elem_len,
              )
          )
      else:
          elem_len = first_elem_len
  
      yield elem
      for n, elem in enumerate(it, 1):
          if len(elem) != elem_len:
              raise ValueError(
                  "element at index %d was length %d, expected %d"
                  % (
                      n,
                      len(elem),
                      elem_len,
                  ),
              )
          yield elem
  
file_path: zipline/zipline/utils/functional.py
imports: from functools import reduce
  from operator import itemgetter
  from pprint import pformat
  from six import viewkeys, iteritems
  from six.moves import map, zip
  from toolz import curry, flip
  from .sentinel import sentinel
label_desc: Use image node_id 6 for calling a global function with example usage: _gen_unzip(it, elem_len) without return types