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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
create_testcase06 | () | Conversion of the physical parameter to the internally defined parameter
to be passed to george
| Conversion of the physical parameter to the internally defined parameter
to be passed to george
| def create_testcase06():
import george
bjd0 = photometry['phot_bjd'] - Tref
err = bjd0 * 0 + photometry['phot_precision']
""" Conversion of the physical parameter to the internally defined parameter
to be passed to george
"""
gp_pams = np.zeros(4)
gp_pams[0] = np.log(activity['Hamp_PH'... | [
"def",
"create_testcase06",
"(",
")",
":",
"import",
"george",
"bjd0",
"=",
"photometry",
"[",
"'phot_bjd'",
"]",
"-",
"Tref",
"err",
"=",
"bjd0",
"*",
"0",
"+",
"photometry",
"[",
"'phot_precision'",
"]",
"gp_pams",
"=",
"np",
".",
"zeros",
"(",
"4",
... | [
268,
0
] | [
334,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up Coolmaster components. | Set up Coolmaster components. | async def async_setup(hass, config):
"""Set up Coolmaster components."""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
15,
0
] | [
18,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, entry) | Set up Coolmaster from a config entry. | Set up Coolmaster from a config entry. | async def async_setup_entry(hass, entry):
"""Set up Coolmaster from a config entry."""
host = entry.data[CONF_HOST]
port = entry.data[CONF_PORT]
coolmaster = CoolMasterNet(host, port)
try:
info = await coolmaster.info()
if not info:
raise ConfigEntryNotReady
except (O... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"host",
"=",
"entry",
".",
"data",
"[",
"CONF_HOST",
"]",
"port",
"=",
"entry",
".",
"data",
"[",
"CONF_PORT",
"]",
"coolmaster",
"=",
"CoolMasterNet",
"(",
"host",
",",
"port",
... | [
21,
0
] | [
42,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a Coolmaster config entry. | Unload a Coolmaster config entry. | async def async_unload_entry(hass, entry):
"""Unload a Coolmaster config entry."""
unload_ok = await hass.config_entries.async_forward_entry_unload(entry, "climate")
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"unload_ok",
"=",
"await",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",
"\"climate\"",
")",
"if",
"unload_ok",
":",
"hass",
".",
"data",
"[",
"... | [
45,
0
] | [
52,
20
] | python | en | ['en', 'en', 'en'] | True |
CoolmasterDataUpdateCoordinator.__init__ | (self, hass, coolmaster) | Initialize global Coolmaster data updater. | Initialize global Coolmaster data updater. | def __init__(self, hass, coolmaster):
"""Initialize global Coolmaster data updater."""
self._coolmaster = coolmaster
super().__init__(
hass,
_LOGGER,
name=DOMAIN,
update_interval=SCAN_INTERVAL,
) | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"coolmaster",
")",
":",
"self",
".",
"_coolmaster",
"=",
"coolmaster",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"_LOGGER",
",",
"name",
"=",
"DOMAIN",
",",
"update_interval",
"=",
"SCAN_INTER... | [
58,
4
] | [
67,
9
] | python | en | ['tr', 'en', 'en'] | True |
CoolmasterDataUpdateCoordinator._async_update_data | (self) | Fetch data from Coolmaster. | Fetch data from Coolmaster. | async def _async_update_data(self):
"""Fetch data from Coolmaster."""
try:
return await self._coolmaster.status()
except (OSError, ConnectionRefusedError, TimeoutError) as error:
raise UpdateFailed from error | [
"async",
"def",
"_async_update_data",
"(",
"self",
")",
":",
"try",
":",
"return",
"await",
"self",
".",
"_coolmaster",
".",
"status",
"(",
")",
"except",
"(",
"OSError",
",",
"ConnectionRefusedError",
",",
"TimeoutError",
")",
"as",
"error",
":",
"raise",
... | [
69,
4
] | [
74,
41
] | python | en | ['en', 'en', 'en'] | True |
prepare_backend | (model_name, backend_name, im_size: List[int] = None,
max_batch_size: int = 1,
force_fp16: bool = False,
download_model: bool = True,
config: Configs = None) |
Check if ONNX, MXNet and TensorRT models exist and download/create them otherwise.
:param model_name: Name of required model. Must be one of keys in `models` dict.
:param backend_name: Name of inference backend. (onnx, trt)
:param im_size: Desired maximum size of image in W,H form. Will be overridden ... |
Check if ONNX, MXNet and TensorRT models exist and download/create them otherwise. | def prepare_backend(model_name, backend_name, im_size: List[int] = None,
max_batch_size: int = 1,
force_fp16: bool = False,
download_model: bool = True,
config: Configs = None):
"""
Check if ONNX, MXNet and TensorRT models exist and... | [
"def",
"prepare_backend",
"(",
"model_name",
",",
"backend_name",
",",
"im_size",
":",
"List",
"[",
"int",
"]",
"=",
"None",
",",
"max_batch_size",
":",
"int",
"=",
"1",
",",
"force_fp16",
":",
"bool",
"=",
"False",
",",
"download_model",
":",
"bool",
"=... | [
48,
0
] | [
131,
23
] | python | en | ['en', 'error', 'th'] | False |
get_model | (model_name: str, backend_name: str, im_size: List[int] = None, max_batch_size: int = 1, force_fp16: bool = False,
root_dir: str = "/models", download_model: bool = True, **kwargs) |
Returns inference backend instance with loaded model.
:param model_name: Name of required model. Must be one of keys in `models` dict.
:param backend_name: Name of inference backend. (onnx, mxnet, trt)
:param im_size: Desired maximum size of image in W,H form. Will be overridden if model doesn't suppo... |
Returns inference backend instance with loaded model. | def get_model(model_name: str, backend_name: str, im_size: List[int] = None, max_batch_size: int = 1, force_fp16: bool = False,
root_dir: str = "/models", download_model: bool = True, **kwargs):
"""
Returns inference backend instance with loaded model.
:param model_name: Name of required mode... | [
"def",
"get_model",
"(",
"model_name",
":",
"str",
",",
"backend_name",
":",
"str",
",",
"im_size",
":",
"List",
"[",
"int",
"]",
"=",
"None",
",",
"max_batch_size",
":",
"int",
"=",
"1",
",",
"force_fp16",
":",
"bool",
"=",
"False",
",",
"root_dir",
... | [
134,
0
] | [
180,
16
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up DSMR Reader sensors. | Set up DSMR Reader sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up DSMR Reader sensors."""
sensors = []
for topic in DEFINITIONS:
sensors.append(DSMRSensor(topic))
async_add_entities(sensors) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"sensors",
"=",
"[",
"]",
"for",
"topic",
"in",
"DEFINITIONS",
":",
"sensors",
".",
"append",
"(",
"DSMRSensor",
"(",... | [
11,
0
] | [
18,
31
] | python | en | ['en', 'da', 'en'] | True |
DSMRSensor.__init__ | (self, topic) | Initialize the sensor. | Initialize the sensor. | def __init__(self, topic):
"""Initialize the sensor."""
self._definition = DEFINITIONS[topic]
self._entity_id = slugify(topic.replace("/", "_"))
self._topic = topic
self._name = self._definition.get("name", topic.split("/")[-1])
self._device_class = self._definition.ge... | [
"def",
"__init__",
"(",
"self",
",",
"topic",
")",
":",
"self",
".",
"_definition",
"=",
"DEFINITIONS",
"[",
"topic",
"]",
"self",
".",
"_entity_id",
"=",
"slugify",
"(",
"topic",
".",
"replace",
"(",
"\"/\"",
",",
"\"_\"",
")",
")",
"self",
".",
"_t... | [
24,
4
] | [
38,
26
] | python | en | ['en', 'en', 'en'] | True |
DSMRSensor.async_added_to_hass | (self) | Subscribe to MQTT events. | Subscribe to MQTT events. | async def async_added_to_hass(self):
"""Subscribe to MQTT events."""
@callback
def message_received(message):
"""Handle new MQTT messages."""
if self._transform is not None:
self._state = self._transform(message.payload)
else:
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"@",
"callback",
"def",
"message_received",
"(",
"message",
")",
":",
"\"\"\"Handle new MQTT messages.\"\"\"",
"if",
"self",
".",
"_transform",
"is",
"not",
"None",
":",
"self",
".",
"_state",
"=",
... | [
40,
4
] | [
54,
79
] | python | en | ['en', 'en', 'en'] | True |
DSMRSensor.name | (self) | Return the name of the sensor supplied in constructor. | Return the name of the sensor supplied in constructor. | def name(self):
"""Return the name of the sensor supplied in constructor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
57,
4
] | [
59,
25
] | python | en | ['en', 'en', 'en'] | True |
DSMRSensor.entity_id | (self) | Return the entity ID for this sensor. | Return the entity ID for this sensor. | def entity_id(self):
"""Return the entity ID for this sensor."""
return f"sensor.{self._entity_id}" | [
"def",
"entity_id",
"(",
"self",
")",
":",
"return",
"f\"sensor.{self._entity_id}\""
] | [
62,
4
] | [
64,
42
] | python | en | ['en', 'en', 'en'] | True |
DSMRSensor.state | (self) | Return the current state of the entity. | Return the current state of the entity. | def state(self):
"""Return the current state of the entity."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
67,
4
] | [
69,
26
] | python | en | ['en', 'en', 'en'] | True |
DSMRSensor.device_class | (self) | Return the device_class of this sensor. | Return the device_class of this sensor. | def device_class(self):
"""Return the device_class of this sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
72,
4
] | [
74,
33
] | python | en | ['en', 'en', 'en'] | True |
DSMRSensor.unit_of_measurement | (self) | Return the unit_of_measurement of this sensor. | Return the unit_of_measurement of this sensor. | def unit_of_measurement(self):
"""Return the unit_of_measurement of this sensor."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
77,
4
] | [
79,
40
] | python | en | ['en', 'id', 'en'] | True |
DSMRSensor.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return self._enable_default | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_enable_default"
] | [
82,
4
] | [
84,
35
] | python | en | ['en', 'en', 'en'] | True |
DSMRSensor.icon | (self) | Return the icon of this sensor. | Return the icon of this sensor. | def icon(self):
"""Return the icon of this sensor."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
87,
4
] | [
89,
25
] | python | en | ['en', 'en', 'en'] | True |
test_better_snakecase | (value, expected) | Test that better snakecase works better. | Test that better snakecase works better. | def test_better_snakecase(value, expected):
"""Test that better snakecase works better."""
assert device_tracker._better_snakecase(value) == expected | [
"def",
"test_better_snakecase",
"(",
"value",
",",
"expected",
")",
":",
"assert",
"device_tracker",
".",
"_better_snakecase",
"(",
"value",
")",
"==",
"expected"
] | [
17,
0
] | [
19,
62
] | python | en | ['en', 'no', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up MQTT fan through configuration.yaml. | Set up MQTT fan through configuration.yaml. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
):
"""Set up MQTT fan through configuration.yaml."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
await _async_setup_entity(hass, config, async_add_entities) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATF... | [
112,
0
] | [
117,
63
] | python | en | ['en', 'ny', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up MQTT fan dynamically through MQTT discovery. | Set up MQTT fan dynamically through MQTT discovery. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up MQTT fan dynamically through MQTT discovery."""
async def async_discover(discovery_payload):
"""Discover and add a MQTT fan."""
discovery_data = discovery_payload.discovery_data
try:
config = PLAT... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"async",
"def",
"async_discover",
"(",
"discovery_payload",
")",
":",
"\"\"\"Discover and add a MQTT fan.\"\"\"",
"discovery_data",
"=",
"discovery_payload",
".",
... | [
120,
0
] | [
137,
5
] | python | en | ['en', 'lb', 'en'] | True |
_async_setup_entity | (
hass, config, async_add_entities, config_entry=None, discovery_data=None
) | Set up the MQTT fan. | Set up the MQTT fan. | async def _async_setup_entity(
hass, config, async_add_entities, config_entry=None, discovery_data=None
):
"""Set up the MQTT fan."""
async_add_entities([MqttFan(hass, config, config_entry, discovery_data)]) | [
"async",
"def",
"_async_setup_entity",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"config_entry",
"=",
"None",
",",
"discovery_data",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"[",
"MqttFan",
"(",
"hass",
",",
"config",
",",
"config_en... | [
140,
0
] | [
144,
77
] | python | en | ['en', 'fy', 'en'] | True |
MqttFan.__init__ | (self, hass, config, config_entry, discovery_data) | Initialize the MQTT fan. | Initialize the MQTT fan. | def __init__(self, hass, config, config_entry, discovery_data):
"""Initialize the MQTT fan."""
self.hass = hass
self._unique_id = config.get(CONF_UNIQUE_ID)
self._state = False
self._speed = None
self._oscillation = None
self._supported_features = 0
self._... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config",
",",
"config_entry",
",",
"discovery_data",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"_unique_id",
"=",
"config",
".",
"get",
"(",
"CONF_UNIQUE_ID",
")",
"self",
".",
"_state",
... | [
156,
4
] | [
181,
72
] | python | en | ['en', 'fy', 'en'] | True |
MqttFan.async_added_to_hass | (self) | Subscribe to MQTT events. | Subscribe to MQTT events. | async def async_added_to_hass(self):
"""Subscribe to MQTT events."""
await super().async_added_to_hass()
await self._subscribe_topics() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"_subscribe_topics",
"(",
")"
] | [
183,
4
] | [
186,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.discovery_update | (self, discovery_payload) | Handle updated discovery message. | Handle updated discovery message. | async def discovery_update(self, discovery_payload):
"""Handle updated discovery message."""
config = PLATFORM_SCHEMA(discovery_payload)
self._setup_from_config(config)
await self.attributes_discovery_update(config)
await self.availability_discovery_update(config)
await s... | [
"async",
"def",
"discovery_update",
"(",
"self",
",",
"discovery_payload",
")",
":",
"config",
"=",
"PLATFORM_SCHEMA",
"(",
"discovery_payload",
")",
"self",
".",
"_setup_from_config",
"(",
"config",
")",
"await",
"self",
".",
"attributes_discovery_update",
"(",
"... | [
188,
4
] | [
196,
35
] | python | en | ['en', 'en', 'en'] | True |
MqttFan._setup_from_config | (self, config) | (Re)Setup the entity. | (Re)Setup the entity. | def _setup_from_config(self, config):
"""(Re)Setup the entity."""
self._config = config
self._topic = {
key: config.get(key)
for key in (
CONF_STATE_TOPIC,
CONF_COMMAND_TOPIC,
CONF_SPEED_STATE_TOPIC,
CONF_SPE... | [
"def",
"_setup_from_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_topic",
"=",
"{",
"key",
":",
"config",
".",
"get",
"(",
"key",
")",
"for",
"key",
"in",
"(",
"CONF_STATE_TOPIC",
",",
"CONF_COMMAN... | [
198,
4
] | [
250,
80
] | python | en | ['en', 'haw', 'en'] | True |
MqttFan._subscribe_topics | (self) | (Re)Subscribe to topics. | (Re)Subscribe to topics. | async def _subscribe_topics(self):
"""(Re)Subscribe to topics."""
topics = {}
@callback
@log_messages(self.hass, self.entity_id)
def state_received(msg):
"""Handle new received MQTT message."""
payload = self._templates[CONF_STATE](msg.payload)
... | [
"async",
"def",
"_subscribe_topics",
"(",
"self",
")",
":",
"topics",
"=",
"{",
"}",
"@",
"callback",
"@",
"log_messages",
"(",
"self",
".",
"hass",
",",
"self",
".",
"entity_id",
")",
"def",
"state_received",
"(",
"msg",
")",
":",
"\"\"\"Handle new receiv... | [
252,
4
] | [
318,
9
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.async_will_remove_from_hass | (self) | Unsubscribe when removed. | Unsubscribe when removed. | async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
self._sub_state = await subscription.async_unsubscribe_topics(
self.hass, self._sub_state
)
await MqttAttributes.async_will_remove_from_hass(self)
await MqttAvailability.async_will_remove_fro... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_sub_state",
"=",
"await",
"subscription",
".",
"async_unsubscribe_topics",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_sub_state",
")",
"await",
"MqttAttributes",
".",
"async_... | [
320,
4
] | [
327,
67
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.should_poll | (self) | No polling needed for a MQTT fan. | No polling needed for a MQTT fan. | def should_poll(self):
"""No polling needed for a MQTT fan."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
330,
4
] | [
332,
20
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.assumed_state | (self) | Return true if we do optimistic updates. | Return true if we do optimistic updates. | def assumed_state(self):
"""Return true if we do optimistic updates."""
return self._optimistic | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_optimistic"
] | [
335,
4
] | [
337,
31
] | python | en | ['pt', 'la', 'en'] | False |
MqttFan.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
340,
4
] | [
342,
26
] | python | en | ['en', 'fy', 'en'] | True |
MqttFan.name | (self) | Get entity name. | Get entity name. | def name(self) -> str:
"""Get entity name."""
return self._config[CONF_NAME] | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_NAME",
"]"
] | [
345,
4
] | [
347,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.speed_list | (self) | Get the list of available speeds. | Get the list of available speeds. | def speed_list(self) -> list:
"""Get the list of available speeds."""
return self._config[CONF_SPEED_LIST] | [
"def",
"speed_list",
"(",
"self",
")",
"->",
"list",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_SPEED_LIST",
"]"
] | [
350,
4
] | [
352,
44
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self) -> int:
"""Flag supported features."""
return self._supported_features | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_supported_features"
] | [
355,
4
] | [
357,
39
] | python | en | ['da', 'en', 'en'] | True |
MqttFan.speed | (self) | Return the current speed. | Return the current speed. | def speed(self):
"""Return the current speed."""
return self._speed | [
"def",
"speed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_speed"
] | [
360,
4
] | [
362,
26
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.oscillating | (self) | Return the oscillation state. | Return the oscillation state. | def oscillating(self):
"""Return the oscillation state."""
return self._oscillation | [
"def",
"oscillating",
"(",
"self",
")",
":",
"return",
"self",
".",
"_oscillation"
] | [
365,
4
] | [
367,
32
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.async_turn_on | (self, speed: str = None, **kwargs) | Turn on the entity.
This method is a coroutine.
| Turn on the entity. | async def async_turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the entity.
This method is a coroutine.
"""
mqtt.async_publish(
self.hass,
self._topic[CONF_COMMAND_TOPIC],
self._payload["STATE_ON"],
self._config[CONF_QOS],
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"speed",
":",
"str",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"mqtt",
".",
"async_publish",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_topic",
"[",
"CONF_COMMAND_TOPIC",
"]",
... | [
369,
4
] | [
385,
39
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.async_turn_off | (self, **kwargs) | Turn off the entity.
This method is a coroutine.
| Turn off the entity. | async def async_turn_off(self, **kwargs) -> None:
"""Turn off the entity.
This method is a coroutine.
"""
mqtt.async_publish(
self.hass,
self._topic[CONF_COMMAND_TOPIC],
self._payload["STATE_OFF"],
self._config[CONF_QOS],
self.... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"mqtt",
".",
"async_publish",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_topic",
"[",
"CONF_COMMAND_TOPIC",
"]",
",",
"self",
".",
"_payload",
"[",
"\"ST... | [
387,
4
] | [
401,
39
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.async_set_speed | (self, speed: str) | Set the speed of the fan.
This method is a coroutine.
| Set the speed of the fan. | async def async_set_speed(self, speed: str) -> None:
"""Set the speed of the fan.
This method is a coroutine.
"""
if speed == SPEED_LOW:
mqtt_payload = self._payload["SPEED_LOW"]
elif speed == SPEED_MEDIUM:
mqtt_payload = self._payload["SPEED_MEDIUM"]
... | [
"async",
"def",
"async_set_speed",
"(",
"self",
",",
"speed",
":",
"str",
")",
"->",
"None",
":",
"if",
"speed",
"==",
"SPEED_LOW",
":",
"mqtt_payload",
"=",
"self",
".",
"_payload",
"[",
"\"SPEED_LOW\"",
"]",
"elif",
"speed",
"==",
"SPEED_MEDIUM",
":",
... | [
403,
4
] | [
429,
39
] | python | en | ['en', 'en', 'en'] | True |
MqttFan.async_oscillate | (self, oscillating: bool) | Set oscillation.
This method is a coroutine.
| Set oscillation. | async def async_oscillate(self, oscillating: bool) -> None:
"""Set oscillation.
This method is a coroutine.
"""
if oscillating is False:
payload = self._payload["OSCILLATE_OFF_PAYLOAD"]
else:
payload = self._payload["OSCILLATE_ON_PAYLOAD"]
mqtt.a... | [
"async",
"def",
"async_oscillate",
"(",
"self",
",",
"oscillating",
":",
"bool",
")",
"->",
"None",
":",
"if",
"oscillating",
"is",
"False",
":",
"payload",
"=",
"self",
".",
"_payload",
"[",
"\"OSCILLATE_OFF_PAYLOAD\"",
"]",
"else",
":",
"payload",
"=",
"... | [
431,
4
] | [
451,
39
] | python | en | ['it', 'ru', 'en'] | False |
MqttFan.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
454,
4
] | [
456,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
shift_tokens_right | (input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int) |
Shift input ids one token to the right.
|
Shift input ids one token to the right.
| def shift_tokens_right(input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int):
"""
Shift input ids one token to the right.
"""
shifted_input_ids = input_ids.new_zeros(input_ids.shape)
shifted_input_ids[:, 1:] = input_ids[:, :-1].clone()
shifted_input_ids[:, 0] = decoder_start_t... | [
"def",
"shift_tokens_right",
"(",
"input_ids",
":",
"torch",
".",
"Tensor",
",",
"pad_token_id",
":",
"int",
",",
"decoder_start_token_id",
":",
"int",
")",
":",
"shifted_input_ids",
"=",
"input_ids",
".",
"new_zeros",
"(",
"input_ids",
".",
"shape",
")",
"shi... | [
62,
0
] | [
74,
28
] | python | en | ['en', 'error', 'th'] | False |
_make_causal_mask | (input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0) |
Make causal mask used for bi-directional self-attention.
|
Make causal mask used for bi-directional self-attention.
| def _make_causal_mask(input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0):
"""
Make causal mask used for bi-directional self-attention.
"""
bsz, tgt_len = input_ids_shape
mask = torch.full((tgt_len, tgt_len), float("-inf"))
mask_cond = torch.arange(mask.size(-1))
... | [
"def",
"_make_causal_mask",
"(",
"input_ids_shape",
":",
"torch",
".",
"Size",
",",
"dtype",
":",
"torch",
".",
"dtype",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"tgt_len",
"=",
"input_ids_shape",
"mask",
"=",
"torch",
"."... | [
77,
0
] | [
89,
91
] | python | en | ['en', 'error', 'th'] | False |
_expand_mask | (mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None) |
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
| def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
"""
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
"""
bsz, src_len = mask.size()
tgt_len = tgt_len if tgt_len is not None else src_len
expanded_mask = mask[:, None, N... | [
"def",
"_expand_mask",
"(",
"mask",
":",
"torch",
".",
"Tensor",
",",
"dtype",
":",
"torch",
".",
"dtype",
",",
"tgt_len",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
":",
"bsz",
",",
"src_len",
"=",
"mask",
".",
"size",
"(",
")",
"tgt_len"... | [
92,
0
] | [
103,
82
] | python | en | ['en', 'error', 'th'] | False |
BartLearnedPositionalEmbedding.forward | (self, input_ids_shape: torch.Size, past_key_values_length: int = 0) | `input_ids_shape` is expected to be [bsz x seqlen]. | `input_ids_shape` is expected to be [bsz x seqlen]. | def forward(self, input_ids_shape: torch.Size, past_key_values_length: int = 0):
"""`input_ids_shape` is expected to be [bsz x seqlen]."""
bsz, seq_len = input_ids_shape[:2]
positions = torch.arange(
past_key_values_length, past_key_values_length + seq_len, dtype=torch.long, device=s... | [
"def",
"forward",
"(",
"self",
",",
"input_ids_shape",
":",
"torch",
".",
"Size",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"seq_len",
"=",
"input_ids_shape",
"[",
":",
"2",
"]",
"positions",
"=",
"torch",
".",
"arange",
... | [
117,
4
] | [
123,
55
] | python | en | ['en', 'en', 'en'] | True |
BartAttention.forward | (
self,
hidden_states: torch.Tensor,
key_value_states: Optional[torch.Tensor] = None,
past_key_value: Optional[Tuple[torch.Tensor]] = None,
attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
output_attentions: bool = Fal... | Input shape: Batch x Time x Channel | Input shape: Batch x Time x Channel | def forward(
self,
hidden_states: torch.Tensor,
key_value_states: Optional[torch.Tensor] = None,
past_key_value: Optional[Tuple[torch.Tensor]] = None,
attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
output_attentions:... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
":",
"torch",
".",
"Tensor",
",",
"key_value_states",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
"None",
",",
"past_key_value",
":",
"Optional",
"[",
"Tuple",
"[",
"torch",
".",
"Tensor",
... | [
156,
4
] | [
265,
65
] | python | en | ['en', 'pl', 'en'] | True |
BartEncoderLayer.forward | (
self,
hidden_states: torch.Tensor,
attention_mask: torch.Tensor,
layer_head_mask: torch.Tensor,
output_attentions: bool = False,
) |
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`torch.FloatTensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
... |
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`torch.FloatTensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
... | def forward(
self,
hidden_states: torch.Tensor,
attention_mask: torch.Tensor,
layer_head_mask: torch.Tensor,
output_attentions: bool = False,
):
"""
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
":",
"torch",
".",
"Tensor",
",",
"attention_mask",
":",
"torch",
".",
"Tensor",
",",
"layer_head_mask",
":",
"torch",
".",
"Tensor",
",",
"output_attentions",
":",
"bool",
"=",
"False",
",",
")",
":",
... | [
285,
4
] | [
333,
22
] | python | en | ['en', 'error', 'th'] | False |
BartDecoderLayer.forward | (
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
encoder_layer_head_mask... |
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`torch.FloatTensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
... |
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`torch.FloatTensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
... | def forward(
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
encoder_laye... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
":",
"torch",
".",
"Tensor",
",",
"attention_mask",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_hidden_states",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
... | [
363,
4
] | [
449,
22
] | python | en | ['en', 'error', 'th'] | False |
BartEncoder.forward | (
self,
input_ids=None,
attention_mask=None,
head_mask=None,
inputs_embeds=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
) | r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using :class:`~transfor... | r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it. | def forward(
self,
input_ids=None,
attention_mask=None,
head_mask=None,
inputs_embeds=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
):
r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:... | [
"def",
"forward",
"(",
"self",
",",
"input_ids",
"=",
"None",
",",
"attention_mask",
"=",
"None",
",",
"head_mask",
"=",
"None",
",",
"inputs_embeds",
"=",
"None",
",",
"output_attentions",
"=",
"None",
",",
"output_hidden_states",
"=",
"None",
",",
"return_... | [
684,
4
] | [
812,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
BartDecoder.forward | (
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
head_mask=None,
encoder_head_mask=None,
past_key_values=None,
inputs_embeds=None,
use_cache=None,
output_attentions=None,
... | r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using :class:`~transfor... | r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it. | def forward(
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
head_mask=None,
encoder_head_mask=None,
past_key_values=None,
inputs_embeds=None,
use_cache=None,
output_attentions=Non... | [
"def",
"forward",
"(",
"self",
",",
"input_ids",
"=",
"None",
",",
"attention_mask",
"=",
"None",
",",
"encoder_hidden_states",
"=",
"None",
",",
"encoder_attention_mask",
"=",
"None",
",",
"head_mask",
"=",
"None",
",",
"encoder_head_mask",
"=",
"None",
",",
... | [
870,
4
] | [
1077,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
BartForCausalLM.forward | (
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
head_mask=None,
encoder_head_mask=None,
past_key_values=None,
inputs_embeds=None,
labels=None,
use_cache=None,
output_atte... | r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using :class:`~transfor... | r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it. | def forward(
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
head_mask=None,
encoder_head_mask=None,
past_key_values=None,
inputs_embeds=None,
labels=None,
use_cache=None,
... | [
"def",
"forward",
"(",
"self",
",",
"input_ids",
"=",
"None",
",",
"attention_mask",
"=",
"None",
",",
"encoder_hidden_states",
"=",
"None",
",",
"encoder_attention_mask",
"=",
"None",
",",
"head_mask",
"=",
"None",
",",
"encoder_head_mask",
"=",
"None",
",",
... | [
1623,
4
] | [
1758,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
RobertaConfig.__init__ | (self, pad_token_id=1, bos_token_id=0, eos_token_id=2, **kwargs) | Constructs RobertaConfig. | Constructs RobertaConfig. | def __init__(self, pad_token_id=1, bos_token_id=0, eos_token_id=2, **kwargs):
"""Constructs RobertaConfig."""
super().__init__(pad_token_id=pad_token_id, bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs) | [
"def",
"__init__",
"(",
"self",
",",
"pad_token_id",
"=",
"1",
",",
"bos_token_id",
"=",
"0",
",",
"eos_token_id",
"=",
"2",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"pad_token_id",
"=",
"pad_token_id",
",",
"bos_toke... | [
61,
4
] | [
63,
115
] | python | ca | ['en', 'ca', 'it'] | False |
test_reproducing_states | (hass, caplog) | Test reproducing Fan states. | Test reproducing Fan states. | async def test_reproducing_states(hass, caplog):
"""Test reproducing Fan states."""
hass.states.async_set("fan.entity_off", "off", {})
hass.states.async_set("fan.entity_on", "on", {})
hass.states.async_set("fan.entity_speed", "on", {"speed": "high"})
hass.states.async_set("fan.entity_oscillating", "... | [
"async",
"def",
"test_reproducing_states",
"(",
"hass",
",",
"caplog",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"fan.entity_off\"",
",",
"\"off\"",
",",
"{",
"}",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"fan.entity_on\"",
",",
... | [
6,
0
] | [
86,
67
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the flo component. | Set up the flo component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the flo component."""
hass.data[DOMAIN] = {}
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"return",
"True"
] | [
24,
0
] | [
27,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up flo from a config entry. | Set up flo from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up flo from a config entry."""
session = async_get_clientsession(hass)
hass.data[DOMAIN][entry.entry_id] = {}
try:
hass.data[DOMAIN][entry.entry_id][CLIENT] = client = await async_get_api(
entry.data[CONF_US... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"session",
"=",
"async_get_clientsession",
"(",
"hass",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"=... | [
30,
0
] | [
59,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
62,
0
] | [
75,
20
] | python | en | ['en', 'es', 'en'] | True |
get_coap_context | (hass) | Get CoAP context to be used in all Shelly devices. | Get CoAP context to be used in all Shelly devices. | async def get_coap_context(hass):
"""Get CoAP context to be used in all Shelly devices."""
context = aioshelly.COAP()
await context.initialize()
@callback
def shutdown_listener(ev):
context.close()
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, shutdown_listener)
return cont... | [
"async",
"def",
"get_coap_context",
"(",
"hass",
")",
":",
"context",
"=",
"aioshelly",
".",
"COAP",
"(",
")",
"await",
"context",
".",
"initialize",
"(",
")",
"@",
"callback",
"def",
"shutdown_listener",
"(",
"ev",
")",
":",
"context",
".",
"close",
"("... | [
42,
0
] | [
53,
18
] | python | en | ['en', 'en', 'en'] | True |
get_device_name | (device) | Naming for device. | Naming for device. | def get_device_name(device):
"""Naming for device."""
return device.settings["name"] or device.settings["device"]["hostname"] | [
"def",
"get_device_name",
"(",
"device",
")",
":",
"return",
"device",
".",
"settings",
"[",
"\"name\"",
"]",
"or",
"device",
".",
"settings",
"[",
"\"device\"",
"]",
"[",
"\"hostname\"",
"]"
] | [
56,
0
] | [
58,
75
] | python | en | ['da', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the Shelly component. | Set up the Shelly component. | async def async_setup(hass: HomeAssistant, config: dict):
"""Set up the Shelly component."""
hass.data[DOMAIN] = {DATA_CONFIG_ENTRY: {}}
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"DATA_CONFIG_ENTRY",
":",
"{",
"}",
"}",
"return",
"True"
] | [
61,
0
] | [
64,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Shelly from a config entry. | Set up Shelly from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Shelly from a config entry."""
temperature_unit = "C" if hass.config.units.is_metric else "F"
ip_address = await hass.async_add_executor_job(gethostbyname, entry.data[CONF_HOST])
options = aioshelly.ConnectionOptions(
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"temperature_unit",
"=",
"\"C\"",
"if",
"hass",
".",
"config",
".",
"units",
".",
"is_metric",
"else",
"\"F\"",
"ip_address",
"=",
"await",
"h... | [
67,
0
] | [
107,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
213,
0
] | [
227,
20
] | python | en | ['en', 'es', 'en'] | True |
ShellyDeviceWrapper.__init__ | (self, hass, entry, device: aioshelly.Device) | Initialize the Shelly device wrapper. | Initialize the Shelly device wrapper. | def __init__(self, hass, entry, device: aioshelly.Device):
"""Initialize the Shelly device wrapper."""
sleep_mode = device.settings.get("sleep_mode")
if sleep_mode:
sleep_period = sleep_mode["period"]
if sleep_mode["unit"] == "h":
sleep_period *= 60 # ho... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"entry",
",",
"device",
":",
"aioshelly",
".",
"Device",
")",
":",
"sleep_mode",
"=",
"device",
".",
"settings",
".",
"get",
"(",
"\"sleep_mode\"",
")",
"if",
"sleep_mode",
":",
"sleep_period",
"=",
"slee... | [
113,
4
] | [
140,
66
] | python | en | ['en', 'en', 'en'] | True |
ShellyDeviceWrapper._async_update_data | (self) | Fetch data. | Fetch data. | async def _async_update_data(self):
"""Fetch data."""
_LOGGER.debug("Polling Shelly Device - %s", self.name)
try:
async with async_timeout.timeout(
POLLING_TIMEOUT_MULTIPLIER
* self.device.settings["coiot"]["update_period"]
):
... | [
"async",
"def",
"_async_update_data",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Polling Shelly Device - %s\"",
",",
"self",
".",
"name",
")",
"try",
":",
"async",
"with",
"async_timeout",
".",
"timeout",
"(",
"POLLING_TIMEOUT_MULTIPLIER",
"*",
"sel... | [
142,
4
] | [
152,
81
] | python | cy | ['de', 'cy', 'en'] | False |
ShellyDeviceWrapper.model | (self) | Model of the device. | Model of the device. | def model(self):
"""Model of the device."""
return self.device.settings["device"]["type"] | [
"def",
"model",
"(",
"self",
")",
":",
"return",
"self",
".",
"device",
".",
"settings",
"[",
"\"device\"",
"]",
"[",
"\"type\"",
"]"
] | [
155,
4
] | [
157,
53
] | python | en | ['en', 'en', 'en'] | True |
ShellyDeviceWrapper.mac | (self) | Mac address of the device. | Mac address of the device. | def mac(self):
"""Mac address of the device."""
return self.device.settings["device"]["mac"] | [
"def",
"mac",
"(",
"self",
")",
":",
"return",
"self",
".",
"device",
".",
"settings",
"[",
"\"device\"",
"]",
"[",
"\"mac\"",
"]"
] | [
160,
4
] | [
162,
52
] | python | en | ['en', 'en', 'en'] | True |
ShellyDeviceWrapper.async_setup | (self) | Set up the wrapper. | Set up the wrapper. | async def async_setup(self):
"""Set up the wrapper."""
dev_reg = await device_registry.async_get_registry(self.hass)
model_type = self.device.settings["device"]["type"]
dev_reg.async_get_or_create(
config_entry_id=self.entry.entry_id,
name=self.name,
c... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
":",
"dev_reg",
"=",
"await",
"device_registry",
".",
"async_get_registry",
"(",
"self",
".",
"hass",
")",
"model_type",
"=",
"self",
".",
"device",
".",
"settings",
"[",
"\"device\"",
"]",
"[",
"\"type\"",
... | [
164,
4
] | [
177,
9
] | python | en | ['en', 'en', 'en'] | True |
ShellyDeviceWrapper.shutdown | (self) | Shutdown the wrapper. | Shutdown the wrapper. | def shutdown(self):
"""Shutdown the wrapper."""
self.device.shutdown() | [
"def",
"shutdown",
"(",
"self",
")",
":",
"self",
".",
"device",
".",
"shutdown",
"(",
")"
] | [
179,
4
] | [
181,
30
] | python | en | ['en', 'it', 'en'] | True |
ShellyDeviceRestWrapper.__init__ | (self, hass, device: aioshelly.Device) | Initialize the Shelly device wrapper. | Initialize the Shelly device wrapper. | def __init__(self, hass, device: aioshelly.Device):
"""Initialize the Shelly device wrapper."""
super().__init__(
hass,
_LOGGER,
name=get_device_name(device),
update_interval=timedelta(seconds=REST_SENSORS_UPDATE_INTERVAL),
)
self.device =... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"device",
":",
"aioshelly",
".",
"Device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hass",
",",
"_LOGGER",
",",
"name",
"=",
"get_device_name",
"(",
"device",
")",
",",
"update_interval",
"="... | [
187,
4
] | [
196,
28
] | python | en | ['en', 'en', 'en'] | True |
ShellyDeviceRestWrapper._async_update_data | (self) | Fetch data. | Fetch data. | async def _async_update_data(self):
"""Fetch data."""
try:
async with async_timeout.timeout(5):
_LOGGER.debug("REST update for %s", get_device_name(self.device))
return await self.device.update_status()
except OSError as err:
raise update_c... | [
"async",
"def",
"_async_update_data",
"(",
"self",
")",
":",
"try",
":",
"async",
"with",
"async_timeout",
".",
"timeout",
"(",
"5",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"REST update for %s\"",
",",
"get_device_name",
"(",
"self",
".",
"device",
")",
... | [
198,
4
] | [
205,
81
] | python | cy | ['de', 'cy', 'en'] | False |
ShellyDeviceRestWrapper.mac | (self) | Mac address of the device. | Mac address of the device. | def mac(self):
"""Mac address of the device."""
return self.device.settings["device"]["mac"] | [
"def",
"mac",
"(",
"self",
")",
":",
"return",
"self",
".",
"device",
".",
"settings",
"[",
"\"device\"",
"]",
"[",
"\"mac\"",
"]"
] | [
208,
4
] | [
210,
52
] | python | en | ['en', 'en', 'en'] | True |
ROIPool.__init__ | (self, output_size, spatial_scale) |
:param output_size: e.g. (3,3)
:param spatial_scale: e.g. 1.0/16
|
:param output_size: e.g. (3,3)
:param spatial_scale: e.g. 1.0/16
| def __init__(self, output_size, spatial_scale):
"""
:param output_size: e.g. (3,3)
:param spatial_scale: e.g. 1.0/16
"""
super(ROIPool, self).__init__()
self.output_size = output_size
self.spatial_scale = spatial_scale | [
"def",
"__init__",
"(",
"self",
",",
"output_size",
",",
"spatial_scale",
")",
":",
"super",
"(",
"ROIPool",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"output_size",
"=",
"output_size",
"self",
".",
"spatial_scale",
"=",
"spatial_scale"
] | [
49,
4
] | [
56,
42
] | python | en | ['en', 'error', 'th'] | False |
ROIPool.forward | (self, input, rois) |
:param input: the input features [B C H W]
:param rois: [k, 5] : (im_index, x1, y1, x2, y2)
:return: pooled features (K C H W), K = k
|
:param input: the input features [B C H W]
:param rois: [k, 5] : (im_index, x1, y1, x2, y2)
:return: pooled features (K C H W), K = k
| def forward(self, input, rois):
"""
:param input: the input features [B C H W]
:param rois: [k, 5] : (im_index, x1, y1, x2, y2)
:return: pooled features (K C H W), K = k
"""
return roi_pool(input.float(), rois.float(), self.output_size, self.spatial_scale) | [
"def",
"forward",
"(",
"self",
",",
"input",
",",
"rois",
")",
":",
"return",
"roi_pool",
"(",
"input",
".",
"float",
"(",
")",
",",
"rois",
".",
"float",
"(",
")",
",",
"self",
".",
"output_size",
",",
"self",
".",
"spatial_scale",
")"
] | [
58,
4
] | [
64,
90
] | python | en | ['en', 'error', 'th'] | False |
HomematicipAuth.__init__ | (self, hass, config) | Initialize HomematicIP Cloud client registration. | Initialize HomematicIP Cloud client registration. | def __init__(self, hass, config) -> None:
"""Initialize HomematicIP Cloud client registration."""
self.hass = hass
self.config = config
self.auth = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"config",
"=",
"config",
"self",
".",
"auth",
"=",
"None"
] | [
24,
4
] | [
28,
24
] | python | en | ['nl', 'fr', 'en'] | False |
HomematicipAuth.async_setup | (self) | Connect to HomematicIP for registration. | Connect to HomematicIP for registration. | async def async_setup(self) -> bool:
"""Connect to HomematicIP for registration."""
try:
self.auth = await self.get_auth(
self.hass, self.config.get(HMIPC_HAPID), self.config.get(HMIPC_PIN)
)
return self.auth is not None
except HmipcConnectionE... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"auth",
"=",
"await",
"self",
".",
"get_auth",
"(",
"self",
".",
"hass",
",",
"self",
".",
"config",
".",
"get",
"(",
"HMIPC_HAPID",
")",
",",
"self",
".",... | [
30,
4
] | [
38,
24
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAuth.async_checkbutton | (self) | Check blue butten has been pressed. | Check blue butten has been pressed. | async def async_checkbutton(self) -> bool:
"""Check blue butten has been pressed."""
try:
return await self.auth.isRequestAcknowledged()
except HmipConnectionError:
return False | [
"async",
"def",
"async_checkbutton",
"(",
"self",
")",
"->",
"bool",
":",
"try",
":",
"return",
"await",
"self",
".",
"auth",
".",
"isRequestAcknowledged",
"(",
")",
"except",
"HmipConnectionError",
":",
"return",
"False"
] | [
40,
4
] | [
45,
24
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAuth.async_register | (self) | Register client at HomematicIP. | Register client at HomematicIP. | async def async_register(self):
"""Register client at HomematicIP."""
try:
authtoken = await self.auth.requestAuthToken()
await self.auth.confirmAuthToken(authtoken)
return authtoken
except HmipConnectionError:
return False | [
"async",
"def",
"async_register",
"(",
"self",
")",
":",
"try",
":",
"authtoken",
"=",
"await",
"self",
".",
"auth",
".",
"requestAuthToken",
"(",
")",
"await",
"self",
".",
"auth",
".",
"confirmAuthToken",
"(",
"authtoken",
")",
"return",
"authtoken",
"ex... | [
47,
4
] | [
54,
24
] | python | en | ['da', 'en', 'en'] | True |
HomematicipAuth.get_auth | (self, hass: HomeAssistantType, hapid, pin) | Create a HomematicIP access point object. | Create a HomematicIP access point object. | async def get_auth(self, hass: HomeAssistantType, hapid, pin):
"""Create a HomematicIP access point object."""
auth = AsyncAuth(hass.loop, async_get_clientsession(hass))
try:
await auth.init(hapid)
if pin:
auth.pin = pin
await auth.connectionRe... | [
"async",
"def",
"get_auth",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
",",
"hapid",
",",
"pin",
")",
":",
"auth",
"=",
"AsyncAuth",
"(",
"hass",
".",
"loop",
",",
"async_get_clientsession",
"(",
"hass",
")",
")",
"try",
":",
"await",
"auth",
... | [
56,
4
] | [
66,
19
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.__init__ | (self, hass: HomeAssistantType, config_entry: ConfigEntry) | Initialize HomematicIP Cloud connection. | Initialize HomematicIP Cloud connection. | def __init__(self, hass: HomeAssistantType, config_entry: ConfigEntry) -> None:
"""Initialize HomematicIP Cloud connection."""
self.hass = hass
self.config_entry = config_entry
self.home = None
self._ws_close_requested = False
self._retry_task = None
self._tries ... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"config_entry",
"=",
"config_entry",
"self",
".",
"home",
"=",
"None",
... | [
72,
4
] | [
83,
45
] | python | en | ['nl', 'en', 'en'] | True |
HomematicipHAP.async_setup | (self, tries: int = 0) | Initialize connection. | Initialize connection. | async def async_setup(self, tries: int = 0) -> bool:
"""Initialize connection."""
try:
self.home = await self.get_hap(
self.hass,
self.config_entry.data.get(HMIPC_HAPID),
self.config_entry.data.get(HMIPC_AUTHTOKEN),
self.config_... | [
"async",
"def",
"async_setup",
"(",
"self",
",",
"tries",
":",
"int",
"=",
"0",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"home",
"=",
"await",
"self",
".",
"get_hap",
"(",
"self",
".",
"hass",
",",
"self",
".",
"config_entry",
".",
"data",
... | [
85,
4
] | [
110,
19
] | python | en | ['en', 'en', 'en'] | False |
HomematicipHAP.async_update | (self, *args, **kwargs) | Async update the home device.
Triggered when the HMIP HOME_CHANGED event has fired.
There are several occasions for this event to happen.
1. We are interested to check whether the access point
is still connected. If not, entity state changes cannot
be forwarded to hass. So if ac... | Async update the home device. | def async_update(self, *args, **kwargs) -> None:
"""Async update the home device.
Triggered when the HMIP HOME_CHANGED event has fired.
There are several occasions for this event to happen.
1. We are interested to check whether the access point
is still connected. If not, entity... | [
"def",
"async_update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"home",
".",
"connected",
":",
"_LOGGER",
".",
"error",
"(",
"\"HMIP access point has lost connection with the cloud\"",
")",
"se... | [
113,
4
] | [
138,
46
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.async_create_entity | (self, *args, **kwargs) | Create an entity or a group. | Create an entity or a group. | def async_create_entity(self, *args, **kwargs) -> None:
"""Create an entity or a group."""
is_device = EventType(kwargs["event_type"]) == EventType.DEVICE_ADDED
self.hass.async_create_task(self.async_create_entity_lazy(is_device)) | [
"def",
"async_create_entity",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"is_device",
"=",
"EventType",
"(",
"kwargs",
"[",
"\"event_type\"",
"]",
")",
"==",
"EventType",
".",
"DEVICE_ADDED",
"self",
".",
"hass",
".",... | [
141,
4
] | [
144,
77
] | python | en | ['en', 'ga', 'en'] | True |
HomematicipHAP.async_create_entity_lazy | (self, is_device=True) | Delay entity creation to allow the user to enter a device name. | Delay entity creation to allow the user to enter a device name. | async def async_create_entity_lazy(self, is_device=True) -> None:
"""Delay entity creation to allow the user to enter a device name."""
if is_device:
await asyncio.sleep(30)
await self.hass.config_entries.async_reload(self.config_entry.entry_id) | [
"async",
"def",
"async_create_entity_lazy",
"(",
"self",
",",
"is_device",
"=",
"True",
")",
"->",
"None",
":",
"if",
"is_device",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"30",
")",
"await",
"self",
".",
"hass",
".",
"config_entries",
".",
"async_reloa... | [
146,
4
] | [
150,
79
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.get_state | (self) | Update HMIP state and tell Home Assistant. | Update HMIP state and tell Home Assistant. | async def get_state(self) -> None:
"""Update HMIP state and tell Home Assistant."""
await self.home.get_current_state()
self.update_all() | [
"async",
"def",
"get_state",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"home",
".",
"get_current_state",
"(",
")",
"self",
".",
"update_all",
"(",
")"
] | [
152,
4
] | [
155,
25
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.get_state_finished | (self, future) | Execute when get_state coroutine has finished. | Execute when get_state coroutine has finished. | def get_state_finished(self, future) -> None:
"""Execute when get_state coroutine has finished."""
try:
future.result()
except HmipConnectionError:
# Somehow connection could not recover. Will disconnect and
# so reconnect loop is taking over.
_LOG... | [
"def",
"get_state_finished",
"(",
"self",
",",
"future",
")",
"->",
"None",
":",
"try",
":",
"future",
".",
"result",
"(",
")",
"except",
"HmipConnectionError",
":",
"# Somehow connection could not recover. Will disconnect and",
"# so reconnect loop is taking over.",
"_LO... | [
157,
4
] | [
165,
67
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.set_all_to_unavailable | (self) | Set all devices to unavailable and tell Home Assistant. | Set all devices to unavailable and tell Home Assistant. | def set_all_to_unavailable(self) -> None:
"""Set all devices to unavailable and tell Home Assistant."""
for device in self.home.devices:
device.unreach = True
self.update_all() | [
"def",
"set_all_to_unavailable",
"(",
"self",
")",
"->",
"None",
":",
"for",
"device",
"in",
"self",
".",
"home",
".",
"devices",
":",
"device",
".",
"unreach",
"=",
"True",
"self",
".",
"update_all",
"(",
")"
] | [
167,
4
] | [
171,
25
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.update_all | (self) | Signal all devices to update their state. | Signal all devices to update their state. | def update_all(self) -> None:
"""Signal all devices to update their state."""
for device in self.home.devices:
device.fire_update_event() | [
"def",
"update_all",
"(",
"self",
")",
"->",
"None",
":",
"for",
"device",
"in",
"self",
".",
"home",
".",
"devices",
":",
"device",
".",
"fire_update_event",
"(",
")"
] | [
173,
4
] | [
176,
38
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.async_connect | (self) | Start WebSocket connection. | Start WebSocket connection. | async def async_connect(self) -> None:
"""Start WebSocket connection."""
tries = 0
while True:
retry_delay = 2 ** min(tries, 8)
try:
await self.home.get_current_state()
hmip_events = await self.home.enable_events()
tries = ... | [
"async",
"def",
"async_connect",
"(",
"self",
")",
"->",
"None",
":",
"tries",
"=",
"0",
"while",
"True",
":",
"retry_delay",
"=",
"2",
"**",
"min",
"(",
"tries",
",",
"8",
")",
"try",
":",
"await",
"self",
".",
"home",
".",
"get_current_state",
"(",... | [
178,
4
] | [
208,
21
] | python | en | ['en', 'da', 'en'] | True |
HomematicipHAP.async_reset | (self) | Close the websocket connection. | Close the websocket connection. | async def async_reset(self) -> bool:
"""Close the websocket connection."""
self._ws_close_requested = True
if self._retry_task is not None:
self._retry_task.cancel()
await self.home.disable_events()
_LOGGER.info("Closed connection to HomematicIP cloud server")
... | [
"async",
"def",
"async_reset",
"(",
"self",
")",
"->",
"bool",
":",
"self",
".",
"_ws_close_requested",
"=",
"True",
"if",
"self",
".",
"_retry_task",
"is",
"not",
"None",
":",
"self",
".",
"_retry_task",
".",
"cancel",
"(",
")",
"await",
"self",
".",
... | [
210,
4
] | [
222,
19
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.shutdown | (self, event) | Wrap the call to async_reset.
Used as an argument to EventBus.async_listen_once.
| Wrap the call to async_reset. | def shutdown(self, event) -> None:
"""Wrap the call to async_reset.
Used as an argument to EventBus.async_listen_once.
"""
self.hass.async_create_task(self.async_reset())
_LOGGER.debug(
"Reset connection to access point id %s", self.config_entry.unique_id
) | [
"def",
"shutdown",
"(",
"self",
",",
"event",
")",
"->",
"None",
":",
"self",
".",
"hass",
".",
"async_create_task",
"(",
"self",
".",
"async_reset",
"(",
")",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Reset connection to access point id %s\"",
",",
"self",
".",... | [
225,
4
] | [
233,
9
] | python | en | ['en', 'en', 'en'] | True |
HomematicipHAP.get_hap | (
self, hass: HomeAssistantType, hapid: str, authtoken: str, name: str
) | Create a HomematicIP access point object. | Create a HomematicIP access point object. | async def get_hap(
self, hass: HomeAssistantType, hapid: str, authtoken: str, name: str
) -> AsyncHome:
"""Create a HomematicIP access point object."""
home = AsyncHome(hass.loop, async_get_clientsession(hass))
home.name = name
# Use the title of the config entry as title fo... | [
"async",
"def",
"get_hap",
"(",
"self",
",",
"hass",
":",
"HomeAssistantType",
",",
"hapid",
":",
"str",
",",
"authtoken",
":",
"str",
",",
"name",
":",
"str",
")",
"->",
"AsyncHome",
":",
"home",
"=",
"AsyncHome",
"(",
"hass",
".",
"loop",
",",
"asy... | [
235,
4
] | [
256,
19
] | python | en | ['en', 'en', 'en'] | True |
_make_causal_mask | (input_ids_shape: tf.TensorShape, past_key_values_length: int = 0) |
Make causal mask used for bi-directional self-attention.
|
Make causal mask used for bi-directional self-attention.
| def _make_causal_mask(input_ids_shape: tf.TensorShape, past_key_values_length: int = 0):
"""
Make causal mask used for bi-directional self-attention.
"""
bsz, tgt_len = input_ids_shape
mask = tf.ones((tgt_len, tgt_len)) * LARGE_NEGATIVE
mask_cond = tf.range(shape_list(mask)[-1])
mask = tf.w... | [
"def",
"_make_causal_mask",
"(",
"input_ids_shape",
":",
"tf",
".",
"TensorShape",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"tgt_len",
"=",
"input_ids_shape",
"mask",
"=",
"tf",
".",
"ones",
"(",
"(",
"tgt_len",
",",
"tgt_... | [
85,
0
] | [
98,
58
] | python | en | ['en', 'error', 'th'] | False |
_expand_mask | (mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0) |
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
| def _expand_mask(mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0):
"""
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
"""
src_len = shape_list(mask)[1]
tgt_len = tgt_len if tgt_len is not None else src_len
one_cst = tf.consta... | [
"def",
"_expand_mask",
"(",
"mask",
":",
"tf",
".",
"Tensor",
",",
"tgt_len",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"src_len",
"=",
"shape_list",
"(",
"mask",
")",
"[",
"1",
"]",... | [
102,
0
] | [
112,
53
] | python | en | ['en', 'error', 'th'] | False |
TFMarianSinusoidalPositionalEmbedding.build | (self, input_shape: tf.TensorShape) |
Build shared token embedding layer Shared weights logic adapted from
https://github.com/tensorflow/models/blob/a009f4fb9d2fc4949e32192a944688925ef78659/official/transformer/v2/embedding_layer.py#L24
|
Build shared token embedding layer Shared weights logic adapted from
https://github.com/tensorflow/models/blob/a009f4fb9d2fc4949e32192a944688925ef78659/official/transformer/v2/embedding_layer.py#L24
| def build(self, input_shape: tf.TensorShape):
"""
Build shared token embedding layer Shared weights logic adapted from
https://github.com/tensorflow/models/blob/a009f4fb9d2fc4949e32192a944688925ef78659/official/transformer/v2/embedding_layer.py#L24
"""
weight = self._init_weight... | [
"def",
"build",
"(",
"self",
",",
"input_shape",
":",
"tf",
".",
"TensorShape",
")",
":",
"weight",
"=",
"self",
".",
"_init_weight",
"(",
"self",
".",
"num_positions",
",",
"self",
".",
"embedding_dim",
")",
"self",
".",
"weight",
"=",
"self",
".",
"a... | [
127,
4
] | [
143,
34
] | python | en | ['en', 'error', 'th'] | False |
TFMarianSinusoidalPositionalEmbedding._init_weight | (n_pos: int, dim: int) |
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
the 2nd half of the vector. [dim // 2:]
|
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
the 2nd half of the vector. [dim // 2:]
| def _init_weight(n_pos: int, dim: int):
"""
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
the 2nd half of the vector. [dim // 2:]
"""
position_enc = np.array(
[[pos / np.power(10000, 2 * (j // 2) / dim) ... | [
"def",
"_init_weight",
"(",
"n_pos",
":",
"int",
",",
"dim",
":",
"int",
")",
":",
"position_enc",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"pos",
"/",
"np",
".",
"power",
"(",
"10000",
",",
"2",
"*",
"(",
"j",
"//",
"2",
")",
"/",
"dim",
")",... | [
146,
4
] | [
160,
20
] | python | en | ['en', 'error', 'th'] | False |
TFMarianSinusoidalPositionalEmbedding.call | (self, input_shape: tf.TensorShape, past_key_values_length: int = 0) | Input is expected to be of size [bsz x seqlen]. | Input is expected to be of size [bsz x seqlen]. | def call(self, input_shape: tf.TensorShape, past_key_values_length: int = 0):
"""Input is expected to be of size [bsz x seqlen]."""
bsz, seq_len = input_shape[:2]
positions = tf.range(past_key_values_length, seq_len + past_key_values_length, delta=1, name="range")
return tf.gather(self.... | [
"def",
"call",
"(",
"self",
",",
"input_shape",
":",
"tf",
".",
"TensorShape",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"seq_len",
"=",
"input_shape",
"[",
":",
"2",
"]",
"positions",
"=",
"tf",
".",
"range",
"(",
"p... | [
162,
4
] | [
167,
48
] | python | en | ['en', 'en', 'en'] | True |
TFMarianAttention.call | (
self,
hidden_states: tf.Tensor,
key_value_states: Optional[tf.Tensor] = None,
past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None,
attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
training=False,
) | Input shape: Batch x Time x Channel | Input shape: Batch x Time x Channel | def call(
self,
hidden_states: tf.Tensor,
key_value_states: Optional[tf.Tensor] = None,
past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None,
attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
training=False,
) -> Tupl... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
":",
"tf",
".",
"Tensor",
",",
"key_value_states",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"past_key_value",
":",
"Optional",
"[",
"Tuple",
"[",
"Tuple",
"[",
"tf",
".",
"Tenso... | [
201,
4
] | [
317,
56
] | python | en | ['en', 'pl', 'en'] | True |
TFMarianEncoderLayer.call | (self, hidden_states: tf.Tensor, attention_mask: tf.Tensor, layer_head_mask: tf.Tensor, training=False) |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
laye... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
laye... | def call(self, hidden_states: tf.Tensor, attention_mask: tf.Tensor, layer_head_mask: tf.Tensor, training=False):
"""
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
":",
"tf",
".",
"Tensor",
",",
"attention_mask",
":",
"tf",
".",
"Tensor",
",",
"layer_head_mask",
":",
"tf",
".",
"Tensor",
",",
"training",
"=",
"False",
")",
":",
"residual",
"=",
"hidden_states",
"hid... | [
336,
4
] | [
371,
47
] | python | en | ['en', 'error', 'th'] | False |
TFMarianDecoderLayer.call | (
self,
hidden_states,
attention_mask: Optional[tf.Tensor] = None,
encoder_hidden_states: Optional[tf.Tensor] = None,
encoder_attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
encoder_layer_head_mask: Optional[tf.Tensor] = No... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
enco... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
enco... | def call(
self,
hidden_states,
attention_mask: Optional[tf.Tensor] = None,
encoder_hidden_states: Optional[tf.Tensor] = None,
encoder_attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
encoder_layer_head_mask: Optional[tf.Tens... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
",",
"attention_mask",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_hidden_states",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_attention_mask",
... | [
403,
4
] | [
478,
9
] | python | en | ['en', 'error', 'th'] | False |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Set up Meteo-France from legacy config file. | Set up Meteo-France from legacy config file. | async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""Set up Meteo-France from legacy config file."""
conf = config.get(DOMAIN)
if not conf:
return True
for city_conf in conf:
hass.async_create_task(
hass.config_entries.flow.async_init(
... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
"->",
"bool",
":",
"conf",
"=",
"config",
".",
"get",
"(",
"DOMAIN",
")",
"if",
"not",
"conf",
":",
"return",
"True",
"for",
"city_conf",
"in",
... | [
40,
0
] | [
53,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Set up an Meteo-France account from a config entry. | Set up an Meteo-France account from a config entry. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
"""Set up an Meteo-France account from a config entry."""
hass.data.setdefault(DOMAIN, {})
latitude = entry.data.get(CONF_LATITUDE)
client = MeteoFranceClient()
# Migrate from previous config
if not latitude:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"latitude",
"=",
"entry",
".",
"data",
".",
... | [
56,
0
] | [
179,
15
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.