code: async def power_off(
              self, stop_mode: PowerStopMode = PowerStopMode.HARD,
              comment: str = None, wait: bool = False, wait_interval: int = 5):
          
          params = {"system_id": self.system_id, 'stop_mode': stop_mode.value}
          if comment is not None:
              params["comment"] = comment
          try:
              self._data = await self._handler.power_off(**params)
          except CallError as error:
              if error.status == HTTPStatus.FORBIDDEN:
                  message = "Not allowed to power off machine."
                  raise OperationNotAllowed(message) from error
              else:
                  raise
          if not wait or self.power_state == PowerState.UNKNOWN:
              # Don't wait for a machine that always shows power state as
              # unknown as the driver cannot query the power state.
              return self
          else:
              # Wait for machine to be powered off.
              while self.power_state == PowerState.ON:
                  await asyncio.sleep(wait_interval)
                  self._data = await self._handler.read(system_id=self.system_id)
              if self.power_state == PowerState.ERROR:
                  msg = "{hostname} failed to power off.".format(
                      hostname=self.hostname
                  )
                  raise PowerError(msg, self)
              return self
docs: Power off.
  
          :param stop_mode: How to perform the power off.
          :type stop_mode: `PowerStopMode`
          :param comment: Reason machine was powered on.
          :type comment: `str`
          :param wait: If specified, wait until the machine is powered on.
          :type wait: `bool`
          :param wait_interval: How often to poll, defaults to 5 seconds.
          :type wait_interval: `int`