<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setup_client(self, client_id=None, user_data=None, scan=True, broadcast=False):
 """Setup a newly connected client. ``client_id`` must be unique among all connected clients. If it is passed as None, a random client_id will be generated as a string and returned. This method reserves internal resources for tracking what devices this client has connected to and installs a monitor into the adapter on behalf of the client. It should be called whenever a new client connects to the device server before any other activities by that client are allowed. By default, all clients start receiving ``device_seen`` events but if you want your client to also receive broadcast events, you can pass broadcast=True. Args: client_id (str):
 A unique identifier for this client that will be used to refer to it in all future interactions. If this is None, then a random string will be generated for the client_id. user_data (object):
 An arbitrary object that you would like to store with this client and will be passed to your event handler when events are forwarded to this client. scan (bool):
 Whether to install a monitor to listen for device_found events. broadcast (bool):
 Whether to install a monitor to list for broadcast events. Returns: str: The client_id. If a client id was passed in, it will be the same as what was passed in. If no client id was passed in then it will be a random unique string. """


        if client_id is None:
            client_id = str(uuid.uuid4())

        if client_id in self._clients:
            raise  ArgumentError("Duplicate client_id: {}".format(client_id))

        async def _client_callback(conn_string, _, event_name, event):
            event_tuple = (conn_string, event_name, event)
            await self._forward_client_event(client_id, event_tuple)

        client_monitor = self.adapter.register_monitor([], [], _client_callback)

        self._clients[client_id] = dict(user_data=user_data, connections={},
                                        monitor=client_monitor)

        self._adjust_global_events(client_id, scan, broadcast)
        return client_id