{"record":{"id":"363fe4e9b84a62f7","repo":"tensorflow/models","slug":"invalid-sample-strategy","errorCode":null,"errorMessage":"Invalid sample strategy.","messagePattern":"Invalid sample strategy\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"official/nlp/data/pretrain_dataloader.py","lineNumber":520,"sourceCode":"        not provided for 'whole_word' and 'word_span' sample strategies.\n    \"\"\"\n    if self._max_predictions_per_seq is None:\n      raise ValueError('`max_predictions_per_seq` must be set.')\n\n    if boundary is None and 'word' in self._sample_strategy:\n      raise ValueError('`boundary` must be provided for {} strategy'.format(\n          self._sample_strategy))\n\n    if self._sample_strategy == 'single_token':\n      return self._single_token_mask(inputs)\n    elif self._sample_strategy == 'token_span':\n      return self._token_span_mask(inputs)\n    elif self._sample_strategy == 'whole_word':\n      return self._whole_word_mask(inputs, boundary)\n    elif self._sample_strategy == 'word_span':\n      return self._word_span_mask(inputs, boundary)\n    else:\n      raise NotImplementedError('Invalid sample strategy.')\n\n  def _get_factorization(self, inputs: tf.Tensor, input_mask: tf.Tensor):\n    \"\"\"Samples a permutation of the factorization order.\n\n    Args:\n      inputs: the input tokens.\n      input_mask: the `bool` Tensor of the same shape as `inputs`. If `True`,\n        then this means select for partial prediction.\n\n    Returns:\n      perm_mask: An `int32` Tensor of shape [seq_length, seq_length] consisting\n        of 0s and 1s. If perm_mask[i][j] == 0, then this means that the i-th\n        token (in original order) cannot attend to the jth attention token.\n      target_mask: An `int32` Tensor of shape [seq_len] consisting of 0s and 1s.\n        If target_mask[i] == 1, then the i-th token needs to be predicted and\n        the mask will be used as input. This token will be included in the loss.\n        If target_mask[i] == 0, then the token (or [SEP], [CLS]) will be used as\n        input. This token will not be included in the loss.","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/data/pretrain_dataloader.py#L502-L538","documentation":"Error \"Invalid sample strategy.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/data/pretrain_dataloader.py:520 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"}