Skip to content

chore: add return type hints to utility functions in functionals.py (Phase 2)#389

Open
guozhihao-224 wants to merge 1 commit intoalibaba:mainfrom
guozhihao-224:chore/add-type-hints-functionals-part2
Open

chore: add return type hints to utility functions in functionals.py (Phase 2)#389
guozhihao-224 wants to merge 1 commit intoalibaba:mainfrom
guozhihao-224:chore/add-type-hints-functionals-part2

Conversation

@guozhihao-224
Copy link

Summary

Adds return type annotations to 10 utility functions that had parameter types but were missing return types.

Testing

  • ✅ Syntax check passed

Related

Part of type hints improvement for roll/utils/functionals.py.
Follow-up to #387

Add return type annotations to 10 functions in functionals.py:

  - union_two_dict() -> Dict
  - append_to_dict() -> None
  - compute_clip_fraction() -> float
  - entropy_from_logits() -> torch.Tensor
  - agg_loss() -> torch.Tensor
  - get_eos_mask() -> torch.Tensor
  - get_pad_mask() -> torch.Tensor
  - masked_whiten() -> torch.Tensor
  - response_level_masked_whiten() -> torch.Tensor
  - pad_to_length() -> torch.Tensor

  Other improvements:
  - Add complete parameter types to pad_to_length
  - Translate Chinese comments to English
  - Improve docstrings with Args, Returns, Examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant