def attach(docker_client, container, stdout=True, stderr=True, logs=False):
headers = {<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>"<EOL>}<EOL>query_params = {<EOL>"<STR_LIT>": <NUM_LIT:1> if stdout else <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:1> if stderr else <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:1> if logs else <NUM_LIT:0>,<EOL>"<STR_LIT>": <NUM_LIT:1>,  <EOL>"<STR_LIT>": <NUM_LIT:0>,  <EOL>}<EOL>api_client = docker_client.api<EOL>url = "<STR_LIT>".format(api_client.base_url, container.id)<EOL>response = api_client._post(url, headers=headers, params=query_params, stream=True)  <EOL>socket = api_client._get_raw_response_socket(response)  <EOL>return _read_socket(socket)<EOL>
Implements a method that wraps Docker Attach API to attach to a container and demux stdout and stderr data from the
single data stream that Docker API returns.

The signature of this method is intentionally similar to Docker Python SDK's ``attach()`` method except for the
addition of one parameter called `demux` which, if set to True, will return an iterator that provides the stream
data along with a stream type identifier. Caller can handle the data appropriately.

Parameters
----------
docker_client : docker.Client
    Docker client used to talk to Docker daemon

container : docker.container
    Instance of the container to attach to

stdout : bool
    Do you want to get stdout data?

stderr : bool
    Do you want to get stderr data?

logs : bool
    Do you want to include the container's previous output?