code: def load_file(filename,
                file_type='json',
                klazz=YapconfError,
                open_kwargs=None,
                load_kwargs=None):
      
  
      _check_file_type(file_type, klazz)
  
      open_kwargs = open_kwargs or {'encoding': 'utf-8'}
      load_kwargs = load_kwargs or {}
  
      data = None
      with open(filename, **open_kwargs) as conf_file:
          if str(file_type).lower() == 'json':
              data = json.load(conf_file, **load_kwargs)
          elif str(file_type).lower() == 'yaml':
              data = yaml.safe_load(conf_file.read())
          else:
              raise NotImplementedError('Someone forgot to implement how to '
                                        'load a %s file_type.' % file_type)
  
      if not isinstance(data, dict):
          raise klazz('Successfully loaded %s, but the result was '
                      'not a dictionary.' % filename)
  
      return data
docs: Load a file with the given file type.
  
      Args:
          filename (str): The filename to load.
          file_type (str, optional): Defaults to 'json'. The file type for the
          given filename. Supported types are ``yapconf.FILE_TYPES```
          klazz (optional): The custom exception to raise if something goes
          wrong.
          open_kwargs (dict, optional): Keyword arguments for the open call.
          load_kwargs (dict, optional): Keyword arguments for the load call.
  
      Raises:
          klazz: If no klazz was passed in, this will be the ``YapconfError``
  
      Returns:
          dict: The dictionary from the file.