code: def valid_status(*valid):
      """Decorator to assert that we're in a valid state."""
  
      def decorator(func):
          @functools.wraps(func)
          def _valid_status(self, *args, **kwargs):
              if self.status not in valid:
                  raise protocol.ProtocolError(
                      "`%s` called while in state: %s, valid: (%s)"
                      % (
                          func.__name__,
                          self.status,
                          ",".join(map(str, valid)),
                      )
                  )
              return func(self, *args, **kwargs)
  
          return _valid_status
  
      return decorator
  
imports: import copy
  import functools
  import socket
  import sys
  import time
  from absl import flags
  from absl import logging
  from pysc2.lib import protocol
  from pysc2.lib import static_data
  from pysc2.lib import stopwatch
  import websocket
  from s2clientprotocol import debug_pb2
  from s2clientprotocol import sc2api_pb2
label_desc: Use image node_id 4 for calling a global function with example usage: valid_status() and returns: decorator, _valid_status, func