Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
OutboundTransportManager.stop | (self, wait: bool = True) | Stop all running transports. | Stop all running transports. | async def stop(self, wait: bool = True):
"""Stop all running transports."""
if self._process_task and not self._process_task.done():
self._process_task.cancel()
await self.task_queue.complete(None if wait else 0)
for transport in self.running_transports.values():
... | [
"async",
"def",
"stop",
"(",
"self",
",",
"wait",
":",
"bool",
"=",
"True",
")",
":",
"if",
"self",
".",
"_process_task",
"and",
"not",
"self",
".",
"_process_task",
".",
"done",
"(",
")",
":",
"self",
".",
"_process_task",
".",
"cancel",
"(",
")",
... | [
175,
4
] | [
182,
36
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.get_registered_transport_for_scheme | (self, scheme: str) | Find the registered transport ID for a given scheme. | Find the registered transport ID for a given scheme. | def get_registered_transport_for_scheme(self, scheme: str) -> str:
"""Find the registered transport ID for a given scheme."""
try:
return next(
transport_id
for transport_id, transport in self.registered_transports.items()
if scheme in transpor... | [
"def",
"get_registered_transport_for_scheme",
"(",
"self",
",",
"scheme",
":",
"str",
")",
"->",
"str",
":",
"try",
":",
"return",
"next",
"(",
"transport_id",
"for",
"transport_id",
",",
"transport",
"in",
"self",
".",
"registered_transports",
".",
"items",
"... | [
184,
4
] | [
193,
16
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.get_running_transport_for_scheme | (self, scheme: str) | Find the running transport ID for a given scheme. | Find the running transport ID for a given scheme. | def get_running_transport_for_scheme(self, scheme: str) -> str:
"""Find the running transport ID for a given scheme."""
try:
return next(
transport_id
for transport_id, transport in self.running_transports.items()
if scheme in transport.schemes... | [
"def",
"get_running_transport_for_scheme",
"(",
"self",
",",
"scheme",
":",
"str",
")",
"->",
"str",
":",
"try",
":",
"return",
"next",
"(",
"transport_id",
"for",
"transport_id",
",",
"transport",
"in",
"self",
".",
"running_transports",
".",
"items",
"(",
... | [
195,
4
] | [
204,
16
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.get_running_transport_for_endpoint | (self, endpoint: str) | Find the running transport ID to use for a given endpoint. | Find the running transport ID to use for a given endpoint. | def get_running_transport_for_endpoint(self, endpoint: str):
"""Find the running transport ID to use for a given endpoint."""
# Grab the scheme from the uri
scheme = urlparse(endpoint).scheme
if scheme == "":
raise OutboundDeliveryError(
f"The uri '{endpoint}'... | [
"def",
"get_running_transport_for_endpoint",
"(",
"self",
",",
"endpoint",
":",
"str",
")",
":",
"# Grab the scheme from the uri",
"scheme",
"=",
"urlparse",
"(",
"endpoint",
")",
".",
"scheme",
"if",
"scheme",
"==",
"\"\"",
":",
"raise",
"OutboundDeliveryError",
... | [
206,
4
] | [
221,
27
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.get_transport_instance | (self, transport_id: str) | Get an instance of a running transport by ID. | Get an instance of a running transport by ID. | def get_transport_instance(self, transport_id: str) -> BaseOutboundTransport:
"""Get an instance of a running transport by ID."""
return self.running_transports[transport_id] | [
"def",
"get_transport_instance",
"(",
"self",
",",
"transport_id",
":",
"str",
")",
"->",
"BaseOutboundTransport",
":",
"return",
"self",
".",
"running_transports",
"[",
"transport_id",
"]"
] | [
223,
4
] | [
225,
52
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.enqueue_message | (self, context: InjectionContext, outbound: OutboundMessage) |
Add an outbound message to the queue.
Args:
context: The context of the request
outbound: The outbound message to deliver
|
Add an outbound message to the queue. | def enqueue_message(self, context: InjectionContext, outbound: OutboundMessage):
"""
Add an outbound message to the queue.
Args:
context: The context of the request
outbound: The outbound message to deliver
"""
targets = [outbound.target] if outbound.targ... | [
"def",
"enqueue_message",
"(",
"self",
",",
"context",
":",
"InjectionContext",
",",
"outbound",
":",
"OutboundMessage",
")",
":",
"targets",
"=",
"[",
"outbound",
".",
"target",
"]",
"if",
"outbound",
".",
"target",
"else",
"(",
"outbound",
".",
"target_lis... | [
227,
4
] | [
251,
29
] | python | en | ['en', 'error', 'th'] | False |
OutboundTransportManager.enqueue_webhook | (
self, topic: str, payload: dict, endpoint: str, retries: int = None
) |
Add a webhook to the queue.
Args:
topic: The webhook topic
payload: The webhook payload
endpoint: The webhook endpoint
retries: Override the number of retries
Raises:
OutboundDeliveryError: if the associated transport is not running
... |
Add a webhook to the queue. | def enqueue_webhook(
self, topic: str, payload: dict, endpoint: str, retries: int = None
):
"""
Add a webhook to the queue.
Args:
topic: The webhook topic
payload: The webhook payload
endpoint: The webhook endpoint
retries: Override th... | [
"def",
"enqueue_webhook",
"(",
"self",
",",
"topic",
":",
"str",
",",
"payload",
":",
"dict",
",",
"endpoint",
":",
"str",
",",
"retries",
":",
"int",
"=",
"None",
")",
":",
"transport_id",
"=",
"self",
".",
"get_running_transport_for_endpoint",
"(",
"endp... | [
253,
4
] | [
276,
29
] | python | en | ['en', 'error', 'th'] | False |
OutboundTransportManager.process_queued | (self) |
Start the process to deliver queued messages if necessary.
Returns: the current queue processing task or None
|
Start the process to deliver queued messages if necessary. | def process_queued(self) -> asyncio.Task:
"""
Start the process to deliver queued messages if necessary.
Returns: the current queue processing task or None
"""
if self._process_task and not self._process_task.done():
self.outbound_event.set()
elif self.outbo... | [
"def",
"process_queued",
"(",
"self",
")",
"->",
"asyncio",
".",
"Task",
":",
"if",
"self",
".",
"_process_task",
"and",
"not",
"self",
".",
"_process_task",
".",
"done",
"(",
")",
":",
"self",
".",
"outbound_event",
".",
"set",
"(",
")",
"elif",
"self... | [
278,
4
] | [
290,
33
] | python | en | ['en', 'error', 'th'] | False |
OutboundTransportManager._process_done | (self, task: asyncio.Task) | Handle completion of the drain process. | Handle completion of the drain process. | def _process_done(self, task: asyncio.Task):
"""Handle completion of the drain process."""
exc_info = task_exc_info(task)
if exc_info:
LOGGER.exception(
"Exception in outbound queue processing:", exc_info=exc_info
)
if self._process_task and self._... | [
"def",
"_process_done",
"(",
"self",
",",
"task",
":",
"asyncio",
".",
"Task",
")",
":",
"exc_info",
"=",
"task_exc_info",
"(",
"task",
")",
"if",
"exc_info",
":",
"LOGGER",
".",
"exception",
"(",
"\"Exception in outbound queue processing:\"",
",",
"exc_info",
... | [
292,
4
] | [
300,
37
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager._process_loop | (self) | Continually kick off encoding and delivery on outbound messages. | Continually kick off encoding and delivery on outbound messages. | async def _process_loop(self):
"""Continually kick off encoding and delivery on outbound messages."""
# Note: this method should not call async methods apart from
# waiting for the updated event, to avoid yielding to other queue methods
while True:
self.outbound_event.clear(... | [
"async",
"def",
"_process_loop",
"(",
"self",
")",
":",
"# Note: this method should not call async methods apart from",
"# waiting for the updated event, to avoid yielding to other queue methods",
"while",
"True",
":",
"self",
".",
"outbound_event",
".",
"clear",
"(",
")",
"loo... | [
302,
4
] | [
362,
21
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.encode_queued_message | (self, queued: QueuedOutboundMessage) | Kick off encoding of a queued message. | Kick off encoding of a queued message. | def encode_queued_message(self, queued: QueuedOutboundMessage) -> asyncio.Task:
"""Kick off encoding of a queued message."""
queued.task = self.task_queue.run(
self.perform_encode(queued),
lambda completed: self.finished_encode(queued, completed),
)
return queued.... | [
"def",
"encode_queued_message",
"(",
"self",
",",
"queued",
":",
"QueuedOutboundMessage",
")",
"->",
"asyncio",
".",
"Task",
":",
"queued",
".",
"task",
"=",
"self",
".",
"task_queue",
".",
"run",
"(",
"self",
".",
"perform_encode",
"(",
"queued",
")",
","... | [
364,
4
] | [
370,
26
] | python | en | ['en', 'ca', 'en'] | True |
OutboundTransportManager.perform_encode | (self, queued: QueuedOutboundMessage) | Perform message encoding. | Perform message encoding. | async def perform_encode(self, queued: QueuedOutboundMessage):
"""Perform message encoding."""
transport = self.get_transport_instance(queued.transport_id)
wire_format = transport.wire_format or await queued.context.inject(
BaseWireFormat
)
queued.payload = await wire... | [
"async",
"def",
"perform_encode",
"(",
"self",
",",
"queued",
":",
"QueuedOutboundMessage",
")",
":",
"transport",
"=",
"self",
".",
"get_transport_instance",
"(",
"queued",
".",
"transport_id",
")",
"wire_format",
"=",
"transport",
".",
"wire_format",
"or",
"aw... | [
372,
4
] | [
384,
9
] | python | en | ['es', 'en', 'en'] | True |
OutboundTransportManager.finished_encode | (self, queued: QueuedOutboundMessage, completed: CompletedTask) | Handle completion of queued message encoding. | Handle completion of queued message encoding. | def finished_encode(self, queued: QueuedOutboundMessage, completed: CompletedTask):
"""Handle completion of queued message encoding."""
if completed.exc_info:
queued.error = completed.exc_info
queued.state = QueuedOutboundMessage.STATE_DONE
else:
queued.state ... | [
"def",
"finished_encode",
"(",
"self",
",",
"queued",
":",
"QueuedOutboundMessage",
",",
"completed",
":",
"CompletedTask",
")",
":",
"if",
"completed",
".",
"exc_info",
":",
"queued",
".",
"error",
"=",
"completed",
".",
"exc_info",
"queued",
".",
"state",
... | [
386,
4
] | [
394,
29
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.deliver_queued_message | (self, queued: QueuedOutboundMessage) | Kick off delivery of a queued message. | Kick off delivery of a queued message. | def deliver_queued_message(self, queued: QueuedOutboundMessage) -> asyncio.Task:
"""Kick off delivery of a queued message."""
transport = self.get_transport_instance(queued.transport_id)
queued.task = self.task_queue.run(
transport.handle_message(queued.payload, queued.endpoint),
... | [
"def",
"deliver_queued_message",
"(",
"self",
",",
"queued",
":",
"QueuedOutboundMessage",
")",
"->",
"asyncio",
".",
"Task",
":",
"transport",
"=",
"self",
".",
"get_transport_instance",
"(",
"queued",
".",
"transport_id",
")",
"queued",
".",
"task",
"=",
"se... | [
396,
4
] | [
403,
26
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.finished_deliver | (self, queued: QueuedOutboundMessage, completed: CompletedTask) | Handle completion of queued message delivery. | Handle completion of queued message delivery. | def finished_deliver(self, queued: QueuedOutboundMessage, completed: CompletedTask):
"""Handle completion of queued message delivery."""
if completed.exc_info:
queued.error = completed.exc_info
LOGGER.exception(
"Outbound message could not be delivered", exc_info=... | [
"def",
"finished_deliver",
"(",
"self",
",",
"queued",
":",
"QueuedOutboundMessage",
",",
"completed",
":",
"CompletedTask",
")",
":",
"if",
"completed",
".",
"exc_info",
":",
"queued",
".",
"error",
"=",
"completed",
".",
"exc_info",
"LOGGER",
".",
"exception... | [
405,
4
] | [
423,
29
] | python | en | ['en', 'en', 'en'] | True |
OutboundTransportManager.flush | (self) | Wait for any queued messages to be delivered. | Wait for any queued messages to be delivered. | async def flush(self):
"""Wait for any queued messages to be delivered."""
proc_task = self.process_queued()
if proc_task:
await proc_task | [
"async",
"def",
"flush",
"(",
"self",
")",
":",
"proc_task",
"=",
"self",
".",
"process_queued",
"(",
")",
"if",
"proc_task",
":",
"await",
"proc_task"
] | [
425,
4
] | [
429,
27
] | python | en | ['en', 'en', 'en'] | True |
Perform.__init__ | (self, *, name: str = None, params: Mapping[str, str] = None, **kwargs) |
Initialize a Perform object.
Args:
name: The name of the menu option
params: Input parameter values
|
Initialize a Perform object. | def __init__(self, *, name: str = None, params: Mapping[str, str] = None, **kwargs):
"""
Initialize a Perform object.
Args:
name: The name of the menu option
params: Input parameter values
"""
super(Perform, self).__init__(**kwargs)
self.name = na... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"name",
":",
"str",
"=",
"None",
",",
"params",
":",
"Mapping",
"[",
"str",
",",
"str",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Perform",
",",
"self",
")",
".",
"__init_... | [
23,
4
] | [
33,
28
] | python | en | ['en', 'error', 'th'] | False |
L2Norm.__init__ | (self, n_dims, scale=20., eps=1e-10) | L2 normalization layer.
Args:
n_dims (int): Number of dimensions to be normalized
scale (float, optional): Defaults to 20..
eps (float, optional): Used to avoid division by zero.
Defaults to 1e-10.
| L2 normalization layer. | def __init__(self, n_dims, scale=20., eps=1e-10):
"""L2 normalization layer.
Args:
n_dims (int): Number of dimensions to be normalized
scale (float, optional): Defaults to 20..
eps (float, optional): Used to avoid division by zero.
Defaults to 1e-10.
... | [
"def",
"__init__",
"(",
"self",
",",
"n_dims",
",",
"scale",
"=",
"20.",
",",
"eps",
"=",
"1e-10",
")",
":",
"super",
"(",
"L2Norm",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"n_dims",
"=",
"n_dims",
"self",
".",
"weight",
"=",
"n... | [
147,
4
] | [
160,
26
] | python | en | ['es', 'it', 'en'] | False |
L2Norm.forward | (self, x) | Forward function. | Forward function. | def forward(self, x):
"""Forward function."""
# normalization layer convert to FP32 in FP16 training
x_float = x.float()
norm = x_float.pow(2).sum(1, keepdim=True).sqrt() + self.eps
return (self.weight[None, :, None, None].float().expand_as(x_float) *
x_float / no... | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"# normalization layer convert to FP32 in FP16 training",
"x_float",
"=",
"x",
".",
"float",
"(",
")",
"norm",
"=",
"x_float",
".",
"pow",
"(",
"2",
")",
".",
"sum",
"(",
"1",
",",
"keepdim",
"=",
"True"... | [
162,
4
] | [
168,
42
] | python | en | ['en', 'cy', 'en'] | False |
AbstractDistillTransformerAgentMixin._get_teacher_model | (self) |
Return the teacher model.
This logic is needed because the teacher model may be wrapped by
torch.nn.parallel.DistributedDataParallel.
|
Return the teacher model. | def _get_teacher_model(self) -> nn.Module:
"""
Return the teacher model.
This logic is needed because the teacher model may be wrapped by
torch.nn.parallel.DistributedDataParallel.
"""
if hasattr(self.teacher_model, 'module'):
return self.teacher_model.module... | [
"def",
"_get_teacher_model",
"(",
"self",
")",
"->",
"nn",
".",
"Module",
":",
"if",
"hasattr",
"(",
"self",
".",
"teacher_model",
",",
"'module'",
")",
":",
"return",
"self",
".",
"teacher_model",
".",
"module",
"else",
":",
"return",
"self",
".",
"teac... | [
240,
4
] | [
250,
37
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._register_series_of_hooks | (
self, model: nn.Module, module_map: Dict[str, Type[nn.Module]]
) |
Register hooks in modules of the model, given the mapping of module types.
`module_map` is a dict whose keys are module-type names and whose values are
module types. For each module type, during each forward pass of `model`, all
outputs of modules of that type will be saved to `hooks[m... |
Register hooks in modules of the model, given the mapping of module types. | def _register_series_of_hooks(
self, model: nn.Module, module_map: Dict[str, Type[nn.Module]]
) -> Dict[str, OutputRecorder]:
"""
Register hooks in modules of the model, given the mapping of module types.
`module_map` is a dict whose keys are module-type names and whose values are
... | [
"def",
"_register_series_of_hooks",
"(",
"self",
",",
"model",
":",
"nn",
".",
"Module",
",",
"module_map",
":",
"Dict",
"[",
"str",
",",
"Type",
"[",
"nn",
".",
"Module",
"]",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"OutputRecorder",
"]",
":",
"hoo... | [
252,
4
] | [
268,
20
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin.compute_loss | (self, batch, return_output=False) |
Return the loss.
This will likely call self._perform_forward_passes().
|
Return the loss. | def compute_loss(self, batch, return_output=False):
"""
Return the loss.
This will likely call self._perform_forward_passes().
""" | [
"def",
"compute_loss",
"(",
"self",
",",
"batch",
",",
"return_output",
"=",
"False",
")",
":"
] | [
271,
4
] | [
276,
11
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._perform_forward_passes | (self, batch: Batch) |
Perform forward passes through the student and teacher and pass back outputs.
|
Perform forward passes through the student and teacher and pass back outputs.
| def _perform_forward_passes(self, batch: Batch) -> ForwardPassOutputs:
"""
Perform forward passes through the student and teacher and pass back outputs.
"""
assert isinstance(self, TorchGeneratorAgent)
# Code relies on methods
mask = batch.label_vec != self.NULL_IDX
... | [
"def",
"_perform_forward_passes",
"(",
"self",
",",
"batch",
":",
"Batch",
")",
"->",
"ForwardPassOutputs",
":",
"assert",
"isinstance",
"(",
"self",
",",
"TorchGeneratorAgent",
")",
"# Code relies on methods",
"mask",
"=",
"batch",
".",
"label_vec",
"!=",
"self",... | [
278,
4
] | [
366,
9
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._manipulate_mask | (
self, mask: torch.BoolTensor, student_scores: torch.Tensor, batch: Batch
) |
If necessary, perform further manipulations of the mask.
Needed for BART-based student models to add in an extra start token.
|
If necessary, perform further manipulations of the mask. | def _manipulate_mask(
self, mask: torch.BoolTensor, student_scores: torch.Tensor, batch: Batch
) -> torch.BoolTensor:
"""
If necessary, perform further manipulations of the mask.
Needed for BART-based student models to add in an extra start token.
"""
if hasattr(supe... | [
"def",
"_manipulate_mask",
"(",
"self",
",",
"mask",
":",
"torch",
".",
"BoolTensor",
",",
"student_scores",
":",
"torch",
".",
"Tensor",
",",
"batch",
":",
"Batch",
")",
"->",
"torch",
".",
"BoolTensor",
":",
"if",
"hasattr",
"(",
"super",
"(",
")",
"... | [
368,
4
] | [
382,
23
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._extract_embedding_outputs | (
self, hooks: Dict[str, Dict[str, OutputRecorder]]
) |
Extract out the encoder and decoder embedding outputs.
|
Extract out the encoder and decoder embedding outputs.
| def _extract_embedding_outputs(
self, hooks: Dict[str, Dict[str, OutputRecorder]]
) -> Dict[str, torch.Tensor]:
"""
Extract out the encoder and decoder embedding outputs.
"""
assert len(hooks['embeddings'].outputs) == 2
return {
'encoder': hooks['embedding... | [
"def",
"_extract_embedding_outputs",
"(",
"self",
",",
"hooks",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"OutputRecorder",
"]",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
":",
"assert",
"len",
"(",
"hooks",
"[... | [
384,
4
] | [
394,
9
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._extract_hidden_states | (
self,
hooks: Dict[str, Dict[str, OutputRecorder]],
num_enc_layers: int,
num_dec_layers: int,
) |
Extract out encoder/decoder hidden states per layer.
|
Extract out encoder/decoder hidden states per layer.
| def _extract_hidden_states(
self,
hooks: Dict[str, Dict[str, OutputRecorder]],
num_enc_layers: int,
num_dec_layers: int,
) -> Dict[str, List[torch.Tensor]]:
"""
Extract out encoder/decoder hidden states per layer.
"""
assert len(hooks['encoder']['layer... | [
"def",
"_extract_hidden_states",
"(",
"self",
",",
"hooks",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"OutputRecorder",
"]",
"]",
",",
"num_enc_layers",
":",
"int",
",",
"num_dec_layers",
":",
"int",
",",
")",
"->",
"Dict",
"[",
"str",
","... | [
396,
4
] | [
410,
9
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._extract_attention_matrices | (
self,
hooks: Dict[str, Dict[str, OutputRecorder]],
num_enc_layers: int,
num_dec_layers: int,
) |
Extract out encoder/decoder attention matrices per layer and attention type.
|
Extract out encoder/decoder attention matrices per layer and attention type.
| def _extract_attention_matrices(
self,
hooks: Dict[str, Dict[str, OutputRecorder]],
num_enc_layers: int,
num_dec_layers: int,
) -> Dict[str, List[Dict[str, torch.Tensor]]]:
"""
Extract out encoder/decoder attention matrices per layer and attention type.
"""
... | [
"def",
"_extract_attention_matrices",
"(",
"self",
",",
"hooks",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"OutputRecorder",
"]",
"]",
",",
"num_enc_layers",
":",
"int",
",",
"num_dec_layers",
":",
"int",
",",
")",
"->",
"Dict",
"[",
"str",
... | [
412,
4
] | [
444,
9
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._clear_hook_outputs | (self, hooks: Union[Dict[str, Any], OutputRecorder]) |
Recursively clear outputs from all hooks.
|
Recursively clear outputs from all hooks.
| def _clear_hook_outputs(self, hooks: Union[Dict[str, Any], OutputRecorder]):
"""
Recursively clear outputs from all hooks.
"""
if isinstance(hooks, dict):
for subhooks in hooks.values():
self._clear_hook_outputs(subhooks)
else:
# `hooks` is... | [
"def",
"_clear_hook_outputs",
"(",
"self",
",",
"hooks",
":",
"Union",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"OutputRecorder",
"]",
")",
":",
"if",
"isinstance",
"(",
"hooks",
",",
"dict",
")",
":",
"for",
"subhooks",
"in",
"hooks",
".",
"va... | [
446,
4
] | [
455,
25
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._get_encoder_loss | (self, fwd_pass: ForwardPassOutputs) |
Return the loss on the encoder's output layer.
|
Return the loss on the encoder's output layer.
| def _get_encoder_loss(self, fwd_pass: ForwardPassOutputs) -> torch.Tensor:
"""
Return the loss on the encoder's output layer.
"""
assert isinstance(self, TorchGeneratorAgent)
# Code relies on methods
encoder_loss = F.mse_loss(
input=fwd_pass.student_enc_output... | [
"def",
"_get_encoder_loss",
"(",
"self",
",",
"fwd_pass",
":",
"ForwardPassOutputs",
")",
"->",
"torch",
".",
"Tensor",
":",
"assert",
"isinstance",
"(",
"self",
",",
"TorchGeneratorAgent",
")",
"# Code relies on methods",
"encoder_loss",
"=",
"F",
".",
"mse_loss"... | [
457,
4
] | [
478,
27
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._get_embedding_losses | (
self, fwd_pass: ForwardPassOutputs
) |
Return the encoder and decoder embedding losses.
|
Return the encoder and decoder embedding losses.
| def _get_embedding_losses(
self, fwd_pass: ForwardPassOutputs
) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Return the encoder and decoder embedding losses.
"""
assert isinstance(self, TorchGeneratorAgent)
# Code relies on methods
enc_emb_loss, enc_emb_loss_per_... | [
"def",
"_get_embedding_losses",
"(",
"self",
",",
"fwd_pass",
":",
"ForwardPassOutputs",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
":",
"assert",
"isinstance",
"(",
"self",
",",
"TorchGeneratorAgent",
")",
"# Code relie... | [
480,
4
] | [
510,
41
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._get_component_embedding_loss | (
self,
student_emb_output: torch.Tensor,
teacher_emb_output: torch.Tensor,
mask: torch.BoolTensor,
num_tokens: torch.Tensor,
) |
Compute the embedding loss for either the encoder or the decoder.
|
Compute the embedding loss for either the encoder or the decoder.
| def _get_component_embedding_loss(
self,
student_emb_output: torch.Tensor,
teacher_emb_output: torch.Tensor,
mask: torch.BoolTensor,
num_tokens: torch.Tensor,
) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Compute the embedding loss for either the encoder or the ... | [
"def",
"_get_component_embedding_loss",
"(",
"self",
",",
"student_emb_output",
":",
"torch",
".",
"Tensor",
",",
"teacher_emb_output",
":",
"torch",
".",
"Tensor",
",",
"mask",
":",
"torch",
".",
"BoolTensor",
",",
"num_tokens",
":",
"torch",
".",
"Tensor",
"... | [
512,
4
] | [
534,
57
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._get_hidden_losses | (
self, fwd_pass: ForwardPassOutputs
) |
Return the encoder and decoder hidden losses.
|
Return the encoder and decoder hidden losses.
| def _get_hidden_losses(
self, fwd_pass: ForwardPassOutputs
) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Return the encoder and decoder hidden losses.
"""
assert isinstance(self, TorchGeneratorAgent)
# Code relies on methods
enc_hidden_loss, enc_hidden_loss_per_... | [
"def",
"_get_hidden_losses",
"(",
"self",
",",
"fwd_pass",
":",
"ForwardPassOutputs",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
":",
"assert",
"isinstance",
"(",
"self",
",",
"TorchGeneratorAgent",
")",
"# Code relies o... | [
536,
4
] | [
570,
47
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._get_component_hidden_loss | (
self,
student_hidden_states: List[torch.Tensor],
teacher_hidden_states: List[torch.Tensor],
mask: torch.BoolTensor,
num_tokens: torch.Tensor,
mapped_layers: List[int],
) |
Compute the loss across all hidden layers for either the encoder or the decoder.
(The loss is averaged across all hidden layers and over the embedding dimension
so that it doesn't get too high for fp16 tensors.)
|
Compute the loss across all hidden layers for either the encoder or the decoder. | def _get_component_hidden_loss(
self,
student_hidden_states: List[torch.Tensor],
teacher_hidden_states: List[torch.Tensor],
mask: torch.BoolTensor,
num_tokens: torch.Tensor,
mapped_layers: List[int],
) -> Tuple[torch.Tensor, torch.Tensor]:
"""
Compute ... | [
"def",
"_get_component_hidden_loss",
"(",
"self",
",",
"student_hidden_states",
":",
"List",
"[",
"torch",
".",
"Tensor",
"]",
",",
"teacher_hidden_states",
":",
"List",
"[",
"torch",
".",
"Tensor",
"]",
",",
"mask",
":",
"torch",
".",
"BoolTensor",
",",
"nu... | [
572,
4
] | [
608,
51
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._get_attention_losses | (
self, fwd_pass: ForwardPassOutputs
) |
Return attention losses.
Compute and return losses on encoder and decoder self-attention and decoder
enc/dec attention.
|
Return attention losses. | def _get_attention_losses(
self, fwd_pass: ForwardPassOutputs
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
"""
Return attention losses.
Compute and return losses on encoder and decoder self-attention and decoder
enc/dec attention.
"""
enc_self_attn_l... | [
"def",
"_get_attention_losses",
"(",
"self",
",",
"fwd_pass",
":",
"ForwardPassOutputs",
")",
"->",
"Tuple",
"[",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
",",
"torch",
".",
"Tensor",
"]",
":",
"enc_self_attn_loss",
"=",
"self",
".",
"_get_and_re... | [
610,
4
] | [
649,
72
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._get_and_record_component_attention_loss | (
self,
teacher_attention_matrices: List[Dict[str, torch.Tensor]],
student_attention_matrices: List[Dict[str, torch.Tensor]],
mask: torch.BoolTensor,
tokens_per_example: torch.Tensor,
num_tokens: torch.Tensor,
mapped_layers: List[int],
attn_type: str,
... |
Calculate the given attention loss and register it as the given metric name.
|
Calculate the given attention loss and register it as the given metric name.
| def _get_and_record_component_attention_loss(
self,
teacher_attention_matrices: List[Dict[str, torch.Tensor]],
student_attention_matrices: List[Dict[str, torch.Tensor]],
mask: torch.BoolTensor,
tokens_per_example: torch.Tensor,
num_tokens: torch.Tensor,
mapped_lay... | [
"def",
"_get_and_record_component_attention_loss",
"(",
"self",
",",
"teacher_attention_matrices",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
"]",
",",
"student_attention_matrices",
":",
"List",
"[",
"Dict",
"[",
"str",
",",
"torch",... | [
651,
4
] | [
712,
24
] | python | en | ['en', 'error', 'th'] | False |
AbstractDistillTransformerAgentMixin._get_prediction_loss | (self, fwd_pass: ForwardPassOutputs) |
Calculate and return the KL loss on the teacher's prediction layer.
Also record prediction-loss metrics.
|
Calculate and return the KL loss on the teacher's prediction layer. | def _get_prediction_loss(self, fwd_pass: ForwardPassOutputs) -> torch.Tensor:
"""
Calculate and return the KL loss on the teacher's prediction layer.
Also record prediction-loss metrics.
"""
assert isinstance(self, TorchGeneratorAgent)
# Code relies on methods
pr... | [
"def",
"_get_prediction_loss",
"(",
"self",
",",
"fwd_pass",
":",
"ForwardPassOutputs",
")",
"->",
"torch",
".",
"Tensor",
":",
"assert",
"isinstance",
"(",
"self",
",",
"TorchGeneratorAgent",
")",
"# Code relies on methods",
"pred_loss",
"=",
"F",
".",
"kl_div",
... | [
714,
4
] | [
737,
24
] | python | en | ['en', 'error', 'th'] | False |
DistillNarrowTransformerAgentMixin._get_projection_layer | (self, student_model) |
Return a projection layer from the student hidden dim to the teacher hidden dim.
|
Return a projection layer from the student hidden dim to the teacher hidden dim.
| def _get_projection_layer(self, student_model):
"""
Return a projection layer from the student hidden dim to the teacher hidden dim.
"""
teacher_model = self._get_teacher_model()
student_hidden_dim = student_model.encoder.dim
teacher_hidden_dim = teacher_model.encoder.d... | [
"def",
"_get_projection_layer",
"(",
"self",
",",
"student_model",
")",
":",
"teacher_model",
"=",
"self",
".",
"_get_teacher_model",
"(",
")",
"student_hidden_dim",
"=",
"student_model",
".",
"encoder",
".",
"dim",
"teacher_hidden_dim",
"=",
"teacher_model",
".",
... | [
891,
4
] | [
912,
20
] | python | en | ['en', 'error', 'th'] | False |
DistillTransformerAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
DistillTransformerAgentMixin.add_cmdline_args(parser, partial_opt=partial_opt)
TransformerGeneratorAge... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"DistillTransformerAgentMixin",
".",
"add_cmdline_args",
"(",
"parser",
",",
"partial_op... | [
983,
4
] | [
991,
21
] | python | en | ['en', 'error', 'th'] | False |
DistillNarrowTransformerAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
DistillNarrowTransformerAgentMixin.add_cmdline_args(
parser, partial_opt=partial_opt
)
... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"DistillNarrowTransformerAgentMixin",
".",
"add_cmdline_args",
"(",
"parser",
",",
"part... | [
998,
4
] | [
1008,
21
] | python | en | ['en', 'error', 'th'] | False |
BartLikeAgent._manipulate_mask | (
self, mask: torch.BoolTensor, student_scores: torch.Tensor, batch: Batch
) |
Add one extra (masked-out) token to the mask, for compatibility with BART.
|
Add one extra (masked-out) token to the mask, for compatibility with BART.
| def _manipulate_mask(
self, mask: torch.BoolTensor, student_scores: torch.Tensor, batch: Batch
) -> torch.BoolTensor:
"""
Add one extra (masked-out) token to the mask, for compatibility with BART.
"""
assert student_scores.size(1) == batch.label_vec.size(1) + 1
mask =... | [
"def",
"_manipulate_mask",
"(",
"self",
",",
"mask",
":",
"torch",
".",
"BoolTensor",
",",
"student_scores",
":",
"torch",
".",
"Tensor",
",",
"batch",
":",
"Batch",
")",
"->",
"torch",
".",
"BoolTensor",
":",
"assert",
"student_scores",
".",
"size",
"(",
... | [
1020,
4
] | [
1028,
19
] | python | en | ['en', 'error', 'th'] | False |
DistillBartAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
DistillTransformerAgentMixin.add_cmdline_args(parser, partial_opt=partial_opt)
BartLikeAgent.add_cmdli... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"DistillTransformerAgentMixin",
".",
"add_cmdline_args",
"(",
"parser",
",",
"partial_op... | [
1033,
4
] | [
1041,
21
] | python | en | ['en', 'error', 'th'] | False |
DistillNarrowBartAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
DistillNarrowTransformerAgentMixin.add_cmdline_args(
parser, partial_opt=partial_opt
)
... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"DistillNarrowTransformerAgentMixin",
".",
"add_cmdline_args",
"(",
"parser",
",",
"part... | [
1046,
4
] | [
1056,
21
] | python | en | ['en', 'error', 'th'] | False |
verify_or_create_SSL_key_and_cert | (keyfile, certfile) |
Verify or create new key/certificate files.
Args:
keyfile (str): Path to ssl.key file.
certfile (str): Parth to ssl.cert file.
Notes:
If files don't already exist, they are created.
|
Verify or create new key/certificate files. | def verify_or_create_SSL_key_and_cert(keyfile, certfile):
"""
Verify or create new key/certificate files.
Args:
keyfile (str): Path to ssl.key file.
certfile (str): Parth to ssl.cert file.
Notes:
If files don't already exist, they are created.
"""
if not (os.path.exis... | [
"def",
"verify_or_create_SSL_key_and_cert",
"(",
"keyfile",
",",
"certfile",
")",
":",
"if",
"not",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"keyfile",
")",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"certfile",
")",
")",
":",
"# key/cert does not ex... | [
72,
0
] | [
128,
15
] | python | en | ['en', 'error', 'th'] | False |
getSSLContext | () |
This is called by the portal when creating the SSL context
server-side.
Returns:
ssl_context (tuple): A key and certificate that is either
existing previously or created on the fly.
|
This is called by the portal when creating the SSL context
server-side. | def getSSLContext():
"""
This is called by the portal when creating the SSL context
server-side.
Returns:
ssl_context (tuple): A key and certificate that is either
existing previously or created on the fly.
"""
if verify_or_create_SSL_key_and_cert(_PRIVATE_KEY_FILE, _CERTI... | [
"def",
"getSSLContext",
"(",
")",
":",
"if",
"verify_or_create_SSL_key_and_cert",
"(",
"_PRIVATE_KEY_FILE",
",",
"_CERTIFICATE_FILE",
")",
":",
"return",
"twisted_ssl",
".",
"DefaultOpenSSLContextFactory",
"(",
"_PRIVATE_KEY_FILE",
",",
"_CERTIFICATE_FILE",
")",
"else",
... | [
131,
0
] | [
145,
19
] | python | en | ['en', 'error', 'th'] | False |
iso_to_plotly_time_string | (iso_string) | Remove timezone info and replace 'T' delimeter with ' ' (ws). | Remove timezone info and replace 'T' delimeter with ' ' (ws). | def iso_to_plotly_time_string(iso_string):
"""Remove timezone info and replace 'T' delimeter with ' ' (ws)."""
# make sure we don't send timezone info to plotly
if (iso_string.split("-")[:3] == "00:00") or (iso_string.split("+")[0] == "00:00"):
raise Exception(
"Plotly won't accept times... | [
"def",
"iso_to_plotly_time_string",
"(",
"iso_string",
")",
":",
"# make sure we don't send timezone info to plotly",
"if",
"(",
"iso_string",
".",
"split",
"(",
"\"-\"",
")",
"[",
":",
"3",
"]",
"==",
"\"00:00\"",
")",
"or",
"(",
"iso_string",
".",
"split",
"("... | [
210,
0
] | [
224,
43
] | python | en | ['en', 'en', 'en'] | True |
PlotlyJSONEncoder.coerce_to_strict | (self, const) |
This is used to ultimately *encode* into strict JSON, see `encode`
|
This is used to ultimately *encode* into strict JSON, see `encode` | def coerce_to_strict(self, const):
"""
This is used to ultimately *encode* into strict JSON, see `encode`
"""
# before python 2.7, 'true', 'false', 'null', were include here.
if const in ("Infinity", "-Infinity", "NaN"):
return None
else:
return c... | [
"def",
"coerce_to_strict",
"(",
"self",
",",
"const",
")",
":",
"# before python 2.7, 'true', 'false', 'null', were include here.",
"if",
"const",
"in",
"(",
"\"Infinity\"",
",",
"\"-Infinity\"",
",",
"\"NaN\"",
")",
":",
"return",
"None",
"else",
":",
"return",
"co... | [
24,
4
] | [
33,
24
] | python | en | ['en', 'error', 'th'] | False |
PlotlyJSONEncoder.encode | (self, o) |
Load and then dump the result using parse_constant kwarg
Note that setting invalid separators will cause a failure at this step.
|
Load and then dump the result using parse_constant kwarg | def encode(self, o):
"""
Load and then dump the result using parse_constant kwarg
Note that setting invalid separators will cause a failure at this step.
"""
# this will raise errors in a normal-expected way
encoded_o = super(PlotlyJSONEncoder, self).encode(o)
... | [
"def",
"encode",
"(",
"self",
",",
"o",
")",
":",
"# this will raise errors in a normal-expected way",
"encoded_o",
"=",
"super",
"(",
"PlotlyJSONEncoder",
",",
"self",
")",
".",
"encode",
"(",
"o",
")",
"# now:",
"# 1. `loads` to switch Infinity, -Infinity, NaN to N... | [
35,
4
] | [
64,
13
] | python | en | ['en', 'error', 'th'] | False |
PlotlyJSONEncoder.default | (self, obj) |
Accept an object (of unknown type) and try to encode with priority:
1. builtin: user-defined objects
2. sage: sage math cloud
3. pandas: dataframes/series
4. numpy: ndarrays
5. datetime: time/datetime objects
Each method throws a NotEnco... |
Accept an object (of unknown type) and try to encode with priority:
1. builtin: user-defined objects
2. sage: sage math cloud
3. pandas: dataframes/series
4. numpy: ndarrays
5. datetime: time/datetime objects | def default(self, obj):
"""
Accept an object (of unknown type) and try to encode with priority:
1. builtin: user-defined objects
2. sage: sage math cloud
3. pandas: dataframes/series
4. numpy: ndarrays
5. datetime: time/datetime objects
... | [
"def",
"default",
"(",
"self",
",",
"obj",
")",
":",
"# TODO: The ordering if these methods is *very* important. Is this OK?",
"encoding_methods",
"=",
"(",
"self",
".",
"encode_as_plotly",
",",
"self",
".",
"encode_as_sage",
",",
"self",
".",
"encode_as_numpy",
",",
... | [
66,
4
] | [
114,
51
] | python | en | ['en', 'error', 'th'] | False |
PlotlyJSONEncoder.encode_as_plotly | (obj) | Attempt to use a builtin `to_plotly_json` method. | Attempt to use a builtin `to_plotly_json` method. | def encode_as_plotly(obj):
"""Attempt to use a builtin `to_plotly_json` method."""
try:
return obj.to_plotly_json()
except AttributeError:
raise NotEncodable | [
"def",
"encode_as_plotly",
"(",
"obj",
")",
":",
"try",
":",
"return",
"obj",
".",
"to_plotly_json",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"NotEncodable"
] | [
117,
4
] | [
122,
30
] | python | en | ['en', 'en', 'en'] | True |
PlotlyJSONEncoder.encode_as_list | (obj) | Attempt to use `tolist` method to convert to normal Python list. | Attempt to use `tolist` method to convert to normal Python list. | def encode_as_list(obj):
"""Attempt to use `tolist` method to convert to normal Python list."""
if hasattr(obj, "tolist"):
return obj.tolist()
else:
raise NotEncodable | [
"def",
"encode_as_list",
"(",
"obj",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"\"tolist\"",
")",
":",
"return",
"obj",
".",
"tolist",
"(",
")",
"else",
":",
"raise",
"NotEncodable"
] | [
125,
4
] | [
130,
30
] | python | en | ['en', 'en', 'en'] | True |
PlotlyJSONEncoder.encode_as_sage | (obj) | Attempt to convert sage.all.RR to floats and sage.all.ZZ to ints | Attempt to convert sage.all.RR to floats and sage.all.ZZ to ints | def encode_as_sage(obj):
"""Attempt to convert sage.all.RR to floats and sage.all.ZZ to ints"""
sage_all = get_module("sage.all")
if not sage_all:
raise NotEncodable
if obj in sage_all.RR:
return float(obj)
elif obj in sage_all.ZZ:
return int(... | [
"def",
"encode_as_sage",
"(",
"obj",
")",
":",
"sage_all",
"=",
"get_module",
"(",
"\"sage.all\"",
")",
"if",
"not",
"sage_all",
":",
"raise",
"NotEncodable",
"if",
"obj",
"in",
"sage_all",
".",
"RR",
":",
"return",
"float",
"(",
"obj",
")",
"elif",
"obj... | [
133,
4
] | [
144,
30
] | python | en | ['en', 'en', 'en'] | True |
PlotlyJSONEncoder.encode_as_pandas | (obj) | Attempt to convert pandas.NaT | Attempt to convert pandas.NaT | def encode_as_pandas(obj):
"""Attempt to convert pandas.NaT"""
pandas = get_module("pandas", should_load=False)
if not pandas:
raise NotEncodable
if obj is pandas.NaT:
return None
else:
raise NotEncodable | [
"def",
"encode_as_pandas",
"(",
"obj",
")",
":",
"pandas",
"=",
"get_module",
"(",
"\"pandas\"",
",",
"should_load",
"=",
"False",
")",
"if",
"not",
"pandas",
":",
"raise",
"NotEncodable",
"if",
"obj",
"is",
"pandas",
".",
"NaT",
":",
"return",
"None",
"... | [
147,
4
] | [
156,
30
] | python | en | ['en', 'lb', 'en'] | True |
PlotlyJSONEncoder.encode_as_numpy | (obj) | Attempt to convert numpy.ma.core.masked | Attempt to convert numpy.ma.core.masked | def encode_as_numpy(obj):
"""Attempt to convert numpy.ma.core.masked"""
numpy = get_module("numpy", should_load=False)
if not numpy:
raise NotEncodable
if obj is numpy.ma.core.masked:
return float("nan")
else:
raise NotEncodable | [
"def",
"encode_as_numpy",
"(",
"obj",
")",
":",
"numpy",
"=",
"get_module",
"(",
"\"numpy\"",
",",
"should_load",
"=",
"False",
")",
"if",
"not",
"numpy",
":",
"raise",
"NotEncodable",
"if",
"obj",
"is",
"numpy",
".",
"ma",
".",
"core",
".",
"masked",
... | [
159,
4
] | [
168,
30
] | python | en | ['en', 'en', 'en'] | True |
PlotlyJSONEncoder.encode_as_datetime | (obj) | Convert datetime objects to iso-format strings | Convert datetime objects to iso-format strings | def encode_as_datetime(obj):
"""Convert datetime objects to iso-format strings"""
try:
return obj.isoformat()
except AttributeError:
raise NotEncodable | [
"def",
"encode_as_datetime",
"(",
"obj",
")",
":",
"try",
":",
"return",
"obj",
".",
"isoformat",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"NotEncodable"
] | [
171,
4
] | [
176,
30
] | python | en | ['en', 'en', 'en'] | True |
PlotlyJSONEncoder.encode_as_date | (obj) | Attempt to convert to utc-iso time string using date methods. | Attempt to convert to utc-iso time string using date methods. | def encode_as_date(obj):
"""Attempt to convert to utc-iso time string using date methods."""
try:
time_string = obj.isoformat()
except AttributeError:
raise NotEncodable
else:
return iso_to_plotly_time_string(time_string) | [
"def",
"encode_as_date",
"(",
"obj",
")",
":",
"try",
":",
"time_string",
"=",
"obj",
".",
"isoformat",
"(",
")",
"except",
"AttributeError",
":",
"raise",
"NotEncodable",
"else",
":",
"return",
"iso_to_plotly_time_string",
"(",
"time_string",
")"
] | [
179,
4
] | [
186,
57
] | python | en | ['en', 'en', 'en'] | True |
PlotlyJSONEncoder.encode_as_decimal | (obj) | Attempt to encode decimal by converting it to float | Attempt to encode decimal by converting it to float | def encode_as_decimal(obj):
"""Attempt to encode decimal by converting it to float"""
if isinstance(obj, decimal.Decimal):
return float(obj)
else:
raise NotEncodable | [
"def",
"encode_as_decimal",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"decimal",
".",
"Decimal",
")",
":",
"return",
"float",
"(",
"obj",
")",
"else",
":",
"raise",
"NotEncodable"
] | [
189,
4
] | [
194,
30
] | python | en | ['en', 'en', 'en'] | True |
PlotlyJSONEncoder.encode_as_pil | (obj) | Attempt to convert PIL.Image.Image to base64 data uri | Attempt to convert PIL.Image.Image to base64 data uri | def encode_as_pil(obj):
"""Attempt to convert PIL.Image.Image to base64 data uri"""
image = get_module("PIL.Image")
if image is not None and isinstance(obj, image.Image):
return ImageUriValidator.pil_image_to_uri(obj)
else:
raise NotEncodable | [
"def",
"encode_as_pil",
"(",
"obj",
")",
":",
"image",
"=",
"get_module",
"(",
"\"PIL.Image\"",
")",
"if",
"image",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"obj",
",",
"image",
".",
"Image",
")",
":",
"return",
"ImageUriValidator",
".",
"pil_image_t... | [
197,
4
] | [
203,
30
] | python | en | ['en', 'en', 'en'] | True |
_get_config_directory | () | Find the predefined detector config directory. | Find the predefined detector config directory. | def _get_config_directory():
"""Find the predefined detector config directory."""
try:
# Assume we are running in the source mmdetection3d repo
repo_dpath = dirname(dirname(dirname(dirname(__file__))))
except NameError:
# For IPython development when this __file__ is not defined
... | [
"def",
"_get_config_directory",
"(",
")",
":",
"try",
":",
"# Assume we are running in the source mmdetection3d repo",
"repo_dpath",
"=",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"__file__",
")",
")",
")",
")",
"except",
"NameError",
":",
"#... | [
21,
0
] | [
33,
23
] | python | en | ['en', 'en', 'en'] | True |
_get_config_module | (fname) | Load a configuration as a python module. | Load a configuration as a python module. | def _get_config_module(fname):
"""Load a configuration as a python module."""
from mmcv import Config
config_dpath = _get_config_directory()
config_fpath = join(config_dpath, fname)
config_mod = Config.fromfile(config_fpath)
return config_mod | [
"def",
"_get_config_module",
"(",
"fname",
")",
":",
"from",
"mmcv",
"import",
"Config",
"config_dpath",
"=",
"_get_config_directory",
"(",
")",
"config_fpath",
"=",
"join",
"(",
"config_dpath",
",",
"fname",
")",
"config_mod",
"=",
"Config",
".",
"fromfile",
... | [
36,
0
] | [
42,
21
] | python | en | ['en', 'fr', 'en'] | True |
_get_head_cfg | (fname) | Grab configs necessary to create a bbox_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
| Grab configs necessary to create a bbox_head. | def _get_head_cfg(fname):
"""Grab configs necessary to create a bbox_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
"""
import mmcv
config = _get_config_module(fname)
model = copy.deepcopy(config.model)
train_cfg = mmcv.Config(c... | [
"def",
"_get_head_cfg",
"(",
"fname",
")",
":",
"import",
"mmcv",
"config",
"=",
"_get_config_module",
"(",
"fname",
")",
"model",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
".",
"model",
")",
"train_cfg",
"=",
"mmcv",
".",
"Config",
"(",
"copy",
".",
... | [
45,
0
] | [
60,
20
] | python | en | ['en', 'en', 'en'] | True |
_get_rpn_head_cfg | (fname) | Grab configs necessary to create a rpn_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
| Grab configs necessary to create a rpn_head. | def _get_rpn_head_cfg(fname):
"""Grab configs necessary to create a rpn_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
"""
import mmcv
config = _get_config_module(fname)
model = copy.deepcopy(config.model)
train_cfg = mmcv.Confi... | [
"def",
"_get_rpn_head_cfg",
"(",
"fname",
")",
":",
"import",
"mmcv",
"config",
"=",
"_get_config_module",
"(",
"fname",
")",
"model",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
".",
"model",
")",
"train_cfg",
"=",
"mmcv",
".",
"Config",
"(",
"copy",
"... | [
63,
0
] | [
78,
43
] | python | en | ['en', 'en', 'en'] | True |
_get_roi_head_cfg | (fname) | Grab configs necessary to create a roi_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
| Grab configs necessary to create a roi_head. | def _get_roi_head_cfg(fname):
"""Grab configs necessary to create a roi_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
"""
import mmcv
config = _get_config_module(fname)
model = copy.deepcopy(config.model)
train_cfg = mmcv.Confi... | [
"def",
"_get_roi_head_cfg",
"(",
"fname",
")",
":",
"import",
"mmcv",
"config",
"=",
"_get_config_module",
"(",
"fname",
")",
"model",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
".",
"model",
")",
"train_cfg",
"=",
"mmcv",
".",
"Config",
"(",
"copy",
"... | [
81,
0
] | [
96,
19
] | python | en | ['en', 'gd', 'en'] | True |
_get_pts_bbox_head_cfg | (fname) | Grab configs necessary to create a pts_bbox_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
| Grab configs necessary to create a pts_bbox_head. | def _get_pts_bbox_head_cfg(fname):
"""Grab configs necessary to create a pts_bbox_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
"""
import mmcv
config = _get_config_module(fname)
model = copy.deepcopy(config.model)
train_cfg = ... | [
"def",
"_get_pts_bbox_head_cfg",
"(",
"fname",
")",
":",
"import",
"mmcv",
"config",
"=",
"_get_config_module",
"(",
"fname",
")",
"model",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
".",
"model",
")",
"train_cfg",
"=",
"mmcv",
".",
"Config",
"(",
"copy"... | [
99,
0
] | [
114,
24
] | python | en | ['en', 'en', 'en'] | True |
_get_vote_head_cfg | (fname) | Grab configs necessary to create a vote_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
| Grab configs necessary to create a vote_head. | def _get_vote_head_cfg(fname):
"""Grab configs necessary to create a vote_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
"""
import mmcv
config = _get_config_module(fname)
model = copy.deepcopy(config.model)
train_cfg = mmcv.Con... | [
"def",
"_get_vote_head_cfg",
"(",
"fname",
")",
":",
"import",
"mmcv",
"config",
"=",
"_get_config_module",
"(",
"fname",
")",
"model",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
".",
"model",
")",
"train_cfg",
"=",
"mmcv",
".",
"Config",
"(",
"copy",
... | [
117,
0
] | [
132,
20
] | python | en | ['en', 'it', 'en'] | True |
_get_parta2_bbox_head_cfg | (fname) | Grab configs necessary to create a parta2_bbox_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
| Grab configs necessary to create a parta2_bbox_head. | def _get_parta2_bbox_head_cfg(fname):
"""Grab configs necessary to create a parta2_bbox_head.
These are deep copied to allow for safe modification of parameters without
influencing other tests.
"""
config = _get_config_module(fname)
model = copy.deepcopy(config.model)
vote_head = model.roi... | [
"def",
"_get_parta2_bbox_head_cfg",
"(",
"fname",
")",
":",
"config",
"=",
"_get_config_module",
"(",
"fname",
")",
"model",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
".",
"model",
")",
"vote_head",
"=",
"model",
".",
"roi_head",
".",
"bbox_head",
"return... | [
135,
0
] | [
145,
20
] | python | en | ['en', 'it', 'en'] | True |
inter | (rbbox1, rbbox2) | Compute intersection of two rotated boxes.
Args:
rbox1 (np.ndarray, shape=[5]): Rotated 2d box.
rbox2 (np.ndarray, shape=[5]): Rotated 2d box.
Returns:
float: Intersection of two rotated boxes.
| Compute intersection of two rotated boxes. | def inter(rbbox1, rbbox2):
"""Compute intersection of two rotated boxes.
Args:
rbox1 (np.ndarray, shape=[5]): Rotated 2d box.
rbox2 (np.ndarray, shape=[5]): Rotated 2d box.
Returns:
float: Intersection of two rotated boxes.
"""
corners1 = cuda.local.array((8, ), dtype=numba... | [
"def",
"inter",
"(",
"rbbox1",
",",
"rbbox2",
")",
":",
"corners1",
"=",
"cuda",
".",
"local",
".",
"array",
"(",
"(",
"8",
",",
")",
",",
"dtype",
"=",
"numba",
".",
"float32",
")",
"corners2",
"=",
"cuda",
".",
"local",
".",
"array",
"(",
"(",
... | [
230,
0
] | [
252,
55
] | python | en | ['en', 'en', 'en'] | True |
devRotateIoUEval | (rbox1, rbox2, criterion=-1) | Compute rotated iou on device.
Args:
rbox1 (np.ndarray, shape=[5]): Rotated 2d box.
rbox2 (np.ndarray, shape=[5]): Rotated 2d box.
criterion (int, optional): Indicate different type of iou.
-1 indicate `area_inter / (area1 + area2 - area_inter)`,
0 indicate `area_int... | Compute rotated iou on device. | def devRotateIoUEval(rbox1, rbox2, criterion=-1):
"""Compute rotated iou on device.
Args:
rbox1 (np.ndarray, shape=[5]): Rotated 2d box.
rbox2 (np.ndarray, shape=[5]): Rotated 2d box.
criterion (int, optional): Indicate different type of iou.
-1 indicate `area_inter / (area1... | [
"def",
"devRotateIoUEval",
"(",
"rbox1",
",",
"rbox2",
",",
"criterion",
"=",
"-",
"1",
")",
":",
"area1",
"=",
"rbox1",
"[",
"2",
"]",
"*",
"rbox1",
"[",
"3",
"]",
"area2",
"=",
"rbox2",
"[",
"2",
"]",
"*",
"rbox2",
"[",
"3",
"]",
"area_inter",
... | [
256,
0
] | [
280,
25
] | python | en | ['en', 'en', 'en'] | True |
rotate_iou_kernel_eval | (N,
K,
dev_boxes,
dev_query_boxes,
dev_iou,
criterion=-1) | Kernel of computing rotated iou.
Args:
N (int): The number of boxes.
K (int): The number of query boxes.
dev_boxes (np.ndarray): Boxes on device.
dev_query_boxes (np.ndarray): Query boxes on device.
dev_iou (np.ndarray): Computed iou to return.
criterion (int, option... | Kernel of computing rotated iou. | def rotate_iou_kernel_eval(N,
K,
dev_boxes,
dev_query_boxes,
dev_iou,
criterion=-1):
"""Kernel of computing rotated iou.
Args:
N (int): The number of boxes.
K (... | [
"def",
"rotate_iou_kernel_eval",
"(",
"N",
",",
"K",
",",
"dev_boxes",
",",
"dev_query_boxes",
",",
"dev_iou",
",",
"criterion",
"=",
"-",
"1",
")",
":",
"threadsPerBlock",
"=",
"8",
"*",
"8",
"row_start",
"=",
"cuda",
".",
"blockIdx",
".",
"x",
"col_sta... | [
286,
0
] | [
336,
57
] | python | en | ['en', 'mi', 'en'] | True |
rotate_iou_gpu_eval | (boxes, query_boxes, criterion=-1, device_id=0) | Rotated box iou running in gpu. 500x faster than cpu version (take 5ms
in one example with numba.cuda code). convert from [this project](
https://github.com/hongzhenwang/RRPN-revise/tree/master/lib/rotation).
Args:
boxes (torch.Tensor): rbboxes. format: centers, dims,
angles(clockwise w... | Rotated box iou running in gpu. 500x faster than cpu version (take 5ms
in one example with numba.cuda code). convert from [this project](
https://github.com/hongzhenwang/RRPN-revise/tree/master/lib/rotation). | def rotate_iou_gpu_eval(boxes, query_boxes, criterion=-1, device_id=0):
"""Rotated box iou running in gpu. 500x faster than cpu version (take 5ms
in one example with numba.cuda code). convert from [this project](
https://github.com/hongzhenwang/RRPN-revise/tree/master/lib/rotation).
Args:
boxes... | [
"def",
"rotate_iou_gpu_eval",
"(",
"boxes",
",",
"query_boxes",
",",
"criterion",
"=",
"-",
"1",
",",
"device_id",
"=",
"0",
")",
":",
"boxes",
"=",
"boxes",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"query_boxes",
"=",
"query_boxes",
".",
"astype",... | [
339,
0
] | [
377,
34
] | python | en | ['en', 'jv', 'en'] | True |
Ants.ant | (self, ctx, genus: str, species: str=None, subspecies: str=None) | Bring up some simple info on an ant genus or species. | Bring up some simple info on an ant genus or species. | async def ant(self, ctx, genus: str, species: str=None, subspecies: str=None):
"""Bring up some simple info on an ant genus or species."""
genus = genus.lower().capitalize()
if species is not None:
species = species.lower()
if subspecies is not None:
subspecies... | [
"async",
"def",
"ant",
"(",
"self",
",",
"ctx",
",",
"genus",
":",
"str",
",",
"species",
":",
"str",
"=",
"None",
",",
"subspecies",
":",
"str",
"=",
"None",
")",
":",
"genus",
"=",
"genus",
".",
"lower",
"(",
")",
".",
"capitalize",
"(",
")",
... | [
18,
4
] | [
68,
44
] | python | en | ['en', 'en', 'en'] | True |
Font.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... | def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
64,
28
] | python | en | ['en', 'error', 'th'] | False |
Font.colorsrc | (self) |
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def colorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["colorsrc"] | [
"def",
"colorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"colorsrc\"",
"]"
] | [
73,
4
] | [
84,
31
] | python | en | ['en', 'error', 'th'] | False |
Font.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... | def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
93,
4
] | [
116,
29
] | python | en | ['en', 'error', 'th'] | False |
Font.familysrc | (self) |
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def familysrc(self):
"""
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["familysrc"] | [
"def",
"familysrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"familysrc\"",
"]"
] | [
125,
4
] | [
136,
32
] | python | en | ['en', 'error', 'th'] | False |
Font.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
"""
return self["size"... | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
145,
4
] | [
155,
27
] | python | en | ['en', 'error', 'th'] | False |
Font.sizesrc | (self) |
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def sizesrc(self):
"""
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["sizesrc"] | [
"def",
"sizesrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"sizesrc\"",
"]"
] | [
164,
4
] | [
175,
30
] | python | en | ['en', 'error', 'th'] | False |
Font.__init__ | (
self,
arg=None,
color=None,
colorsrc=None,
family=None,
familysrc=None,
size=None,
sizesrc=None,
**kwargs
) |
Construct a new Font object
Sets the font used in hover labels.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.sankey.hoverlabel.Font`
color
... |
Construct a new Font object
Sets the font used in hover labels. | def __init__(
self,
arg=None,
color=None,
colorsrc=None,
family=None,
familysrc=None,
size=None,
sizesrc=None,
**kwargs
):
"""
Construct a new Font object
Sets the font used in hover labels.
Parameters
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"colorsrc",
"=",
"None",
",",
"family",
"=",
"None",
",",
"familysrc",
"=",
"None",
",",
"size",
"=",
"None",
",",
"sizesrc",
"=",
"None",
",",
"*",
"*",
"kw... | [
215,
4
] | [
329,
34
] | python | en | ['en', 'error', 'th'] | False |
TestBlendedSkillTalkModels.test_bst_single_task | (self) |
Test model trained single-task on BlendedSkillTalk.
|
Test model trained single-task on BlendedSkillTalk.
| def test_bst_single_task(self):
"""
Test model trained single-task on BlendedSkillTalk.
"""
valid, _ = testing_utils.eval_model(
opt={
**SHARED_OPTS,
'model_file': f'zoo:blended_skill_talk/bst_single_task/model',
},
skip... | [
"def",
"test_bst_single_task",
"(",
"self",
")",
":",
"valid",
",",
"_",
"=",
"testing_utils",
".",
"eval_model",
"(",
"opt",
"=",
"{",
"*",
"*",
"SHARED_OPTS",
",",
"'model_file'",
":",
"f'zoo:blended_skill_talk/bst_single_task/model'",
",",
"}",
",",
"skip_tes... | [
19,
4
] | [
30,
70
] | python | en | ['en', 'error', 'th'] | False |
TestBlendedSkillTalkModels.test_convai2_single_task | (self) |
Test model trained single-task on ConvAI2.
|
Test model trained single-task on ConvAI2.
| def test_convai2_single_task(self):
"""
Test model trained single-task on ConvAI2.
"""
valid, _ = testing_utils.eval_model(
opt={
**SHARED_OPTS,
'model_file': f'zoo:blended_skill_talk/convai2_single_task/model',
},
skip_... | [
"def",
"test_convai2_single_task",
"(",
"self",
")",
":",
"valid",
",",
"_",
"=",
"testing_utils",
".",
"eval_model",
"(",
"opt",
"=",
"{",
"*",
"*",
"SHARED_OPTS",
",",
"'model_file'",
":",
"f'zoo:blended_skill_talk/convai2_single_task/model'",
",",
"}",
",",
"... | [
32,
4
] | [
43,
70
] | python | en | ['en', 'error', 'th'] | False |
TestBlendedSkillTalkModels.test_ed_single_task | (self) |
Test model trained single-task on EmpatheticDialogues.
|
Test model trained single-task on EmpatheticDialogues.
| def test_ed_single_task(self):
"""
Test model trained single-task on EmpatheticDialogues.
"""
valid, _ = testing_utils.eval_model(
opt={
**SHARED_OPTS,
'model_file': f'zoo:blended_skill_talk/ed_single_task/model',
},
ski... | [
"def",
"test_ed_single_task",
"(",
"self",
")",
":",
"valid",
",",
"_",
"=",
"testing_utils",
".",
"eval_model",
"(",
"opt",
"=",
"{",
"*",
"*",
"SHARED_OPTS",
",",
"'model_file'",
":",
"f'zoo:blended_skill_talk/ed_single_task/model'",
",",
"}",
",",
"skip_test"... | [
45,
4
] | [
56,
70
] | python | en | ['en', 'error', 'th'] | False |
TestBlendedSkillTalkModels.test_wizard_single_task | (self) |
Test model trained single-task on Wizard of Wikipedia.
|
Test model trained single-task on Wizard of Wikipedia.
| def test_wizard_single_task(self):
"""
Test model trained single-task on Wizard of Wikipedia.
"""
valid, _ = testing_utils.eval_model(
opt={
**SHARED_OPTS,
'model_file': f'zoo:blended_skill_talk/wizard_single_task/model',
},
... | [
"def",
"test_wizard_single_task",
"(",
"self",
")",
":",
"valid",
",",
"_",
"=",
"testing_utils",
".",
"eval_model",
"(",
"opt",
"=",
"{",
"*",
"*",
"SHARED_OPTS",
",",
"'model_file'",
":",
"f'zoo:blended_skill_talk/wizard_single_task/model'",
",",
"}",
",",
"sk... | [
58,
4
] | [
69,
70
] | python | en | ['en', 'error', 'th'] | False |
TestBlendedSkillTalkModels.test_multi_task | (self) |
Test model trained multi-task on dialogue datasets.
|
Test model trained multi-task on dialogue datasets.
| def test_multi_task(self):
"""
Test model trained multi-task on dialogue datasets.
"""
valid, _ = testing_utils.eval_model(
opt={
**SHARED_OPTS,
'model_file': f'zoo:blended_skill_talk/multi_task/model',
},
skip_test=True... | [
"def",
"test_multi_task",
"(",
"self",
")",
":",
"valid",
",",
"_",
"=",
"testing_utils",
".",
"eval_model",
"(",
"opt",
"=",
"{",
"*",
"*",
"SHARED_OPTS",
",",
"'model_file'",
":",
"f'zoo:blended_skill_talk/multi_task/model'",
",",
"}",
",",
"skip_test",
"=",... | [
71,
4
] | [
82,
70
] | python | en | ['en', 'error', 'th'] | False |
TestBlendedSkillTalkModels.test_multi_task_bst_tuned | (self) |
Test model trained multi-task and then tuned on BlendedSkillTalk.
|
Test model trained multi-task and then tuned on BlendedSkillTalk.
| def test_multi_task_bst_tuned(self):
"""
Test model trained multi-task and then tuned on BlendedSkillTalk.
"""
valid, _ = testing_utils.eval_model(
opt={
**SHARED_OPTS,
'model_file': f'zoo:blended_skill_talk/multi_task_bst_tuned/model',
... | [
"def",
"test_multi_task_bst_tuned",
"(",
"self",
")",
":",
"valid",
",",
"_",
"=",
"testing_utils",
".",
"eval_model",
"(",
"opt",
"=",
"{",
"*",
"*",
"SHARED_OPTS",
",",
"'model_file'",
":",
"f'zoo:blended_skill_talk/multi_task_bst_tuned/model'",
",",
"}",
",",
... | [
84,
4
] | [
95,
70
] | python | en | ['en', 'error', 'th'] | False |
Stream.maxpoints | (self) |
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000]... |
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000] | def maxpoints(self):
"""
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or ... | [
"def",
"maxpoints",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"maxpoints\"",
"]"
] | [
15,
4
] | [
28,
32
] | python | en | ['en', 'error', 'th'] | False |
Stream.token | (self) |
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string
Returns
-------
str
|
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string | def token(self):
"""
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string
Returns
-------
... | [
"def",
"token",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"token\"",
"]"
] | [
37,
4
] | [
50,
28
] | python | en | ['en', 'error', 'th'] | False |
Stream.__init__ | (self, arg=None, maxpoints=None, token=None, **kwargs) |
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.mesh3d.Stream`
maxpoints
Sets the maximum number of points to keep on the plots
... |
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.mesh3d.Stream`
maxpoints
Sets the maximum number of points to keep on the plots
... | def __init__(self, arg=None, maxpoints=None, token=None, **kwargs):
"""
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.mesh3d.Stream`
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"maxpoints",
"=",
"None",
",",
"token",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Stream",
",",
"self",
")",
".",
"__init__",
"(",
"\"stream\"",
")",
"if",
"\"_paren... | [
72,
4
] | [
139,
34
] | python | en | ['en', 'error', 'th'] | False |
Textfont.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... | def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
64,
28
] | python | en | ['en', 'error', 'th'] | False |
Textfont.colorsrc | (self) |
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def colorsrc(self):
"""
Sets the source reference on Chart Studio Cloud for color .
The 'colorsrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["colorsrc"] | [
"def",
"colorsrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"colorsrc\"",
"]"
] | [
73,
4
] | [
84,
31
] | python | en | ['en', 'error', 'th'] | False |
Textfont.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... | def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
93,
4
] | [
116,
29
] | python | en | ['en', 'error', 'th'] | False |
Textfont.familysrc | (self) |
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def familysrc(self):
"""
Sets the source reference on Chart Studio Cloud for family .
The 'familysrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["familysrc"] | [
"def",
"familysrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"familysrc\"",
"]"
] | [
125,
4
] | [
136,
32
] | python | en | ['en', 'error', 'th'] | False |
Textfont.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
"""
return self["size"... | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
145,
4
] | [
155,
27
] | python | en | ['en', 'error', 'th'] | False |
Textfont.sizesrc | (self) |
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
|
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object | def sizesrc(self):
"""
Sets the source reference on Chart Studio Cloud for size .
The 'sizesrc' property must be specified as a string or
as a plotly.grid_objs.Column object
Returns
-------
str
"""
return self["sizesrc"] | [
"def",
"sizesrc",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"sizesrc\"",
"]"
] | [
164,
4
] | [
175,
30
] | python | en | ['en', 'error', 'th'] | False |
Textfont.__init__ | (
self,
arg=None,
color=None,
colorsrc=None,
family=None,
familysrc=None,
size=None,
sizesrc=None,
**kwargs
) |
Construct a new Textfont object
Sets the font used for `textinfo`.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.pie.Textfont`
color
colorsrc
... |
Construct a new Textfont object
Sets the font used for `textinfo`. | def __init__(
self,
arg=None,
color=None,
colorsrc=None,
family=None,
familysrc=None,
size=None,
sizesrc=None,
**kwargs
):
"""
Construct a new Textfont object
Sets the font used for `textinfo`.
Paramete... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"colorsrc",
"=",
"None",
",",
"family",
"=",
"None",
",",
"familysrc",
"=",
"None",
",",
"size",
"=",
"None",
",",
"sizesrc",
"=",
"None",
",",
"*",
"*",
"kw... | [
215,
4
] | [
328,
34
] | python | en | ['en', 'error', 'th'] | False |
ColorBar.bgcolor | (self) |
Sets the color of padded area.
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
... |
Sets the color of padded area.
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
... | def bgcolor(self):
"""
Sets the color of padded area.
The 'bgcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva str... | [
"def",
"bgcolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bgcolor\"",
"]"
] | [
59,
4
] | [
109,
30
] | python | en | ['en', 'error', 'th'] | False |
ColorBar.bordercolor | (self) |
Sets the axis line color.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
... |
Sets the axis line color.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
... | def bordercolor(self):
"""
Sets the axis line color.
The 'bordercolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva ... | [
"def",
"bordercolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"bordercolor\"",
"]"
] | [
118,
4
] | [
168,
34
] | python | en | ['en', 'error', 'th'] | False |
ColorBar.borderwidth | (self) |
Sets the width (in px) or the border enclosing this color bar.
The 'borderwidth' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
|
Sets the width (in px) or the border enclosing this color bar.
The 'borderwidth' property is a number and may be specified as:
- An int or float in the interval [0, inf] | def borderwidth(self):
"""
Sets the width (in px) or the border enclosing this color bar.
The 'borderwidth' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
"""
return self["... | [
"def",
"borderwidth",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"borderwidth\"",
"]"
] | [
177,
4
] | [
188,
34
] | python | en | ['en', 'error', 'th'] | False |
ColorBar.dtick | (self) |
Sets the step in-between ticks on this axis. Use with `tick0`.
Must be a positive number, or special strings available to
"log" and "date" axes. If the axis `type` is "log", then ticks
are set every 10^(n*dtick) where n is the tick number. For
example, to set a tick mark at 1, 1... |
Sets the step in-between ticks on this axis. Use with `tick0`.
Must be a positive number, or special strings available to
"log" and "date" axes. If the axis `type` is "log", then ticks
are set every 10^(n*dtick) where n is the tick number. For
example, to set a tick mark at 1, 1... | def dtick(self):
"""
Sets the step in-between ticks on this axis. Use with `tick0`.
Must be a positive number, or special strings available to
"log" and "date" axes. If the axis `type` is "log", then ticks
are set every 10^(n*dtick) where n is the tick number. For
example... | [
"def",
"dtick",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"dtick\"",
"]"
] | [
197,
4
] | [
226,
28
] | python | en | ['en', 'error', 'th'] | False |
ColorBar.exponentformat | (self) |
Determines a formatting rule for the tick exponents. For
example, consider the number 1,000,000,000. If "none", it
appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If
"power", 1x10^9 (with 9 in a super script). If "SI", 1G. If
"B", 1B.
The 'exponentformat' prop... |
Determines a formatting rule for the tick exponents. For
example, consider the number 1,000,000,000. If "none", it
appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If
"power", 1x10^9 (with 9 in a super script). If "SI", 1G. If
"B", 1B.
The 'exponentformat' prop... | def exponentformat(self):
"""
Determines a formatting rule for the tick exponents. For
example, consider the number 1,000,000,000. If "none", it
appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If
"power", 1x10^9 (with 9 in a super script). If "SI", 1G. If
"B", 1B.
... | [
"def",
"exponentformat",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"exponentformat\"",
"]"
] | [
235,
4
] | [
251,
37
] | python | en | ['en', 'error', 'th'] | False |
ColorBar.len | (self) |
Sets the length of the color bar This measure excludes the
padding of both ends. That is, the color bar length is this
length minus the padding on both ends.
The 'len' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Return... |
Sets the length of the color bar This measure excludes the
padding of both ends. That is, the color bar length is this
length minus the padding on both ends.
The 'len' property is a number and may be specified as:
- An int or float in the interval [0, inf] | def len(self):
"""
Sets the length of the color bar This measure excludes the
padding of both ends. That is, the color bar length is this
length minus the padding on both ends.
The 'len' property is a number and may be specified as:
- An int or float in the interva... | [
"def",
"len",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"len\"",
"]"
] | [
260,
4
] | [
273,
26
] | python | en | ['en', 'error', 'th'] | False |
ColorBar.lenmode | (self) |
Determines whether this color bar's length (i.e. the measure in
the color variation direction) is set in units of plot
"fraction" or in *pixels. Use `len` to set the value.
The 'lenmode' property is an enumeration that may be specified as:
- One of the following enumerati... |
Determines whether this color bar's length (i.e. the measure in
the color variation direction) is set in units of plot
"fraction" or in *pixels. Use `len` to set the value.
The 'lenmode' property is an enumeration that may be specified as:
- One of the following enumerati... | def lenmode(self):
"""
Determines whether this color bar's length (i.e. the measure in
the color variation direction) is set in units of plot
"fraction" or in *pixels. Use `len` to set the value.
The 'lenmode' property is an enumeration that may be specified as:
- ... | [
"def",
"lenmode",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"lenmode\"",
"]"
] | [
282,
4
] | [
296,
30
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.