parameters: (shape: Shape, sequence, default=None)
docstring: If sequence is a dict with dimension names as keys, orders its values according to this shape.
  
      Otherwise, the sequence is returned unchanged.
  
      Args:
        sequence: Sequence or dict to be ordered
        default: default value used for dimensions not contained in sequence
  
      Returns:
        ordered sequence of values
docstring_summary: If sequence is a dict with dimension names as keys, orders its values according to this shape.
docstring_tokens: If sequence is a dict with dimension names as keys orders its values according to this shape .
function: def order_by_shape(shape: Shape, sequence, default=None) -> tuple or list:
      """
      If sequence is a dict with dimension names as keys, orders its values according to this shape.
  
      Otherwise, the sequence is returned unchanged.
  
      Args:
        sequence: Sequence or dict to be ordered
        default: default value used for dimensions not contained in sequence
  
      Returns:
        ordered sequence of values
      """
      if isinstance(sequence, dict):
          result = [sequence.get(name, default) for name in shape.names]
          return result
      elif isinstance(sequence, (tuple, list)):
          assert len(sequence) == shape.rank
          return sequence
      else:  # just a constant
          return sequence
function_tokens: def order_by_shape ( shape : Shape , sequence , default = None ) -> tuple or list : if isinstance ( sequence , dict ) : result = [ sequence . get ( name , default ) for name in shape . names ] return result elif isinstance ( sequence , ( tuple , list ) ) : assert len ( sequence ) == shape . rank return sequence else : # just a constant return sequence