prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Why is there a restiction on shape in multi discrete?
  https://github.com/openai/gym/blob/422c9c7bb3c3c5a756c3b12dfe99733bfbfe3920/gym/spaces/multi_discrete.py#L10
  
  Why is this imposed?
  Say one may need a high dimensional space like a (3,3,3) grid with discretised values for each element in the grid. 
  It can be very easily circumvented by using np.random.random_sample and passing the shape
  Is there some specific reason for doing this?
  
  Also note this example provided in dict_space doesn't work currently.
  https://github.com/openai/gym/blob/422c9c7bb3c3c5a756c3b12dfe99733bfbfe3920/gym/spaces/dict_space.py#L22
  
  
  
  </issue>
  <code>
  [start of gym/spaces/multi_discrete.py]
  1 import gym
  2 import numpy as np
  3 
  4 class MultiDiscrete(gym.Space):
  5     def __init__(self, nvec):
  6         """
  7         nvec: vector of counts of each categorical variable
  8         """
  9         self.nvec = np.asarray(nvec, dtype=np.int32)
  10         assert self.nvec.ndim == 1, 'nvec should be a 1d array (or list) of ints'
  11         gym.Space.__init__(self, (self.nvec.size,), np.int8)
  12     def sample(self):
  13         return (gym.spaces.np_random.rand(self.nvec.size) * self.nvec).astype(self.dtype)
  14     def contains(self, x):
  15         return (0 <= x).all() and (x < self.nvec).all() and x.dtype.kind in 'ui'
  16     
  17     __contains__ = contains
  18     
  19     def to_jsonable(self, sample_n):
  20         return [sample.tolist() for sample in sample_n]
  21     def from_jsonable(self, sample_n):
  22         return np.array(sample_n)
  23
  [end of gym/spaces/multi_discrete.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/gym/spaces/multi_discrete.py b/gym/spaces/multi_discrete.py
  --- a/gym/spaces/multi_discrete.py
  +++ b/gym/spaces/multi_discrete.py
  @@ -7,10 +7,9 @@
           nvec: vector of counts of each categorical variable
           """
           self.nvec = np.asarray(nvec, dtype=np.int32)
  -        assert self.nvec.ndim == 1, 'nvec should be a 1d array (or list) of ints'
  -        gym.Space.__init__(self, (self.nvec.size,), np.int8)
  +        gym.Space.__init__(self, (self.nvec.shape,), np.int8)
       def sample(self):
  -        return (gym.spaces.np_random.rand(self.nvec.size) * self.nvec).astype(self.dtype)
  +        return (gym.spaces.np_random.random_sample(self.nvec.shape) * self.nvec).astype(self.dtype)
       def contains(self, x):
           return (0 <= x).all() and (x < self.nvec).all() and x.dtype.kind in 'ui'
  
verification_info: {"golden_diff": "diff --git a/gym/spaces/multi_discrete.py b/gym/spaces/multi_discrete.py\n--- a/gym/spaces/multi_discrete.py\n+++ b/gym/spaces/multi_discrete.py\n@@ -7,10 +7,9 @@\n         nvec: vector of counts of each categorical variable\n         \"\"\"\n         self.nvec = np.asarray(nvec, dtype=np.int32)\n-        assert self.nvec.ndim == 1, 'nvec should be a 1d array (or list) of ints'\n-        gym.Space.__init__(self, (self.nvec.size,), np.int8)\n+        gym.Space.__init__(self, (self.nvec.shape,), np.int8)\n     def sample(self):\n-        return (gym.spaces.np_random.rand(self.nvec.size) * self.nvec).astype(self.dtype)\n+        return (gym.spaces.np_random.random_sample(self.nvec.shape) * self.nvec).astype(self.dtype)\n     def contains(self, x):\n         return (0 <= x).all() and (x < self.nvec).all() and x.dtype.kind in 'ui'\n", "issue": "Why is there a restiction on shape in multi discrete?\nhttps://github.com/openai/gym/blob/422c9c7bb3c3c5a756c3b12dfe99733bfbfe3920/gym/spaces/multi_discrete.py#L10\r\n\r\nWhy is this imposed?\r\nSay one may need a high dimensional space like a (3,3,3) grid with discretised values for each element in the grid. \r\nIt can be very easily circumvented by using np.random.random_sample and passing the shape\r\nIs there some specific reason for doing this?\r\n\r\nAlso note this example provided in dict_space doesn't work currently.\r\nhttps://github.com/openai/gym/blob/422c9c7bb3c3c5a756c3b12dfe99733bfbfe3920/gym/spaces/dict_space.py#L22\r\n\r\n\n", "before_files": [{"content": "import gym\nimport numpy as np\n\nclass MultiDiscrete(gym.Space):\n    def __init__(self, nvec):\n        \"\"\"\n        nvec: vector of counts of each categorical variable\n        \"\"\"\n        self.nvec = np.asarray(nvec, dtype=np.int32)\n        assert self.nvec.ndim == 1, 'nvec should be a 1d array (or list) of ints'\n        gym.Space.__init__(self, (self.nvec.size,), np.int8)\n    def sample(self):\n        return (gym.spaces.np_random.rand(self.nvec.size) * self.nvec).astype(self.dtype)\n    def contains(self, x):\n        return (0 <= x).all() and (x < self.nvec).all() and x.dtype.kind in 'ui'\n    \n    __contains__ = contains\n    \n    def to_jsonable(self, sample_n):\n        return [sample.tolist() for sample in sample_n]\n    def from_jsonable(self, sample_n):\n        return np.array(sample_n)\n", "path": "gym/spaces/multi_discrete.py"}]}