code: def _instantiate_task(api, kwargs):
      
      file_id = kwargs['file_id']
      kwargs['file_id'] = file_id if str(file_id).strip() else None
      kwargs['cid'] = kwargs['file_id'] or None
      kwargs['rate_download'] = kwargs['rateDownload']
      kwargs['percent_done'] = kwargs['percentDone']
      kwargs['add_time'] = get_utcdatetime(kwargs['add_time'])
      kwargs['last_update'] = get_utcdatetime(kwargs['last_update'])
      is_transferred = (kwargs['status'] == 2 and kwargs['move'] == 1)
      if is_transferred:
          kwargs['pid'] = api.downloads_directory.cid
      else:
          kwargs['pid'] = None
      del kwargs['rateDownload']
      del kwargs['percentDone']
      if 'url' in kwargs:
          if not kwargs['url']:
              kwargs['url'] = None
      else:
          kwargs['url'] = None
      task = Task(api, **kwargs)
      if is_transferred:
          task._parent = api.downloads_directory
      return task
docs: Create a Task object from raw kwargs