code: def get_bin_pack_residual(
      node_resources: List[ResourceDict],
      resource_demands: List[ResourceDict],
      strict_spread: bool = False,
  ) -> (List[ResourceDict], List[ResourceDict]):
      """Return a subset of resource_demands that cannot fit in the cluster.
  
      TODO(ekl): this currently does not guarantee the resources will be packed
      correctly by the Ray scheduler. This is only possible once the Ray backend
      supports a placement groups API.
  
      Args:
          node_resources (List[ResourceDict]): List of resources per node.
          resource_demands (List[ResourceDict]): List of resource bundles that
              need to be bin packed onto the nodes.
          strict_spread: If true, each element in resource_demands must be
              placed on a different entry in `node_resources`.
  
      Returns:
          List[ResourceDict]: the residual list resources that do not fit.
          List[ResourceDict]: The updated node_resources after the method.
      """
  
      unfulfilled = []
  
      # A most naive bin packing algorithm.
      nodes = copy.deepcopy(node_resources)
      # List of nodes that cannot be used again due to strict spread.
      used = []
      # We order the resource demands in the following way:
      # More complex demands first.
      # Break ties: heavier demands first.
      # Break ties: lexicographically (to ensure stable ordering).
      for demand in sorted(
          resource_demands,
          key=lambda demand: (
              len(demand.values()),
              sum(demand.values()),
              sorted(demand.items()),
          ),
          reverse=True,
      ):
          found = False
          node = None
          for i in range(len(nodes)):
              node = nodes[i]
              if _fits(node, demand):
                  found = True
                  # In the strict_spread case, we can't reuse nodes.
                  if strict_spread:
                      used.append(node)
                      del nodes[i]
                  break
          if found and node:
              _inplace_subtract(node, demand)
          else:
              unfulfilled.append(demand)
  
      return unfulfilled, nodes + used
  
imports: import collections
  import copy
  import logging
  import os
  from abc import abstractmethod
  from functools import partial
  from typing import Callable, Dict, List, Optional, Tuple
  import ray
  from ray._private.gcs_utils import PlacementGroupTableData
  from ray.autoscaler._private.constants import AUTOSCALER_CONSERVE_GPU_NODES, AUTOSCALER_UTILIZATION_SCORER_KEY
  from ray.autoscaler._private.loader import load_function_or_class
  from ray.autoscaler._private.node_provider_availability_tracker import NodeAvailabilitySummary
  from ray.autoscaler._private.util import NodeID, NodeIP, NodeType, NodeTypeConfigDict, ResourceDict, is_placement_group_resource
  from ray.autoscaler.node_provider import NodeProvider
  from ray.autoscaler.tags import NODE_KIND_HEAD, NODE_KIND_UNMANAGED, NODE_KIND_WORKER, TAG_RAY_NODE_KIND, TAG_RAY_USER_NODE_TYPE
  from ray.core.generated.common_pb2 import PlacementStrategy
label_desc: Use image node_id 6 for calling a global function with example usage: get_bin_pack_residual(node_resources, resource_demands, strict_spread) and returns: unfulfilled,  unknown