code: def _broadcast(
      value: Union[SupportsFloat, np.ndarray],
      dtype,
      shape: Tuple[int, ...],
      inf_sign: str,
  ) -> np.ndarray:
      """Handle infinite bounds and broadcast at the same time if needed."""
      if is_float_integer(value):
          value = get_inf(dtype, inf_sign) if np.isinf(value) else value  # type: ignore
          value = np.full(shape, value, dtype=dtype)
      else:
          assert isinstance(value, np.ndarray)
          if np.any(np.isinf(value)):
              # create new array with dtype, but maintain old one to preserve np.inf
              temp = value.astype(dtype)
              temp[np.isinf(value)] = get_inf(dtype, inf_sign)
              value = temp
      return value
  
imports: from typing import Dict, List, Optional, Sequence, SupportsFloat, Tuple, Type, Union
  import numpy
  import gym.error
  from gym import logger
  from gym.spaces.space import Space
label_desc: Use image node_id 5 for calling a global function with example usage: _broadcast(value, dtype, shape, inf_sign) and returns: value