code: from rllab.envs.base import Step
  from rllab.misc.overrides import overrides
  from rllab.envs.mujoco.mujoco_env import MujocoEnv
  import numpy as np
  from rllab.core.serializable import Serializable
  from rllab.misc import logger
  from rllab.misc import autoargs
  from contextlib import contextmanager
  
  class SwimmerEnv(MujocoEnv, Serializable):
  
      FILE = 'swimmer.xml'
  
      @autoargs.arg('ctrl_cost_coeff', type=float,
                    help='cost coefficient for controls')
      def __init__(
              self,
              ctrl_cost_coeff=1e-2,
              *args, **kwargs):
          self.ctrl_cost_coeff = ctrl_cost_coeff
          super(SwimmerEnv, self).__init__(*args, **kwargs)
          Serializable.quick_init(self, locals())
  
      def get_current_obs(self):
          return np.concatenate([
              self.model.data.qpos.flat,
              self.model.data.qvel.flat,
              self.get_body_com("torso").flat,
          ]).reshape(-1)
  
      def step(self, action):
          self.forward_dynamics(action)
          next_obs = self.get_current_obs()
          lb, ub = self.action_bounds
          scaling = (ub - lb) * 0.5
          ctrl_cost = 0.5 * self.ctrl_cost_coeff * np.sum(
              np.square(action / scaling))
          forward_reward = self.get_body_comvel("torso")[0]
          reward = forward_reward - ctrl_cost
          done = False
          return Step(next_obs, reward, done)
  
      # @overrides
      # def reset_mujoco(self, init_state=None):
      #     super(SwimmerEnv, self).reset_mujoco(init)
          # if init_state is not None:
          #     idx = self.model.body_names.index("torso")
          #     self.model.data.com_subtree[idx][0] = init_state[0]
          #     self.model.data.com_subtree[idx][1] = init_state[1]
  
      @overrides  # ignoring the goal
      def reset(self, *args, **kwargs):
          return super(SwimmerEnv, self).reset(*args, **kwargs) # passing in keyword arguments
  
      @overrides
      def log_diagnostics(self, paths):
          if len(paths) > 0:
              progs = [
                  path["observations"][-1][-3] - path["observations"][0][-3]
                  for path in paths
              ]
              logger.record_tabular('AverageForwardProgress', np.mean(progs))
              logger.record_tabular('MaxForwardProgress', np.max(progs))
              logger.record_tabular('MinForwardProgress', np.min(progs))
              logger.record_tabular('StdForwardProgress', np.std(progs))
          else:
              logger.record_tabular('AverageForwardProgress', np.nan)
              logger.record_tabular('MaxForwardProgress', np.nan)
              logger.record_tabular('MinForwardProgress', np.nan)
              logger.record_tabular('StdForwardProgress', np.nan)
  
      @contextmanager
      def set_kill_outside(self):
          self.kill_outside = True
          try:
              yield
          finally:
              self.kill_outside = False
apis: numpy.max numpy.min numpy.std numpy.square numpy.mean