code: def _parse_einsum_equation(
      equation: str,
  ) -> tuple[EquationType, tuple[str, str, str]]:
      """Returns the EquationType and I/O substrings of an einsum equation.
  
      Args:
        equation: The einsum equation `string`.
  
      Returns:
        A nested tuple `(equation_type, (ab_str, bc_str, ac_str))`, where
        `equation_type` specifies the type of einsum equation and `**_str`
        are the components of the equation. Excluding ellipses, the input equation
        should be of the form `ab,bc->ac` where `a`, `b`, and `c` can be themselves
        be substrings.
  
      Raises:
        ValueError: If `equation` is not a valid einsum equation in the context of
          the `tf.keras.layers.EinsumDense` layer.
      """
  
      def _try_match(regex_str):
          maybe_match = re.fullmatch(regex_str, equation)
          return (
              maybe_match.groups() if maybe_match is not None else None
          )
  
      error_message = (
          "Invalid Einsum equation string " + equation + " ."
          "Must be one of the forms {ab,bc->ac}, {...ab,bc->...ac}, "
          "{ab...,bc->ac...}"
      )
      case_pairs = [
          # equation_type, regex_str
          (
              EquationType.NO_ELLIPSES,
              r"([a-zA-Z]+),([a-zA-Z]+)->([a-zA-Z]+)",
          ),
          (
              EquationType.LEFT_ELLIPSES,
              r"\.\.\.([a-zA-Z]+),([a-zA-Z]+)->\.\.\.([a-zA-Z]+)",
          ),
          (
              EquationType.RIGHT_ELLIPSES,
              r"([a-zA-Z]+)\.\.\.,([a-zA-Z]+)->([a-zA-Z]+)\.\.\.",
          ),
      ]
      for equation_type, regex_str in case_pairs:
          groups = _try_match(regex_str)
          if groups is not None:
              if not _is_valid_einsum_equation(*groups):
                  raise ValueError(error_message)
              return equation_type, groups
      # No valid cases found. Raise an error.
      raise ValueError(error_message)
  
file_path: privacy/tensorflow_privacy/privacy/fast_gradient_clipping/registry_functions/einsum_utils.py
imports: import enum
  import itertools
  import os
  import re
  from typing import Optional
  import tensorflow
  from tensorflow_privacy.privacy.fast_gradient_clipping import common_manip_utils
label_desc: Use image node_id 3 for calling a global function with example usage: _parse_einsum_equation(equation) and returns: unknown, equation_type,  groups