class_docstr: A RL task: environment and a collection of trajectories.
class_docstr_tok: ["A","RL","task",":","environment","and","a","collection","of","trajectories","."]
docstr: Save this task to file.
docstr_tok: ["Save","this","task","to","file","."]
code: def save_to_file(self, file_name):
      """Save this task to file."""
      # Save trajectories from new epochs first.
      epochs_to_save = [
          e
          for e in self._trajectories
          if e not in self._saved_epochs_unchanged
      ]
      for epoch in epochs_to_save:
          training.pickle_to_file(
              self._trajectories[epoch],
              self._epoch_filename(file_name, epoch),
              gzip=True,
          )
      # Now save the list of epochs (so the trajectories are already there,
      # even in case of preemption).
      dictionary = {
          "n_interactions": self._n_interactions,
          "n_trajectories": self._n_trajectories,
          "max_steps": self._max_steps,
          "gamma": self._gamma,
          "all_epochs": list(self._trajectories.keys()),
      }
      training.pickle_to_file(dictionary, file_name, gzip=False)
  
imports: import collections
  import os
  import gin
  import gym
  import numpy
  from trax import fastmath
  from trax.rl import advantages
  from trax.supervised import training
label_desc: Use image node_id 15 for calling the RLTask obj's underlying member method code with example usage: obj.save_to_file(file_name) without return types