def make_namedtuple_tf_ngram(unischema, ngram, *args, **kargs):
    """Creates a dictionary of timestep keys and namedtuple values from args and kargs.

    :param ngram: The ngram definition.
    :param args: args.
    :param kargs: kargs.
    :return: A dictionary of timestep keys and namedtuple values.
    """
    ngram_result = {}
    previous_args_end = 0
    for timestep in range(min(ngram.fields.keys()), max(ngram.fields.keys()
        ) + 1):
        current_field_names = ngram.get_field_names_at_timestep(timestep)
        new_schema = ngram.get_schema_at_timestep(schema=unischema,
            timestep=timestep)
        new_args_end = previous_args_end + len(current_field_names)
        args_timestep = args[previous_args_end:new_args_end]
        previous_args_end = new_args_end
        kargs_timestep = kargs[str(timestep)] if str(timestep) in kargs else {}
        ngram_result[timestep] = new_schema._get_namedtuple()(*
            args_timestep, **kargs_timestep)
    return ngram_result
