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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
HomematicipCoverSlats.async_close_cover_tilt | (self, **kwargs) | Close the slats. | Close the slats. | async def async_close_cover_tilt(self, **kwargs) -> None:
"""Close the slats."""
await self._device.set_slats_level(HMIP_SLATS_CLOSED) | [
"async",
"def",
"async_close_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"set_slats_level",
"(",
"HMIP_SLATS_CLOSED",
")"
] | [
111,
4
] | [
113,
61
] | python | en | ['en', 'ca', 'en'] | True |
HomematicipCoverSlats.async_stop_cover_tilt | (self, **kwargs) | Stop the device if in motion. | Stop the device if in motion. | async def async_stop_cover_tilt(self, **kwargs) -> None:
"""Stop the device if in motion."""
await self._device.set_shutter_stop() | [
"async",
"def",
"async_stop_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"set_shutter_stop",
"(",
")"
] | [
115,
4
] | [
117,
45
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGarageDoorModule.current_cover_position | (self) | Return current position of cover. | Return current position of cover. | def current_cover_position(self) -> int:
"""Return current position of cover."""
door_state_to_position = {
DoorState.CLOSED: 0,
DoorState.OPEN: 100,
DoorState.VENTILATION_POSITION: 10,
DoorState.POSITION_UNKNOWN: None,
}
return door_state_... | [
"def",
"current_cover_position",
"(",
"self",
")",
"->",
"int",
":",
"door_state_to_position",
"=",
"{",
"DoorState",
".",
"CLOSED",
":",
"0",
",",
"DoorState",
".",
"OPEN",
":",
"100",
",",
"DoorState",
".",
"VENTILATION_POSITION",
":",
"10",
",",
"DoorStat... | [
124,
4
] | [
132,
65
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGarageDoorModule.is_closed | (self) | Return if the cover is closed. | Return if the cover is closed. | def is_closed(self) -> Optional[bool]:
"""Return if the cover is closed."""
return self._device.doorState == DoorState.CLOSED | [
"def",
"is_closed",
"(",
"self",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"return",
"self",
".",
"_device",
".",
"doorState",
"==",
"DoorState",
".",
"CLOSED"
] | [
135,
4
] | [
137,
57
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGarageDoorModule.async_open_cover | (self, **kwargs) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs) -> None:
"""Open the cover."""
await self._device.send_door_command(DoorCommand.OPEN) | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"send_door_command",
"(",
"DoorCommand",
".",
"OPEN",
")"
] | [
139,
4
] | [
141,
62
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGarageDoorModule.async_close_cover | (self, **kwargs) | Close the cover. | Close the cover. | async def async_close_cover(self, **kwargs) -> None:
"""Close the cover."""
await self._device.send_door_command(DoorCommand.CLOSE) | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"send_door_command",
"(",
"DoorCommand",
".",
"CLOSE",
")"
] | [
143,
4
] | [
145,
63
] | python | en | ['en', 'en', 'en'] | True |
HomematicipGarageDoorModule.async_stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover(self, **kwargs) -> None:
"""Stop the cover."""
await self._device.send_door_command(DoorCommand.STOP) | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"send_door_command",
"(",
"DoorCommand",
".",
"STOP",
")"
] | [
147,
4
] | [
149,
62
] | python | en | ['en', 'en', 'en'] | True |
HomematicipCoverShutterGroup.__init__ | (self, hap: HomematicipHAP, device, post: str = "ShutterGroup") | Initialize switching group. | Initialize switching group. | def __init__(self, hap: HomematicipHAP, device, post: str = "ShutterGroup") -> None:
"""Initialize switching group."""
device.modelType = f"HmIP-{post}"
super().__init__(hap, device, post) | [
"def",
"__init__",
"(",
"self",
",",
"hap",
":",
"HomematicipHAP",
",",
"device",
",",
"post",
":",
"str",
"=",
"\"ShutterGroup\"",
")",
"->",
"None",
":",
"device",
".",
"modelType",
"=",
"f\"HmIP-{post}\"",
"super",
"(",
")",
".",
"__init__",
"(",
"hap... | [
155,
4
] | [
158,
43
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Zigbee Home Automation switch from config entry. | Set up the Zigbee Home Automation switch from config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Zigbee Home Automation switch from config entry."""
entities_to_create = hass.data[DATA_ZHA][DOMAIN]
unsub = async_dispatcher_connect(
hass,
SIGNAL_ADD_ENTITIES,
functools.partial(
discove... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities_to_create",
"=",
"hass",
".",
"data",
"[",
"DATA_ZHA",
"]",
"[",
"DOMAIN",
"]",
"unsub",
"=",
"async_dispatcher_connect",
"(",
"hass",
",",
"S... | [
27,
0
] | [
38,
59
] | python | en | ['en', 'en', 'en'] | True |
BaseSwitch.__init__ | (self, *args, **kwargs) | Initialize the ZHA switch. | Initialize the ZHA switch. | def __init__(self, *args, **kwargs):
"""Initialize the ZHA switch."""
self._on_off_channel = None
self._state = None
super().__init__(*args, **kwargs) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_on_off_channel",
"=",
"None",
"self",
".",
"_state",
"=",
"None",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
"... | [
44,
4
] | [
48,
41
] | python | en | ['en', 'pl', 'en'] | True |
BaseSwitch.is_on | (self) | Return if the switch is on based on the statemachine. | Return if the switch is on based on the statemachine. | def is_on(self) -> bool:
"""Return if the switch is on based on the statemachine."""
if self._state is None:
return False
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_state",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"_state"
] | [
51,
4
] | [
55,
26
] | python | en | ['en', 'en', 'en'] | True |
BaseSwitch.async_turn_on | (self, **kwargs) | Turn the entity on. | Turn the entity on. | async def async_turn_on(self, **kwargs) -> None:
"""Turn the entity on."""
result = await self._on_off_channel.on()
if not isinstance(result, list) or result[1] is not Status.SUCCESS:
return
self._state = True
self.async_write_ha_state() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"result",
"=",
"await",
"self",
".",
"_on_off_channel",
".",
"on",
"(",
")",
"if",
"not",
"isinstance",
"(",
"result",
",",
"list",
")",
"or",
"result",
"[... | [
57,
4
] | [
63,
35
] | python | en | ['en', 'en', 'en'] | True |
BaseSwitch.async_turn_off | (self, **kwargs) | Turn the entity off. | Turn the entity off. | async def async_turn_off(self, **kwargs) -> None:
"""Turn the entity off."""
result = await self._on_off_channel.off()
if not isinstance(result, list) or result[1] is not Status.SUCCESS:
return
self._state = False
self.async_write_ha_state() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"result",
"=",
"await",
"self",
".",
"_on_off_channel",
".",
"off",
"(",
")",
"if",
"not",
"isinstance",
"(",
"result",
",",
"list",
")",
"or",
"result",
... | [
65,
4
] | [
71,
35
] | python | en | ['en', 'en', 'en'] | True |
_mock_config_entry_with_options_populated | () | Create a mock config entry with options populated. | Create a mock config entry with options populated. | def _mock_config_entry_with_options_populated():
"""Create a mock config entry with options populated."""
return MockConfigEntry(
domain=DOMAIN,
data={CONF_NAME: "mock_name", CONF_PORT: 12345},
options={
"filter": {
"include_domains": [
"fa... | [
"def",
"_mock_config_entry_with_options_populated",
"(",
")",
":",
"return",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_NAME",
":",
"\"mock_name\"",
",",
"CONF_PORT",
":",
"12345",
"}",
",",
"options",
"=",
"{",
"\"filter\"",
... | [
10,
0
] | [
30,
5
] | python | en | ['en', 'en', 'en'] | True |
test_user_form | (hass) | Test we can setup a new instance. | Test we can setup a new instance. | async def test_user_form(hass):
"""Test we can setup a new instance."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
asse... | [
"async",
"def",
"test_user_form",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",... | [
33,
0
] | [
81,
48
] | python | en | ['en', 'en', 'en'] | True |
test_import | (hass) | Test we can import instance. | Test we can import instance. | async def test_import(hass):
"""Test we can import instance."""
await setup.async_setup_component(hass, "persistent_notification", {})
entry = MockConfigEntry(
domain=DOMAIN, data={CONF_NAME: "mock_name", CONF_PORT: 12345}
)
entry.add_to_hass(hass)
await hass.async_block_till_done()
... | [
"async",
"def",
"test_import",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
... | [
84,
0
] | [
122,
48
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow_exclude_mode_advanced | (hass) | Test config flow options in exclude mode with advanced options. | Test config flow options in exclude mode with advanced options. | async def test_options_flow_exclude_mode_advanced(hass):
"""Test config flow options in exclude mode with advanced options."""
config_entry = _mock_config_entry_with_options_populated()
config_entry.add_to_hass(hass)
hass.states.async_set("climate.old", "off")
await hass.async_block_till_done()
... | [
"async",
"def",
"test_options_flow_exclude_mode_advanced",
"(",
"hass",
")",
":",
"config_entry",
"=",
"_mock_config_entry_with_options_populated",
"(",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"climate... | [
125,
0
] | [
173,
5
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow_exclude_mode_basic | (hass) | Test config flow options in exclude mode. | Test config flow options in exclude mode. | async def test_options_flow_exclude_mode_basic(hass):
"""Test config flow options in exclude mode."""
config_entry = _mock_config_entry_with_options_populated()
config_entry.add_to_hass(hass)
hass.states.async_set("climate.old", "off")
await hass.async_block_till_done()
result = await hass.co... | [
"async",
"def",
"test_options_flow_exclude_mode_basic",
"(",
"hass",
")",
":",
"config_entry",
"=",
"_mock_config_entry_with_options_populated",
"(",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"climate.ol... | [
176,
0
] | [
224,
5
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow_include_mode_basic | (hass) | Test config flow options in include mode. | Test config flow options in include mode. | async def test_options_flow_include_mode_basic(hass):
"""Test config flow options in include mode."""
config_entry = _mock_config_entry_with_options_populated()
config_entry.add_to_hass(hass)
hass.states.async_set("climate.old", "off")
hass.states.async_set("climate.new", "off")
await hass.as... | [
"async",
"def",
"test_options_flow_include_mode_basic",
"(",
"hass",
")",
":",
"config_entry",
"=",
"_mock_config_entry_with_options_populated",
"(",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"climate.ol... | [
227,
0
] | [
277,
5
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow_exclude_mode_with_cameras | (hass) | Test config flow options in exclude mode with cameras. | Test config flow options in exclude mode with cameras. | async def test_options_flow_exclude_mode_with_cameras(hass):
"""Test config flow options in exclude mode with cameras."""
config_entry = _mock_config_entry_with_options_populated()
config_entry.add_to_hass(hass)
hass.states.async_set("climate.old", "off")
hass.states.async_set("camera.native_h264"... | [
"async",
"def",
"test_options_flow_exclude_mode_with_cameras",
"(",
"hass",
")",
":",
"config_entry",
"=",
"_mock_config_entry_with_options_populated",
"(",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"cli... | [
280,
0
] | [
399,
5
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow_include_mode_with_cameras | (hass) | Test config flow options in include mode with cameras. | Test config flow options in include mode with cameras. | async def test_options_flow_include_mode_with_cameras(hass):
"""Test config flow options in include mode with cameras."""
config_entry = _mock_config_entry_with_options_populated()
config_entry.add_to_hass(hass)
hass.states.async_set("climate.old", "off")
hass.states.async_set("camera.native_h264"... | [
"async",
"def",
"test_options_flow_include_mode_with_cameras",
"(",
"hass",
")",
":",
"config_entry",
"=",
"_mock_config_entry_with_options_populated",
"(",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"cli... | [
402,
0
] | [
521,
5
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow_blocked_when_from_yaml | (hass) | Test config flow options. | Test config flow options. | async def test_options_flow_blocked_when_from_yaml(hass):
"""Test config flow options."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_NAME: "mock_name", CONF_PORT: 12345},
options={
"auto_start": True,
"filter": {
"include_domains": ... | [
"async",
"def",
"test_options_flow_blocked_when_from_yaml",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_NAME",
":",
"\"mock_name\"",
",",
"CONF_PORT",
":",
"12345",
"}",
",",
"options"... | [
524,
0
] | [
561,
74
] | python | en | ['en', 'fr', 'en'] | True |
test_options_flow_include_mode_basic_accessory | (hass) | Test config flow options in include mode with a single accessory. | Test config flow options in include mode with a single accessory. | async def test_options_flow_include_mode_basic_accessory(hass):
"""Test config flow options in include mode with a single accessory."""
config_entry = _mock_config_entry_with_options_populated()
config_entry.add_to_hass(hass)
hass.states.async_set("media_player.tv", "off")
hass.states.async_set("m... | [
"async",
"def",
"test_options_flow_include_mode_basic_accessory",
"(",
"hass",
")",
":",
"config_entry",
"=",
"_mock_config_entry_with_options_populated",
"(",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"... | [
564,
0
] | [
614,
5
] | python | en | ['en', 'en', 'en'] | True |
create_file | (path) | Create a test file. | Create a test file. | def create_file(path):
"""Create a test file."""
with open(path, "w") as test_file:
test_file.write("test") | [
"def",
"create_file",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"\"w\"",
")",
"as",
"test_file",
":",
"test_file",
".",
"write",
"(",
"\"test\"",
")"
] | [
17,
0
] | [
20,
31
] | python | en | ['en', 'sm', 'en'] | True |
remove_file | () | Remove test file. | Remove test file. | def remove_file():
"""Remove test file."""
yield
if os.path.isfile(TEST_FILE):
os.remove(TEST_FILE) | [
"def",
"remove_file",
"(",
")",
":",
"yield",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"TEST_FILE",
")",
":",
"os",
".",
"remove",
"(",
"TEST_FILE",
")"
] | [
24,
0
] | [
28,
28
] | python | en | ['en', 'it', 'en'] | True |
test_invalid_path | (hass) | Test that an invalid path is caught. | Test that an invalid path is caught. | async def test_invalid_path(hass):
"""Test that an invalid path is caught."""
config = {"sensor": {"platform": "filesize", CONF_FILE_PATHS: ["invalid_path"]}}
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids()) == 0 | [
"async",
"def",
"test_invalid_path",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"filesize\"",
",",
"CONF_FILE_PATHS",
":",
"[",
"\"invalid_path\"",
"]",
"}",
"}",
"assert",
"await",
"async_setup_component",
"(",
"... | [
31,
0
] | [
36,
51
] | python | en | ['en', 'en', 'en'] | True |
test_valid_path | (hass) | Test for a valid path. | Test for a valid path. | async def test_valid_path(hass):
"""Test for a valid path."""
create_file(TEST_FILE)
config = {"sensor": {"platform": "filesize", CONF_FILE_PATHS: [TEST_FILE]}}
hass.config.allowlist_external_dirs = {TEST_DIR}
assert await async_setup_component(hass, "sensor", config)
await hass.async_block_till... | [
"async",
"def",
"test_valid_path",
"(",
"hass",
")",
":",
"create_file",
"(",
"TEST_FILE",
")",
"config",
"=",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"filesize\"",
",",
"CONF_FILE_PATHS",
":",
"[",
"TEST_FILE",
"]",
"}",
"}",
"hass",
".",
"con... | [
39,
0
] | [
49,
45
] | python | en | ['en', 'en', 'en'] | True |
test_reload | (hass, tmpdir) | Verify we can reload filesize sensors. | Verify we can reload filesize sensors. | async def test_reload(hass, tmpdir):
"""Verify we can reload filesize sensors."""
testfile = f"{tmpdir}/file"
await hass.async_add_executor_job(create_file, testfile)
with patch.object(hass.config, "is_allowed_path", return_value=True):
await async_setup_component(
hass,
... | [
"async",
"def",
"test_reload",
"(",
"hass",
",",
"tmpdir",
")",
":",
"testfile",
"=",
"f\"{tmpdir}/file\"",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"create_file",
",",
"testfile",
")",
"with",
"patch",
".",
"object",
"(",
"hass",
".",
"config",
... | [
52,
0
] | [
89,
49
] | python | en | ['en', 'en', 'en'] | True |
generate_and_validate | (integrations: Dict[str, Integration]) | Validate and generate zeroconf data. | Validate and generate zeroconf data. | def generate_and_validate(integrations: Dict[str, Integration]):
"""Validate and generate zeroconf data."""
service_type_dict = defaultdict(list)
homekit_dict = {}
for domain in sorted(integrations):
integration = integrations[domain]
if not integration.manifest:
continue
... | [
"def",
"generate_and_validate",
"(",
"integrations",
":",
"Dict",
"[",
"str",
",",
"Integration",
"]",
")",
":",
"service_type_dict",
"=",
"defaultdict",
"(",
"list",
")",
"homekit_dict",
"=",
"{",
"}",
"for",
"domain",
"in",
"sorted",
"(",
"integrations",
"... | [
21,
0
] | [
88,
85
] | python | en | ['de', 'en', 'en'] | True |
validate | (integrations: Dict[str, Integration], config: Config) | Validate zeroconf file. | Validate zeroconf file. | def validate(integrations: Dict[str, Integration], config: Config):
"""Validate zeroconf file."""
zeroconf_path = config.root / "homeassistant/generated/zeroconf.py"
config.cache["zeroconf"] = content = generate_and_validate(integrations)
if config.specific_integrations:
return
with open(s... | [
"def",
"validate",
"(",
"integrations",
":",
"Dict",
"[",
"str",
",",
"Integration",
"]",
",",
"config",
":",
"Config",
")",
":",
"zeroconf_path",
"=",
"config",
".",
"root",
"/",
"\"homeassistant/generated/zeroconf.py\"",
"config",
".",
"cache",
"[",
"\"zeroc... | [
91,
0
] | [
107,
14
] | python | it | ['pl', 'it', 'it'] | True |
generate | (integrations: Dict[str, Integration], config: Config) | Generate zeroconf file. | Generate zeroconf file. | def generate(integrations: Dict[str, Integration], config: Config):
"""Generate zeroconf file."""
zeroconf_path = config.root / "homeassistant/generated/zeroconf.py"
with open(str(zeroconf_path), "w") as fp:
fp.write(f"{config.cache['zeroconf']}\n") | [
"def",
"generate",
"(",
"integrations",
":",
"Dict",
"[",
"str",
",",
"Integration",
"]",
",",
"config",
":",
"Config",
")",
":",
"zeroconf_path",
"=",
"config",
".",
"root",
"/",
"\"homeassistant/generated/zeroconf.py\"",
"with",
"open",
"(",
"str",
"(",
"z... | [
110,
0
] | [
114,
49
] | python | it | ['pl', 'it', 'it'] | True |
async_setup | (hass, base_config) | Set up the Lutron component. | Set up the Lutron component. | async def async_setup(hass, base_config):
"""Set up the Lutron component."""
bridge_configs = base_config[DOMAIN]
hass.data.setdefault(DOMAIN, {})
for config in bridge_configs:
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
cont... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"base_config",
")",
":",
"bridge_configs",
"=",
"base_config",
"[",
"DOMAIN",
"]",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"for",
"config",
"in",
"bridge_configs",
":",
"... | [
38,
0
] | [
59,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up a bridge from a config entry. | Set up a bridge from a config entry. | async def async_setup_entry(hass, config_entry):
"""Set up a bridge from a config entry."""
host = config_entry.data[CONF_HOST]
keyfile = hass.config.path(config_entry.data[CONF_KEYFILE])
certfile = hass.config.path(config_entry.data[CONF_CERTFILE])
ca_certs = hass.config.path(config_entry.data[CON... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"host",
"=",
"config_entry",
".",
"data",
"[",
"CONF_HOST",
"]",
"keyfile",
"=",
"hass",
".",
"config",
".",
"path",
"(",
"config_entry",
".",
"data",
"[",
"CONF_KEYFILE",
"]"... | [
62,
0
] | [
90,
15
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaDevice.__init__ | (self, device, bridge) | Set up the base class.
[:param]device the device metadata
[:param]bridge the smartbridge object
| Set up the base class. | def __init__(self, device, bridge):
"""Set up the base class.
[:param]device the device metadata
[:param]bridge the smartbridge object
"""
self._device = device
self._smartbridge = bridge | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"bridge",
")",
":",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_smartbridge",
"=",
"bridge"
] | [
96,
4
] | [
103,
34
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaDevice.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self._smartbridge.add_subscriber(self.device_id, self.async_write_ha_state) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_smartbridge",
".",
"add_subscriber",
"(",
"self",
".",
"device_id",
",",
"self",
".",
"async_write_ha_state",
")"
] | [
105,
4
] | [
107,
83
] | python | en | ['en', 'no', 'en'] | False |
LutronCasetaDevice.device_id | (self) | Return the device ID used for calling pylutron_caseta. | Return the device ID used for calling pylutron_caseta. | def device_id(self):
"""Return the device ID used for calling pylutron_caseta."""
return self._device["device_id"] | [
"def",
"device_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
"[",
"\"device_id\"",
"]"
] | [
110,
4
] | [
112,
40
] | python | en | ['en', 'sm', 'en'] | True |
LutronCasetaDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._device["name"] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
"[",
"\"name\"",
"]"
] | [
115,
4
] | [
117,
35
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaDevice.serial | (self) | Return the serial number of the device. | Return the serial number of the device. | def serial(self):
"""Return the serial number of the device."""
return self._device["serial"] | [
"def",
"serial",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
"[",
"\"serial\"",
"]"
] | [
120,
4
] | [
122,
37
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaDevice.unique_id | (self) | Return the unique ID of the device (serial). | Return the unique ID of the device (serial). | def unique_id(self):
"""Return the unique ID of the device (serial)."""
return str(self.serial) | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"str",
"(",
"self",
".",
"serial",
")"
] | [
125,
4
] | [
127,
31
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaDevice.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {
"identifiers": {(DOMAIN, self.serial)},
"name": self.name,
"manufacturer": "Lutron",
"model": self._device["model"],
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"serial",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"manufacturer\"",
":",
"\"Lutron\"",
",",
"\"model\"",
":",
... | [
130,
4
] | [
137,
9
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {"device_id": self.device_id, "zone_id": self._device["zone"]} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"device_id\"",
":",
"self",
".",
"device_id",
",",
"\"zone_id\"",
":",
"self",
".",
"_device",
"[",
"\"zone\"",
"]",
"}"
] | [
140,
4
] | [
142,
77
] | python | en | ['en', 'en', 'en'] | True |
LutronCasetaDevice.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
145,
4
] | [
147,
20
] | python | en | ['en', 'en', 'en'] | True |
MarianTokenizer.normalize | (self, x: str) | Cover moses empty string edge case. They return empty list for '' input! | Cover moses empty string edge case. They return empty list for '' input! | def normalize(self, x: str) -> str:
"""Cover moses empty string edge case. They return empty list for '' input!"""
return self.punc_normalizer(x) if x else "" | [
"def",
"normalize",
"(",
"self",
",",
"x",
":",
"str",
")",
"->",
"str",
":",
"return",
"self",
".",
"punc_normalizer",
"(",
"x",
")",
"if",
"x",
"else",
"\"\""
] | [
159,
4
] | [
161,
51
] | python | en | ['en', 'en', 'en'] | True |
MarianTokenizer.remove_language_code | (self, text: str) | Remove language codes like >>fr<< before sentencepiece | Remove language codes like >>fr<< before sentencepiece | def remove_language_code(self, text: str):
"""Remove language codes like >>fr<< before sentencepiece"""
match = self.language_code_re.match(text)
code: list = [match.group(0)] if match else []
return code, self.language_code_re.sub("", text) | [
"def",
"remove_language_code",
"(",
"self",
",",
"text",
":",
"str",
")",
":",
"match",
"=",
"self",
".",
"language_code_re",
".",
"match",
"(",
"text",
")",
"code",
":",
"list",
"=",
"[",
"match",
".",
"group",
"(",
"0",
")",
"]",
"if",
"match",
"... | [
166,
4
] | [
170,
56
] | python | en | ['fr', 'en', 'en'] | True |
MarianTokenizer._convert_id_to_token | (self, index: int) | Converts an index (integer) in a token (str) using the decoder. | Converts an index (integer) in a token (str) using the decoder. | def _convert_id_to_token(self, index: int) -> str:
"""Converts an index (integer) in a token (str) using the decoder."""
return self.decoder.get(index, self.unk_token) | [
"def",
"_convert_id_to_token",
"(",
"self",
",",
"index",
":",
"int",
")",
"->",
"str",
":",
"return",
"self",
".",
"decoder",
".",
"get",
"(",
"index",
",",
"self",
".",
"unk_token",
")"
] | [
177,
4
] | [
179,
54
] | python | en | ['en', 'en', 'en'] | True |
MarianTokenizer.batch_decode | (self, sequences, **kwargs) |
Convert a list of lists of token ids into a list of strings by calling decode.
Args:
sequences (:obj:`Union[List[int], List[List[int]], np.ndarray, torch.Tensor, tf.Tensor]`):
List of tokenized input ids. Can be obtained using the ``__call__`` method.
skip_speci... |
Convert a list of lists of token ids into a list of strings by calling decode. | def batch_decode(self, sequences, **kwargs):
"""
Convert a list of lists of token ids into a list of strings by calling decode.
Args:
sequences (:obj:`Union[List[int], List[List[int]], np.ndarray, torch.Tensor, tf.Tensor]`):
List of tokenized input ids. Can be obtain... | [
"def",
"batch_decode",
"(",
"self",
",",
"sequences",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
")",
".",
"batch_decode",
"(",
"sequences",
",",
"*",
"*",
"kwargs",
")"
] | [
181,
4
] | [
201,
56
] | python | en | ['en', 'error', 'th'] | False |
MarianTokenizer.decode | (self, token_ids, **kwargs) |
Converts a sequence of ids in a string, using the tokenizer and vocabulary with options to remove special
tokens and clean up tokenization spaces.
Similar to doing ``self.convert_tokens_to_string(self.convert_ids_to_tokens(token_ids))``.
Args:
token_ids (:obj:`Union[int, L... |
Converts a sequence of ids in a string, using the tokenizer and vocabulary with options to remove special
tokens and clean up tokenization spaces. | def decode(self, token_ids, **kwargs):
"""
Converts a sequence of ids in a string, using the tokenizer and vocabulary with options to remove special
tokens and clean up tokenization spaces.
Similar to doing ``self.convert_tokens_to_string(self.convert_ids_to_tokens(token_ids))``.
... | [
"def",
"decode",
"(",
"self",
",",
"token_ids",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
")",
".",
"decode",
"(",
"token_ids",
",",
"*",
"*",
"kwargs",
")"
] | [
203,
4
] | [
226,
50
] | python | en | ['en', 'error', 'th'] | False |
MarianTokenizer.convert_tokens_to_string | (self, tokens: List[str]) | Uses source spm if _decode_use_source_tokenizer is True, and target spm otherwise | Uses source spm if _decode_use_source_tokenizer is True, and target spm otherwise | def convert_tokens_to_string(self, tokens: List[str]) -> str:
"""Uses source spm if _decode_use_source_tokenizer is True, and target spm otherwise """
if self._decode_use_source_tokenizer:
return self.spm_source.DecodePieces(tokens)
else:
return self.spm_target.DecodePiec... | [
"def",
"convert_tokens_to_string",
"(",
"self",
",",
"tokens",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"if",
"self",
".",
"_decode_use_source_tokenizer",
":",
"return",
"self",
".",
"spm_source",
".",
"DecodePieces",
"(",
"tokens",
")",
"else",
... | [
228,
4
] | [
233,
55
] | python | en | ['en', 'en', 'en'] | True |
MarianTokenizer.build_inputs_with_special_tokens | (self, token_ids_0, token_ids_1=None) | Build model inputs from a sequence by appending eos_token_id. | Build model inputs from a sequence by appending eos_token_id. | def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None) -> List[int]:
"""Build model inputs from a sequence by appending eos_token_id."""
if token_ids_1 is None:
return token_ids_0 + [self.eos_token_id]
# We don't expect to process pairs, but leave the pair logic fo... | [
"def",
"build_inputs_with_special_tokens",
"(",
"self",
",",
"token_ids_0",
",",
"token_ids_1",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"if",
"token_ids_1",
"is",
"None",
":",
"return",
"token_ids_0",
"+",
"[",
"self",
".",
"eos_token_id",
"]",... | [
235,
4
] | [
240,
62
] | python | en | ['en', 'en', 'en'] | True |
MarianTokenizer.as_target_tokenizer | (self) |
Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to
sequence-to-sequence models that need a slightly different processing for the labels.
|
Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to
sequence-to-sequence models that need a slightly different processing for the labels.
| def as_target_tokenizer(self):
"""
Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to
sequence-to-sequence models that need a slightly different processing for the labels.
"""
self.current_spm = self.spm_target
yield
self.c... | [
"def",
"as_target_tokenizer",
"(",
"self",
")",
":",
"self",
".",
"current_spm",
"=",
"self",
".",
"spm_target",
"yield",
"self",
".",
"current_spm",
"=",
"self",
".",
"spm_source"
] | [
243,
4
] | [
250,
42
] | python | en | ['en', 'error', 'th'] | False |
MarianTokenizer.get_special_tokens_mask | (
self, token_ids_0: List, token_ids_1: Optional[List] = None, already_has_special_tokens: bool = False
) | Get list where entries are [1] if a token is [eos] or [pad] else 0. | Get list where entries are [1] if a token is [eos] or [pad] else 0. | def get_special_tokens_mask(
self, token_ids_0: List, token_ids_1: Optional[List] = None, already_has_special_tokens: bool = False
) -> List[int]:
"""Get list where entries are [1] if a token is [eos] or [pad] else 0."""
if already_has_special_tokens:
return self._special_token_m... | [
"def",
"get_special_tokens_mask",
"(",
"self",
",",
"token_ids_0",
":",
"List",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"]",
"=",
"None",
",",
"already_has_special_tokens",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"int",
"]",
":",
"if",... | [
298,
4
] | [
307,
76
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Swiss hydrological sensor. | Set up the Swiss hydrological sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Swiss hydrological sensor."""
station = config.get(CONF_STATION)
monitored_conditions = config.get(CONF_MONITORED_CONDITIONS)
hydro_data = HydrologicalData(station)
hydro_data.update()
if hydro_data.data is None... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"station",
"=",
"config",
".",
"get",
"(",
"CONF_STATION",
")",
"monitored_conditions",
"=",
"config",
".",
"get",
"(",
"CONF_MONITORED_COND... | [
65,
0
] | [
82,
32
] | python | en | ['en', 'bg', 'en'] | True |
SwissHydrologicalDataSensor.__init__ | (self, hydro_data, station, condition) | Initialize the Swiss hydrological sensor. | Initialize the Swiss hydrological sensor. | def __init__(self, hydro_data, station, condition):
"""Initialize the Swiss hydrological sensor."""
self.hydro_data = hydro_data
self._condition = condition
self._data = self._state = self._unit_of_measurement = None
self._icon = CONDITIONS[condition]
self._station = stat... | [
"def",
"__init__",
"(",
"self",
",",
"hydro_data",
",",
"station",
",",
"condition",
")",
":",
"self",
".",
"hydro_data",
"=",
"hydro_data",
"self",
".",
"_condition",
"=",
"condition",
"self",
".",
"_data",
"=",
"self",
".",
"_state",
"=",
"self",
".",
... | [
88,
4
] | [
94,
31
] | python | en | ['en', 'en', 'en'] | True |
SwissHydrologicalDataSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return "{} {}".format(self._data["water-body-name"], self._condition) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"\"{} {}\"",
".",
"format",
"(",
"self",
".",
"_data",
"[",
"\"water-body-name\"",
"]",
",",
"self",
".",
"_condition",
")"
] | [
97,
4
] | [
99,
77
] | python | en | ['en', 'mi', 'en'] | True |
SwissHydrologicalDataSensor.unique_id | (self) | Return a unique, friendly identifier for this entity. | Return a unique, friendly identifier for this entity. | def unique_id(self) -> str:
"""Return a unique, friendly identifier for this entity."""
return f"{self._station}_{self._condition}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._station}_{self._condition}\""
] | [
102,
4
] | [
104,
51
] | python | en | ['en', 'en', 'en'] | True |
SwissHydrologicalDataSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
if self._state is not None:
return self.hydro_data.data["parameters"][self._condition]["unit"]
return None | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"is",
"not",
"None",
":",
"return",
"self",
".",
"hydro_data",
".",
"data",
"[",
"\"parameters\"",
"]",
"[",
"self",
".",
"_condition",
"]",
"[",
"\"unit\"",
"]",
"return",... | [
107,
4
] | [
111,
19
] | python | en | ['en', 'en', 'en'] | True |
SwissHydrologicalDataSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
if isinstance(self._state, (int, float)):
return round(self._state, 2)
return None | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_state",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"return",
"round",
"(",
"self",
".",
"_state",
",",
"2",
")",
"return",
"None"
] | [
114,
4
] | [
118,
19
] | python | en | ['en', 'en', 'en'] | True |
SwissHydrologicalDataSensor.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
attrs = {}
if not self._data:
attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
return attrs
attrs[ATTR_WATER_BODY_TYPE] = self._data["water-body-type"]
attrs[ATTR_STATION] = self._data["na... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"}",
"if",
"not",
"self",
".",
"_data",
":",
"attrs",
"[",
"ATTR_ATTRIBUTION",
"]",
"=",
"ATTRIBUTION",
"return",
"attrs",
"attrs",
"[",
"ATTR_WATER_BODY_TYPE",
"]",
"=",
"self",
"... | [
121,
4
] | [
141,
20
] | python | en | ['en', 'en', 'en'] | True |
SwissHydrologicalDataSensor.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self):
"""Icon to use in the frontend."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
144,
4
] | [
146,
25
] | python | en | ['en', 'en', 'en'] | True |
SwissHydrologicalDataSensor.update | (self) | Get the latest data and update the state. | Get the latest data and update the state. | def update(self):
"""Get the latest data and update the state."""
self.hydro_data.update()
self._data = self.hydro_data.data
if self._data is None:
self._state = None
else:
self._state = self._data["parameters"][self._condition]["value"] | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"hydro_data",
".",
"update",
"(",
")",
"self",
".",
"_data",
"=",
"self",
".",
"hydro_data",
".",
"data",
"if",
"self",
".",
"_data",
"is",
"None",
":",
"self",
".",
"_state",
"=",
"None",
"else"... | [
148,
4
] | [
156,
76
] | python | en | ['en', 'en', 'en'] | True |
HydrologicalData.__init__ | (self, station) | Initialize the data object. | Initialize the data object. | def __init__(self, station):
"""Initialize the data object."""
self.station = station
self.data = None | [
"def",
"__init__",
"(",
"self",
",",
"station",
")",
":",
"self",
".",
"station",
"=",
"station",
"self",
".",
"data",
"=",
"None"
] | [
162,
4
] | [
165,
24
] | python | en | ['en', 'en', 'en'] | True |
HydrologicalData.update | (self) | Get the latest data. | Get the latest data. | def update(self):
"""Get the latest data."""
shd = SwissHydroData()
self.data = shd.get_station(self.station) | [
"def",
"update",
"(",
"self",
")",
":",
"shd",
"=",
"SwissHydroData",
"(",
")",
"self",
".",
"data",
"=",
"shd",
".",
"get_station",
"(",
"self",
".",
"station",
")"
] | [
168,
4
] | [
172,
49
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Geolocation component. | Set up the Geolocation component. | async def async_setup(hass, config):
"""Set up the Geolocation component."""
component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"component",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
",",
"SCAN_INTERVAL",
")",
"await",
"component",
".",
"asy... | [
27,
0
] | [
33,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Set up a config entry. | Set up a config entry. | async def async_setup_entry(hass, entry):
"""Set up a config entry."""
return await hass.data[DOMAIN].async_setup_entry(entry) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"return",
"await",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"async_setup_entry",
"(",
"entry",
")"
] | [
36,
0
] | [
38,
59
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
return await hass.data[DOMAIN].async_unload_entry(entry) | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"return",
"await",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"async_unload_entry",
"(",
"entry",
")"
] | [
41,
0
] | [
43,
60
] | python | en | ['en', 'es', 'en'] | True |
GeolocationEvent.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
if self.distance is not None:
return round(self.distance, 1)
return None | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"distance",
"is",
"not",
"None",
":",
"return",
"round",
"(",
"self",
".",
"distance",
",",
"1",
")",
"return",
"None"
] | [
50,
4
] | [
54,
19
] | python | en | ['en', 'en', 'en'] | True |
GeolocationEvent.source | (self) | Return source value of this external event. | Return source value of this external event. | def source(self) -> str:
"""Return source value of this external event."""
raise NotImplementedError | [
"def",
"source",
"(",
"self",
")",
"->",
"str",
":",
"raise",
"NotImplementedError"
] | [
57,
4
] | [
59,
33
] | python | en | ['en', 'en', 'en'] | True |
GeolocationEvent.distance | (self) | Return distance value of this external event. | Return distance value of this external event. | def distance(self) -> Optional[float]:
"""Return distance value of this external event."""
return None | [
"def",
"distance",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"None"
] | [
62,
4
] | [
64,
19
] | python | en | ['en', 'en', 'en'] | True |
GeolocationEvent.latitude | (self) | Return latitude value of this external event. | Return latitude value of this external event. | def latitude(self) -> Optional[float]:
"""Return latitude value of this external event."""
return None | [
"def",
"latitude",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"None"
] | [
67,
4
] | [
69,
19
] | python | en | ['en', 'la', 'en'] | True |
GeolocationEvent.longitude | (self) | Return longitude value of this external event. | Return longitude value of this external event. | def longitude(self) -> Optional[float]:
"""Return longitude value of this external event."""
return None | [
"def",
"longitude",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"None"
] | [
72,
4
] | [
74,
19
] | python | en | ['en', 'en', 'en'] | True |
GeolocationEvent.state_attributes | (self) | Return the state attributes of this external event. | Return the state attributes of this external event. | def state_attributes(self):
"""Return the state attributes of this external event."""
data = {}
if self.latitude is not None:
data[ATTR_LATITUDE] = round(self.latitude, 5)
if self.longitude is not None:
data[ATTR_LONGITUDE] = round(self.longitude, 5)
if se... | [
"def",
"state_attributes",
"(",
"self",
")",
":",
"data",
"=",
"{",
"}",
"if",
"self",
".",
"latitude",
"is",
"not",
"None",
":",
"data",
"[",
"ATTR_LATITUDE",
"]",
"=",
"round",
"(",
"self",
".",
"latitude",
",",
"5",
")",
"if",
"self",
".",
"long... | [
77,
4
] | [
86,
19
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the ZoneMinder cameras. | Set up the ZoneMinder cameras. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the ZoneMinder cameras."""
filter_urllib3_logging()
cameras = []
for zm_client in hass.data[ZONEMINDER_DOMAIN].values():
monitors = zm_client.get_monitors()
if not monitors:
_LOGGER.warning("Could ... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"filter_urllib3_logging",
"(",
")",
"cameras",
"=",
"[",
"]",
"for",
"zm_client",
"in",
"hass",
".",
"data",
"[",
"ZONEMINDER_DOMAIN",
"]"... | [
16,
0
] | [
29,
25
] | python | en | ['en', 'da', 'en'] | True |
ZoneMinderCamera.__init__ | (self, monitor, verify_ssl) | Initialize as a subclass of MjpegCamera. | Initialize as a subclass of MjpegCamera. | def __init__(self, monitor, verify_ssl):
"""Initialize as a subclass of MjpegCamera."""
device_info = {
CONF_NAME: monitor.name,
CONF_MJPEG_URL: monitor.mjpeg_image_url,
CONF_STILL_IMAGE_URL: monitor.still_image_url,
CONF_VERIFY_SSL: verify_ssl,
}
... | [
"def",
"__init__",
"(",
"self",
",",
"monitor",
",",
"verify_ssl",
")",
":",
"device_info",
"=",
"{",
"CONF_NAME",
":",
"monitor",
".",
"name",
",",
"CONF_MJPEG_URL",
":",
"monitor",
".",
"mjpeg_image_url",
",",
"CONF_STILL_IMAGE_URL",
":",
"monitor",
".",
"... | [
35,
4
] | [
46,
31
] | python | en | ['en', 'en', 'en'] | True |
ZoneMinderCamera.should_poll | (self) | Update the recording state periodically. | Update the recording state periodically. | def should_poll(self):
"""Update the recording state periodically."""
return True | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"True"
] | [
49,
4
] | [
51,
19
] | python | en | ['en', 'en', 'en'] | True |
ZoneMinderCamera.update | (self) | Update our recording state from the ZM API. | Update our recording state from the ZM API. | def update(self):
"""Update our recording state from the ZM API."""
_LOGGER.debug("Updating camera state for monitor %i", self._monitor.id)
self._is_recording = self._monitor.is_recording
self._is_available = self._monitor.is_available | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating camera state for monitor %i\"",
",",
"self",
".",
"_monitor",
".",
"id",
")",
"self",
".",
"_is_recording",
"=",
"self",
".",
"_monitor",
".",
"is_recording",
"self",
".",
"_is... | [
53,
4
] | [
57,
55
] | python | en | ['en', 'en', 'en'] | True |
ZoneMinderCamera.is_recording | (self) | Return whether the monitor is in alarm mode. | Return whether the monitor is in alarm mode. | def is_recording(self):
"""Return whether the monitor is in alarm mode."""
return self._is_recording | [
"def",
"is_recording",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_recording"
] | [
60,
4
] | [
62,
33
] | python | en | ['en', 'en', 'en'] | True |
ZoneMinderCamera.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self):
"""Return True if entity is available."""
return self._is_available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_available"
] | [
65,
4
] | [
67,
33
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the EnOcean switch platform. | Set up the EnOcean switch platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the EnOcean switch platform."""
channel = config.get(CONF_CHANNEL)
dev_id = config.get(CONF_ID)
dev_name = config.get(CONF_NAME)
add_entities([EnOceanSwitch(dev_id, dev_name, channel)]) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"channel",
"=",
"config",
".",
"get",
"(",
"CONF_CHANNEL",
")",
"dev_id",
"=",
"config",
".",
"get",
"(",
"CONF_ID",
")",
"dev_name",
... | [
22,
0
] | [
28,
60
] | python | en | ['en', 'da', 'en'] | True |
EnOceanSwitch.__init__ | (self, dev_id, dev_name, channel) | Initialize the EnOcean switch device. | Initialize the EnOcean switch device. | def __init__(self, dev_id, dev_name, channel):
"""Initialize the EnOcean switch device."""
super().__init__(dev_id, dev_name)
self._light = None
self._on_state = False
self._on_state2 = False
self.channel = channel | [
"def",
"__init__",
"(",
"self",
",",
"dev_id",
",",
"dev_name",
",",
"channel",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"dev_id",
",",
"dev_name",
")",
"self",
".",
"_light",
"=",
"None",
"self",
".",
"_on_state",
"=",
"False",
"self",
"."... | [
34,
4
] | [
40,
30
] | python | en | ['en', 'en', 'en'] | True |
EnOceanSwitch.is_on | (self) | Return whether the switch is on or off. | Return whether the switch is on or off. | def is_on(self):
"""Return whether the switch is on or off."""
return self._on_state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_on_state"
] | [
43,
4
] | [
45,
29
] | python | en | ['en', 'en', 'en'] | True |
EnOceanSwitch.name | (self) | Return the device name. | Return the device name. | def name(self):
"""Return the device name."""
return self.dev_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"dev_name"
] | [
48,
4
] | [
50,
28
] | python | en | ['en', 'en', 'en'] | True |
EnOceanSwitch.turn_on | (self, **kwargs) | Turn on the switch. | Turn on the switch. | def turn_on(self, **kwargs):
"""Turn on the switch."""
optional = [0x03]
optional.extend(self.dev_id)
optional.extend([0xFF, 0x00])
self.send_command(
data=[0xD2, 0x01, self.channel & 0xFF, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00],
optional=optional,
... | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"optional",
"=",
"[",
"0x03",
"]",
"optional",
".",
"extend",
"(",
"self",
".",
"dev_id",
")",
"optional",
".",
"extend",
"(",
"[",
"0xFF",
",",
"0x00",
"]",
")",
"self",
".",
"sen... | [
52,
4
] | [
62,
29
] | python | en | ['en', 'en', 'en'] | True |
EnOceanSwitch.turn_off | (self, **kwargs) | Turn off the switch. | Turn off the switch. | def turn_off(self, **kwargs):
"""Turn off the switch."""
optional = [0x03]
optional.extend(self.dev_id)
optional.extend([0xFF, 0x00])
self.send_command(
data=[0xD2, 0x01, self.channel & 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
optional=optional,
... | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"optional",
"=",
"[",
"0x03",
"]",
"optional",
".",
"extend",
"(",
"self",
".",
"dev_id",
")",
"optional",
".",
"extend",
"(",
"[",
"0xFF",
",",
"0x00",
"]",
")",
"self",
".",
"se... | [
64,
4
] | [
74,
30
] | python | en | ['en', 'en', 'en'] | True |
EnOceanSwitch.value_changed | (self, packet) | Update the internal state of the switch. | Update the internal state of the switch. | def value_changed(self, packet):
"""Update the internal state of the switch."""
if packet.data[0] == 0xA5:
# power meter telegram, turn on if > 10 watts
packet.parse_eep(0x12, 0x01)
if packet.parsed["DT"]["raw_value"] == 1:
raw_val = packet.parsed["MR"... | [
"def",
"value_changed",
"(",
"self",
",",
"packet",
")",
":",
"if",
"packet",
".",
"data",
"[",
"0",
"]",
"==",
"0xA5",
":",
"# power meter telegram, turn on if > 10 watts",
"packet",
".",
"parse_eep",
"(",
"0x12",
",",
"0x01",
")",
"if",
"packet",
".",
"p... | [
76,
4
] | [
96,
51
] | python | en | ['en', 'en', 'en'] | True |
async_setup_scanner | (hass, config, async_see, discovery_info=None) | Set up an endpoint for the Meraki tracker. | Set up an endpoint for the Meraki tracker. | async def async_setup_scanner(hass, config, async_see, discovery_info=None):
"""Set up an endpoint for the Meraki tracker."""
hass.http.register_view(MerakiView(config, async_see))
return True | [
"async",
"def",
"async_setup_scanner",
"(",
"hass",
",",
"config",
",",
"async_see",
",",
"discovery_info",
"=",
"None",
")",
":",
"hass",
".",
"http",
".",
"register_view",
"(",
"MerakiView",
"(",
"config",
",",
"async_see",
")",
")",
"return",
"True"
] | [
26,
0
] | [
30,
15
] | python | en | ['en', 'en', 'en'] | True |
MerakiView.__init__ | (self, config, async_see) | Initialize Meraki URL endpoints. | Initialize Meraki URL endpoints. | def __init__(self, config, async_see):
"""Initialize Meraki URL endpoints."""
self.async_see = async_see
self.validator = config[CONF_VALIDATOR]
self.secret = config[CONF_SECRET] | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"async_see",
")",
":",
"self",
".",
"async_see",
"=",
"async_see",
"self",
".",
"validator",
"=",
"config",
"[",
"CONF_VALIDATOR",
"]",
"self",
".",
"secret",
"=",
"config",
"[",
"CONF_SECRET",
"]"
] | [
39,
4
] | [
43,
41
] | python | cs | ['cs', 'fy', 'it'] | False |
MerakiView.get | (self, request) | Meraki message received as GET. | Meraki message received as GET. | async def get(self, request):
"""Meraki message received as GET."""
return self.validator | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"validator"
] | [
45,
4
] | [
47,
29
] | python | en | ['en', 'jv', 'en'] | True |
MerakiView.post | (self, request) | Meraki CMX message received. | Meraki CMX message received. | async def post(self, request):
"""Meraki CMX message received."""
try:
data = await request.json()
except ValueError:
return self.json_message("Invalid JSON", HTTP_BAD_REQUEST)
_LOGGER.debug("Meraki Data from Post: %s", json.dumps(data))
if not data.get("s... | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"data",
"=",
"await",
"request",
".",
"json",
"(",
")",
"except",
"ValueError",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Invalid JSON\"",
",",
"HTTP_BAD_REQUEST",
")",
... | [
49,
4
] | [
73,
47
] | python | en | ['en', 'lt', 'en'] | True |
shift_tokens_right | (input_ids: torch.Tensor, pad_token_id: int) |
Shift input ids one token to the right, and wrap the last non pad token (the <LID> token) Note that MBart does not
have a single `decoder_start_token_id` in contrast to other Bart-like models.
|
Shift input ids one token to the right, and wrap the last non pad token (the <LID> token) Note that MBart does not
have a single `decoder_start_token_id` in contrast to other Bart-like models.
| def shift_tokens_right(input_ids: torch.Tensor, pad_token_id: int):
"""
Shift input ids one token to the right, and wrap the last non pad token (the <LID> token) Note that MBart does not
have a single `decoder_start_token_id` in contrast to other Bart-like models.
"""
prev_output_tokens = input_ids.... | [
"def",
"shift_tokens_right",
"(",
"input_ids",
":",
"torch",
".",
"Tensor",
",",
"pad_token_id",
":",
"int",
")",
":",
"prev_output_tokens",
"=",
"input_ids",
".",
"clone",
"(",
")",
"assert",
"pad_token_id",
"is",
"not",
"None",
",",
"\"self.model.config.pad_to... | [
61,
0
] | [
77,
29
] | 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",
"."... | [
81,
0
] | [
93,
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"... | [
97,
0
] | [
108,
82
] | python | en | ['en', 'error', 'th'] | False |
MBartLearnedPositionalEmbedding.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",
... | [
123,
4
] | [
129,
55
] | python | en | ['en', 'en', 'en'] | True |
MBartAttention.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",
... | [
163,
4
] | [
272,
65
] | python | en | ['en', 'pl', 'en'] | True |
MBartEncoderLayer.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",
",",
")",
":",
... | [
292,
4
] | [
340,
22
] | python | en | ['en', 'error', 'th'] | False |
MBartDecoderLayer.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",
"]",
"=",
... | [
370,
4
] | [
456,
22
] | python | en | ['en', 'error', 'th'] | False |
MBartEncoder.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_... | [
689,
4
] | [
819,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
MBartDecoder.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",
",",
... | [
879,
4
] | [
1088,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
MBartForCausalLM.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",
",",
... | [
1631,
4
] | [
1766,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
to_device | (obj, device) |
Move a tensor, tuple, list, or dict onto device.
|
Move a tensor, tuple, list, or dict onto device.
| def to_device(obj, device):
"""
Move a tensor, tuple, list, or dict onto device.
"""
if torch.is_tensor(obj):
return obj.to(device)
if isinstance(obj, tuple):
return tuple(to_device(t, device) for t in obj)
if isinstance(obj, list):
return [to_device(t, device) for t in o... | [
"def",
"to_device",
"(",
"obj",
",",
"device",
")",
":",
"if",
"torch",
".",
"is_tensor",
"(",
"obj",
")",
":",
"return",
"obj",
".",
"to",
"(",
"device",
")",
"if",
"isinstance",
"(",
"obj",
",",
"tuple",
")",
":",
"return",
"tuple",
"(",
"to_devi... | [
14,
0
] | [
28,
73
] | python | en | ['en', 'error', 'th'] | False |
replace_layer_choice | (root_module, init_fn, modules=None) |
Replace layer choice modules with modules that are initiated with init_fn.
Parameters
----------
root_module : nn.Module
Root module to traverse.
init_fn : Callable
Initializing function.
modules : dict, optional
Update the replaced modules into the dict and check dupli... |
Replace layer choice modules with modules that are initiated with init_fn. | def replace_layer_choice(root_module, init_fn, modules=None):
"""
Replace layer choice modules with modules that are initiated with init_fn.
Parameters
----------
root_module : nn.Module
Root module to traverse.
init_fn : Callable
Initializing function.
modules : dict, optio... | [
"def",
"replace_layer_choice",
"(",
"root_module",
",",
"init_fn",
",",
"modules",
"=",
"None",
")",
":",
"return",
"_replace_module_with_type",
"(",
"root_module",
",",
"init_fn",
",",
"(",
"LayerChoice",
",",
"nn",
".",
"LayerChoice",
")",
",",
"modules",
")... | [
142,
0
] | [
160,
98
] | 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.