Returns a tuple of `vals`. Args: vals: input data to convert to a tuple. wrap_array: if `True`, treat the input numerical array (ndarray/tensor) as one item of the tuple. if `False`, try to convert the array with `tuple(vals)`, default to `False`.
(vals: Any, wrap_array: bool = False)
| 164 | |
| 165 | |
| 166 | def ensure_tuple(vals: Any, wrap_array: bool = False) -> tuple: |
| 167 | """ |
| 168 | Returns a tuple of `vals`. |
| 169 | |
| 170 | Args: |
| 171 | vals: input data to convert to a tuple. |
| 172 | wrap_array: if `True`, treat the input numerical array (ndarray/tensor) as one item of the tuple. |
| 173 | if `False`, try to convert the array with `tuple(vals)`, default to `False`. |
| 174 | |
| 175 | """ |
| 176 | if wrap_array and isinstance(vals, (np.ndarray, torch.Tensor)): |
| 177 | return (vals,) |
| 178 | return tuple(vals) if issequenceiterable(vals) else (vals,) |
| 179 | |
| 180 | |
| 181 | def ensure_tuple_size(vals: Any, dim: int, pad_val: Any = 0, pad_from_start: bool = False) -> tuple: |
searching dependent graphs…