prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN 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
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `gym/spaces/multi_discrete.py`
  Content:
  ```
  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 FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
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"}], "after_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        gym.Space.__init__(self, (self.nvec.shape,), np.int8)\n    def sample(self):\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    \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"}]}