class_docstr:    ### Description
  
  The inverted pendulum swingup problem is based on the classic problem in control theory.
  The system consists of a pendulum attached at one end to a fixed point, and the other end being free.
  The pendulum starts in a random position and the goal is to apply torque on the free end to swing it
  into an upright position, with its center of gravity right above the fixed point.
  
  The diagram below specifies the coordinate system used for the implementation of the pendulum's
  dynamic equations.
  
  ![Pendulum Coordinate System](./diagrams/pendulum.png)
  
  -  `x-y`: cartesian coordinates of the pendulum's end in meters.
  - `theta` : angle in radians.
  - `tau`: torque in `N m`. Defined as positive _counter-clockwise_.
  
  ### Action Space
  
  The action is a `ndarray` with shape `(1,)` representing the torque applied to free end of the pendulum.
  
  | Num | Action | Min  | Max |
  |-----|--------|------|-----|
  | 0   | Torque | -2.0 | 2.0 |
  
  
  ### Observation Space
  
  The observation is a `ndarray` with shape `(3,)` representing the x-y coordinates of the pendulum's free
  end and its angular velocity.
  
  | Num | Observation      | Min  | Max |
  |-----|------------------|------|-----|
  | 0   | x = cos(theta)   | -1.0 | 1.0 |
  | 1   | y = sin(theta)   | -1.0 | 1.0 |
  | 2   | Angular Velocity | -8.0 | 8.0 |
  
  ### Rewards
  
  The reward function is defined as:
  
  *r = -(theta<sup>2</sup> + 0.1 * theta_dt<sup>2</sup> + 0.001 * torque<sup>2</sup>)*
  
  where `$    heta$` is the pendulum's angle normalized between *[-pi, pi]* (with 0 being in the upright position).
  Based on the above equation, the minimum reward that can be obtained is
  *-(pi<sup>2</sup> + 0.1 * 8<sup>2</sup> + 0.001 * 2<sup>2</sup>) = -16.2736044*,
  while the maximum reward is zero (pendulum is upright with zero velocity and no torque applied).
  
  ### Starting State
  
  The starting state is a random angle in *[-pi, pi]* and a random angular velocity in *[-1,1]*.
  
  ### Episode Truncation
  
  The episode truncates at 200 time steps.
  
  ### Arguments
  
  - `g`: acceleration of gravity measured in *(m s<sup>-2</sup>)* used to calculate the pendulum dynamics.
    The default value is g = 10.0 .
  
  ```
  gym.make('Pendulum-v1', g=9.81)
  ```
  
  ### Version History
  
  * v1: Simplify the math equations, no difference in behavior.
  * v0: Initial versions release (1.0.0)
