def _show_dim(dim: int | DimVar | MultiDimVar | KnownDim) -> str:
  """Summarizes a dimension variable into a human-readable summary."""
  if isinstance(dim, DimVar | MultiDimVar):
    if isinstance(dim.name, str):
      return f"var({repr(dim.name)})"
    else:
      assert isinstance(dim.name, tuple)
      return f"var({repr(dim.name[0])})[{repr(dim.name[1])}]"
  elif isinstance(dim, KnownDim):
    if isinstance(dim.name, str):
      return f"var({repr(dim.name)}):={dim.size}"
    else:
      assert isinstance(dim.name, tuple)
      return f"var({repr(dim.name[0])})[{repr(dim.name[1])}]:={dim.size}"
  else:
    return repr(dim)
Summarizes a dimension variable into a human-readable summary.
penzai/core/shapecheck.py