code: def get_max_layer_size(
      modules: List[Tuple[str, torch.nn.Module]],
      module_sizes: Dict[str, int],
      no_split_module_classes: List[str],
  ):
      """
      Utility function that will scan a list of named modules and return the maximum size used by one full layer. The
      definition of a layer being:
      - a module with no direct children (just parameters and buffers)
      - a module whose class name is in the list `no_split_module_classes`
  
      Args:
          modules (`List[Tuple[str, torch.nn.Module]]`):
              The list of named modules where we want to determine the maximum layer size.
          module_sizes (`Dict[str, int]`):
              A dictionary mapping each layer name to its size (as generated by `compute_module_sizes`).
          no_split_module_classes (`List[str]`):
              A list of class names for layers we don't want to be split.
  
      Returns:
          `Tuple[int, List[str]]`: The maximum size of a layer with the list of layer names realizing that maximum size.
      """
      max_size = 0
      layer_names = []
      modules_to_treat = modules.copy()
      while len(modules_to_treat) > 0:
          module_name, module = modules_to_treat.pop(0)
          modules_children = (
              list(module.named_children())
              if isinstance(module, torch.nn.Module)
              else []
          )
          if (
              len(modules_children) == 0
              or module.__class__.__name__ in no_split_module_classes
          ):
              # No splitting this one so we compare to the max_size
              size = module_sizes[module_name]
              if size > max_size:
                  max_size = size
                  layer_names = [module_name]
              elif size == max_size:
                  layer_names.append(module_name)
          else:
              modules_to_treat = [
                  (f"{module_name}.{n}", v) for n, v in modules_children
              ] + modules_to_treat
      return max_size, layer_names
  
imports: import contextlib
  import gc
  import inspect
  import json
  import logging
  import os
  import re
  import shutil
  import tempfile
  from collections import OrderedDict, defaultdict
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.nn
  from ..state import AcceleratorState
  from .constants import SAFE_WEIGHTS_NAME, WEIGHTS_NAME
  from .dataclasses import AutocastKwargs, CustomDtype, DistributedType
  from .imports import is_mps_available, is_npu_available, is_xpu_available
  from .offload import load_offloaded_weight, offload_weight, save_offload_index
  from .tqdm import is_tqdm_available, tqdm
  from safetensors import safe_open
  from safetensors.torch import load_file
label_desc: Use image node_id 16 for calling a global function with example usage: get_max_layer_size(modules, module_sizes, no_split_module_classes) and returns: max_size,  layer_names