<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stream(input, encoding=None, errors='strict'):
 	"""Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding. 	 	Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body. 	"""

	
	input = (i for i in input if i)  # Omits `None` (empty wrappers) and empty chunks.
	
	if encoding:  # Automatically, and iteratively, encode the text if requested.
		input = iterencode(input, encoding, errors=errors)
	
	return input