original_docstring: 
          Applies this transformation to a given subgraph, defined by a set of
          nodes. Raises an error if arguments are invalid or transformation is
          not applicable.
  
          The subgraph is defined by the `where` dictionary, where each key is
          taken from the `PatternNode` fields of the transformation. For example,
          applying `MapCollapse` on two maps can pe performed as follows:
  
          ```
          MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b)
          ```
  
          :param sdfg: The SDFG to apply the transformation to.
          :param options: A set of parameters to use for applying the
                          transformation.
          :param expr_index: The pattern expression index to try to match with.
          :param verify: Check that `can_be_applied` returns True before applying.
          :param annotate: Run memlet propagation after application if necessary.
          :param permissive: Apply transformation in permissive mode.
          :param save: Save transformation as part of the SDFG file. Set to
                       False if composing transformations.
          :param where: A dictionary of node names (from the transformation) to
                        nodes in the SDFG or a single state.
          
docstring: Applies this transformation to a given subgraph, defined by a set of
  nodes. Raises an error if arguments are invalid or transformation is
  not applicable.
  
  The subgraph is defined by the `where` dictionary, where each key is
  taken from the `PatternNode` fields of the transformation. For example,
  applying `MapCollapse` on two maps can pe performed as follows.
  
  
docstring_tokens: Applies this transformation to a given subgraph defined by a set of nodes . Raises an error if arguments are invalid or transformation is not applicable . The subgraph is defined by the ` where ` dictionary where each key is taken from the ` PatternNode ` fields of the transformation . For example applying ` MapCollapse ` on two maps can pe performed as follows .
code: def apply_to(cls,
                   sdfg: SDFG,
                   options: Optional[Dict[str, Any]] = None,
                   expr_index: int = 0,
                   verify: bool = True,
                   annotate: bool = True,
                   permissive: bool = False,
                   save: bool = True,
                   **where: Union[nd.Node, SDFGState]):
          """
          Applies this transformation to a given subgraph, defined by a set of
          nodes. Raises an error if arguments are invalid or transformation is
          not applicable.
  
          The subgraph is defined by the `where` dictionary, where each key is
          taken from the `PatternNode` fields of the transformation. For example,
          applying `MapCollapse` on two maps can pe performed as follows:
  
          ```
          MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b)
          ```
  
          :param sdfg: The SDFG to apply the transformation to.
          :param options: A set of parameters to use for applying the
                          transformation.
          :param expr_index: The pattern expression index to try to match with.
          :param verify: Check that `can_be_applied` returns True before applying.
          :param annotate: Run memlet propagation after application if necessary.
          :param permissive: Apply transformation in permissive mode.
          :param save: Save transformation as part of the SDFG file. Set to
                       False if composing transformations.
          :param where: A dictionary of node names (from the transformation) to
                        nodes in the SDFG or a single state.
          """
          if len(where) == 0:
              raise ValueError('At least one node is required')
          options = options or {}
  
          # Check that all keyword arguments are nodes and if interstate or not
          sample_node = next(iter(where.values()))
  
          if isinstance(sample_node, SDFGState):
              graph = sdfg
              state_id = -1
          elif isinstance(sample_node, nd.Node):
              graph = next(s for s in sdfg.nodes() if sample_node in s.nodes())
              state_id = sdfg.node_id(graph)
          else:
              raise TypeError('Invalid node type "%s"' % type(sample_node).__name__)
  
          # Check that all nodes in the pattern are set
          required_nodes = cls.expressions()[expr_index].nodes()
          required_node_names = {
              pname: pval
              for pname, pval in cls._get_pattern_nodes().items() if pval in required_nodes
          }
          required = set(required_node_names.keys())
          intersection = required & set(where.keys())
          if len(required - intersection) > 0:
              raise ValueError('Missing nodes for transformation subgraph: %s' % (required - intersection))
  
          # Construct subgraph and instantiate transformation
          subgraph = {required_node_names[k]: graph.node_id(where[k]) for k in required}
          instance = cls(sdfg, sdfg.sdfg_id, state_id, subgraph, expr_index)
  
          # Construct transformation parameters
          for optname, optval in options.items():
              if not optname in cls.__properties__:
                  raise ValueError('Property "%s" not found in transformation' % optname)
              setattr(instance, optname, optval)
  
          if verify:
              if not instance.can_be_applied(graph, expr_index, sdfg, permissive=permissive):
                  raise ValueError('Transformation cannot be applied on the ' 'given subgraph ("can_be_applied" failed)')
  
          # Apply to SDFG
          return instance.apply_pattern(annotate=annotate, append=save)
