code: def check_type(stochastic):
      
      val = stochastic.value
  
      if val.__class__ in bool_dtypes:
          return bool, ()
      elif val.__class__ in integer_dtypes:
          return int, ()
      elif val.__class__ in float_dtypes:
          return float, ()
      elif val.__class__ in complex_dtypes:
          return complex, ()
      elif isinstance(val, ndarray):
          if obj2sctype(val) in bool_dtypes:
              return bool, val.shape
          elif obj2sctype(val) in integer_dtypes:
              return int, val.shape
          elif obj2sctype(val) in float_dtypes:
              return float, val.shape
          elif obj2sctype(val) in complex_dtypes:
              return complex, val.shape
          else:
              return 'object', val.shape
      else:
          return 'object', ()
docs: type, shape = check_type(stochastic)
  
      Checks the type of a stochastic's value. Output value 'type' may be
      bool, int, float, or complex. Nonnative numpy dtypes are lumped into
      these categories. Output value 'shape' is () if the stochastic's value
      is scalar, or a nontrivial tuple otherwise.