class_docstr: ``Compose`` provides the ability to chain a series of callables together in
  a sequential manner. Each transform in the sequence must take a single
  argument and return a single value.
  
  ``Compose`` can be used in two ways:
  
  #. With a series of transforms that accept and return a single
     ndarray / tensor / tensor-like parameter.
  #. With a series of transforms that accept and return a dictionary that
     contains one or more parameters. Such transforms must have pass-through
     semantics that unused values in the dictionary must be copied to the return
     dictionary. It is required that the dictionary is copied between input
     and output of each transform.
  
  If some transform takes a data item dictionary as input, and returns a
  sequence of data items in the transform chain, all following transforms
  will be applied to each item of this list if `map_items` is `True` (the
  default).  If `map_items` is `False`, the returned sequence is passed whole
  to the next callable in the chain.
  
  For example:
  
  A `Compose([transformA, transformB, transformC],
  map_items=True)(data_dict)` could achieve the following patch-based
  transformation on the `data_dict` input:
  
  #. transformA normalizes the intensity of 'img' field in the `data_dict`.
  #. transformB crops out image patches from the 'img' and 'seg' of
     `data_dict`, and return a list of three patch samples::
  
      {'img': 3x100x100 data, 'seg': 1x100x100 data, 'shape': (100, 100)}
                           applying transformB
                               ---------->
      [{'img': 3x20x20 data, 'seg': 1x20x20 data, 'shape': (20, 20)},
       {'img': 3x20x20 data, 'seg': 1x20x20 data, 'shape': (20, 20)},
       {'img': 3x20x20 data, 'seg': 1x20x20 data, 'shape': (20, 20)},]
  
  #. transformC then randomly rotates or flips 'img' and 'seg' of
     each dictionary item in the list returned by transformB.
  
  The composed transforms will be set the same global random seed if user called
  `set_determinism()`.
  
  When using the pass-through dictionary operation, you can make use of
  :class:`monai.transforms.adaptors.adaptor` to wrap transforms that don't conform
  to the requirements. This approach allows you to use transforms from
  otherwise incompatible libraries with minimal additional work.
  
  Note:
  
      In many cases, Compose is not the best way to create pre-processing
      pipelines. Pre-processing is often not a strictly sequential series of
      operations, and much of the complexity arises when a not-sequential
      set of functions must be called as if it were a sequence.
  
      Example: images and labels
      Images typically require some kind of normalization that labels do not.
      Both are then typically augmented through the use of random rotations,
      flips, and deformations.
      Compose can be used with a series of transforms that take a dictionary
      that contains 'image' and 'label' entries. This might require wrapping
      `torchvision` transforms before passing them to compose.
      Alternatively, one can create a class with a `__call__` function that
      calls your pre-processing functions taking into account that not all of
      them are called on the labels.
  
  Lazy resampling:
  
      Lazy resampling is an experimental feature introduced in 1.2. Its purpose is
      to reduce the number of resample operations that must be carried out when executing
      a pipeline of transforms. This can provide significant performance improvements in
      terms of pipeline executing speed and memory usage, and can also significantly
      reduce the loss of information that occurs when performing a number of spatial
      resamples in succession.
  
      Lazy resampling can be enabled or disabled through the ``lazy`` parameter, either by
      specifying it at initialisation time or overriding it at call time.
  
      * False (default): Don't perform any lazy resampling
      * None: Perform lazy resampling based on the 'lazy' properties of the transform instances.
      * True: Always perform lazy resampling if possible. This will ignore the ``lazy`` properties
        of the transform instances
  
      Please see the :ref:`Lazy Resampling topic<lazy_resampling>` for more details of this feature
      and examples of its use.
  
  Args:
      transforms: sequence of callables.
      map_items: whether to apply transform to each item in the input `data` if `data` is a list or tuple.
          defaults to `True`.
      unpack_items: whether to unpack input `data` with `*` as parameters for the callable function of transform.
          defaults to `False`.
      log_stats: this optional parameter allows you to specify a logger by name for logging of pipeline execution.
          Setting this to False disables logging. Setting it to True enables logging to the default loggers.
          Setting a string overrides the logger name to which logging is performed.
      lazy: whether to enable :ref:`Lazy Resampling<lazy_resampling>` for lazy transforms. If False, transforms will
          be carried out on a transform by transform basis. If True, all lazy transforms will be executed by
          accumulating changes and resampling as few times as possible. If lazy is None, `Compose` will
          perform lazy execution on lazy transforms that have their `lazy` property set to True.
      overrides: this optional parameter allows you to specify a dictionary of parameters that should be overridden
          when executing a pipeline. These each parameter that is compatible with a given transform is then applied
          to that transform before it is executed. Note that overrides are currently only applied when
          :ref:`Lazy Resampling<lazy_resampling>` is enabled for the pipeline or a given transform. If lazy is False
          they are ignored. Currently supported args are:
          {``"mode"``, ``"padding_mode"``, ``"dtype"``, ``"align_corners"``, ``"resample_mode"``, ``device``}.
