<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def flood_fill_aplx(self, *args, **kwargs):
 """Unreliably flood-fill APLX to a set of application cores. .. note:: Most users should use the :py:meth:`.load_application` wrapper around this method which guarantees successful loading. This method can be called in either of the following ways:: Note that the latter format is the same format produced by :py:func:`~rig.place_and_route.util.build_application_map`. .. warning:: The loading process is likely, but not guaranteed, to succeed. This is because the flood-fill packets used during loading are not guaranteed to arrive. The effect is that some chips may not receive the complete application binary and will silently ignore the application loading request. As a result, the user is responsible for checking that each core was successfully loaded with the correct binary. At present, the two recommended approaches to this are: * If the ``wait`` argument is given then the user should check that the correct number of application binaries reach the initial barrier (i.e., the ``wait`` state). If the number does not match the expected number of loaded cores the next approach must be used: * The user can check the process list of each chip to ensure the application was loaded into the correct set of cores. See :py:meth:`.read_vcpu_struct_field`. Parameters app_id : int wait : bool (Default: True) Should the application await the AppSignal.start signal after it has been loaded? """

        # Coerce the arguments into a single form.  If there are two arguments
        # then assume that we have filename and a map of chips and cores;
        # otherwise there should be ONE argument which is of the form of the
        # return value of `build_application_map`.
        application_map = {}
        if len(args) == 1:
            application_map = args[0]
        elif len(args) == 2:
            application_map = {args[0]: args[1]}
        else:
            raise TypeError(
                "flood_fill_aplx: accepts either 1 or 2 positional arguments: "
                "a map of filenames to targets OR a single filename and its"
                "targets"
            )

        # Get the application ID, the context system will guarantee that this
        # is available
        app_id = kwargs.pop("app_id")

        flags = 0x0000
        if kwargs.pop("wait"):
            flags |= AppFlags.wait

        # The forward and retry parameters
        fr = NNConstants.forward << 8 | NNConstants.retry

        # Load each APLX in turn
        for (aplx, targets) in iteritems(application_map):
            # Determine the minimum number of flood-fills that are necessary to
            # load the APLX. The regions and cores should be sorted into
            # ascending order, `compress_flood_fill_regions` ensures this is
            # done.
            fills = regions.compress_flood_fill_regions(targets)

            # Load the APLX data
            with open(aplx, "rb") as f:
                aplx_data = f.read()
            n_blocks = ((len(aplx_data) + self.scp_data_length - 1) //
                        self.scp_data_length)

            # Start the flood fill for this application
            # Get an index for the nearest neighbour operation
            pid = self._get_next_nn_id()

            # Send the flood-fill start packet
            self._send_ffs(pid, n_blocks, fr)

            # Send the core select packets
            for (region, cores) in fills:
                self._send_ffcs(region, cores, fr)

            # Send the data
            base_address = self.read_struct_field(
                "sv", "sdram_sys", 255, 255)
            self._send_ffd(pid, aplx_data, base_address)

            # Send the flood-fill END packet
            self._send_ffe(pid, app_id, flags, fr)