code: def get_bounds_as_ndarray(
      parameters: Dict[str, Tensor],
      bounds: Dict[
          str,
          Tuple[
              Union[float, Tensor, NoneType],
              Union[float, Tensor, NoneType],
          ],
      ],
  ) -> Optional[np.ndarray]:
      r"""Helper method for converting bounds into an ndarray.
  
      Args:
          parameters: A dictionary of parameters.
          bounds: A dictionary of (optional) lower and upper bounds.
  
      Returns:
          An ndarray of bounds.
      """
      inf = float("inf")
      full_size = sum(param.numel() for param in parameters.values())
      out = np.full((full_size, 2), (-inf, inf))
      index = 0
      for name, param in parameters.items():
          size = param.numel()
          if name in bounds:
              lower, upper = bounds[name]
              lower = -inf if lower is None else lower
              upper = inf if upper is None else upper
              if isinstance(lower, Tensor):
                  lower = lower.cpu()
              if isinstance(upper, Tensor):
                  upper = upper.cpu()
              out[index : index + size, 0] = lower
              out[index : index + size, 1] = upper
          index = index + size
      # If all bounds are +/- inf, return None.
      if np.isinf(out).all():
          out = None
      return out
  
file_path: botorch/botorch/optim/utils/numpy_utils.py
imports: from __future__ import annotations
  from itertools import tee
  from typing import Callable, Dict, Iterator, Optional, Tuple, Union
  import numpy
  import torch
  from botorch.utils.types import NoneType
  from numpy import ndarray
  from torch import Tensor
label_desc: Use image node_id 4 for calling a global function with example usage: get_bounds_as_ndarray(parameters, bounds) and returns: out