code_tokens: def apply_to ( cls , sdfg : SDFG , options : Optional [ Dict [ str , Any ] ] = None , expr_index : int = 0 , verify : bool = True , annotate : bool = True , permissive : bool = False , save : bool = True , ** where : Union [ nd . Node , SDFGState ] ) : if len ( where ) == 0 : raise ValueError ( 'At least one node is required' ) options = options or { } sample_node = next ( iter ( where . values ( ) ) ) if isinstance ( sample_node , SDFGState ) : graph = sdfg state_id = - 1 elif isinstance ( sample_node , nd . Node ) : graph = next ( s for s in sdfg . nodes ( ) if sample_node in s . nodes ( ) ) state_id = sdfg . node_id ( graph ) else : raise TypeError ( 'Invalid node type "%s"' % type ( sample_node ) . __name__ ) required_nodes = cls . expressions ( ) [ expr_index ] . nodes ( ) required_node_names = { pname : pval for pname , pval in cls . _get_pattern_nodes ( ) . items ( ) if pval in required_nodes } required = set ( required_node_names . keys ( ) ) intersection = required & set ( where . keys ( ) ) if len ( required - intersection ) > 0 : raise ValueError ( 'Missing nodes for transformation subgraph: %s' % ( required - intersection ) ) subgraph = { required_node_names [ k ] : graph . node_id ( where [ k ] ) for k in required } instance = cls ( sdfg , sdfg . sdfg_id , state_id , subgraph , expr_index ) for optname , optval in options . items ( ) : if not optname in cls . __properties__ : raise ValueError ( 'Property "%s" not found in transformation' % optname ) setattr ( instance , optname , optval ) if verify : if not instance . can_be_applied ( graph , expr_index , sdfg , permissive = permissive ) : raise ValueError ( 'Transformation cannot be applied on the ' 'given subgraph ("can_be_applied" failed)' ) return instance . apply_pattern ( annotate = annotate , append = save )
short_docstring: Applies this transformation to a given subgraph, defined by a set of
  nodes.
short_docstring_tokens: Applies this transformation to a given subgraph defined by a set of nodes .
comment: """
          Applies this transformation to a given subgraph, defined by a set of
          nodes. Raises an error if arguments are invalid or transformation is
          not applicable.
  
          The subgraph is defined by the `where` dictionary, where each key is
          taken from the `PatternNode` fields of the transformation. For example,
          applying `MapCollapse` on two maps can pe performed as follows:
  
          ```
          MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b)
          ```
  
          :param sdfg: The SDFG to apply the transformation to.
          :param options: A set of parameters to use for applying the
                          transformation.
          :param expr_index: The pattern expression index to try to match with.
          :param verify: Check that `can_be_applied` returns True before applying.
          :param annotate: Run memlet propagation after application if necessary.
          :param permissive: Apply transformation in permissive mode.
          :param save: Save transformation as part of the SDFG file. Set to
                       False if composing transformations.
          :param where: A dictionary of node names (from the transformation) to
                        nodes in the SDFG or a single state.
          """$SEP$# Check that all keyword arguments are nodes and if interstate or not$SEP$# Check that all nodes in the pattern are set$SEP$# Construct subgraph and instantiate transformation$SEP$# Construct transformation parameters$SEP$# Apply to SDFG