#NEWLINE# def batch_length( batch ) : #NEWLINE# #INDENT# 'Determine the number of samples in a batch.\n\n    Parameters\n    ----------\n    batch : dict\n        A batch dictionary.  Each value must implement `len`.\n        All values must have the same `len`.\n\n    Returns\n    -------\n    n : int >= 0 or None\n        The number of samples in this batch.\n        If the batch has no fields, n is None.\n\n    Raises\n    ------\n    RuntimeError\n        If some two values have unequal length\n    ' #NEWLINE# n = None #NEWLINE# for value in six . itervalues ( batch ) : #NEWLINE# #INDENT# if ( n is None ) : #NEWLINE# #INDENT# n = len ( value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( value ) != n ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Unequal field lengths' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return n