code: def set_mode_apm(self, mode, custom_mode = 0, custom_sub_mode = 0):
          '''enter arbitrary mode'''
          if isinstance(mode, str):
              mode_map = self.mode_mapping()
              if mode_map is None or mode not in mode_map:
                  print("Unknown mode '%s'" % mode)
                  return
              mode = mode_map[mode]
          # set mode by integer mode number for ArduPilot
          self.mav.set_mode_send(self.target_system,
                                 mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
                                 modef set_mode_apm(self, mode, custom_mode = 0, custom_sub_mode = 0):
          '''enter arbitrary mode'''
          if isinstance(mode, str):
              mode_map = self.mode_mapping()
              if mode_map is None or mode not in mode_map:
                  print("Unknown mode '%s'" % mode)
                  return
              mode = mode_map[mode]
          # set mode by integer mode number for ArduPilot
          self.mav.set_mode_send(self.target_system,
                                 mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
                                 mode)
docs: enter arbitrary mode