espnet2.gan_codec.shared.encoder.seanet_2d.tuple_it
Less than 1 minute
espnet2.gan_codec.shared.encoder.seanet_2d.tuple_it
espnet2.gan_codec.shared.encoder.seanet_2d.tuple_it(x, num=2)
Converts various input types to a tuple of a specified size.
This function handles different types of inputs, converting them to a tuple of a specified number of elements. It supports inputs of type list and int, while leaving other types unchanged.
- Parameters:
- x (Union *[*list , int , Any ]) – The input to be converted into a tuple.
- num (int) – The size of the tuple to return. Default is 2.
- Returns: A tuple containing the first two elements of the list, or a tuple of the specified size filled with the integer value if the input is an integer. If the input is neither a list nor an int, it returns the input unchanged.
- Return type: Union[Tuple, Any]
Examples
>>> tuple_it([1, 2, 3, 4])
(1, 2)
>>> tuple_it(5, num=3)
(5, 5, 5)
>>> tuple_it("string")
'string'
NOTE
If the input is a list with fewer than two elements, the returned tuple will contain only the available elements.