prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  multinomial
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `ivy/functional/backends/paddle/random.py`
  Content:
  ```
  1 """Collection of Paddle random functions, wrapped to fit Ivy syntax and signature."""
  2 
  3 # global
  4 import paddle
  5 import ivy.functional.backends.paddle as paddle_backend
  6 from typing import Optional, Union, Sequence
  7 
  8 # local
  9 import ivy
  10 from paddle.fluid.libpaddle import Place
  11 from ivy.utils.exceptions import IvyNotImplementedException
  12 from ivy.functional.backends.paddle.device import to_device
  13 from ivy.functional.ivy.random import (
  14     _check_bounds_and_get_shape,
  15     _randint_check_dtype_and_bound,
  16     _check_valid_scale,
  17 )
  18 from ivy.func_wrapper import with_unsupported_device_and_dtypes
  19 from . import backend_version
  20 
  21 # Extra #
  22 # ------#
  23 
  24 
  25 @with_unsupported_device_and_dtypes(
  26     {"2.5.0 and below": {"cpu": ("int8",)}},
  27     backend_version,
  28 )
  29 def random_uniform(
  30     *,
  31     low: Union[float, paddle.Tensor] = 0.0,
  32     high: Union[float, paddle.Tensor] = 1.0,
  33     shape: Optional[Union[paddle.Tensor, ivy.NativeShape, Sequence[int]]] = None,
  34     dtype: paddle.dtype,
  35     device: Place,
  36     seed=None,
  37     out: Optional[paddle.Tensor] = None,
  38 ) -> paddle.Tensor:
  39     if not dtype:
  40         dtype = ivy.default_int_dtype()
  41     dtype = ivy.as_native_dtype(dtype)
  42     low = paddle.cast(low, "float32") if isinstance(low, paddle.Tensor) else low
  43     high = paddle.cast(high, "float32") if isinstance(high, paddle.Tensor) else high
  44     shape = _check_bounds_and_get_shape(low, high, shape).shape
  45     # Set range and seed
  46     rng = high - low
  47     if seed:
  48         _ = paddle.seed(seed)
  49     random_base = paddle.uniform(shape, min=0.0, max=1.0)
  50 
  51     return paddle_backend.add(paddle_backend.multiply(random_base, rng), low).cast(
  52         dtype
  53     )
  54 
  55 
  56 @with_unsupported_device_and_dtypes(
  57     {"2.5.0 and below": {"cpu": ("complex64", "complex128")}},
  58     backend_version,
  59 )
  60 def random_normal(
  61     *,
  62     mean: Union[float, paddle.Tensor] = 0.0,
  63     std: Union[float, paddle.Tensor] = 1.0,
  64     shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None,
  65     dtype: paddle.dtype,
  66     seed: Optional[int] = None,
  67     device: Place,
  68     out: Optional[paddle.Tensor] = None,
  69 ) -> paddle.Tensor:
  70     _check_valid_scale(std)
  71     shape = _check_bounds_and_get_shape(mean, std, shape).shape
  72     if seed:
  73         paddle.seed(seed)
  74     if isinstance(mean, (int, float)) and isinstance(std, (int, float)):
  75         return paddle.normal(mean, std, shape).cast(dtype)
  76     if mean.dtype not in [paddle.float32, paddle.float64]:
  77         mean = mean.cast("float32")
  78     std = std.cast(mean.dtype)
  79     return paddle.normal(mean, std).cast(dtype)
  80 
  81 
  82 def multinomial(
  83     population_size: int,
  84     num_samples: int,
  85     /,
  86     *,
  87     batch_size: int = 1,
  88     probs: Optional[paddle.Tensor] = None,
  89     replace: bool = True,
  90     device: Place,
  91     seed: Optional[int] = None,
  92     out: Optional[paddle.Tensor] = None,
  93 ) -> paddle.Tensor:
  94     raise IvyNotImplementedException()
  95 
  96 
  97 @with_unsupported_device_and_dtypes(
  98     {"2.5.0 and below": {"cpu": ("int8",)}},
  99     backend_version,
  100 )
  101 def randint(
  102     low: Union[int, paddle.Tensor],
  103     high: Union[int, paddle.Tensor],
  104     /,
  105     *,
  106     shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None,
  107     device: Place,
  108     dtype: Optional[Union[paddle.dtype, ivy.Dtype]] = None,
  109     seed: Optional[int] = None,
  110     out: Optional[paddle.Tensor] = None,
  111 ) -> paddle.Tensor:
  112     if not dtype:
  113         dtype = ivy.default_int_dtype()
  114     dtype = ivy.as_native_dtype(dtype)
  115     _randint_check_dtype_and_bound(low, high, dtype)
  116     low = paddle.cast(low, "float32") if isinstance(low, paddle.Tensor) else low
  117     high = paddle.cast(high, "float32") if isinstance(high, paddle.Tensor) else high
  118     shape = _check_bounds_and_get_shape(low, high, shape).shape
  119     range = high - low
  120     if seed:
  121         _ = paddle.seed(seed)
  122     _retval = to_device(
  123         paddle.cast(
  124             paddle.uniform(shape or [1], min=0.0, max=1.0) * range + low, dtype
  125         ),
  126         device,
  127     )
  128     return _retval if shape else _retval.squeeze(axis=0)
  129 
  130 
  131 def seed(*, seed_value: int = 0) -> None:
  132     _ = paddle.seed(seed_value)
  133     return
  134 
  135 
  136 def shuffle(
  137     x: paddle.Tensor,
  138     axis: Optional[int] = 0,
  139     /,
  140     *,
  141     seed: Optional[int] = None,
  142     out: Optional[paddle.Tensor] = None,
  143 ) -> paddle.Tensor:
  144     if seed:
  145         _ = paddle.seed(seed)
  146     # Use Paddle's randperm function to generate shuffled indices
  147     indices = paddle.randperm(x.shape[0], dtype="int64")
  148     if x.dtype in [
  149         paddle.int8,
  150         paddle.int16,
  151         paddle.uint8,
  152         paddle.float16,
  153         paddle.complex64,
  154         paddle.complex128,
  155         paddle.bool,
  156     ]:
  157         if paddle.is_complex(x):
  158             shuffled_real = paddle.index_select(x.real(), indices)
  159             shuffled_imag = paddle.index_select(x.imag(), indices)
  160             return paddle.complex(shuffled_real, shuffled_imag)
  161         return paddle.index_select(x.cast("float32"), indices).cast(x.dtype)
  162     return paddle.index_select(x, indices)
  163
  ```
  --- 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/ivy/functional/backends/paddle/random.py b/ivy/functional/backends/paddle/random.py
  --- a/ivy/functional/backends/paddle/random.py
  +++ b/ivy/functional/backends/paddle/random.py
  @@ -8,7 +8,6 @@
   # local
   import ivy
   from paddle.fluid.libpaddle import Place
  -from ivy.utils.exceptions import IvyNotImplementedException
   from ivy.functional.backends.paddle.device import to_device
   from ivy.functional.ivy.random import (
       _check_bounds_and_get_shape,
  @@ -79,6 +78,10 @@
       return paddle.normal(mean, std).cast(dtype)
   
   
  +@with_unsupported_device_and_dtypes(
  +    {"2.4.2 and below": {"cpu": ("float16",)}},
  +    backend_version,
  +)
   def multinomial(
       population_size: int,
       num_samples: int,
  @@ -91,7 +94,13 @@
       seed: Optional[int] = None,
       out: Optional[paddle.Tensor] = None,
   ) -> paddle.Tensor:
  -    raise IvyNotImplementedException()
  +    if probs is None:
  +        probs = paddle.ones((batch_size, num_samples)) / population_size
  +        probs = paddle.cast(probs, paddle.float32)
  +    if seed:
  +        paddle.seed(seed)
  +    x = paddle.multinomial(probs, num_samples=num_samples, replacement=replace)
  +    return x
   
   
   @with_unsupported_device_and_dtypes(
  
verification_info: {"golden_diff": "diff --git a/ivy/functional/backends/paddle/random.py b/ivy/functional/backends/paddle/random.py\n--- a/ivy/functional/backends/paddle/random.py\n+++ b/ivy/functional/backends/paddle/random.py\n@@ -8,7 +8,6 @@\n # local\n import ivy\n from paddle.fluid.libpaddle import Place\n-from ivy.utils.exceptions import IvyNotImplementedException\n from ivy.functional.backends.paddle.device import to_device\n from ivy.functional.ivy.random import (\n     _check_bounds_and_get_shape,\n@@ -79,6 +78,10 @@\n     return paddle.normal(mean, std).cast(dtype)\n \n \n+@with_unsupported_device_and_dtypes(\n+    {\"2.4.2 and below\": {\"cpu\": (\"float16\",)}},\n+    backend_version,\n+)\n def multinomial(\n     population_size: int,\n     num_samples: int,\n@@ -91,7 +94,13 @@\n     seed: Optional[int] = None,\n     out: Optional[paddle.Tensor] = None,\n ) -> paddle.Tensor:\n-    raise IvyNotImplementedException()\n+    if probs is None:\n+        probs = paddle.ones((batch_size, num_samples)) / population_size\n+        probs = paddle.cast(probs, paddle.float32)\n+    if seed:\n+        paddle.seed(seed)\n+    x = paddle.multinomial(probs, num_samples=num_samples, replacement=replace)\n+    return x\n \n \n @with_unsupported_device_and_dtypes(\n", "issue": "multinomial\n\n", "before_files": [{"content": "\"\"\"Collection of Paddle random functions, wrapped to fit Ivy syntax and signature.\"\"\"\n\n# global\nimport paddle\nimport ivy.functional.backends.paddle as paddle_backend\nfrom typing import Optional, Union, Sequence\n\n# local\nimport ivy\nfrom paddle.fluid.libpaddle import Place\nfrom ivy.utils.exceptions import IvyNotImplementedException\nfrom ivy.functional.backends.paddle.device import to_device\nfrom ivy.functional.ivy.random import (\n    _check_bounds_and_get_shape,\n    _randint_check_dtype_and_bound,\n    _check_valid_scale,\n)\nfrom ivy.func_wrapper import with_unsupported_device_and_dtypes\nfrom . import backend_version\n\n# Extra #\n# ------#\n\n\n@with_unsupported_device_and_dtypes(\n    {\"2.5.0 and below\": {\"cpu\": (\"int8\",)}},\n    backend_version,\n)\ndef random_uniform(\n    *,\n    low: Union[float, paddle.Tensor] = 0.0,\n    high: Union[float, paddle.Tensor] = 1.0,\n    shape: Optional[Union[paddle.Tensor, ivy.NativeShape, Sequence[int]]] = None,\n    dtype: paddle.dtype,\n    device: Place,\n    seed=None,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    if not dtype:\n        dtype = ivy.default_int_dtype()\n    dtype = ivy.as_native_dtype(dtype)\n    low = paddle.cast(low, \"float32\") if isinstance(low, paddle.Tensor) else low\n    high = paddle.cast(high, \"float32\") if isinstance(high, paddle.Tensor) else high\n    shape = _check_bounds_and_get_shape(low, high, shape).shape\n    # Set range and seed\n    rng = high - low\n    if seed:\n        _ = paddle.seed(seed)\n    random_base = paddle.uniform(shape, min=0.0, max=1.0)\n\n    return paddle_backend.add(paddle_backend.multiply(random_base, rng), low).cast(\n        dtype\n    )\n\n\n@with_unsupported_device_and_dtypes(\n    {\"2.5.0 and below\": {\"cpu\": (\"complex64\", \"complex128\")}},\n    backend_version,\n)\ndef random_normal(\n    *,\n    mean: Union[float, paddle.Tensor] = 0.0,\n    std: Union[float, paddle.Tensor] = 1.0,\n    shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None,\n    dtype: paddle.dtype,\n    seed: Optional[int] = None,\n    device: Place,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    _check_valid_scale(std)\n    shape = _check_bounds_and_get_shape(mean, std, shape).shape\n    if seed:\n        paddle.seed(seed)\n    if isinstance(mean, (int, float)) and isinstance(std, (int, float)):\n        return paddle.normal(mean, std, shape).cast(dtype)\n    if mean.dtype not in [paddle.float32, paddle.float64]:\n        mean = mean.cast(\"float32\")\n    std = std.cast(mean.dtype)\n    return paddle.normal(mean, std).cast(dtype)\n\n\ndef multinomial(\n    population_size: int,\n    num_samples: int,\n    /,\n    *,\n    batch_size: int = 1,\n    probs: Optional[paddle.Tensor] = None,\n    replace: bool = True,\n    device: Place,\n    seed: Optional[int] = None,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    raise IvyNotImplementedException()\n\n\n@with_unsupported_device_and_dtypes(\n    {\"2.5.0 and below\": {\"cpu\": (\"int8\",)}},\n    backend_version,\n)\ndef randint(\n    low: Union[int, paddle.Tensor],\n    high: Union[int, paddle.Tensor],\n    /,\n    *,\n    shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None,\n    device: Place,\n    dtype: Optional[Union[paddle.dtype, ivy.Dtype]] = None,\n    seed: Optional[int] = None,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    if not dtype:\n        dtype = ivy.default_int_dtype()\n    dtype = ivy.as_native_dtype(dtype)\n    _randint_check_dtype_and_bound(low, high, dtype)\n    low = paddle.cast(low, \"float32\") if isinstance(low, paddle.Tensor) else low\n    high = paddle.cast(high, \"float32\") if isinstance(high, paddle.Tensor) else high\n    shape = _check_bounds_and_get_shape(low, high, shape).shape\n    range = high - low\n    if seed:\n        _ = paddle.seed(seed)\n    _retval = to_device(\n        paddle.cast(\n            paddle.uniform(shape or [1], min=0.0, max=1.0) * range + low, dtype\n        ),\n        device,\n    )\n    return _retval if shape else _retval.squeeze(axis=0)\n\n\ndef seed(*, seed_value: int = 0) -> None:\n    _ = paddle.seed(seed_value)\n    return\n\n\ndef shuffle(\n    x: paddle.Tensor,\n    axis: Optional[int] = 0,\n    /,\n    *,\n    seed: Optional[int] = None,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    if seed:\n        _ = paddle.seed(seed)\n    # Use Paddle's randperm function to generate shuffled indices\n    indices = paddle.randperm(x.shape[0], dtype=\"int64\")\n    if x.dtype in [\n        paddle.int8,\n        paddle.int16,\n        paddle.uint8,\n        paddle.float16,\n        paddle.complex64,\n        paddle.complex128,\n        paddle.bool,\n    ]:\n        if paddle.is_complex(x):\n            shuffled_real = paddle.index_select(x.real(), indices)\n            shuffled_imag = paddle.index_select(x.imag(), indices)\n            return paddle.complex(shuffled_real, shuffled_imag)\n        return paddle.index_select(x.cast(\"float32\"), indices).cast(x.dtype)\n    return paddle.index_select(x, indices)\n", "path": "ivy/functional/backends/paddle/random.py"}], "after_files": [{"content": "\"\"\"Collection of Paddle random functions, wrapped to fit Ivy syntax and signature.\"\"\"\n\n# global\nimport paddle\nimport ivy.functional.backends.paddle as paddle_backend\nfrom typing import Optional, Union, Sequence\n\n# local\nimport ivy\nfrom paddle.fluid.libpaddle import Place\nfrom ivy.functional.backends.paddle.device import to_device\nfrom ivy.functional.ivy.random import (\n    _check_bounds_and_get_shape,\n    _randint_check_dtype_and_bound,\n    _check_valid_scale,\n)\nfrom ivy.func_wrapper import with_unsupported_device_and_dtypes\nfrom . import backend_version\n\n# Extra #\n# ------#\n\n\n@with_unsupported_device_and_dtypes(\n    {\"2.5.0 and below\": {\"cpu\": (\"int8\",)}},\n    backend_version,\n)\ndef random_uniform(\n    *,\n    low: Union[float, paddle.Tensor] = 0.0,\n    high: Union[float, paddle.Tensor] = 1.0,\n    shape: Optional[Union[paddle.Tensor, ivy.NativeShape, Sequence[int]]] = None,\n    dtype: paddle.dtype,\n    device: Place,\n    seed=None,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    if not dtype:\n        dtype = ivy.default_int_dtype()\n    dtype = ivy.as_native_dtype(dtype)\n    low = paddle.cast(low, \"float32\") if isinstance(low, paddle.Tensor) else low\n    high = paddle.cast(high, \"float32\") if isinstance(high, paddle.Tensor) else high\n    shape = _check_bounds_and_get_shape(low, high, shape).shape\n    # Set range and seed\n    rng = high - low\n    if seed:\n        _ = paddle.seed(seed)\n    random_base = paddle.uniform(shape, min=0.0, max=1.0)\n\n    return paddle_backend.add(paddle_backend.multiply(random_base, rng), low).cast(\n        dtype\n    )\n\n\n@with_unsupported_device_and_dtypes(\n    {\"2.5.0 and below\": {\"cpu\": (\"complex64\", \"complex128\")}},\n    backend_version,\n)\ndef random_normal(\n    *,\n    mean: Union[float, paddle.Tensor] = 0.0,\n    std: Union[float, paddle.Tensor] = 1.0,\n    shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None,\n    dtype: paddle.dtype,\n    seed: Optional[int] = None,\n    device: Place,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    _check_valid_scale(std)\n    shape = _check_bounds_and_get_shape(mean, std, shape).shape\n    if seed:\n        paddle.seed(seed)\n    if isinstance(mean, (int, float)) and isinstance(std, (int, float)):\n        return paddle.normal(mean, std, shape).cast(dtype)\n    if mean.dtype not in [paddle.float32, paddle.float64]:\n        mean = mean.cast(\"float32\")\n    std = std.cast(mean.dtype)\n    return paddle.normal(mean, std).cast(dtype)\n\n\n@with_unsupported_device_and_dtypes(\n    {\"2.4.2 and below\": {\"cpu\": (\"float16\",)}},\n    backend_version,\n)\ndef multinomial(\n    population_size: int,\n    num_samples: int,\n    /,\n    *,\n    batch_size: int = 1,\n    probs: Optional[paddle.Tensor] = None,\n    replace: bool = True,\n    device: Place,\n    seed: Optional[int] = None,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    if probs is None:\n        probs = paddle.ones((batch_size, num_samples)) / population_size\n        probs = paddle.cast(probs, paddle.float32)\n    if seed:\n        paddle.seed(seed)\n    x = paddle.multinomial(probs, num_samples=num_samples, replacement=replace)\n    return x\n\n\n@with_unsupported_device_and_dtypes(\n    {\"2.5.0 and below\": {\"cpu\": (\"int8\",)}},\n    backend_version,\n)\ndef randint(\n    low: Union[int, paddle.Tensor],\n    high: Union[int, paddle.Tensor],\n    /,\n    *,\n    shape: Optional[Union[ivy.NativeShape, Sequence[int]]] = None,\n    device: Place,\n    dtype: Optional[Union[paddle.dtype, ivy.Dtype]] = None,\n    seed: Optional[int] = None,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    if not dtype:\n        dtype = ivy.default_int_dtype()\n    dtype = ivy.as_native_dtype(dtype)\n    _randint_check_dtype_and_bound(low, high, dtype)\n    low = paddle.cast(low, \"float32\") if isinstance(low, paddle.Tensor) else low\n    high = paddle.cast(high, \"float32\") if isinstance(high, paddle.Tensor) else high\n    shape = _check_bounds_and_get_shape(low, high, shape).shape\n    range = high - low\n    if seed:\n        _ = paddle.seed(seed)\n    _retval = to_device(\n        paddle.cast(\n            paddle.uniform(shape or [1], min=0.0, max=1.0) * range + low, dtype\n        ),\n        device,\n    )\n    return _retval if shape else _retval.squeeze(axis=0)\n\n\ndef seed(*, seed_value: int = 0) -> None:\n    _ = paddle.seed(seed_value)\n    return\n\n\ndef shuffle(\n    x: paddle.Tensor,\n    axis: Optional[int] = 0,\n    /,\n    *,\n    seed: Optional[int] = None,\n    out: Optional[paddle.Tensor] = None,\n) -> paddle.Tensor:\n    if seed:\n        _ = paddle.seed(seed)\n    # Use Paddle's randperm function to generate shuffled indices\n    indices = paddle.randperm(x.shape[0], dtype=\"int64\")\n    if x.dtype in [\n        paddle.int8,\n        paddle.int16,\n        paddle.uint8,\n        paddle.float16,\n        paddle.complex64,\n        paddle.complex128,\n        paddle.bool,\n    ]:\n        if paddle.is_complex(x):\n            shuffled_real = paddle.index_select(x.real(), indices)\n            shuffled_imag = paddle.index_select(x.imag(), indices)\n            return paddle.complex(shuffled_real, shuffled_imag)\n        return paddle.index_select(x.cast(\"float32\"), indices).cast(x.dtype)\n    return paddle.index_select(x, indices)\n", "path": "ivy/functional/backends/paddle/random.py"}]}