Unverified Commit 8a8ae276 authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Use google style to document properties (#6130)



* Use google style to document properties

* Update src/transformers/configuration_utils.py
Co-authored-by: default avatarLysandre Debut <lysandre@huggingface.co>
Co-authored-by: default avatarLysandre Debut <lysandre@huggingface.co>
parent fc64559c
......@@ -194,12 +194,18 @@ class PretrainedConfig(object):
raise err
@property
def use_return_tuple(self):
def use_return_tuple(self) -> bool:
"""
:obj:`bool`: Whether or not the model should return a tuple.
"""
# If torchscript is set, force return_tuple to avoid jit errors
return self.return_tuple or self.torchscript
@property
def num_labels(self) -> int:
"""
:obj:`int`: The number of labels for classification models.
"""
return len(self.id2label)
@num_labels.setter
......
......@@ -238,10 +238,7 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin):
@property
def dummy_inputs(self) -> Dict[str, tf.Tensor]:
"""
Dummy inputs to build the network.
Returns:
:obj:`Dict[str, tf.Tensor]`: The dummy inputs.
:obj:`Dict[str, tf.Tensor]`: Dummy inputs to build the network.
"""
return {"input_ids": tf.constant(DUMMY_INPUTS)}
......
......@@ -157,10 +157,8 @@ class ModuleUtilsMixin:
@property
def device(self) -> device:
"""
The device on which the module is (assuming that all the module parameters are on the same device).
Returns:
:obj:`torch.device` The device of the module.
:obj:`torch.device`: The device on which the module is (assuming that all the module parameters are on the same
device).
"""
try:
return next(self.parameters()).device
......@@ -178,10 +176,7 @@ class ModuleUtilsMixin:
@property
def dtype(self) -> dtype:
"""
The dtype of the module (assuming that all the module parameters have the same dtype).
Returns:
:obj:`torch.dtype` The dtype of the module.
:obj:`torch.dtype`: The dtype of the module (assuming that all the module parameters have the same dtype).
"""
try:
return next(self.parameters()).dtype
......@@ -350,10 +345,8 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin):
@property
def dummy_inputs(self) -> Dict[str, torch.Tensor]:
""" Dummy inputs to do a forward pass in the network.
Returns:
:obj:`Dict[str, torch.Tensor]`: The dummy inputs.
"""
:obj:`Dict[str, torch.Tensor]`: Dummy inputs to do a forward pass in the network.
"""
return {"input_ids": torch.tensor(DUMMY_INPUTS)}
......@@ -371,7 +364,10 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin):
self.config = config
@property
def base_model(self):
def base_model(self) -> nn.Module:
"""
:obj:`torch.nn.Module`: The main body of the model.
"""
return getattr(self, self.base_model_prefix, self)
def get_input_embeddings(self) -> nn.Module:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment