def _get_type(dtype):
  """
  Defensively try to extract a scalar type from any wacky thing
  that might get passed in as a 'dtype' to an array constructor
  """
  if isinstance(dtype, macro):
    dtype = dtype.as_fn()
  
  while isinstance(dtype, jit):
    dtype = dtype.f 
  
  while isinstance(dtype, Expr):
    if isinstance(dtype, UntypedFn):
      if len(dtype.body) == 1:
        stmt = dtype.body[0]
        if stmt.__class__ is Return:
          expr = stmt.value 
          if expr.__class__ is Cast:
            dtype = expr.type 
            break
      assert False, "Don't know how to convert function %s into Parakeet type" % dtype
    elif isinstance(dtype, TypedFn):
      dtype = dtype.return_type
    if isinstance(dtype, TypeValue):
      dtype = dtype.type_value  
    elif isinstance(dtype.type, TypeValueT):
      dtype = dtype.type
    elif isinstance(dtype, Closure):
      dtype = dtype.fn
    elif isinstance(dtype.type, (ClosureT, FnT)):
      dtype = dtype.type.fn
    else:
      assert False, "Don't know how to turn %s : %s into Parakeet type" % (dtype, dtype.type)  


  if isinstance(dtype, Type):
    if isinstance(dtype, TypeValueT):
      return dtype.type
    else:
      return dtype 
    
  elif isinstance(dtype, (np.dtype, type)):

    return type_conv.equiv_type(dtype)
  elif isinstance(dtype, str):
    return type_conv.equiv_type(np.dtype(dtype))
  assert False, dtype % "Don't know how to turn %s into Parakeet type"
dataset/ETHPy150Open iskandr/parakeet/parakeet/lib/lib_helpers.py/_get_type/swapped operands of `%`