code: def asdim(dimension):
      
      if isinstance(dimension, Dimension):
          return dimension
      elif isinstance(dimension, (tuple, dict, basestring)):
          return Dimension(dimension)
      else:
          raise ValueError('%s type could not be interpreted as Dimension. '
                           'Dimensions must be declared as a string, tuple, '
                           'dictionary or Dimension type.')
docs: Convert the input to a Dimension.
  
      Args:
          dimension: tuple, dict or string type to convert to Dimension
  
      Returns:
          A Dimension object constructed from the dimension spec. No
          copy is performed if the input is already a Dimension.