class_docstr: Base class for all adapter methods that support composition.
  
  Make sure the 'adapter_modules_name' and 'supported_compositions' attributes as well as all abstract methods are
  overriden in derived classes. 'allow_multi_parallelize' can be set to True to allow inputs to be parallelized
  independently multiple times. This is useful when there are multiple parallel input flows through an adapter layer
  (e.g. in LoRA).
class_docstr_tok: ["Base","class","for","all","adapter","methods","that","support","composition",".","Make","sure","the","'adapter_modules_name","'","and","'supported_compositions","'","attributes","as","well","as","all","abstract","methods","are","overriden","in","derived","classes",".","'allow_multi_parallelize","'","can","be","set","to","True","to","allow","inputs","to","be","parallelized","independently","multiple","times",".","This","is","useful","when","there","are","multiple","parallel","input","flows","through","an","adapter","layer","(","e.g",".","in","LoRA",")","."]
docstr: Checks whether the given composition is valid.
  
  Args:
      parent (AdapterCompositionBlock): The parent composition block.
      child (AdapterCompositionBlock): The child composition block.
      lvl (int): The composition depth.
  
  Raises:
      ValueError: If the composition is invalid.
docstr_tok: ["Checks","whether","the","given","composition","is","valid",".","Args",":","parent","(","AdapterCompositionBlock",")",":","The","parent","composition","block",".","child","(","AdapterCompositionBlock",")",":","The","child","composition","block",".","lvl","(","int",")",":","The","composition","depth",".","Raises",":","ValueError",":","If","the","composition","is","invalid","."]
code: def check_composition_valid(
      self,
      parent: AdapterCompositionBlock,
      child: AdapterCompositionBlock,
      lvl: int,
  ):
      """Checks whether the given composition is valid.
  
      Args:
          parent (AdapterCompositionBlock): The parent composition block.
          child (AdapterCompositionBlock): The child composition block.
          lvl (int): The composition depth.
  
      Raises:
          ValueError: If the composition is invalid.
      """
      # Break if setup is too deep
      if isinstance(parent, Stack) and lvl >= 1:
          raise ValueError(
              "Specified adapter setup is too deep. Cannot have {} at level {}".format(
                  child.__class__.__name__, lvl
              )
          )
      elif type(child) not in ALLOWED_NESTINGS[type(parent)]:
          raise ValueError(
              "Cannot nest {} inside {}. Only the following nestings are allowed: {}".format(
                  child.__class__.__name__,
                  parent.__class__.__name__,
                  ", ".join(
                      [
                          t.__name__
                          for t in ALLOWED_NESTINGS[type(parent)]
                      ]
                  ),
              )
          )
  
imports: from abc import ABCMeta, abstractmethod
  from typing import Collection, Dict, List, NamedTuple, Union
  import numpy
  import torch
  from torch import nn
  from ..composition import ALLOWED_NESTINGS, AdapterCompositionBlock, Average, BatchSplit, Fuse, Parallel, Split, Stack
  from ..context import AdapterSetup, ForwardContext
label_desc: Use image node_id 10 for calling the ComposableAdapterLayerBase obj's underlying member method code with example usage: obj.check_composition_valid(parent, child, lvl) without return types