<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_running_apps(self, instance, requests_config):
 """ Determine what mode was specified """

        tags = instance.get('tags', [])
        if tags is None:
            tags = []
        master_address = self._get_master_address(instance)
        # Get the cluster name from the instance configuration
        cluster_name = instance.get('cluster_name')
        if cluster_name is None:
            raise Exception('The cluster_name must be specified in the instance configuration')
        tags.append('cluster_name:%s' % cluster_name)
        tags = list(set(tags))
        # Determine the cluster mode
        cluster_mode = instance.get(SPARK_CLUSTER_MODE)
        if cluster_mode is None:
            self.log.warning(
                'The value for `spark_cluster_mode` was not set in the configuration. '
                'Defaulting to "%s"' % SPARK_YARN_MODE
            )
            cluster_mode = SPARK_YARN_MODE

        if cluster_mode == SPARK_STANDALONE_MODE:
            # check for PRE-20
            pre20 = is_affirmative(instance.get(SPARK_PRE_20_MODE, False))
            return self._standalone_init(master_address, pre20, requests_config, tags)

        elif cluster_mode == SPARK_MESOS_MODE:
            running_apps = self._mesos_init(instance, master_address, requests_config, tags)
            return self._get_spark_app_ids(running_apps, requests_config, tags)

        elif cluster_mode == SPARK_YARN_MODE:
            running_apps = self._yarn_init(master_address, requests_config, tags)
            return self._get_spark_app_ids(running_apps, requests_config, tags)

        else:
            raise Exception('Invalid setting for %s. Received %s.' % (SPARK_CLUSTER_MODE, cluster_mode))