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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
XiaomiDevice.__init__ | (self, device, device_type, xiaomi_hub, config_entry) | Initialize the Xiaomi device. | Initialize the Xiaomi device. | def __init__(self, device, device_type, xiaomi_hub, config_entry):
"""Initialize the Xiaomi device."""
self._state = None
self._is_available = True
self._sid = device["sid"]
self._model = device["model"]
self._protocol = device["proto"]
self._name = f"{device_type... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"device_type",
",",
"xiaomi_hub",
",",
"config_entry",
")",
":",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_is_available",
"=",
"True",
"self",
".",
"_sid",
"=",
"device",
"[",
"\"sid\"",
"]",
... | [
231,
4
] | [
264,
39
] | python | en | ['en', 'en', 'en'] | True |
XiaomiDevice.async_added_to_hass | (self) | Start unavailability tracking. | Start unavailability tracking. | async def async_added_to_hass(self):
"""Start unavailability tracking."""
self._xiaomi_hub.callbacks[self._sid].append(self._add_push_data_job)
self._async_track_unavailable() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_xiaomi_hub",
".",
"callbacks",
"[",
"self",
".",
"_sid",
"]",
".",
"append",
"(",
"self",
".",
"_add_push_data_job",
")",
"self",
".",
"_async_track_unavailable",
"(",
")"
] | [
269,
4
] | [
272,
39
] | python | en | ['en', 'en', 'it'] | True |
XiaomiDevice.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._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
275,
4
] | [
277,
25
] | python | en | ['en', 'en', 'en'] | True |
XiaomiDevice.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
280,
4
] | [
282,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
XiaomiDevice.device_id | (self) | Return the device id of the Xiaomi Aqara device. | Return the device id of the Xiaomi Aqara device. | def device_id(self):
"""Return the device id of the Xiaomi Aqara device."""
return self._device_id | [
"def",
"device_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_id"
] | [
285,
4
] | [
287,
30
] | python | en | ['en', 'yo', 'en'] | True |
XiaomiDevice.device_info | (self) | Return the device info of the Xiaomi Aqara device. | Return the device info of the Xiaomi Aqara device. | def device_info(self):
"""Return the device info of the Xiaomi Aqara device."""
if self._is_gateway:
device_info = {
"identifiers": {(DOMAIN, self._device_id)},
"model": self._model,
}
else:
device_info = {
"conn... | [
"def",
"device_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_gateway",
":",
"device_info",
"=",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device_id",
")",
"}",
",",
"\"model\"",
":",
"self",
".",
"_model",
",",
"}",
... | [
290,
4
] | [
308,
26
] | python | en | ['en', 'yo', 'en'] | True |
XiaomiDevice.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"
] | [
311,
4
] | [
313,
33
] | python | en | ['en', 'en', 'en'] | True |
XiaomiDevice.should_poll | (self) | Return the polling state. No polling needed. | Return the polling state. No polling needed. | def should_poll(self):
"""Return the polling state. No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
316,
4
] | [
318,
20
] | python | en | ['en', 'en', 'en'] | True |
XiaomiDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._device_state_attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_state_attributes"
] | [
321,
4
] | [
323,
44
] | python | en | ['en', 'en', 'en'] | True |
XiaomiDevice._async_set_unavailable | (self, now) | Set state to UNAVAILABLE. | Set state to UNAVAILABLE. | def _async_set_unavailable(self, now):
"""Set state to UNAVAILABLE."""
self._remove_unavailability_tracker = None
self._is_available = False
self.async_write_ha_state() | [
"def",
"_async_set_unavailable",
"(",
"self",
",",
"now",
")",
":",
"self",
".",
"_remove_unavailability_tracker",
"=",
"None",
"self",
".",
"_is_available",
"=",
"False",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
326,
4
] | [
330,
35
] | python | en | ['en', 'en', 'en'] | True |
XiaomiDevice.push_data | (self, data, raw_data) | Push from Hub. | Push from Hub. | def push_data(self, data, raw_data):
"""Push from Hub."""
_LOGGER.debug("PUSH >> %s: %s", self, data)
was_unavailable = self._async_track_unavailable()
is_data = self.parse_data(data, raw_data)
is_voltage = self.parse_voltage(data)
if is_data or is_voltage or was_unavaila... | [
"def",
"push_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"PUSH >> %s: %s\"",
",",
"self",
",",
"data",
")",
"was_unavailable",
"=",
"self",
".",
"_async_track_unavailable",
"(",
")",
"is_data",
"=",
"self",
"... | [
345,
4
] | [
352,
39
] | python | en | ['en', 'uz', 'en'] | True |
XiaomiDevice.parse_voltage | (self, data) | Parse battery level data sent by gateway. | Parse battery level data sent by gateway. | def parse_voltage(self, data):
"""Parse battery level data sent by gateway."""
if "voltage" in data:
voltage_key = "voltage"
elif "battery_voltage" in data:
voltage_key = "battery_voltage"
else:
return False
max_volt = 3300
min_volt = ... | [
"def",
"parse_voltage",
"(",
"self",
",",
"data",
")",
":",
"if",
"\"voltage\"",
"in",
"data",
":",
"voltage_key",
"=",
"\"voltage\"",
"elif",
"\"battery_voltage\"",
"in",
"data",
":",
"voltage_key",
"=",
"\"battery_voltage\"",
"else",
":",
"return",
"False",
... | [
354,
4
] | [
371,
19
] | python | en | ['en', 'en', 'en'] | True |
XiaomiDevice.parse_data | (self, data, raw_data) | Parse data sent by gateway. | Parse data sent by gateway. | def parse_data(self, data, raw_data):
"""Parse data sent by gateway."""
raise NotImplementedError() | [
"def",
"parse_data",
"(",
"self",
",",
"data",
",",
"raw_data",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
373,
4
] | [
375,
35
] | python | en | ['en', 'de', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Niko Home Control light platform. | Set up the Niko Home Control light platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Niko Home Control light platform."""
host = config[CONF_HOST]
try:
nhc = nikohomecontrol.NikoHomeControl(
{"ip": host, "port": 8000, "timeout": 20000}
)
niko_data = NikoH... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"try",
":",
"nhc",
"=",
"nikohomecontrol",
".",
"NikoHomeControl",
"(",
... | [
21,
0
] | [
37,
5
] | python | en | ['en', 'pt', 'en'] | True |
NikoHomeControlLight.__init__ | (self, light, data) | Set up the Niko Home Control light platform. | Set up the Niko Home Control light platform. | def __init__(self, light, data):
"""Set up the Niko Home Control light platform."""
self._data = data
self._light = light
self._unique_id = f"light-{light.id}"
self._name = light.name
self._state = light.is_on
self._brightness = None | [
"def",
"__init__",
"(",
"self",
",",
"light",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_light",
"=",
"light",
"self",
".",
"_unique_id",
"=",
"f\"light-{light.id}\"",
"self",
".",
"_name",
"=",
"light",
".",
"name",
"self... | [
43,
4
] | [
50,
31
] | python | en | ['en', 'pt', 'en'] | True |
NikoHomeControlLight.unique_id | (self) | Return unique ID for light. | Return unique ID for light. | def unique_id(self):
"""Return unique ID for light."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
53,
4
] | [
55,
30
] | python | en | ['fr', 'la', 'en'] | False |
NikoHomeControlLight.name | (self) | Return the display name of this light. | Return the display name of this light. | def name(self):
"""Return the display name of this light."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
58,
4
] | [
60,
25
] | python | en | ['en', 'en', 'en'] | True |
NikoHomeControlLight.brightness | (self) | Return the brightness of the light. | Return the brightness of the light. | def brightness(self):
"""Return the brightness of the light."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
63,
4
] | [
65,
31
] | python | en | ['en', 'no', 'en'] | True |
NikoHomeControlLight.is_on | (self) | Return true if light is on. | Return true if light is on. | def is_on(self):
"""Return true if light is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
68,
4
] | [
70,
26
] | python | en | ['en', 'et', 'en'] | True |
NikoHomeControlLight.turn_on | (self, **kwargs) | Instruct the light to turn on. | Instruct the light to turn on. | def turn_on(self, **kwargs):
"""Instruct the light to turn on."""
self._light.brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
_LOGGER.debug("Turn on: %s", self.name)
self._light.turn_on() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_light",
".",
"brightness",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_BRIGHTNESS",
",",
"255",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Turn on: %s\"",
",",
"self",
".",
"name",
... | [
72,
4
] | [
76,
29
] | python | en | ['en', 'en', 'en'] | True |
NikoHomeControlLight.turn_off | (self, **kwargs) | Instruct the light to turn off. | Instruct the light to turn off. | def turn_off(self, **kwargs):
"""Instruct the light to turn off."""
_LOGGER.debug("Turn off: %s", self.name)
self._light.turn_off() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turn off: %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"_light",
".",
"turn_off",
"(",
")"
] | [
78,
4
] | [
81,
30
] | python | en | ['en', 'en', 'en'] | True |
NikoHomeControlLight.async_update | (self) | Get the latest data from NikoHomeControl API. | Get the latest data from NikoHomeControl API. | async def async_update(self):
"""Get the latest data from NikoHomeControl API."""
await self._data.async_update()
self._state = self._data.get_state(self._light.id) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"_data",
".",
"async_update",
"(",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_data",
".",
"get_state",
"(",
"self",
".",
"_light",
".",
"id",
")"
] | [
83,
4
] | [
86,
58
] | python | en | ['en', 'en', 'en'] | True |
NikoHomeControlData.__init__ | (self, hass, nhc) | Set up Niko Home Control Data object. | Set up Niko Home Control Data object. | def __init__(self, hass, nhc):
"""Set up Niko Home Control Data object."""
self._nhc = nhc
self.hass = hass
self.available = True
self.data = {}
self._system_info = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"nhc",
")",
":",
"self",
".",
"_nhc",
"=",
"nhc",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"available",
"=",
"True",
"self",
".",
"data",
"=",
"{",
"}",
"self",
".",
"_system_info",
"=",
"No... | [
92,
4
] | [
98,
32
] | python | en | ['en', 'en', 'en'] | True |
NikoHomeControlData.async_update | (self) | Get the latest data from the NikoHomeControl API. | Get the latest data from the NikoHomeControl API. | async def async_update(self):
"""Get the latest data from the NikoHomeControl API."""
_LOGGER.debug("Fetching async state in bulk")
try:
self.data = await self.hass.async_add_executor_job(
self._nhc.list_actions_raw
)
self.available = True
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Fetching async state in bulk\"",
")",
"try",
":",
"self",
".",
"data",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"_nhc",
".",
... | [
101,
4
] | [
111,
34
] | python | en | ['en', 'en', 'en'] | True |
NikoHomeControlData.get_state | (self, aid) | Find and filter state based on action id. | Find and filter state based on action id. | def get_state(self, aid):
"""Find and filter state based on action id."""
for state in self.data:
if state["id"] == aid:
return state["value1"] != 0
_LOGGER.error("Failed to retrieve state off unknown light") | [
"def",
"get_state",
"(",
"self",
",",
"aid",
")",
":",
"for",
"state",
"in",
"self",
".",
"data",
":",
"if",
"state",
"[",
"\"id\"",
"]",
"==",
"aid",
":",
"return",
"state",
"[",
"\"value1\"",
"]",
"!=",
"0",
"_LOGGER",
".",
"error",
"(",
"\"Faile... | [
113,
4
] | [
118,
67
] | python | en | ['en', 'en', 'en'] | True |
pyorbit_multinest | (config_in, input_datasets=None, return_output=None) |
On Linux system (BASH):
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
export LD_PRELOAD=/usr/lib/openmpi/lib/libmpi.so:$LD_PRELOAD
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgfortran.so.3
mpirun -np 4 python run_PyPolyChord.py
on Mac:
export LD_LIBRAR... |
On Linux system (BASH):
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib
export LD_PRELOAD=/usr/lib/openmpi/lib/libmpi.so:$LD_PRELOAD
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgfortran.so.3
mpirun -np 4 python run_PyPolyChord.py
on Mac:
export LD_LIBRAR... | def pyorbit_multinest(config_in, input_datasets=None, return_output=None):
output_directory = './' + config_in['output'] + '/multinest/'
mc = ModelContainerMultiNest()
pars_input(config_in, mc, input_datasets)
if mc.nested_sampling_parameters['shutdown_jitter']:
for dataset_name, dataset in m... | [
"def",
"pyorbit_multinest",
"(",
"config_in",
",",
"input_datasets",
"=",
"None",
",",
"return_output",
"=",
"None",
")",
":",
"output_directory",
"=",
"'./'",
"+",
"config_in",
"[",
"'output'",
"]",
"+",
"'/multinest/'",
"mc",
"=",
"ModelContainerMultiNest",
"(... | [
20,
0
] | [
115,
14
] | python | en | ['en', 'error', 'th'] | False |
teardown_module | () | Reset time zone. | Reset time zone. | def teardown_module():
"""Reset time zone."""
dt_util.set_default_time_zone(ORIG_TIME_ZONE) | [
"def",
"teardown_module",
"(",
")",
":",
"dt_util",
".",
"set_default_time_zone",
"(",
"ORIG_TIME_ZONE",
")"
] | [
19,
0
] | [
21,
49
] | python | en | ['nl', 'en', 'en'] | True |
make_nyc_test_params | (dtime, results, havdalah_offset=0) | Make test params for NYC. | Make test params for NYC. | def make_nyc_test_params(dtime, results, havdalah_offset=0):
"""Make test params for NYC."""
if isinstance(results, dict):
time_zone = dt_util.get_time_zone("America/New_York")
results = {
key: time_zone.localize(value) if isinstance(value, datetime) else value
for key, v... | [
"def",
"make_nyc_test_params",
"(",
"dtime",
",",
"results",
",",
"havdalah_offset",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"results",
",",
"dict",
")",
":",
"time_zone",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"\"America/New_York\"",
")",
"results",
... | [
24,
0
] | [
41,
5
] | python | en | ['en', 'en', 'en'] | True |
make_jerusalem_test_params | (dtime, results, havdalah_offset=0) | Make test params for Jerusalem. | Make test params for Jerusalem. | def make_jerusalem_test_params(dtime, results, havdalah_offset=0):
"""Make test params for Jerusalem."""
if isinstance(results, dict):
time_zone = dt_util.get_time_zone("Asia/Jerusalem")
results = {
key: time_zone.localize(value) if isinstance(value, datetime) else value
... | [
"def",
"make_jerusalem_test_params",
"(",
"dtime",
",",
"results",
",",
"havdalah_offset",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"results",
",",
"dict",
")",
":",
"time_zone",
"=",
"dt_util",
".",
"get_time_zone",
"(",
"\"Asia/Jerusalem\"",
")",
"result... | [
44,
0
] | [
61,
5
] | python | en | ['en', 'da', 'en'] | True |
alter_time | (local_time) | Manage multiple time mocks. | Manage multiple time mocks. | def alter_time(local_time):
"""Manage multiple time mocks."""
utc_time = dt_util.as_utc(local_time)
patch1 = patch("homeassistant.util.dt.utcnow", return_value=utc_time)
patch2 = patch("homeassistant.util.dt.now", return_value=local_time)
with patch1, patch2:
yield | [
"def",
"alter_time",
"(",
"local_time",
")",
":",
"utc_time",
"=",
"dt_util",
".",
"as_utc",
"(",
"local_time",
")",
"patch1",
"=",
"patch",
"(",
"\"homeassistant.util.dt.utcnow\"",
",",
"return_value",
"=",
"utc_time",
")",
"patch2",
"=",
"patch",
"(",
"\"hom... | [
65,
0
] | [
72,
13
] | python | da | ['pl', 'da', 'en'] | False |
parse_and_log_command | (channel, tsn, command_id, args) | Parse and log a zigbee cluster command. | Parse and log a zigbee cluster command. | def parse_and_log_command(channel, tsn, command_id, args):
"""Parse and log a zigbee cluster command."""
cmd = channel.cluster.server_commands.get(command_id, [command_id])[0]
channel.debug(
"received '%s' command with %s args on cluster_id '%s' tsn '%s'",
cmd,
args,
channel.... | [
"def",
"parse_and_log_command",
"(",
"channel",
",",
"tsn",
",",
"command_id",
",",
"args",
")",
":",
"cmd",
"=",
"channel",
".",
"cluster",
".",
"server_commands",
".",
"get",
"(",
"command_id",
",",
"[",
"command_id",
"]",
")",
"[",
"0",
"]",
"channel"... | [
29,
0
] | [
39,
14
] | python | en | ['en', 'en', 'en'] | True |
decorate_command | (channel, command) | Wrap a cluster command to make it safe. | Wrap a cluster command to make it safe. | def decorate_command(channel, command):
"""Wrap a cluster command to make it safe."""
@wraps(command)
async def wrapper(*args, **kwds):
try:
result = await command(*args, **kwds)
channel.debug(
"executed '%s' command with args: '%s' kwargs: '%s' result: %s",
... | [
"def",
"decorate_command",
"(",
"channel",
",",
"command",
")",
":",
"@",
"wraps",
"(",
"command",
")",
"async",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"try",
":",
"result",
"=",
"await",
"command",
"(",
"*",
"args",
"... | [
42,
0
] | [
68,
18
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.__init__ | (
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
) | Initialize ZigbeeChannel. | Initialize ZigbeeChannel. | def __init__(
self, cluster: zha_typing.ZigpyClusterType, ch_pool: zha_typing.ChannelPoolType
) -> None:
"""Initialize ZigbeeChannel."""
self._generic_id = f"channel_0x{cluster.cluster_id:04x}"
self._channel_name = getattr(cluster, "ep_attribute", self._generic_id)
self._ch_p... | [
"def",
"__init__",
"(",
"self",
",",
"cluster",
":",
"zha_typing",
".",
"ZigpyClusterType",
",",
"ch_pool",
":",
"zha_typing",
".",
"ChannelPoolType",
")",
"->",
"None",
":",
"self",
".",
"_generic_id",
"=",
"f\"channel_0x{cluster.cluster_id:04x}\"",
"self",
".",
... | [
84,
4
] | [
103,
40
] | python | en | ['en', 'fy', 'it'] | False |
ZigbeeChannel.id | (self) | Return channel id unique for this device only. | Return channel id unique for this device only. | def id(self) -> str:
"""Return channel id unique for this device only."""
return self._id | [
"def",
"id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_id"
] | [
106,
4
] | [
108,
23
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.generic_id | (self) | Return the generic id for this channel. | Return the generic id for this channel. | def generic_id(self):
"""Return the generic id for this channel."""
return self._generic_id | [
"def",
"generic_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_generic_id"
] | [
111,
4
] | [
113,
31
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.unique_id | (self) | Return the unique id for this channel. | Return the unique id for this channel. | def unique_id(self):
"""Return the unique id for this channel."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
116,
4
] | [
118,
30
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.cluster | (self) | Return the zigpy cluster for this channel. | Return the zigpy cluster for this channel. | def cluster(self):
"""Return the zigpy cluster for this channel."""
return self._cluster | [
"def",
"cluster",
"(",
"self",
")",
":",
"return",
"self",
".",
"_cluster"
] | [
121,
4
] | [
123,
28
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.name | (self) | Return friendly name. | Return friendly name. | def name(self) -> str:
"""Return friendly name."""
return self._channel_name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_channel_name"
] | [
126,
4
] | [
128,
33
] | python | en | ['en', 'ig', 'en'] | True |
ZigbeeChannel.status | (self) | Return the status of the channel. | Return the status of the channel. | def status(self):
"""Return the status of the channel."""
return self._status | [
"def",
"status",
"(",
"self",
")",
":",
"return",
"self",
".",
"_status"
] | [
131,
4
] | [
133,
27
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.async_send_signal | (self, signal: str, *args: Any) | Send a signal through hass dispatcher. | Send a signal through hass dispatcher. | def async_send_signal(self, signal: str, *args: Any) -> None:
"""Send a signal through hass dispatcher."""
self._ch_pool.async_send_signal(signal, *args) | [
"def",
"async_send_signal",
"(",
"self",
",",
"signal",
":",
"str",
",",
"*",
"args",
":",
"Any",
")",
"->",
"None",
":",
"self",
".",
"_ch_pool",
".",
"async_send_signal",
"(",
"signal",
",",
"*",
"args",
")"
] | [
136,
4
] | [
138,
54
] | python | en | ['en', 'lb', 'en'] | True |
ZigbeeChannel.bind | (self) | Bind a zigbee cluster.
This also swallows ZigbeeException exceptions that are thrown when
devices are unreachable.
| Bind a zigbee cluster. | async def bind(self):
"""Bind a zigbee cluster.
This also swallows ZigbeeException exceptions that are thrown when
devices are unreachable.
"""
try:
res = await self.cluster.bind()
self.debug("bound '%s' cluster: %s", self.cluster.ep_attribute, res[0])
... | [
"async",
"def",
"bind",
"(",
"self",
")",
":",
"try",
":",
"res",
"=",
"await",
"self",
".",
"cluster",
".",
"bind",
"(",
")",
"self",
".",
"debug",
"(",
"\"bound '%s' cluster: %s\"",
",",
"self",
".",
"cluster",
".",
"ep_attribute",
",",
"res",
"[",
... | [
140,
4
] | [
152,
13
] | python | en | ['en', 'ig', 'nl'] | False |
ZigbeeChannel.configure_reporting | (self) | Configure attribute reporting for a cluster.
This also swallows ZigbeeException exceptions that are thrown when
devices are unreachable.
| Configure attribute reporting for a cluster. | async def configure_reporting(self) -> None:
"""Configure attribute reporting for a cluster.
This also swallows ZigbeeException exceptions that are thrown when
devices are unreachable.
"""
kwargs = {}
if self.cluster.cluster_id >= 0xFC00 and self._ch_pool.manufacturer_co... | [
"async",
"def",
"configure_reporting",
"(",
"self",
")",
"->",
"None",
":",
"kwargs",
"=",
"{",
"}",
"if",
"self",
".",
"cluster",
".",
"cluster_id",
">=",
"0xFC00",
"and",
"self",
".",
"_ch_pool",
".",
"manufacturer_code",
":",
"kwargs",
"[",
"\"manufactu... | [
154,
4
] | [
187,
17
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.async_configure | (self) | Set cluster binding and attribute reporting. | Set cluster binding and attribute reporting. | async def async_configure(self):
"""Set cluster binding and attribute reporting."""
if not self._ch_pool.skip_configuration:
await self.bind()
if self.cluster.is_server:
await self.configure_reporting()
self.debug("finished channel configuration")
... | [
"async",
"def",
"async_configure",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_ch_pool",
".",
"skip_configuration",
":",
"await",
"self",
".",
"bind",
"(",
")",
"if",
"self",
".",
"cluster",
".",
"is_server",
":",
"await",
"self",
".",
"configure_... | [
189,
4
] | [
198,
47
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.async_initialize | (self, from_cache) | Initialize channel. | Initialize channel. | async def async_initialize(self, from_cache):
"""Initialize channel."""
if not from_cache and self._ch_pool.skip_configuration:
self._status = ChannelStatus.INITIALIZED
return
self.debug("initializing channel: from_cache: %s", from_cache)
attributes = []
... | [
"async",
"def",
"async_initialize",
"(",
"self",
",",
"from_cache",
")",
":",
"if",
"not",
"from_cache",
"and",
"self",
".",
"_ch_pool",
".",
"skip_configuration",
":",
"self",
".",
"_status",
"=",
"ChannelStatus",
".",
"INITIALIZED",
"return",
"self",
".",
... | [
200,
4
] | [
212,
48
] | python | en | ['en', 'en', 'en'] | False |
ZigbeeChannel.cluster_command | (self, tsn, command_id, args) | Handle commands received to this cluster. | Handle commands received to this cluster. | def cluster_command(self, tsn, command_id, args):
"""Handle commands received to this cluster.""" | [
"def",
"cluster_command",
"(",
"self",
",",
"tsn",
",",
"command_id",
",",
"args",
")",
":"
] | [
215,
4
] | [
216,
55
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.attribute_updated | (self, attrid, value) | Handle attribute updates on this cluster. | Handle attribute updates on this cluster. | def attribute_updated(self, attrid, value):
"""Handle attribute updates on this cluster."""
self.async_send_signal(
f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}",
attrid,
self.cluster.attributes.get(attrid, [attrid])[0],
value,
) | [
"def",
"attribute_updated",
"(",
"self",
",",
"attrid",
",",
"value",
")",
":",
"self",
".",
"async_send_signal",
"(",
"f\"{self.unique_id}_{SIGNAL_ATTR_UPDATED}\"",
",",
"attrid",
",",
"self",
".",
"cluster",
".",
"attributes",
".",
"get",
"(",
"attrid",
",",
... | [
219,
4
] | [
226,
9
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.zdo_command | (self, *args, **kwargs) | Handle ZDO commands on this cluster. | Handle ZDO commands on this cluster. | def zdo_command(self, *args, **kwargs):
"""Handle ZDO commands on this cluster.""" | [
"def",
"zdo_command",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":"
] | [
229,
4
] | [
230,
50
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.zha_send_event | (self, command: str, args: Union[int, dict]) | Relay events to hass. | Relay events to hass. | def zha_send_event(self, command: str, args: Union[int, dict]) -> None:
"""Relay events to hass."""
self._ch_pool.zha_send_event(
{
ATTR_UNIQUE_ID: self.unique_id,
ATTR_CLUSTER_ID: self.cluster.cluster_id,
ATTR_COMMAND: command,
... | [
"def",
"zha_send_event",
"(",
"self",
",",
"command",
":",
"str",
",",
"args",
":",
"Union",
"[",
"int",
",",
"dict",
"]",
")",
"->",
"None",
":",
"self",
".",
"_ch_pool",
".",
"zha_send_event",
"(",
"{",
"ATTR_UNIQUE_ID",
":",
"self",
".",
"unique_id"... | [
233,
4
] | [
242,
9
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.async_update | (self) | Retrieve latest state from cluster. | Retrieve latest state from cluster. | async def async_update(self):
"""Retrieve latest state from cluster.""" | [
"async",
"def",
"async_update",
"(",
"self",
")",
":"
] | [
244,
4
] | [
245,
49
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.get_attribute_value | (self, attribute, from_cache=True) | Get the value for an attribute. | Get the value for an attribute. | async def get_attribute_value(self, attribute, from_cache=True):
"""Get the value for an attribute."""
manufacturer = None
manufacturer_code = self._ch_pool.manufacturer_code
if self.cluster.cluster_id >= 0xFC00 and manufacturer_code:
manufacturer = manufacturer_code
... | [
"async",
"def",
"get_attribute_value",
"(",
"self",
",",
"attribute",
",",
"from_cache",
"=",
"True",
")",
":",
"manufacturer",
"=",
"None",
"manufacturer_code",
"=",
"self",
".",
"_ch_pool",
".",
"manufacturer_code",
"if",
"self",
".",
"cluster",
".",
"cluste... | [
247,
4
] | [
260,
36
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.get_attributes | (self, attributes, from_cache=True) | Get the values for a list of attributes. | Get the values for a list of attributes. | async def get_attributes(self, attributes, from_cache=True):
"""Get the values for a list of attributes."""
manufacturer = None
manufacturer_code = self._ch_pool.manufacturer_code
if self.cluster.cluster_id >= 0xFC00 and manufacturer_code:
manufacturer = manufacturer_code
... | [
"async",
"def",
"get_attributes",
"(",
"self",
",",
"attributes",
",",
"from_cache",
"=",
"True",
")",
":",
"manufacturer",
"=",
"None",
"manufacturer_code",
"=",
"self",
".",
"_ch_pool",
".",
"manufacturer_code",
"if",
"self",
".",
"cluster",
".",
"cluster_id... | [
262,
4
] | [
283,
21
] | python | en | ['en', 'en', 'en'] | True |
ZigbeeChannel.log | (self, level, msg, *args) | Log a message. | Log a message. | def log(self, level, msg, *args):
"""Log a message."""
msg = f"[%s:%s]: {msg}"
args = (self._ch_pool.nwk, self._id) + args
_LOGGER.log(level, msg, *args) | [
"def",
"log",
"(",
"self",
",",
"level",
",",
"msg",
",",
"*",
"args",
")",
":",
"msg",
"=",
"f\"[%s:%s]: {msg}\"",
"args",
"=",
"(",
"self",
".",
"_ch_pool",
".",
"nwk",
",",
"self",
".",
"_id",
")",
"+",
"args",
"_LOGGER",
".",
"log",
"(",
"lev... | [
285,
4
] | [
289,
38
] | python | en | ['en', 'lb', 'en'] | True |
ZigbeeChannel.__getattr__ | (self, name) | Get attribute or a decorated cluster command. | Get attribute or a decorated cluster command. | def __getattr__(self, name):
"""Get attribute or a decorated cluster command."""
if hasattr(self._cluster, name) and callable(getattr(self._cluster, name)):
command = getattr(self._cluster, name)
command.__name__ = name
return decorate_command(self, command)
r... | [
"def",
"__getattr__",
"(",
"self",
",",
"name",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"_cluster",
",",
"name",
")",
"and",
"callable",
"(",
"getattr",
"(",
"self",
".",
"_cluster",
",",
"name",
")",
")",
":",
"command",
"=",
"getattr",
"(",
... | [
291,
4
] | [
297,
42
] | python | en | ['en', 'en', 'en'] | True |
ZDOChannel.__init__ | (self, cluster, device) | Initialize ZDOChannel. | Initialize ZDOChannel. | def __init__(self, cluster, device):
"""Initialize ZDOChannel."""
self.name = CHANNEL_ZDO
self._cluster = cluster
self._zha_device = device
self._status = ChannelStatus.CREATED
self._unique_id = "{}:{}_ZDO".format(str(device.ieee), device.name)
self._cluster.add_l... | [
"def",
"__init__",
"(",
"self",
",",
"cluster",
",",
"device",
")",
":",
"self",
".",
"name",
"=",
"CHANNEL_ZDO",
"self",
".",
"_cluster",
"=",
"cluster",
"self",
".",
"_zha_device",
"=",
"device",
"self",
".",
"_status",
"=",
"ChannelStatus",
".",
"CREA... | [
303,
4
] | [
310,
40
] | python | en | ['en', 'pl', 'it'] | False |
ZDOChannel.unique_id | (self) | Return the unique id for this channel. | Return the unique id for this channel. | def unique_id(self):
"""Return the unique id for this channel."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
313,
4
] | [
315,
30
] | python | en | ['en', 'en', 'en'] | True |
ZDOChannel.cluster | (self) | Return the aigpy cluster for this channel. | Return the aigpy cluster for this channel. | def cluster(self):
"""Return the aigpy cluster for this channel."""
return self._cluster | [
"def",
"cluster",
"(",
"self",
")",
":",
"return",
"self",
".",
"_cluster"
] | [
318,
4
] | [
320,
28
] | python | en | ['en', 'en', 'ur'] | True |
ZDOChannel.status | (self) | Return the status of the channel. | Return the status of the channel. | def status(self):
"""Return the status of the channel."""
return self._status | [
"def",
"status",
"(",
"self",
")",
":",
"return",
"self",
".",
"_status"
] | [
323,
4
] | [
325,
27
] | python | en | ['en', 'en', 'en'] | True |
ZDOChannel.device_announce | (self, zigpy_device) | Device announce handler. | Device announce handler. | def device_announce(self, zigpy_device):
"""Device announce handler.""" | [
"def",
"device_announce",
"(",
"self",
",",
"zigpy_device",
")",
":"
] | [
328,
4
] | [
329,
38
] | python | en | ['en', 'en', 'en'] | True |
ZDOChannel.permit_duration | (self, duration) | Permit handler. | Permit handler. | def permit_duration(self, duration):
"""Permit handler.""" | [
"def",
"permit_duration",
"(",
"self",
",",
"duration",
")",
":"
] | [
332,
4
] | [
333,
29
] | python | de | ['de', 'de', 'en'] | False |
ZDOChannel.async_initialize | (self, from_cache) | Initialize channel. | Initialize channel. | async def async_initialize(self, from_cache):
"""Initialize channel."""
self._status = ChannelStatus.INITIALIZED | [
"async",
"def",
"async_initialize",
"(",
"self",
",",
"from_cache",
")",
":",
"self",
".",
"_status",
"=",
"ChannelStatus",
".",
"INITIALIZED"
] | [
335,
4
] | [
337,
48
] | python | en | ['en', 'en', 'en'] | False |
ZDOChannel.async_configure | (self) | Configure channel. | Configure channel. | async def async_configure(self):
"""Configure channel."""
self._status = ChannelStatus.CONFIGURED | [
"async",
"def",
"async_configure",
"(",
"self",
")",
":",
"self",
".",
"_status",
"=",
"ChannelStatus",
".",
"CONFIGURED"
] | [
339,
4
] | [
341,
47
] | python | en | ['en', 'fr', 'en'] | False |
ZDOChannel.log | (self, level, msg, *args) | Log a message. | Log a message. | def log(self, level, msg, *args):
"""Log a message."""
msg = f"[%s:ZDO](%s): {msg}"
args = (self._zha_device.nwk, self._zha_device.model) + args
_LOGGER.log(level, msg, *args) | [
"def",
"log",
"(",
"self",
",",
"level",
",",
"msg",
",",
"*",
"args",
")",
":",
"msg",
"=",
"f\"[%s:ZDO](%s): {msg}\"",
"args",
"=",
"(",
"self",
".",
"_zha_device",
".",
"nwk",
",",
"self",
".",
"_zha_device",
".",
"model",
")",
"+",
"args",
"_LOGG... | [
343,
4
] | [
347,
38
] | python | en | ['en', 'lb', 'en'] | True |
ClientChannel.attribute_updated | (self, attrid, value) | Handle an attribute updated on this cluster. | Handle an attribute updated on this cluster. | def attribute_updated(self, attrid, value):
"""Handle an attribute updated on this cluster."""
self.zha_send_event(
SIGNAL_ATTR_UPDATED,
{
ATTR_ATTRIBUTE_ID: attrid,
ATTR_ATTRIBUTE_NAME: self._cluster.attributes.get(attrid, ["Unknown"])[
... | [
"def",
"attribute_updated",
"(",
"self",
",",
"attrid",
",",
"value",
")",
":",
"self",
".",
"zha_send_event",
"(",
"SIGNAL_ATTR_UPDATED",
",",
"{",
"ATTR_ATTRIBUTE_ID",
":",
"attrid",
",",
"ATTR_ATTRIBUTE_NAME",
":",
"self",
".",
"_cluster",
".",
"attributes",
... | [
354,
4
] | [
365,
9
] | python | en | ['en', 'en', 'en'] | True |
ClientChannel.cluster_command | (self, tsn, command_id, args) | Handle a cluster command received on this cluster. | Handle a cluster command received on this cluster. | def cluster_command(self, tsn, command_id, args):
"""Handle a cluster command received on this cluster."""
if (
self._cluster.server_commands is not None
and self._cluster.server_commands.get(command_id) is not None
):
self.zha_send_event(self._cluster.server_... | [
"def",
"cluster_command",
"(",
"self",
",",
"tsn",
",",
"command_id",
",",
"args",
")",
":",
"if",
"(",
"self",
".",
"_cluster",
".",
"server_commands",
"is",
"not",
"None",
"and",
"self",
".",
"_cluster",
".",
"server_commands",
".",
"get",
"(",
"comman... | [
368,
4
] | [
374,
87
] | python | en | ['en', 'en', 'en'] | True |
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
] | [
107,
34
] | python | en | ['en', 'error', 'th'] | False |
LEDLearnedPositionalEmbedding.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",
... | [
118,
4
] | [
124,
41
] | python | en | ['en', 'en', 'en'] | True |
LEDEncoderSelfAttention.forward | (
self,
hidden_states,
attention_mask=None,
layer_head_mask=None,
is_index_masked=None,
is_index_global_attn=None,
is_global_attn=None,
output_attentions=False,
) |
:class:`LEDEncoderSelfAttention` expects `len(hidden_states)` to be multiple of `attention_window`. Padding to
`attention_window` happens in :meth:`LEDEncoderModel.forward` to avoid redoing the padding on each layer.
The `attention_mask` is changed in :meth:`LEDEncoderModel.forward` from 0, 1,... |
:class:`LEDEncoderSelfAttention` expects `len(hidden_states)` to be multiple of `attention_window`. Padding to
`attention_window` happens in :meth:`LEDEncoderModel.forward` to avoid redoing the padding on each layer. | def forward(
self,
hidden_states,
attention_mask=None,
layer_head_mask=None,
is_index_masked=None,
is_index_global_attn=None,
is_global_attn=None,
output_attentions=False,
):
"""
:class:`LEDEncoderSelfAttention` expects `len(hidden_stat... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
",",
"attention_mask",
"=",
"None",
",",
"layer_head_mask",
"=",
"None",
",",
"is_index_masked",
"=",
"None",
",",
"is_index_global_attn",
"=",
"None",
",",
"is_global_attn",
"=",
"None",
",",
"output_attentio... | [
162,
4
] | [
323,
100
] | python | en | ['en', 'error', 'th'] | False |
LEDEncoderSelfAttention._pad_and_transpose_last_two_dims | (hidden_states_padded, padding) | pads rows and then flips rows and columns | pads rows and then flips rows and columns | def _pad_and_transpose_last_two_dims(hidden_states_padded, padding):
"""pads rows and then flips rows and columns"""
hidden_states_padded = F.pad(
hidden_states_padded, padding
) # padding value is not important because it will be overwritten
hidden_states_padded = hidden_st... | [
"def",
"_pad_and_transpose_last_two_dims",
"(",
"hidden_states_padded",
",",
"padding",
")",
":",
"hidden_states_padded",
"=",
"F",
".",
"pad",
"(",
"hidden_states_padded",
",",
"padding",
")",
"# padding value is not important because it will be overwritten",
"hidden_states_pa... | [
326,
4
] | [
334,
35
] | python | en | ['en', 'en', 'en'] | True |
LEDEncoderSelfAttention._pad_and_diagonalize | (chunked_hidden_states) |
shift every row 1 step right, converting columns into diagonals.
Example::
chunked_hidden_states: [ 0.4983, 2.6918, -0.0071, 1.0492,
-1.8348, 0.7672, 0.2986, 0.0285,
-0.7584, 0.4206, -0.0405, 0.1599,
... |
shift every row 1 step right, converting columns into diagonals. | def _pad_and_diagonalize(chunked_hidden_states):
"""
shift every row 1 step right, converting columns into diagonals.
Example::
chunked_hidden_states: [ 0.4983, 2.6918, -0.0071, 1.0492,
-1.8348, 0.7672, 0.2986, 0.0285,
... | [
"def",
"_pad_and_diagonalize",
"(",
"chunked_hidden_states",
")",
":",
"total_num_heads",
",",
"num_chunks",
",",
"window_overlap",
",",
"hidden_dim",
"=",
"chunked_hidden_states",
".",
"size",
"(",
")",
"chunked_hidden_states",
"=",
"F",
".",
"pad",
"(",
"chunked_h... | [
337,
4
] | [
368,
36
] | python | en | ['en', 'error', 'th'] | False |
LEDEncoderSelfAttention._chunk | (hidden_states, window_overlap) | convert into overlapping chunks. Chunk size = 2w, overlap size = w | convert into overlapping chunks. Chunk size = 2w, overlap size = w | def _chunk(hidden_states, window_overlap):
"""convert into overlapping chunks. Chunk size = 2w, overlap size = w"""
# non-overlapping chunks of size = 2w
hidden_states = hidden_states.view(
hidden_states.size(0),
hidden_states.size(1) // (window_overlap * 2),
... | [
"def",
"_chunk",
"(",
"hidden_states",
",",
"window_overlap",
")",
":",
"# non-overlapping chunks of size = 2w",
"hidden_states",
"=",
"hidden_states",
".",
"view",
"(",
"hidden_states",
".",
"size",
"(",
"0",
")",
",",
"hidden_states",
".",
"size",
"(",
"1",
")... | [
371,
4
] | [
388,
77
] | python | en | ['en', 'en', 'en'] | True |
LEDEncoderSelfAttention._sliding_chunks_query_key_matmul | (self, query: torch.Tensor, key: torch.Tensor, window_overlap: int) |
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained LEDEncoder) with an
overlap of size window_overlap
|
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrained LEDEncoder) with an
overlap of size window_overlap
| def _sliding_chunks_query_key_matmul(self, query: torch.Tensor, key: torch.Tensor, window_overlap: int):
"""
Matrix multiplication of query and key tensors using with a sliding window attention pattern. This
implementation splits the input into overlapping chunks of size 2w (e.g. 512 for pretrai... | [
"def",
"_sliding_chunks_query_key_matmul",
"(",
"self",
",",
"query",
":",
"torch",
".",
"Tensor",
",",
"key",
":",
"torch",
".",
"Tensor",
",",
"window_overlap",
":",
"int",
")",
":",
"batch_size",
",",
"seq_len",
",",
"num_heads",
",",
"head_dim",
"=",
"... | [
402,
4
] | [
466,
40
] | python | en | ['en', 'error', 'th'] | False |
LEDEncoderSelfAttention._sliding_chunks_matmul_attn_probs_value | (
self, attn_probs: torch.Tensor, value: torch.Tensor, window_overlap: int
) |
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
|
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
| def _sliding_chunks_matmul_attn_probs_value(
self, attn_probs: torch.Tensor, value: torch.Tensor, window_overlap: int
):
"""
Same as _sliding_chunks_query_key_matmul but for attn_probs and value tensors. Returned tensor will be of the
same shape as `attn_probs`
"""
ba... | [
"def",
"_sliding_chunks_matmul_attn_probs_value",
"(",
"self",
",",
"attn_probs",
":",
"torch",
".",
"Tensor",
",",
"value",
":",
"torch",
".",
"Tensor",
",",
"window_overlap",
":",
"int",
")",
":",
"batch_size",
",",
"seq_len",
",",
"num_heads",
",",
"head_di... | [
468,
4
] | [
507,
85
] | python | en | ['en', 'error', 'th'] | False |
LEDEncoderSelfAttention._get_global_attn_indices | (is_index_global_attn) | compute global attn indices required throughout forward pass | compute global attn indices required throughout forward pass | def _get_global_attn_indices(is_index_global_attn):
""" compute global attn indices required throughout forward pass """
# helper variable
num_global_attn_indices = is_index_global_attn.long().sum(dim=1)
# max number of global attn indices in batch
max_num_global_attn_indices = ... | [
"def",
"_get_global_attn_indices",
"(",
"is_index_global_attn",
")",
":",
"# helper variable",
"num_global_attn_indices",
"=",
"is_index_global_attn",
".",
"long",
"(",
")",
".",
"sum",
"(",
"dim",
"=",
"1",
")",
"# max number of global attn indices in batch",
"max_num_gl... | [
510,
4
] | [
536,
9
] | python | en | ['en', 'en', 'en'] | True |
LEDEncoderAttention.forward | (
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
is_index_masked: Optional[torch.Tensor] = None,
is_index_global_attn: Optional[torch.Tensor] = None,
is_global_attn: Optional[bool] ... | Input shape: Batch x Time x Channel | Input shape: Batch x Time x Channel | def forward(
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
is_index_masked: Optional[torch.Tensor] = None,
is_index_global_attn: Optional[torch.Tensor] = None,
is_global_attn: Opti... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
":",
"torch",
".",
"Tensor",
",",
"attention_mask",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
"None",
",",
"layer_head_mask",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
"None... | [
705,
4
] | [
730,
22
] | python | en | ['en', 'pl', 'en'] | True |
LEDDecoderAttention.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",
... | [
763,
4
] | [
871,
65
] | python | en | ['en', 'pl', 'en'] | True |
LEDEncoderLayer.forward | (
self,
hidden_states: torch.Tensor,
attention_mask: torch.Tensor,
layer_head_mask: torch.Tensor,
is_index_masked=None,
is_index_global_attn=None,
is_global_attn=None,
output_attentions=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,
is_index_masked=None,
is_index_global_attn=None,
is_global_attn=None,
output_attentions=False,
):
"""
Args:
hidden_... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
":",
"torch",
".",
"Tensor",
",",
"attention_mask",
":",
"torch",
".",
"Tensor",
",",
"layer_head_mask",
":",
"torch",
".",
"Tensor",
",",
"is_index_masked",
"=",
"None",
",",
"is_index_global_attn",
"=",
... | [
887,
4
] | [
933,
50
] | python | en | ['en', 'error', 'th'] | False |
LEDDecoderLayer.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",
"]",
"=",
... | [
963,
4
] | [
1048,
22
] | python | en | ['en', 'error', 'th'] | False |
LEDEncoder._pad_to_window_size | (
self,
input_ids: torch.Tensor,
attention_mask: torch.Tensor,
inputs_embeds: torch.Tensor,
pad_token_id: int,
) | A helper function to pad tokens and mask to work with implementation of Longformer self-attention. | A helper function to pad tokens and mask to work with implementation of Longformer self-attention. | def _pad_to_window_size(
self,
input_ids: torch.Tensor,
attention_mask: torch.Tensor,
inputs_embeds: torch.Tensor,
pad_token_id: int,
):
"""A helper function to pad tokens and mask to work with implementation of Longformer self-attention."""
# padding
... | [
"def",
"_pad_to_window_size",
"(",
"self",
",",
"input_ids",
":",
"torch",
".",
"Tensor",
",",
"attention_mask",
":",
"torch",
".",
"Tensor",
",",
"inputs_embeds",
":",
"torch",
".",
"Tensor",
",",
"pad_token_id",
":",
"int",
",",
")",
":",
"# padding",
"a... | [
1653,
4
] | [
1692,
68
] | python | en | ['en', 'en', 'en'] | True |
LEDEncoder.forward | (
self,
input_ids=None,
attention_mask=None,
global_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,
global_attention_mask=None,
head_mask=None,
inputs_embeds=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
):
r"""
Args:
input_ids (:o... | [
"def",
"forward",
"(",
"self",
",",
"input_ids",
"=",
"None",
",",
"attention_mask",
"=",
"None",
",",
"global_attention_mask",
"=",
"None",
",",
"head_mask",
"=",
"None",
",",
"inputs_embeds",
"=",
"None",
",",
"output_attentions",
"=",
"None",
",",
"output... | [
1694,
4
] | [
1876,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
PlumLightpadConfigFlow.async_step_user | (
self, user_input: Optional[ConfigType] = None
) | Handle a flow initialized by the user or redirected to by import. | Handle a flow initialized by the user or redirected to by import. | async def async_step_user(
self, user_input: Optional[ConfigType] = None
) -> Dict[str, Any]:
"""Handle a flow initialized by the user or redirected to by import."""
if not user_input:
return self._show_form()
username = user_input[CONF_USERNAME]
password = user_... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"ConfigType",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"not",
"user_input",
":",
"return",
"self",
".",
"_show_form",
"(",
")",... | [
35,
4
] | [
57,
9
] | python | en | ['en', 'en', 'en'] | True |
PlumLightpadConfigFlow.async_step_import | (
self, import_config: Optional[ConfigType]
) | Import a config entry from configuration.yaml. | Import a config entry from configuration.yaml. | async def async_step_import(
self, import_config: Optional[ConfigType]
) -> Dict[str, Any]:
"""Import a config entry from configuration.yaml."""
return await self.async_step_user(import_config) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_config",
":",
"Optional",
"[",
"ConfigType",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"import_config",
")"
] | [
59,
4
] | [
63,
56
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the ZoneMinder component. | Set up the ZoneMinder component. | def setup(hass, config):
"""Set up the ZoneMinder component."""
hass.data[DOMAIN] = {}
success = True
for conf in config[DOMAIN]:
protocol = "https" if conf[CONF_SSL] else "http"
host_name = conf[CONF_HOST]
server_origin = f"{protocol}://{host_name}"
zm_client = ZoneM... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"success",
"=",
"True",
"for",
"conf",
"in",
"config",
"[",
"DOMAIN",
"]",
":",
"protocol",
"=",
"\"https\"",
"if",
"conf",
"[",
"CONF_SSL... | [
52,
0
] | [
97,
18
] | python | en | ['en', 'en', 'en'] | True |
create_clones | (config, model_fn, args=None, kwargs=None) | Creates multiple clones according to config using a `model_fn`.
The returned values of `model_fn(*args, **kwargs)` are collected along with
the scope and device used to created it in a namedtuple
`Clone(outputs, scope, device)`
Note: it is assumed that any loss created by `model_fn` is collected at
the tf.G... | Creates multiple clones according to config using a `model_fn`. | def create_clones(config, model_fn, args=None, kwargs=None):
"""Creates multiple clones according to config using a `model_fn`.
The returned values of `model_fn(*args, **kwargs)` are collected along with
the scope and device used to created it in a namedtuple
`Clone(outputs, scope, device)`
Note: it is assu... | [
"def",
"create_clones",
"(",
"config",
",",
"model_fn",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"clones",
"=",
"[",
"]",
"args",
"=",
"args",
"or",
"[",
"]",
"kwargs",
"=",
"kwargs",
"or",
"{",
"}",
"with",
"slim",
".",
"a... | [
145,
0
] | [
197,
15
] | python | en | ['en', 'en', 'en'] | True |
_gather_clone_loss | (clone, num_clones, regularization_losses) | Gather the loss for a single clone.
Args:
clone: A Clone namedtuple.
num_clones: The number of clones being deployed.
regularization_losses: Possibly empty list of regularization_losses
to add to the clone losses.
Returns:
A tensor for the total loss for the clone. Can be None.
| Gather the loss for a single clone. | def _gather_clone_loss(clone, num_clones, regularization_losses):
"""Gather the loss for a single clone.
Args:
clone: A Clone namedtuple.
num_clones: The number of clones being deployed.
regularization_losses: Possibly empty list of regularization_losses
to add to the clone losses.
Returns:
... | [
"def",
"_gather_clone_loss",
"(",
"clone",
",",
"num_clones",
",",
"regularization_losses",
")",
":",
"# The return value.",
"sum_loss",
"=",
"None",
"# Individual components of the loss that will need summaries.",
"clone_loss",
"=",
"None",
"regularization_loss",
"=",
"None"... | [
214,
0
] | [
256,
17
] | python | en | ['en', 'en', 'en'] | True |
_optimize_clone | (optimizer, clone, num_clones, regularization_losses,
**kwargs) | Compute losses and gradients for a single clone.
Args:
optimizer: A tf.Optimizer object.
clone: A Clone namedtuple.
num_clones: The number of clones being deployed.
regularization_losses: Possibly empty list of regularization_losses
to add to the clone losses.
**kwargs: Dict of kwarg to pa... | Compute losses and gradients for a single clone. | def _optimize_clone(optimizer, clone, num_clones, regularization_losses,
**kwargs):
"""Compute losses and gradients for a single clone.
Args:
optimizer: A tf.Optimizer object.
clone: A Clone namedtuple.
num_clones: The number of clones being deployed.
regularization_losses: Pos... | [
"def",
"_optimize_clone",
"(",
"optimizer",
",",
"clone",
",",
"num_clones",
",",
"regularization_losses",
",",
"*",
"*",
"kwargs",
")",
":",
"sum_loss",
"=",
"_gather_clone_loss",
"(",
"clone",
",",
"num_clones",
",",
"regularization_losses",
")",
"clone_grad",
... | [
259,
0
] | [
282,
29
] | python | en | ['en', 'en', 'en'] | True |
optimize_clones | (clones, optimizer,
regularization_losses=None,
**kwargs) | Compute clone losses and gradients for the given list of `Clones`.
Note: The regularization_losses are added to the first clone losses.
Args:
clones: List of `Clones` created by `create_clones()`.
optimizer: An `Optimizer` object.
regularization_losses: Optional list of regularization losses. If None it
... | Compute clone losses and gradients for the given list of `Clones`. | def optimize_clones(clones, optimizer,
regularization_losses=None,
**kwargs):
"""Compute clone losses and gradients for the given list of `Clones`.
Note: The regularization_losses are added to the first clone losses.
Args:
clones: List of `Clones` created by `create_cl... | [
"def",
"optimize_clones",
"(",
"clones",
",",
"optimizer",
",",
"regularization_losses",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"grads_and_vars",
"=",
"[",
"]",
"clones_losses",
"=",
"[",
"]",
"num_clones",
"=",
"len",
"(",
"clones",
")",
"if",
... | [
285,
0
] | [
327,
35
] | python | en | ['en', 'en', 'en'] | True |
deploy | (config,
model_fn,
args=None,
kwargs=None,
optimizer=None,
summarize_gradients=False) | Deploys a Slim-constructed model across multiple clones.
The deployment options are specified by the config object and support
deploying one or several clones on different GPUs and one or several replicas
of such clones.
The argument `model_fn` is called `config.num_clones` times to create the
model clones ... | Deploys a Slim-constructed model across multiple clones. | def deploy(config,
model_fn,
args=None,
kwargs=None,
optimizer=None,
summarize_gradients=False):
"""Deploys a Slim-constructed model across multiple clones.
The deployment options are specified by the config object and support
deploying one or several clones... | [
"def",
"deploy",
"(",
"config",
",",
"model_fn",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"optimizer",
"=",
"None",
",",
"summarize_gradients",
"=",
"False",
")",
":",
"# Gather initial summaries.",
"summaries",
"=",
"set",
"(",
"tf",
"."... | [
330,
0
] | [
433,
64
] | python | en | ['es', 'en', 'en'] | True |
_sum_clones_gradients | (clone_grads) | Calculate the sum gradient for each shared variable across all clones.
This function assumes that the clone_grads has been scaled appropriately by
1 / num_clones.
Args:
clone_grads: A List of List of tuples (gradient, variable), one list per
`Clone`.
Returns:
List of tuples of (gradient, variabl... | Calculate the sum gradient for each shared variable across all clones. | def _sum_clones_gradients(clone_grads):
"""Calculate the sum gradient for each shared variable across all clones.
This function assumes that the clone_grads has been scaled appropriately by
1 / num_clones.
Args:
clone_grads: A List of List of tuples (gradient, variable), one list per
`Clone`.
Retur... | [
"def",
"_sum_clones_gradients",
"(",
"clone_grads",
")",
":",
"sum_grads",
"=",
"[",
"]",
"for",
"grad_and_vars",
"in",
"zip",
"(",
"*",
"clone_grads",
")",
":",
"# Note that each grad_and_vars looks like the following:",
"# ((grad_var0_clone0, var0), ... (grad_varN_cloneN,... | [
436,
0
] | [
466,
18
] | python | en | ['en', 'en', 'en'] | True |
_add_gradients_summaries | (grads_and_vars) | Add histogram summaries to gradients.
Note: The summaries are also added to the SUMMARIES collection.
Args:
grads_and_vars: A list of gradient to variable pairs (tuples).
Returns:
The _list_ of the added summaries for grads_and_vars.
| Add histogram summaries to gradients. | def _add_gradients_summaries(grads_and_vars):
"""Add histogram summaries to gradients.
Note: The summaries are also added to the SUMMARIES collection.
Args:
grads_and_vars: A list of gradient to variable pairs (tuples).
Returns:
The _list_ of the added summaries for grads_and_vars.
"""
summaries ... | [
"def",
"_add_gradients_summaries",
"(",
"grads_and_vars",
")",
":",
"summaries",
"=",
"[",
"]",
"for",
"grad",
",",
"var",
"in",
"grads_and_vars",
":",
"if",
"grad",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"grad",
",",
"tf",
".",
"IndexedSlices"... | [
469,
0
] | [
493,
18
] | python | en | ['en', 'de', 'en'] | True |
DeploymentConfig.__init__ | (self,
num_clones=1,
clone_on_cpu=False,
replica_id=0,
num_replicas=1,
num_ps_tasks=0,
worker_job_name='worker',
ps_job_name='ps') | Create a DeploymentConfig.
The config describes how to deploy a model across multiple clones and
replicas. The model will be replicated `num_clones` times in each replica.
If `clone_on_cpu` is True, each clone will placed on CPU.
If `num_replicas` is 1, the model is deployed via a single process. In... | Create a DeploymentConfig. | def __init__(self,
num_clones=1,
clone_on_cpu=False,
replica_id=0,
num_replicas=1,
num_ps_tasks=0,
worker_job_name='worker',
ps_job_name='ps'):
"""Create a DeploymentConfig.
The config describes how to depl... | [
"def",
"__init__",
"(",
"self",
",",
"num_clones",
"=",
"1",
",",
"clone_on_cpu",
"=",
"False",
",",
"replica_id",
"=",
"0",
",",
"num_replicas",
"=",
"1",
",",
"num_ps_tasks",
"=",
"0",
",",
"worker_job_name",
"=",
"'worker'",
",",
"ps_job_name",
"=",
"... | [
504,
2
] | [
554,
79
] | python | en | ['en', 'gl', 'en'] | True |
DeploymentConfig.caching_device | (self) | Returns the device to use for caching variables.
Variables are cached on the worker CPU when using replicas.
Returns:
A device string or None if the variables do not need to be cached.
| Returns the device to use for caching variables. | def caching_device(self):
"""Returns the device to use for caching variables.
Variables are cached on the worker CPU when using replicas.
Returns:
A device string or None if the variables do not need to be cached.
"""
if self._num_ps_tasks > 0:
return lambda op: op.device
else:
... | [
"def",
"caching_device",
"(",
"self",
")",
":",
"if",
"self",
".",
"_num_ps_tasks",
">",
"0",
":",
"return",
"lambda",
"op",
":",
"op",
".",
"device",
"else",
":",
"return",
"None"
] | [
584,
2
] | [
595,
17
] | python | en | ['en', 'en', 'en'] | True |
DeploymentConfig.clone_device | (self, clone_index) | Device used to create the clone and all the ops inside the clone.
Args:
clone_index: Int, representing the clone_index.
Returns:
A value suitable for `tf.device()`.
Raises:
ValueError: if `clone_index` is greater or equal to the number of clones".
| Device used to create the clone and all the ops inside the clone. | def clone_device(self, clone_index):
"""Device used to create the clone and all the ops inside the clone.
Args:
clone_index: Int, representing the clone_index.
Returns:
A value suitable for `tf.device()`.
Raises:
ValueError: if `clone_index` is greater or equal to the number of clon... | [
"def",
"clone_device",
"(",
"self",
",",
"clone_index",
")",
":",
"if",
"clone_index",
">=",
"self",
".",
"_num_clones",
":",
"raise",
"ValueError",
"(",
"'clone_index must be less than num_clones'",
")",
"device",
"=",
"''",
"if",
"self",
".",
"_num_ps_tasks",
... | [
597,
2
] | [
618,
17
] | python | en | ['en', 'en', 'en'] | True |
DeploymentConfig.clone_scope | (self, clone_index) | Name scope to create the clone.
Args:
clone_index: Int, representing the clone_index.
Returns:
A name_scope suitable for `tf.name_scope()`.
Raises:
ValueError: if `clone_index` is greater or equal to the number of clones".
| Name scope to create the clone. | def clone_scope(self, clone_index):
"""Name scope to create the clone.
Args:
clone_index: Int, representing the clone_index.
Returns:
A name_scope suitable for `tf.name_scope()`.
Raises:
ValueError: if `clone_index` is greater or equal to the number of clones".
"""
if clone_... | [
"def",
"clone_scope",
"(",
"self",
",",
"clone_index",
")",
":",
"if",
"clone_index",
">=",
"self",
".",
"_num_clones",
":",
"raise",
"ValueError",
"(",
"'clone_index must be less than num_clones'",
")",
"scope",
"=",
"''",
"if",
"self",
".",
"_num_clones",
">",... | [
620,
2
] | [
637,
16
] | python | en | ['en', 'mi', 'en'] | True |
DeploymentConfig.optimizer_device | (self) | Device to use with the optimizer.
Returns:
A value suitable for `tf.device()`.
| Device to use with the optimizer. | def optimizer_device(self):
"""Device to use with the optimizer.
Returns:
A value suitable for `tf.device()`.
"""
if self._num_ps_tasks > 0 or self._num_clones > 0:
device = self._worker_device
device += _get_device(self._clone_on_cpu).name
return device
else:
return '... | [
"def",
"optimizer_device",
"(",
"self",
")",
":",
"if",
"self",
".",
"_num_ps_tasks",
">",
"0",
"or",
"self",
".",
"_num_clones",
">",
"0",
":",
"device",
"=",
"self",
".",
"_worker_device",
"device",
"+=",
"_get_device",
"(",
"self",
".",
"_clone_on_cpu",... | [
639,
2
] | [
650,
15
] | python | en | ['en', 'en', 'en'] | True |
DeploymentConfig.inputs_device | (self) | Device to use to build the inputs.
Returns:
A value suitable for `tf.device()`.
| Device to use to build the inputs. | def inputs_device(self):
"""Device to use to build the inputs.
Returns:
A value suitable for `tf.device()`.
"""
device = ''
if self._num_ps_tasks > 0:
device += self._worker_device
device += '/device:CPU:0'
return device | [
"def",
"inputs_device",
"(",
"self",
")",
":",
"device",
"=",
"''",
"if",
"self",
".",
"_num_ps_tasks",
">",
"0",
":",
"device",
"+=",
"self",
".",
"_worker_device",
"device",
"+=",
"'/device:CPU:0'",
"return",
"device"
] | [
652,
2
] | [
662,
17
] | python | en | ['en', 'en', 'en'] | True |
DeploymentConfig.variables_device | (self) | Returns the device to use for variables created inside the clone.
Returns:
A value suitable for `tf.device()`.
| Returns the device to use for variables created inside the clone. | def variables_device(self):
"""Returns the device to use for variables created inside the clone.
Returns:
A value suitable for `tf.device()`.
"""
device = ''
if self._num_ps_tasks > 0:
device += self._ps_device
device += _get_device(self._clone_on_cpu).name
class _PSDeviceChoo... | [
"def",
"variables_device",
"(",
"self",
")",
":",
"device",
"=",
"''",
"if",
"self",
".",
"_num_ps_tasks",
">",
"0",
":",
"device",
"+=",
"self",
".",
"_ps_device",
"device",
"+=",
"_get_device",
"(",
"self",
".",
"_clone_on_cpu",
")",
".",
"name",
"clas... | [
664,
2
] | [
700,
27
] | python | en | ['en', 'en', 'en'] | True |
is_closed | (hass, entity_id) | Return if the cover is closed based on the statemachine. | Return if the cover is closed based on the statemachine. | def is_closed(hass, entity_id):
"""Return if the cover is closed based on the statemachine."""
return hass.states.is_state(entity_id, STATE_CLOSED) | [
"def",
"is_closed",
"(",
"hass",
",",
"entity_id",
")",
":",
"return",
"hass",
".",
"states",
".",
"is_state",
"(",
"entity_id",
",",
"STATE_CLOSED",
")"
] | [
83,
0
] | [
85,
56
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Track states and offer events for covers. | Track states and offer events for covers. | async def async_setup(hass, config):
"""Track states and offer events for covers."""
component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
component.async_register_entity_service(
SERVICE_OPEN_COVER, {}, "async_o... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"component",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
",",
"SCAN_INTERVAL",
")",
"await",
"component",
".",
"asy... | [
88,
0
] | [
153,
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.