<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def allocate_disks(logical_disk, server, raid_config):
 """Allocate physical disks to a logical disk. This method allocated physical disks to a logical disk based on the current state of the server and criteria mentioned in the logical disk. :param logical_disk: a dictionary of a logical disk from the RAID configuration input to the module. :param server: An objects.Server object :param raid_config: The target RAID configuration requested. :raises: PhysicalDisksNotFoundError, if cannot find physical disks for the request. """

    size_gb = logical_disk['size_gb']
    raid_level = logical_disk['raid_level']
    number_of_physical_disks = logical_disk.get(
        'number_of_physical_disks', constants.RAID_LEVEL_MIN_DISKS[raid_level])
    share_physical_disks = logical_disk.get('share_physical_disks', False)

    # Try to create a new independent array for this request.
    for controller in server.controllers:
        physical_drives = controller.unassigned_physical_drives
        physical_drives = _get_criteria_matching_disks(logical_disk,
                                                       physical_drives)

        if size_gb != "MAX":
            # If we want to allocate for a logical disk for which size_gb is
            # mentioned, we take the smallest physical drives which is required
            # to match the criteria.
            reverse_sort = False
            physical_drives = [x for x in physical_drives
                               if x.size_gb >= size_gb]
        else:
            # If we want to allocate for a logical disk for which size_gb is
            # MAX, we take the largest physical drives available.
            reverse_sort = True

        if len(physical_drives) >= number_of_physical_disks:
            selected_drives = sorted(physical_drives, key=lambda x: x.size_gb,
                                     reverse=reverse_sort)
            selected_drive_ids = [x.id for x in selected_drives]
            logical_disk['controller'] = controller.id
            physical_disks = selected_drive_ids[:number_of_physical_disks]
            logical_disk['physical_disks'] = physical_disks
            return

    # We didn't find physical disks to create an independent array.
    # Check if we can get some shared arrays.
    if share_physical_disks:
        sharable_disk_wwns = []
        for sharable_logical_disk in raid_config['logical_disks']:
            if (sharable_logical_disk.get('share_physical_disks', False) and
                    'root_device_hint' in sharable_logical_disk):
                wwn = sharable_logical_disk['root_device_hint']['wwn']
                sharable_disk_wwns.append(wwn)

        for controller in server.controllers:
            sharable_arrays = [x for x in controller.raid_arrays if
                               x.logical_drives[0].wwn in sharable_disk_wwns]

            for array in sharable_arrays:

                # Check if criterias for the logical disk match the ones with
                # physical disks in the raid array.
                criteria_matched_disks = _get_criteria_matching_disks(
                    logical_disk, array.physical_drives)

                # Check if all disks in the array don't match the criteria
                if len(criteria_matched_disks) != len(array.physical_drives):
                    continue

                # Check if raid array can accomodate the logical disk.
                if array.can_accomodate(logical_disk):
                    logical_disk['controller'] = controller.id
                    logical_disk['array'] = array.id
                    return

    # We check both options and couldn't get any physical disks.
    raise exception.PhysicalDisksNotFoundError(size_gb=size_gb,
                                               raid_level=raid_level)