<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def connect(self, hardware: hc.API):
 """ Connect to a running hardware API. This can be either a simulator or a full hardware controller. Note that there is no true disconnected state for a :py:class:`.ProtocolContext`; :py:meth:`disconnect` simply creates a new simulator and replaces the current hardware with it. """

        self._hw_manager.set_hw(hardware)
        self._hw_manager.hardware.cache_instruments()