parameters: (self, dim: str or 'Shape' or None)
docstring: Finds the index of the dimension within this `Shape`.
  
          See Also:
              `Shape.indices()`.
  
          Args:
              dim: Dimension name or single-dimension `Shape`.
  
          Returns:
              Index as `int`.
docstring_summary: Finds the index of the dimension within this `Shape`.
docstring_tokens: Finds the index of the dimension within this Shape .
function: def index(self, dim: str or 'Shape' or None) -> int:
          """
          Finds the index of the dimension within this `Shape`.
  
          See Also:
              `Shape.indices()`.
  
          Args:
              dim: Dimension name or single-dimension `Shape`.
  
          Returns:
              Index as `int`.
          """
          if dim is None:
              return None
          elif isinstance(dim, str):
              return self.names.index(dim)
          elif isinstance(dim, Shape):
              assert dim.rank == 1, f"index() requires a single dimension as input but got {dim}. Use indices() for multiple dimensions."
              return self.names.index(dim.name)
          else:
              raise ValueError(f"index() requires a single dimension as input but got {dim}")
function_tokens: def index ( self , dim : str or 'Shape' or None ) -> int : if dim is None : return None elif isinstance ( dim , str ) : return self . names . index ( dim ) elif isinstance ( dim , Shape ) : assert dim . rank == 1 , f"index() requires a single dimension as input but got {dim}. Use indices() for multiple dimensions." return self . names . index ( dim . name ) else : raise ValueError ( f"index() requires a single dimension as input but got {dim}" )