code: def convert_type(d, intype, outtype, convert_list=True, in_place=True):
      
      if not in_place:
          out_dict = copy.deepcopy(d)
      else:
          out_dict = d
  
      def _convert(obj):
          if isinstance(obj, intype):
              try:
                  obj = outtype(obj)
              except Exception:
                  pass
          elif isinstance(obj, list) and convert_list:
              obj = _traverse_iter(obj)
          elif isinstance(obj, tuple) and convert_list:
              obj = tuple(_traverse_iter(obj))
  
          return obj
  
      def _traverse_dict(dic):
          for key in dic.keys():
              if is_dict_like(dic[key]):
                  _traverse_dict(dic[key])
              else:
                  dic[key] = _convert(dic[key])
  
      def _traverse_iter(iter):
          new_iter = []
          for key in iter:
              if is_dict_like(key):
                  _traverse_dict(key)
                  new_iter.append(key)
              else:
                  new_iter.append(_convert(key))
  
          return new_iter
  
      if is_dict_like(out_dict):
          _traverse_dict(out_dict)
      else:
          _convert(out_dict)
  
      return out_dict
docs: convert all values of one type to another
  
      Parameters
      ----------
      d : dict
      intype : type_class
      outtype : type_class
      convert_list : bool
          whether to convert instances inside lists and tuples
      in_place : bool
          if True, applies conversions to original dict, else returns copy
  
      Examples
      --------
  
      >>> from pprint import pprint
  
      >>> d = {'a':'1','b':'2'}
      >>> pprint(convert_type(d,str,float))
      {'a': 1.0, 'b': 2.0}
  
      >>> d = {'a':['1','2']}
      >>> pprint(convert_type(d,str,float))
      {'a': [1.0, 2.0]}
  
      >>> d = {'a':[('1','2'),[3,4]]}
      >>> pprint(convert_type(d,str,float))
      {'a': [(1.0, 2.0), [3, 4]]}