<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read(tex):
 """Read and parse all LaTeX source :param Union[str,iterable] tex: LaTeX source :return TexEnv: the global environment """

    if isinstance(tex, str):
        tex = tex
    else:
        tex = ''.join(itertools.chain(*tex))
    buf, children = Buffer(tokenize(tex)), []
    while buf.hasNext():
        content = read_tex(buf)
        if content is not None:
            children.append(content)
    return TexEnv('[tex]', children), tex