class_docstr_tok: ["``","Compose","``","provides","the","ability","to","chain","a","series","of","callables","together","in","a","sequential","manner",".","Each","transform","in","the","sequence","must","take","a","single","argument","and","return","a","single","value",".","``","Compose","``","can","be","used","in","two","ways",":","#",".","With","a","series","of","transforms","that","accept","and","return","a","single","ndarray","\/","tensor","\/","tensor-like","parameter",".","#",".","With","a","series","of","transforms","that","accept","and","return","a","dictionary","that","contains","one","or","more","parameters",".","Such","transforms","must","have","pass-through","semantics","that","unused","values","in","the","dictionary","must","be","copied","to","the","return","dictionary",".","It","is","required","that","the","dictionary","is","copied","between","input","and","output","of","each","transform",".","If","some","transform","takes","a","data","item","dictionary","as","input",",","and","returns","a","sequence","of","data","items","in","the","transform","chain",",","all","following","transforms","will","be","applied","to","each","item","of","this","list","if","`","map_items","`","is","`","True","`","(","the","default",")",".","If","`","map_items","`","is","`","False","`",",","the","returned","sequence","is","passed","whole","to","the","next","callable","in","the","chain",".","For","example",":","A","`","Compose","(","[","transformA",",","transformB",",","transformC","]",",","map_items=True",")","(","data_dict",")","`","could","achieve","the","following","patch-based","transformation","on","the","`","data_dict","`","input",":","#",".","transformA","normalizes","the","intensity","of","'img","'","field","in","the","`","data_dict","`",".","#",".","transformB","crops","out","image","patches","from","the","'img","'","and","'seg","'","of","`","data_dict","`",",","and","return","a","list","of","three","patch","samples",":",":","{","'img","'",":","3x100x100","data",",","'seg","'",":","1x100x100","data",",","'shape","'",":","(","100",",","100",")","}","applying","transformB","--","--","--","--","--",">","[","{","'img","'",":","3x20x20","data",",","'seg","'",":","1x20x20","data",",","'shape","'",":","(","20",",","20",")","}",",","{","'img","'",":","3x20x20","data",",","'seg","'",":","1x20x20","data",",","'shape","'",":","(","20",",","20",")","}",",","{","'img","'",":","3x20x20","data",",","'seg","'",":","1x20x20","data",",","'shape","'",":","(","20",",","20",")","}",",","]","#",".","transformC","then","randomly","rotates","or","flips","'img","'","and","'seg","'","of","each","dictionary","item","in","the","list","returned","by","transformB",".","The","composed","transforms","will","be","set","the","same","global","random","seed","if","user","called","`","set_determinism","(",")","`",".","When","using","the","pass-through","dictionary","operation",",","you","can","make","use","of",":","class",":","`","monai.transforms.adaptors.adaptor","`","to","wrap","transforms","that","do","n't","conform","to","the","requirements",".","This","approach","allows","you","to","use","transforms","from","otherwise","incompatible","libraries","with","minimal","additional","work",".","Note",":","In","many","cases",",","Compose","is","not","the","best","way","to","create","pre-processing","pipelines",".","Pre-processing","is","often","not","a","strictly","sequential","series","of","operations",",","and","much","of","the","complexity","arises","when","a","not-sequential","set","of","functions","must","be","called","as","if","it","were","a","sequence",".","Example",":","images","and","labels","Images","typically","require","some","kind","of","normalization","that","labels","do","not",".","Both","are","then","typically","augmented","through","the","use","of","random","rotations",",","flips",",","and","deformations",".","Compose","can","be","used","with","a","series","of","transforms","that","take","a","dictionary","that","contains","'image","'","and","'label","'","entries",".","This","might","require","wrapping","`","torchvision","`","transforms","before","passing","them","to","compose",".","Alternatively",",","one","can","create","a","class","with","a","`","__call__","`","function","that","calls","your","pre-processing","functions","taking","into","account","that","not","all","of","them","are","called","on","the","labels",".","Lazy","resampling",":","Lazy","resampling","is","an","experimental","feature","introduced","in","1.2",".","Its","purpose","is","to","reduce","the","number","of","resample","operations","that","must","be","carried","out","when","executing","a","pipeline","of","transforms",".","This","can","provide","significant","performance","improvements","in","terms","of","pipeline","executing","speed","and","memory","usage",",","and","can","also","significantly","reduce","the","loss","of","information","that","occurs","when","performing","a","number","of","spatial","resamples","in","succession",".","Lazy","resampling","can","be","enabled","or","disabled","through","the","``","lazy","``","parameter",",","either","by","specifying","it","at","initialisation","time","or","overriding","it","at","call","time",".","*","False","(","default",")",":","Do","n't","perform","any","lazy","resampling","*","None",":","Perform","lazy","resampling","based","on","the","'lazy","'","properties","of","the","transform","instances",".","*","True",":","Always","perform","lazy","resampling","if","possible",".","This","will","ignore","the","``","lazy","``","properties","of","the","transform","instances","Please","see","the",":","ref",":","`","Lazy","Resampling","topic","<","lazy_resampling",">","`","for","more","details","of","this","feature","and","examples","of","its","use",".","Args",":","transforms",":","sequence","of","callables",".","map_items",":","whether","to","apply","transform","to","each","item","in","the","input","`","data","`","if","`","data","`","is","a","list","or","tuple",".","defaults","to","`","True","`",".","unpack_items",":","whether","to","unpack","input","`","data","`","with","`","*","`","as","parameters","for","the","callable","function","of","transform",".","defaults","to","`","False","`",".","log_stats",":","this","optional","parameter","allows","you","to","specify","a","logger","by","name","for","logging","of","pipeline","execution",".","Setting","this","to","False","disables","logging",".","Setting","it","to","True","enables","logging","to","the","default","loggers",".","Setting","a","string","overrides","the","logger","name","to","which","logging","is","performed",".","lazy",":","whether","to","enable",":","ref",":","`","Lazy","Resampling","<","lazy_resampling",">","`","for","lazy","transforms",".","If","False",",","transforms","will","be","carried","out","on","a","transform","by","transform","basis",".","If","True",",","all","lazy","transforms","will","be","executed","by","accumulating","changes","and","resampling","as","few","times","as","possible",".","If","lazy","is","None",",","`","Compose","`","will","perform","lazy","execution","on","lazy","transforms","that","have","their","`","lazy","`","property","set","to","True",".","overrides",":","this","optional","parameter","allows","you","to","specify","a","dictionary","of","parameters","that","should","be","overridden","when","executing","a","pipeline",".","These","each","parameter","that","is","compatible","with","a","given","transform","is","then","applied","to","that","transform","before","it","is","executed",".","Note","that","overrides","are","currently","only","applied","when",":","ref",":","`","Lazy","Resampling","<","lazy_resampling",">","`","is","enabled","for","the","pipeline","or","a","given","transform",".","If","lazy","is","False","they","are","ignored",".","Currently","supported","args","are",":","{","``","``","mode","''","``",",","``","``","padding_mode","''","``",",","``","``","dtype","''","``",",","``","``","align_corners","''","``",",","``","``","resample_mode","''","``",",","``","device","``","}","."]
code: def inverse(self, data):
      self._raise_if_not_invertible(data)
  
      invertible_transforms = [
          t
          for t in self.flatten().transforms
          if isinstance(t, InvertibleTransform)
      ]
      if not invertible_transforms:
          warnings.warn(
              "inverse has been called but no invertible transforms have been supplied"
          )
  
      if self._lazy is True:
          warnings.warn(
              f"'lazy' is set to {self._lazy} but lazy execution is not supported when inverting. "
              f"'lazy' has been overridden to False for the call to inverse"
          )
      # loop backwards over transforms
      for t in reversed(invertible_transforms):
          data = apply_transform(
              t.inverse,
              data,
              self.map_items,
              self.unpack_items,
              lazy=False,
              log_stats=self.log_stats,
          )
      return data
  
imports: from __future__ import annotations
  import warnings
  from collections.abc import Callable, Mapping, Sequence
  from copy import deepcopy
  from typing import Any
  import numpy
  import monai
  from monai.apps.utils import get_logger
  from monai.config import NdarrayOrTensor
  from monai.transforms.inverse import InvertibleTransform
  from monai.transforms.lazy.functional import apply_pending_transforms
  from monai.transforms.traits import ThreadUnsafe
  from monai.transforms.transform import LazyTransform, MapTransform, Randomizable, RandomizableTransform, Transform, apply_transform
  from monai.utils import MAX_SEED, TraceKeys, TraceStatusKeys, ensure_tuple, get_seed
label_desc: Use image node_id 9 for calling the Compose obj's underlying member method code with example usage: obj.inverse(data) and returns: data