code: def parse_composition(
      adapter_composition, level=0, model_type=None
  ) -> AdapterCompositionBlock:
      """
      Parses and validates a setup of adapters.
  
      Args:
          adapter_composition: The adapter setup to be parsed.
          level (int, optional): If set to none, disables validation. Defaults to 0.
      """
      if not adapter_composition:
          return None
      elif isinstance(adapter_composition, AdapterCompositionBlock):
          if level is not None:
              validate_composition(
                  adapter_composition,
                  level=level,
                  model_type=model_type,
              )
          return adapter_composition
      elif isinstance(adapter_composition, str):
          if level == 0:
              return Stack(adapter_composition)
          else:
              return adapter_composition
      elif isinstance(adapter_composition, Sequence):
          # for backwards compatibility
          if level == 1:
              block_class = Fuse
          else:
              block_class = Stack
          level = level + 1 if level is not None else None
          return block_class(
              *[
                  parse_composition(b, level)
                  for b in adapter_composition
              ]
          )
      else:
          raise TypeError(adapter_composition)
  
imports: import itertools
  from collections.abc import Sequence
  from typing import List, Optional, Set, Tuple, Union
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: parse_composition(adapter_composition, level, model_type) and returns: None, adapter_composition, Stack, adapter_composition, block_class