def var(name: str) -> DimVar:
  """Creates a variable for an axis shape.

  The resulting variable can be used in place of a single array dimension. It
  can also be unpacked with ``*var(name)`` to replace a sequence of array
  dimensions, or with ``**var(name)`` to replace a subdictionary of named array
  axes.

  Args:
    name: Name for the variable.

  Returns:
    Variable that can be matched with axes. Repeat uses of variables with the
    same name must have the same length. The result can be unpacked with
    ``*var(name)`` to stand in for multiple positional dimensions or with
    ``**var(name)`` to stand in for multiple named axes.
  """
  if not isinstance(name, str):
    raise TypeError(f"Variable names must be strings. Got {repr(name)}")
  return DimVar(name)
Creates a variable for an axis shape.

  The resulting variable can be used in place of a single array dimension. It
  can also be unpacked with ``*var(name)`` to replace a sequence of array
  dimensions, or with ``**var(name)`` to replace a subdictionary of named array
  axes.

  Args:
    name: Name for the variable.

  Returns:
    Variable that can be matched with axes. Repeat uses of variables with the
    same name must have the same length. The result can be unpacked with
    ``*var(name)`` to stand in for multiple positional dimensions or with
    ``**var(name)`` to stand in for multiple named axes.
  
penzai/core/shapecheck.py