def SEQUENCE_MASK_LENGTHS_FILTER()

in Synthesis_incorporation/value_search/operation_filtering.py [0:0]


def SEQUENCE_MASK_LENGTHS_FILTER(arg_value):
    """The value must contain few ints with a small maximum."""
    # Only int tensors (not SparseTensors), or list of ints, are ok.
    if not (
        arg_value.is_tensor and arg_value.has_int_dtype() or arg_value.elem_type is int
    ):
        return False
    max_value = arg_value.max()
    num_elements = arg_value.num_elements()
    return num_elements > 0 and max_value * num_elements <= limits.MAX_TENSOR_ELEMENTS