Dataset balancing
Helper functions used to balance a dataset.
Qircuit length balancing
get_tensor_gate_length
def get_tensor_gate_length(
clr_tensor:Tensor, padding_token:int=0
)->Tensor:
Returns the gate count of a tokenized circuit. Make sure you use use the correct padding_token.
add_balance_fn_quantile_qc_length
def add_balance_fn_quantile_qc_length(
indices:Union, x:Union, y:Union, z:VAR_POSITIONAL, padding_token:int=0, balance_quantile:float=0.5,
device:device=device(type='cpu'), quantile_length_weights:Optional=None
)->Tensor:
Balances according to gate length.