code: def wrap(x, m, M):
      """Wraps ``x`` so m <= x <= M; but unlike ``bound()`` which
      truncates, ``wrap()`` wraps x around the coordinate system defined by m,M.\n
      For example, m = -180, M = 180 (degrees), x = 360 --> returns 0.
  
      Args:
          x: a scalar
          m: minimum possible value in range
          M: maximum possible value in range
  
      Returns:
          x: a scalar, wrapped
      """
      diff = M - m
      while x > M:
          x = x - diff
      while x < m:
          x = x + diff
      return x
  
file_path: gym/gym/envs/classic_control/acrobot.py
imports: from typing import Optional
  import numpy
  from numpy import cos, pi, sin
  from gym import core, logger, spaces
  from gym.error import DependencyNotInstalled
  from gym.envs.classic_control import utils
label_desc: Use image node_id 1 for calling a global function with example usage: wrap(x, m, M) and returns: x