class_docstr: Returns an abstract Garage wrapper class for gym.Env.
  
  In order to provide pickling (serialization) and parameterization
  for :class:`gym.Env` instances, they must be wrapped with :class:`GymEnv`.
  This ensures compatibility with existing samplers and checkpointing when
  the envs are passed internally around garage.
  
  Furthermore, classes inheriting from :class:`GymEnv` should silently
  convert :attribute:`action_space` and :attribute:`observation_space`
  from :class:`gym.Space` to :class:`akro.Space`.
  
  :class:`GymEnv` handles all environments created by :func:`~gym.make`.
  
  It returns a different wrapper class instance if the input environment
  requires special handling.
  Current supported wrapper classes are:
      garage.envs.bullet.BulletEnv for Bullet-based gym environments.
  See __new__() for details.
class_docstr_tok: ["Returns","an","abstract","Garage","wrapper","class","for","gym.Env",".","In","order","to","provide","pickling","(","serialization",")","and","parameterization","for",":","class",":","`","gym.Env","`","instances",",","they","must","be","wrapped","with",":","class",":","`","GymEnv","`",".","This","ensures","compatibility","with","existing","samplers","and","checkpointing","when","the","envs","are","passed","internally","around","garage",".","Furthermore",",","classes","inheriting","from",":","class",":","`","GymEnv","`","should","silently","convert",":","attribute",":","`","action_space","`","and",":","attribute",":","`","observation_space","`","from",":","class",":","`","gym.Space","`","to",":","class",":","`","akro.Space","`",".",":","class",":","`","GymEnv","`","handles","all","environments","created","by",":","func",":","`","~gym.make","`",".","It","returns","a","different","wrapper","class","instance","if","the","input","environment","requires","special","handling",".","Current","supported","wrapper","classes","are",":","garage.envs.bullet.BulletEnv","for","Bullet-based","gym","environments",".","See","__new__","(",")","for","details","."]
docstr: Close viewer window.
  
  Unfortunately, some gym environments don't close the viewer windows
  properly, which leads to "out of memory" issues when several of
  these environments are tested one after the other.
  This method searches for the viewer object of type MjViewer, Viewer
  or SimpleImageViewer, based on environment, and if the environment
  is wrapped in other environment classes, it performs depth search
  in those as well.
  This method can be removed once OpenAI solves the issue.
docstr_tok: ["Close","viewer","window",".","Unfortunately",",","some","gym","environments","do","n't","close","the","viewer","windows","properly",",","which","leads","to","``","out","of","memory","''","issues","when","several","of","these","environments","are","tested","one","after","the","other",".","This","method","searches","for","the","viewer","object","of","type","MjViewer",",","Viewer","or","SimpleImageViewer",",","based","on","environment",",","and","if","the","environment","is","wrapped","in","other","environment","classes",",","it","performs","depth","search","in","those","as","well",".","This","method","can","be","removed","once","OpenAI","solves","the","issue","."]
code: def _close_viewer_window(self):
      """Close viewer window.
  
      Unfortunately, some gym environments don't close the viewer windows
      properly, which leads to "out of memory" issues when several of
      these environments are tested one after the other.
      This method searches for the viewer object of type MjViewer, Viewer
      or SimpleImageViewer, based on environment, and if the environment
      is wrapped in other environment classes, it performs depth search
      in those as well.
      This method can be removed once OpenAI solves the issue.
      """
      # We need to do some strange things here to fix-up flaws in gym
      # pylint: disable=import-outside-toplevel
      if hasattr(self._env, "spec") and self._env.spec:
          if any(
              package in getattr(self._env.spec, "entry_point", "")
              for package in KNOWN_GYM_NOT_CLOSE_MJ_VIEWER
          ):
              # This import is not in the header to avoid a MuJoCo dependency
              # with non-MuJoCo environments that use this base class.
              try:
                  from mujoco_py.mjviewer import MjViewer
                  import glfw
              except ImportError:
                  # If we can't import mujoco_py, we must not have an
                  # instance of a class that we know how to close here.
                  return
              if hasattr(self._env, "viewer") and isinstance(
                  self._env.viewer, MjViewer
              ):
                  glfw.destroy_window(self._env.viewer.window)
          elif any(
              package in getattr(self._env.spec, "entry_point", "")
              for package in KNOWN_GYM_NOT_CLOSE_VIEWER
          ):
              if hasattr(self._env, "viewer"):
                  from gym.envs.classic_control.rendering import (
                      Viewer,
                      SimpleImageViewer,
                  )
  
                  if isinstance(
                      self._env.viewer, (SimpleImageViewer, Viewer)
                  ):
                      self._env.viewer.close()
  
imports: import copy
  import warnings
  import akro
  import gym
  import numpy
  from garage import Environment, EnvSpec, EnvStep, StepType
label_desc: Use image node_id 12 for calling the GymEnv obj's underlying member method code with example usage: obj._close_viewer_window() without return types