{"record":{"id":"5b8b5b4b5ff153b2","repo":"tensorflow/models","slug":"sample-random-and-sample-around-keyframe-cannot-be","errorCode":null,"errorMessage":"sample_random and sample_around_keyframe cannot be both True.","messagePattern":"sample_random and sample_around_keyframe cannot be both True\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/videoglue/datasets/common/utils.py","lineNumber":1024,"sourceCode":"    sync_random_state: bool = True):\n  \"\"\"Adds functions to process label feature to builders.\n\n  Args:\n    parser_builder: An instance of a builders.BaseParserBuilder.\n    sampler_builder: An instance of a builders.SamplerBuilder.\n    preprocessor_builder: An instance of a builders.PreprocessorBuilder.\n    input_box_dim_name: The input feature name.\n    output_box_dim_name: The output feature name.\n    sample_around_keyframe: Whether to sample the sequence around the keyframe.\n      If True, it requires keyframe id is known.\n    sample_random:  Whether to perform random sampling.\n    num_instances_per_frame: The number of instances per frame.\n    num_frames: The number of frames to sample.\n    temporal_stride: The temopral sampling stride.\n    sync_random_state: Whether to sync the random state.\n  \"\"\"\n  if sample_random and sample_around_keyframe:\n    raise ValueError(\n        'sample_random and sample_around_keyframe cannot be both True.')\n\n  # Parse box dim.\n  parser_builder.parse_feature(\n      feature_name=input_box_dim_name,\n      # Entire signal stored in one Feature.\n      feature_type=tf.io.VarLenFeature(dtype=tf.float32),\n      output_name=output_box_dim_name)\n\n  sampler_builder.add_fn(\n      fn=tf.sparse.to_dense,\n      feature_name=output_box_dim_name,\n      fn_name='{}_sparse_to_dense'.format(output_box_dim_name))\n\n  # Temporal sampler.\n  if sample_random:\n    # Sample random clip.\n    def sample_sequence_fn(x, state=None):","sourceCodeStart":1006,"sourceCodeEnd":1042,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/videoglue/datasets/common/utils.py#L1006-L1042","documentation":"Error \"sample_random and sample_around_keyframe cannot be both True.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/videoglue/datasets/common/utils.py:1024 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}