MCPcopy Create free account
hub / github.com/OpenMOSS/MOSS-TTSD / find_max_valid_positions

Function find_max_valid_positions

generation_utils.py:348–357  ·  view source on GitHub ↗
(C: torch.Tensor, invalid_value=1024)

Source from the content-addressed store, hash-verified

346
347
348def find_max_valid_positions(C: torch.Tensor, invalid_value=1024) -> torch.Tensor:
349 values = C[:, :, 1]
350 mask = values != invalid_value
351 reversed_mask = mask.flip(dims=[1])
352 reversed_indices = torch.argmax(reversed_mask.int(), dim=1)
353 seq_len = C.size(1)
354 original_indices = seq_len - 1 - reversed_indices
355 has_valid = mask.any(dim=1)
356 original_indices = torch.where(has_valid, original_indices, -1)
357 return original_indices
358
359
360def normalize_text(text: str) -> str:

Callers 1

process_batchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected