code: def _mode_switching_function(self, switched_to_mode):
      # add mode tool
  
      def _select_task(mode_name):
          if mode_name == "":
              self.chat_memory.set_mode(None)
              switched_to_mode.append(None)
              return "success"
  
          avail_modes = list(self._modes.keys())
          if mode_name not in avail_modes:
              return f'Error: task is not found. Available tasks: {", ".join(avail_modes)}'
          self.chat_memory.set_mode(mode_name)
          switched_to_mode.append(mode_name)
          return "success"
  
      return Function(
          name="select_task",
          callback=_select_task,
          description="Have to be used by assistant to select task. Input is task type."
          " If user want to unselect task input should be empty string."
          " Available tasks: "
          + "; ".join(self._get_avail_modes_items()),
      )
  
file_path: mindsdb/mindsdb/interfaces/chatbot/chatbot_executor.py
imports: from .model_executor import ModelExecutor
  from .types import Function, BotException
label_desc: Use image node_id 5 for calling the MultiModeBotExecutor obj's underlying member method code with example usage: obj._mode_switching_function(switched_to_mode) and returns: Function, str, str, str, str