<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def train_model(self, train_op, cost_to_log, num_steps, feed_vars=(), feed_data=None, print_every=100):
 """Trains the given model. Args: train_op: The training operation. cost_to_log: A cost to log. num_steps: Number of batches to run. feed_vars: A list or tuple of the variables that will be fed. feed_data: A generator that produces tuples of the same length as feed_vars. print_every: Print and save every so many steps. Returns: `cost_to_log` from the final step. """

    costs = [train_op]
    if (isinstance(cost_to_log, collections.Sequence)
        and not isinstance(cost_to_log, six.string_types)):
      costs.extend(cost_to_log)
    else:
      costs.append(cost_to_log)
    return self.run_model(costs,
                          num_steps,
                          feed_vars=feed_vars,
                          feed_data=feed_data,
                          print_every=print_every)[2:]