class_docstr: Class providing functionality for computing operations related to interval bounds
class_docstr_tok: ["Class","providing","functionality","for","computing","operations","related","to","interval","bounds"]
docstr: Helper function converts a datapoint it into its interval representation
  
  :param x: input datapoint of shape [batch size, feature_1, feature_2, ...]
  :param bounds: Either a scalar to apply to the whole datapoint, or an array of [2, feature_1, feature_2]
                 where bounds[0] are the lower bounds and bounds[1] are the upper bound
  :param limits: if to clip to a range with limits[0] being the lower bounds and limits[1] being upper bounds.
  :return: Data of the form [batch_size, 2, feature_1, feature_2, ...]
           where [batch_size, 0, x.shape] are the lower bounds and [batch_size, 1, x.shape] are the upper bounds.
docstr_tok: ["Helper","function","converts","a","datapoint","it","into","its","interval","representation",":","param","x",":","input","datapoint","of","shape","[","batch","size",",","feature_1",",","feature_2",",","...","]",":","param","bounds",":","Either","a","scalar","to","apply","to","the","whole","datapoint",",","or","an","array","of","[","2",",","feature_1",",","feature_2","]","where","bounds","[","0","]","are","the","lower","bounds","and","bounds","[","1","]","are","the","upper","bound",":","param","limits",":","if","to","clip","to","a","range","with","limits","[","0","]","being","the","lower","bounds","and","limits","[","1","]","being","upper","bounds",".",":","return",":","Data","of","the","form","[","batch_size",",","2",",","feature_1",",","feature_2",",","...","]","where","[","batch_size",",","0",",","x.shape","]","are","the","lower","bounds","and","[","batch_size",",","1",",","x.shape","]","are","the","upper","bounds","."]
code: def concrete_to_interval(
      x: np.ndarray,
      bounds: Union[float, List[float], np.ndarray],
      limits: Optional[Union[List[float], np.ndarray]] = None,
  ) -> np.ndarray:
      """
      Helper function converts a datapoint it into its interval representation
  
      :param x: input datapoint of shape [batch size, feature_1, feature_2, ...]
      :param bounds: Either a scalar to apply to the whole datapoint, or an array of [2, feature_1, feature_2]
                     where bounds[0] are the lower bounds and bounds[1] are the upper bound
      :param limits: if to clip to a range with limits[0] being the lower bounds and limits[1] being upper bounds.
      :return: Data of the form [batch_size, 2, feature_1, feature_2, ...]
               where [batch_size, 0, x.shape] are the lower bounds and [batch_size, 1, x.shape] are the upper bounds.
      """
  
      x = np.expand_dims(x, axis=1)
  
      if isinstance(bounds, float):
          up_x = x + bounds
          lb_x = x - bounds
      elif isinstance(bounds, (list, np.ndarray)):
          up_x = x + bounds[1]
          lb_x = x - bounds[0]
      else:
          raise ValueError(
              "Bounds must be a float, list, or numpy array."
          )
  
      final_batched_input = np.concatenate((lb_x, up_x), axis=1)
  
      if limits is not None:
          return np.clip(final_batched_input, limits[0], limits[1])
  
      return final_batched_input
  
imports: from typing import List, Union, Tuple, Optional
  import torch
  import numpy
label_desc: Use image node_id 3 for calling the PyTorchIntervalBounds obj's underlying member method code with example usage: obj.concrete_to_interval(x, bounds, limits) and returns: final_batched_input, np