opennmt/utils/misc.py
def extract_batches(tensors):
    """Returns a generator to iterate on each batch of a Numpy array or dict of
    Numpy arrays."""
    if not isinstance(tensors, dict):
        for tensor in tensors:
            yield tensor
    else:
        batch_size = None
        for value in tensors.values():
            batch_size = batch_size or value.shape[0]
        for b in range(batch_size):
            yield {key: value[b] for key, value in tensors.items()}
Returns a generator to iterate on each batch of a Numpy array or dict of
    Numpy arrays.
Returns a generator to iterate on each batch of a Numpy array or dict of
Numpy arrays.
Returns a generator to iterate on each batch of a Numpy array or dict of Numpy arrays .
def extract_batches(tensors):
    if not isinstance(tensors, dict):
        for tensor in tensors:
            yield tensor
    else:
        batch_size = None
        for value in tensors.values():
            batch_size = batch_size or value.shape[0]
        for b in range(batch_size):
            yield {key: value[b] for key, value in tensors.items()}
def extract_batches ( tensors ) : if not isinstance ( tensors , dict ) : for tensor in tensors : yield tensor else : batch_size = None for value in tensors . values ( ) : batch_size = batch_size or value . shape [ 0 ] for b in range ( batch_size ) : yield { key : value [ b ] for key , value in tensors . items ( ) }
Returns a generator to iterate on each batch of a Numpy array or dict of
Numpy arrays.
Returns a generator to iterate on each batch of a Numpy array or dict of Numpy arrays .
"""Returns a generator to iterate on each batch of a Numpy array or dict of
    Numpy arrays."""
tensors