code: def _internal_add(self, pattern: Pattern, label, renaming) -> int:
          
          pattern_index = len(self.patterns)
          renamed_constraints = [c.with_renamed_vars(renaming) for c in pattern.local_constraints]
          constraint_indices = [self._add_constraint(c, pattern_index) for c in renamed_constraints]
          self.patterns.append((pattern, label, constraint_indices))
          self.pattern_vars.append(renaming)
          pattern = rename_variables(pattern.expression, renaming)
          state = self.root
          patterns_stack = [deque([pattern])]
  
          self._process_pattern_stack(state, patterns_stack, renamed_constraints, pattern_index)
  
          return pattern_index
docs: Add a new pattern to the matcher.
  
          Equivalent patterns are not added again. However, patterns that are structurally equivalent,
          but have different constraints or different variable names are distinguished by the matcher.
  
          Args:
              pattern: The pattern to add.
  
          Returns:
              The internal id for the pattern. This is mainly used by the :class:`CommutativeMatcher`.