class_docstr_tok: ["#","#","#","Description","The","inverted","pendulum","swingup","problem","is","based","on","the","classic","problem","in","control","theory",".","The","system","consists","of","a","pendulum","attached","at","one","end","to","a","fixed","point",",","and","the","other","end","being","free",".","The","pendulum","starts","in","a","random","position","and","the","goal","is","to","apply","torque","on","the","free","end","to","swing","it","into","an","upright","position",",","with","its","center","of","gravity","right","above","the","fixed","point",".","The","diagram","below","specifies","the","coordinate","system","used","for","the","implementation","of","the","pendulum's","dynamic","equations",".","!","[","Pendulum","Coordinate","System","]","(",".\/diagrams\/pendulum.png",")","-","`","x-y","`",":","cartesian","coordinates","of","the","pendulum","'s","end","in","meters",".","-","`","theta","`",":","angle","in","radians",".","-","`","tau","`",":","torque","in","`","N","m","`",".","Defined","as","positive","_counter-clockwise_",".","#","#","#","Action","Space","The","action","is","a","`","ndarray","`","with","shape","`","(","1",",",")","`","representing","the","torque","applied","to","free","end","of","the","pendulum",".","|","Num","|","Action","|","Min","|","Max","|","|","--","--","-|","--","--","--","--","|","--","--","--","|","--","--","-|","|","0","|","Torque","|","-2.0","|","2.0","|","#","#","#","Observation","Space","The","observation","is","a","`","ndarray","`","with","shape","`","(","3",",",")","`","representing","the","x-y","coordinates","of","the","pendulum","'s","free","end","and","its","angular","velocity",".","|","Num","|","Observation","|","Min","|","Max","|","|","--","--","-|","--","--","--","--","--","--","--","--","--","|","--","--","--","|","--","--","-|","|","0","|","x","=","cos","(","theta",")","|","-1.0","|","1.0","|","|","1","|","y","=","sin","(","theta",")","|","-1.0","|","1.0","|","|","2","|","Angular","Velocity","|","-8.0","|","8.0","|","#","#","#","Rewards","The","reward","function","is","defined","as",":","*","r","=","-","(","theta","<","sup",">","2","<","\/sup",">","+","0.1","*","theta_dt","<","sup",">","2","<","\/sup",">","+","0.001","*","torque","<","sup",">","2","<","\/sup",">",")","*","where","`","$","heta","$","`","is","the","pendulum","'s","angle","normalized","between","*","[","-pi",",","pi","]","*","(","with","0","being","in","the","upright","position",")",".","Based","on","the","above","equation",",","the","minimum","reward","that","can","be","obtained","is","*","-","(","pi","<","sup",">","2","<","\/sup",">","+","0.1","*","8","<","sup",">","2","<","\/sup",">","+","0.001","*","2","<","sup",">","2","<","\/sup",">",")","=","-16.2736044","*",",","while","the","maximum","reward","is","zero","(","pendulum","is","upright","with","zero","velocity","and","no","torque","applied",")",".","#","#","#","Starting","State","The","starting","state","is","a","random","angle","in","*","[","-pi",",","pi","]","*","and","a","random","angular","velocity","in","*","[","-1,1","]","*",".","#","#","#","Episode","Truncation","The","episode","truncates","at","200","time","steps",".","#","#","#","Arguments","-","`","g","`",":","acceleration","of","gravity","measured","in","*","(","m","s","<","sup",">","-2","<","\/sup",">",")","*","used","to","calculate","the","pendulum","dynamics",".","The","default","value","is","g","=","10.0",".","``","`","gym.make","(","'Pendulum-v1","'",",","g=9.81",")","``","`","#","#","#","Version","History","*","v1",":","Simplify","the","math","equations",",","no","difference","in","behavior",".","*","v0",":","Initial","versions","release","(","1.0.0",")"]
code: def reset(
      self,
      *,
      seed: Optional[int] = None,
      options: Optional[dict] = None,
  ):
      super().reset(seed=seed)
      if options is None:
          high = np.array([DEFAULT_X, DEFAULT_Y])
      else:
          # Note that if you use custom reset bounds, it may lead to out-of-bound
          # state/observations.
          x = (
              options.get("x_init")
              if "x_init" in options
              else DEFAULT_X
          )
          y = (
              options.get("y_init")
              if "y_init" in options
              else DEFAULT_Y
          )
          x = utils.verify_number_and_cast(x)
          y = utils.verify_number_and_cast(y)
          high = np.array([x, y])
      low = -high  # We enforce symmetric limits.
      self.state = self.np_random.uniform(low=low, high=high)
      self.last_u = None
  
      if self.render_mode == "human":
          self.render()
      return self._get_obs(), {}
  
file_path: gym/gym/envs/classic_control/pendulum.py
imports: from os import path
  from typing import Optional
  import numpy
  import gym
  from gym import spaces
  from gym.envs.classic_control import utils
  from gym.error import DependencyNotInstalled
label_desc: Use image node_id 3 for calling the PendulumEnv obj's underlying member method code with example usage: obj.reset() and returns: self,  dict