class_docstr: An `ArraySpec` that specifies minimum and maximum values.
  
  Example usage:
  ```python
  # Specifying the same minimum and maximum for every element.
  spec = BoundedArraySpec((3, 4), np.float64, minimum=0.0, maximum=1.0)
  
  # Specifying a different minimum and maximum for each element.
  spec = BoundedArraySpec(
      (2,), np.float64, minimum=[0.1, 0.2], maximum=[0.9, 0.9])
  
  # Specifying the same minimum and a different maximum for each element.
  spec = BoundedArraySpec(
      (3,), np.float64, minimum=-10.0, maximum=[4.0, 5.0, 3.0])
  ```
  
  Bounds are meant to be inclusive. This is especially important for
  integer types. The following spec will be satisfied by arrays
  with values in the set {0, 1, 2}:
  ```python
  spec = BoundedArraySpec((3, 4), np.int, minimum=0, maximum=2)
  ```
docstr: Initializes a new `BoundedArraySpec`.
  
  Args:
    shape: An iterable specifying the array shape.
    dtype: numpy dtype or string specifying the array dtype.
    minimum: Number or sequence specifying the maximum element bounds
      (inclusive). Must be broadcastable to `shape`.
    maximum: Number or sequence specifying the maximum element bounds
      (inclusive). Must be broadcastable to `shape`.
    name: Optional string containing a semantic name for the corresponding
      array. Defaults to `None`.
  
  Raises:
    ValueError: If `minimum` or `maximum` are not broadcastable to `shape` or
      if the limits are outside of the range of the specified dtype.
    TypeError: If the shape is not an iterable or if the `dtype` is an invalid
      numpy dtype.
docstr_tok: ["Initializes","a","new","`","BoundedArraySpec","`",".","Args",":","shape",":","An","iterable","specifying","the","array","shape",".","dtype",":","numpy","dtype","or","string","specifying","the","array","dtype",".","minimum",":","Number","or","sequence","specifying","the","maximum","element","bounds","(","inclusive",")",".","Must","be","broadcastable","to","`","shape","`",".","maximum",":","Number","or","sequence","specifying","the","maximum","element","bounds","(","inclusive",")",".","Must","be","broadcastable","to","`","shape","`",".","name",":","Optional","string","containing","a","semantic","name","for","the","corresponding","array",".","Defaults","to","`","None","`",".","Raises",":","ValueError",":","If","`","minimum","`","or","`","maximum","`","are","not","broadcastable","to","`","shape","`","or","if","the","limits","are","outside","of","the","range","of","the","specified","dtype",".","TypeError",":","If","the","shape","is","not","an","iterable","or","if","the","`","dtype","`","is","an","invalid","numpy","dtype","."]
code: def __init__(
      self, shape, dtype, minimum=None, maximum=None, name=None
  ):
      """Initializes a new `BoundedArraySpec`.
  
      Args:
        shape: An iterable specifying the array shape.
        dtype: numpy dtype or string specifying the array dtype.
        minimum: Number or sequence specifying the maximum element bounds
          (inclusive). Must be broadcastable to `shape`.
        maximum: Number or sequence specifying the maximum element bounds
          (inclusive). Must be broadcastable to `shape`.
        name: Optional string containing a semantic name for the corresponding
          array. Defaults to `None`.
  
      Raises:
        ValueError: If `minimum` or `maximum` are not broadcastable to `shape` or
          if the limits are outside of the range of the specified dtype.
        TypeError: If the shape is not an iterable or if the `dtype` is an invalid
          numpy dtype.
      """
      super(BoundedArraySpec, self).__init__(shape, dtype, name)
  
      try:
          np.broadcast_to(minimum, shape=shape)
      except ValueError as numpy_exception:
          raise ValueError(
              "minimum is not compatible with shape. Message: {!r}.".format(
                  numpy_exception
              )
          )
  
      try:
          np.broadcast_to(maximum, shape=shape)
      except ValueError as numpy_exception:
          raise ValueError(
              "maximum is not compatible with shape. Message: {!r}.".format(
                  numpy_exception
              )
          )
  
      tf_dtype = tf.as_dtype(self._dtype)
      low = tf_dtype.min
      high = tf_dtype.max
  
      if minimum is None:
          minimum = low
      if maximum is None:
          maximum = high
  
      self._minimum = np.array(minimum)
      self._maximum = np.array(maximum)
  
      if tf_dtype.is_floating:
          # Replacing infinities with extreme finite float values.
          self._minimum[self._minimum == -np.inf] = low
          self._minimum[self._minimum == np.inf] = high
  
          self._maximum[self._maximum == -np.inf] = low
          self._maximum[self._maximum == np.inf] = high
  
      if np.any(self._minimum > self._maximum):
          raise ValueError(
              "Spec bounds min has values greater than max: [{},{}]".format(
                  self._minimum, self._maximum
              )
          )
      if (
          np.any(self._minimum < low)
          or np.any(self._minimum > high)
          or np.any(self._maximum < low)
          or np.any(self._maximum > high)
      ):
          raise ValueError(
              "Spec bounds [{},{}] not within the range [{}, {}] of the given "
              "dtype ({})".format(
                  self._minimum, self._maximum, low, high, self._dtype
              )
          )
  
      self._minimum = self._minimum.astype(self._dtype)
      self._minimum.setflags(write=False)
  
      self._maximum = self._maximum.astype(self._dtype)
      self._maximum.setflags(write=False)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numbers
  import gin
  import numpy
  import tensorflow
label_desc: Use image node_id 1 to create a new BoundedArraySpec object from inherited base classes: ArraySpec with example: obj = BoundedArraySpec(shape, dtype, minimum, maximum, name)