code: def parse_pattern_str(
      pattern: str, parent_layer: nn.Layer
  ) -> Union[None, List[Dict[str, Union[nn.Layer, str, None]]]]:
      """parse the string type pattern.
  
      Args:
          pattern (str): The pattern to discribe layer.
          parent_layer (nn.Layer): The root layer relative to the pattern.
  
      Returns:
          Union[None, List[Dict[str, Union[nn.Layer, str, None]]]]: None if failed. If successfully, the members are layers parsed in order:
                                                                  [
                                                                      {"layer": first layer, "name": first layer's name parsed, "index": first layer's index parsed if exist},
                                                                      {"layer": second layer, "name": second layer's name parsed, "index": second layer's index parsed if exist},
                                                                      ...
                                                                  ]
      """
  
      pattern_list = pattern.split(".")
      if not pattern_list:
          msg = f"The pattern('{pattern}') is illegal. Please check and retry."
          return None
  
      layer_list = []
      while len(pattern_list) > 0:
          if "[" in pattern_list[0]:
              target_layer_name = pattern_list[0].split("[")[0]
              target_layer_index = (
                  pattern_list[0].split("[")[1].split("]")[0]
              )
          else:
              target_layer_name = pattern_list[0]
              target_layer_index = None
  
          target_layer = getattr(parent_layer, target_layer_name, None)
  
          if target_layer is None:
              msg = f"Not found layer named('{target_layer_name}') specifed in pattern('{pattern}')."
              return None
  
          if target_layer_index and target_layer:
              if int(target_layer_index) < 0 or int(
                  target_layer_index
              ) >= len(target_layer):
                  msg = f"Not found layer by index('{target_layer_index}') specifed in pattern('{pattern}'). The index should < {len(target_layer)} and > 0."
                  return None
  
              target_layer = target_layer[target_layer_index]
  
          layer_list.append(
              {
                  "layer": target_layer,
                  "name": target_layer_name,
                  "index": target_layer_index,
              }
          )
  
          pattern_list = pattern_list[1:]
          parent_layer = target_layer
      return layer_list
  
imports: import math
  from typing import Any
  from typing import Callable
  from typing import Dict
  from typing import List
  from typing import Tuple
  from typing import Union
  import paddle
  import paddle.nn
  from paddle import concat
  from paddle import ParamAttr
  from paddle import reshape
  from paddle import split
  from paddle import transpose
  from paddle.nn import AdaptiveAvgPool2D
  from paddle.nn import BatchNorm
  from paddle.nn import Conv2D
  from paddle.nn import Dropout
  from paddle.nn import Linear
  from paddle.nn import MaxPool2D
  from paddle.nn.initializer import KaimingNormal
  from paddle.regularizer import L2Decay
label_desc: Use image node_id 3 for calling a global function with example usage: parse_pattern_str(pattern, parent_layer) and returns: layer_list, None, None, None