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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Font.color | (self) |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... |
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
... | def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A name... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
63,
28
] | python | en | ['en', 'error', 'th'] | False |
Font.family | (self) |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... |
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts ... | def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
prefer... | [
"def",
"family",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"family\"",
"]"
] | [
72,
4
] | [
94,
29
] | python | en | ['en', 'error', 'th'] | False |
Font.size | (self) |
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
|
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf] | def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
Returns
-------
int|float
"""
return self["size"] | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"size\"",
"]"
] | [
103,
4
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
Font.__init__ | (self, arg=None, color=None, family=None, size=None, **kwargs) |
Construct a new Font object
Sets the hover label text font. By default uses the global
hover font and size, with color from `hoverlabel.bordercolor`.
Parameters
----------
arg
dict of properties compatible with this constructor or
an ins... |
Construct a new Font object
Sets the hover label text font. By default uses the global
hover font and size, with color from `hoverlabel.bordercolor`. | def __init__(self, arg=None, color=None, family=None, size=None, **kwargs):
"""
Construct a new Font object
Sets the hover label text font. By default uses the global
hover font and size, with color from `hoverlabel.bordercolor`.
Parameters
----------
ar... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"family",
"=",
"None",
",",
"size",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Font",
",",
"self",
")",
".",
"__init__",
"(",
"\"font\"",... | [
143,
4
] | [
227,
34
] | python | en | ['en', 'error', 'th'] | False |
Title.font | (self) |
Sets the title font. Note that the title's font used to be
customized by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.layout.title.Font`
- A dict of stri... |
Sets the title font. Note that the title's font used to be
customized by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.layout.title.Font`
- A dict of stri... | def font(self):
"""
Sets the title font. Note that the title's font used to be
customized by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.layout.title.Font`... | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | [
25,
4
] | [
63,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.pad | (self) |
Sets the padding of the title. Each padding value only applies
when the corresponding `xanchor`/`yanchor` value is set
accordingly. E.g. for left padding to take effect, `xanchor`
must be set to "left". The same rule applies if
`xanchor`/`yanchor` is determined automatically. Pa... |
Sets the padding of the title. Each padding value only applies
when the corresponding `xanchor`/`yanchor` value is set
accordingly. E.g. for left padding to take effect, `xanchor`
must be set to "left". The same rule applies if
`xanchor`/`yanchor` is determined automatically. Pa... | def pad(self):
"""
Sets the padding of the title. Each padding value only applies
when the corresponding `xanchor`/`yanchor` value is set
accordingly. E.g. for left padding to take effect, `xanchor`
must be set to "left". The same rule applies if
`xanchor`/`yanchor` is de... | [
"def",
"pad",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"pad\"",
"]"
] | [
72,
4
] | [
106,
26
] | python | en | ['en', 'error', 'th'] | False |
Title.text | (self) |
Sets the plot's title. Note that before the existence of
`title.text`, the title's contents used to be defined as the
`title` attribute itself. This behavior has been deprecated.
The 'text' property is a string and must be specified as:
- A string
- A number tha... |
Sets the plot's title. Note that before the existence of
`title.text`, the title's contents used to be defined as the
`title` attribute itself. This behavior has been deprecated.
The 'text' property is a string and must be specified as:
- A string
- A number tha... | def text(self):
"""
Sets the plot's title. Note that before the existence of
`title.text`, the title's contents used to be defined as the
`title` attribute itself. This behavior has been deprecated.
The 'text' property is a string and must be specified as:
- A stri... | [
"def",
"text",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"text\"",
"]"
] | [
115,
4
] | [
129,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.x | (self) |
Sets the x position with respect to `xref` in normalized
coordinates from 0 (left) to 1 (right).
The 'x' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
|
Sets the x position with respect to `xref` in normalized
coordinates from 0 (left) to 1 (right).
The 'x' property is a number and may be specified as:
- An int or float in the interval [0, 1] | def x(self):
"""
Sets the x position with respect to `xref` in normalized
coordinates from 0 (left) to 1 (right).
The 'x' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
"""
... | [
"def",
"x",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"x\"",
"]"
] | [
138,
4
] | [
150,
24
] | python | en | ['en', 'error', 'th'] | False |
Title.xanchor | (self) |
Sets the title's horizontal alignment with respect to its x
position. "left" means that the title starts at x, "right"
means that the title ends at x and "center" means that the
title's center is at x. "auto" divides `xref` by three and
calculates the `xanchor` value automatical... |
Sets the title's horizontal alignment with respect to its x
position. "left" means that the title starts at x, "right"
means that the title ends at x and "center" means that the
title's center is at x. "auto" divides `xref` by three and
calculates the `xanchor` value automatical... | def xanchor(self):
"""
Sets the title's horizontal alignment with respect to its x
position. "left" means that the title starts at x, "right"
means that the title ends at x and "center" means that the
title's center is at x. "auto" divides `xref` by three and
calculates t... | [
"def",
"xanchor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"xanchor\"",
"]"
] | [
159,
4
] | [
176,
30
] | python | en | ['en', 'error', 'th'] | False |
Title.xref | (self) |
Sets the container `x` refers to. "container" spans the entire
`width` of the plot. "paper" refers to the width of the
plotting area only.
The 'xref' property is an enumeration that may be specified as:
- One of the following enumeration values:
['containe... |
Sets the container `x` refers to. "container" spans the entire
`width` of the plot. "paper" refers to the width of the
plotting area only.
The 'xref' property is an enumeration that may be specified as:
- One of the following enumeration values:
['containe... | def xref(self):
"""
Sets the container `x` refers to. "container" spans the entire
`width` of the plot. "paper" refers to the width of the
plotting area only.
The 'xref' property is an enumeration that may be specified as:
- One of the following enumeration values:... | [
"def",
"xref",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"xref\"",
"]"
] | [
185,
4
] | [
199,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.y | (self) |
Sets the y position with respect to `yref` in normalized
coordinates from 0 (bottom) to 1 (top). "auto" places the
baseline of the title onto the vertical center of the top
margin.
The 'y' property is a number and may be specified as:
- An int or float in the inte... |
Sets the y position with respect to `yref` in normalized
coordinates from 0 (bottom) to 1 (top). "auto" places the
baseline of the title onto the vertical center of the top
margin.
The 'y' property is a number and may be specified as:
- An int or float in the inte... | def y(self):
"""
Sets the y position with respect to `yref` in normalized
coordinates from 0 (bottom) to 1 (top). "auto" places the
baseline of the title onto the vertical center of the top
margin.
The 'y' property is a number and may be specified as:
- An ... | [
"def",
"y",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"y\"",
"]"
] | [
208,
4
] | [
222,
24
] | python | en | ['en', 'error', 'th'] | False |
Title.yanchor | (self) |
Sets the title's vertical alignment with respect to its y
position. "top" means that the title's cap line is at y,
"bottom" means that the title's baseline is at y and "middle"
means that the title's midline is at y. "auto" divides `yref`
by three and calculates the `yanchor` va... |
Sets the title's vertical alignment with respect to its y
position. "top" means that the title's cap line is at y,
"bottom" means that the title's baseline is at y and "middle"
means that the title's midline is at y. "auto" divides `yref`
by three and calculates the `yanchor` va... | def yanchor(self):
"""
Sets the title's vertical alignment with respect to its y
position. "top" means that the title's cap line is at y,
"bottom" means that the title's baseline is at y and "middle"
means that the title's midline is at y. "auto" divides `yref`
by three a... | [
"def",
"yanchor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"yanchor\"",
"]"
] | [
231,
4
] | [
248,
30
] | python | en | ['en', 'error', 'th'] | False |
Title.yref | (self) |
Sets the container `y` refers to. "container" spans the entire
`height` of the plot. "paper" refers to the height of the
plotting area only.
The 'yref' property is an enumeration that may be specified as:
- One of the following enumeration values:
['contai... |
Sets the container `y` refers to. "container" spans the entire
`height` of the plot. "paper" refers to the height of the
plotting area only.
The 'yref' property is an enumeration that may be specified as:
- One of the following enumeration values:
['contai... | def yref(self):
"""
Sets the container `y` refers to. "container" spans the entire
`height` of the plot. "paper" refers to the height of the
plotting area only.
The 'yref' property is an enumeration that may be specified as:
- One of the following enumeration value... | [
"def",
"yref",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"yref\"",
"]"
] | [
257,
4
] | [
271,
27
] | python | en | ['en', 'error', 'th'] | False |
Title.__init__ | (
self,
arg=None,
font=None,
pad=None,
text=None,
x=None,
xanchor=None,
xref=None,
y=None,
yanchor=None,
yref=None,
**kwargs
) |
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.layout.Title`
font
Sets the title font. Note that the title's font used to
... |
Construct a new Title object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.layout.Title`
font
Sets the title font. Note that the title's font used to
... | def __init__(
self,
arg=None,
font=None,
pad=None,
text=None,
x=None,
xanchor=None,
xref=None,
y=None,
yanchor=None,
yref=None,
**kwargs
):
"""
Construct a new Title object
Parameters
... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"font",
"=",
"None",
",",
"pad",
"=",
"None",
",",
"text",
"=",
"None",
",",
"x",
"=",
"None",
",",
"xanchor",
"=",
"None",
",",
"xref",
"=",
"None",
",",
"y",
"=",
"None",
",",
"y... | [
331,
4
] | [
477,
34
] | python | en | ['en', 'error', 'th'] | False |
Box.fillcolor | (self) |
Sets the inner box plot fill color.
The 'fillcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,1... |
Sets the inner box plot fill color.
The 'fillcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,1... | def fillcolor(self):
"""
Sets the inner box plot fill color.
The 'fillcolor' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv... | [
"def",
"fillcolor",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"fillcolor\"",
"]"
] | [
15,
4
] | [
65,
32
] | python | en | ['en', 'error', 'th'] | False |
Box.line | (self) |
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.violin.box.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
... |
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.violin.box.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
... | def line(self):
"""
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.violin.box.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict pro... | [
"def",
"line",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"line\"",
"]"
] | [
74,
4
] | [
93,
27
] | python | en | ['en', 'error', 'th'] | False |
Box.visible | (self) |
Determines if an miniature box plot is drawn inside the
violins.
The 'visible' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Determines if an miniature box plot is drawn inside the
violins.
The 'visible' property must be specified as a bool
(either True, or False) | def visible(self):
"""
Determines if an miniature box plot is drawn inside the
violins.
The 'visible' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["visible"] | [
"def",
"visible",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"visible\"",
"]"
] | [
102,
4
] | [
114,
30
] | python | en | ['en', 'error', 'th'] | False |
Box.width | (self) |
Sets the width of the inner box plots relative to the violins'
width. For example, with 1, the inner box plots are as wide as
the violins.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
... |
Sets the width of the inner box plots relative to the violins'
width. For example, with 1, the inner box plots are as wide as
the violins.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, 1] | def width(self):
"""
Sets the width of the inner box plots relative to the violins'
width. For example, with 1, the inner box plots are as wide as
the violins.
The 'width' property is a number and may be specified as:
- An int or float in the interval [0, 1]
... | [
"def",
"width",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"width\"",
"]"
] | [
123,
4
] | [
136,
28
] | python | en | ['en', 'error', 'th'] | False |
Box.__init__ | (
self, arg=None, fillcolor=None, line=None, visible=None, width=None, **kwargs
) |
Construct a new Box object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.violin.Box`
fillcolor
Sets the inner box plot fill color.
line
:c... |
Construct a new Box object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.violin.Box`
fillcolor
Sets the inner box plot fill color.
line
:c... | def __init__(
self, arg=None, fillcolor=None, line=None, visible=None, width=None, **kwargs
):
"""
Construct a new Box object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotl... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"fillcolor",
"=",
"None",
",",
"line",
"=",
"None",
",",
"visible",
"=",
"None",
",",
"width",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Box",
",",
"self",
")",
... | [
161,
4
] | [
241,
34
] | python | en | ['en', 'error', 'th'] | False |
load_word_vector | (vector_path, word2id, dim=300) |
Read pretrained vectors
Make lookup table with vocabulary
Load vector at lookup table
|
Read pretrained vectors
Make lookup table with vocabulary
Load vector at lookup table
| def load_word_vector(vector_path, word2id, dim=300):
"""
Read pretrained vectors
Make lookup table with vocabulary
Load vector at lookup table
"""
import numpy as np
vocab_size = len(word2id)
lookup_table = np.random.normal(size=[vocab_size, dim])
if 'glove' in str(vector_path):
... | [
"def",
"load_word_vector",
"(",
"vector_path",
",",
"word2id",
",",
"dim",
"=",
"300",
")",
":",
"import",
"numpy",
"as",
"np",
"vocab_size",
"=",
"len",
"(",
"word2id",
")",
"lookup_table",
"=",
"np",
".",
"random",
".",
"normal",
"(",
"size",
"=",
"[... | [
321,
0
] | [
350,
23
] | python | en | ['en', 'error', 'th'] | False |
Bar.color | (self) |
Sets the background color of the arc.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100... |
Sets the background color of the arc.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100... | def color(self):
"""
Sets the background color of the arc.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva ... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
Bar.line | (self) |
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.indicator.gauge.bar.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
... |
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.indicator.gauge.bar.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported dict properties:
... | def line(self):
"""
The 'line' property is an instance of Line
that may be specified as:
- An instance of :class:`plotly.graph_objs.indicator.gauge.bar.Line`
- A dict of string/value properties that will be passed
to the Line constructor
Supported... | [
"def",
"line",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"line\"",
"]"
] | [
74,
4
] | [
95,
27
] | python | en | ['en', 'error', 'th'] | False |
Bar.thickness | (self) |
Sets the thickness of the bar as a fraction of the total
thickness of the gauge.
The 'thickness' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
|
Sets the thickness of the bar as a fraction of the total
thickness of the gauge.
The 'thickness' property is a number and may be specified as:
- An int or float in the interval [0, 1] | def thickness(self):
"""
Sets the thickness of the bar as a fraction of the total
thickness of the gauge.
The 'thickness' property is a number and may be specified as:
- An int or float in the interval [0, 1]
Returns
-------
int|float
"""
... | [
"def",
"thickness",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"thickness\"",
"]"
] | [
104,
4
] | [
116,
32
] | python | en | ['en', 'error', 'th'] | False |
Bar.__init__ | (self, arg=None, color=None, line=None, thickness=None, **kwargs) |
Construct a new Bar object
Set the appearance of the gauge's value
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.indicator.gauge.Bar`
color
... |
Construct a new Bar object
Set the appearance of the gauge's value | def __init__(self, arg=None, color=None, line=None, thickness=None, **kwargs):
"""
Construct a new Bar object
Set the appearance of the gauge's value
Parameters
----------
arg
dict of properties compatible with this constructor or
an inst... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"line",
"=",
"None",
",",
"thickness",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Bar",
",",
"self",
")",
".",
"__init__",
"(",
"\"bar\""... | [
137,
4
] | [
210,
34
] | python | en | ['en', 'error', 'th'] | False |
CrossencoderAgent.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command-line arguments specifically for this agent.
|
Add command-line arguments specifically for this agent.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command-line arguments specifically for this agent.
"""
TransformerRankerAgent.add_cmdline_args(parser, partial_opt=partial_opt)
parser.set_defaults(encode_ca... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"TransformerRankerAgent",
".",
"add_cmdline_args",
"(",
"parser",
",",
"partial_opt",
... | [
24,
4
] | [
32,
21
] | python | en | ['en', 'error', 'th'] | False |
CrossencoderAgent.vectorize | (self, *args, **kwargs) |
Add the start and end token to the text.
|
Add the start and end token to the text.
| def vectorize(self, *args, **kwargs):
"""
Add the start and end token to the text.
"""
kwargs['add_start'] = True
kwargs['add_end'] = True
obs = super().vectorize(*args, **kwargs)
return obs | [
"def",
"vectorize",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'add_start'",
"]",
"=",
"True",
"kwargs",
"[",
"'add_end'",
"]",
"=",
"True",
"obs",
"=",
"super",
"(",
")",
".",
"vectorize",
"(",
"*",
"args",
... | [
37,
4
] | [
44,
18
] | python | en | ['en', 'error', 'th'] | False |
CrossencoderAgent._set_text_vec | (self, *args, **kwargs) |
Add the start and end token to the text.
|
Add the start and end token to the text.
| def _set_text_vec(self, *args, **kwargs):
"""
Add the start and end token to the text.
"""
obs = super()._set_text_vec(*args, **kwargs)
if 'text_vec' in obs and 'added_start_end_tokens' not in obs:
obs.force_set(
'text_vec', self._add_start_end_tokens(... | [
"def",
"_set_text_vec",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"obs",
"=",
"super",
"(",
")",
".",
"_set_text_vec",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"'text_vec'",
"in",
"obs",
"and",
"'added_start_end_t... | [
46,
4
] | [
56,
18
] | python | en | ['en', 'error', 'th'] | False |
CrossEncoderModule.forward | (self, tokens, segments) |
Scores each concatenation text + candidate.
|
Scores each concatenation text + candidate.
| def forward(self, tokens, segments):
"""
Scores each concatenation text + candidate.
"""
encoded = self.encoder(tokens, None, segments)
res = self.linear_layer(encoded)
return res | [
"def",
"forward",
"(",
"self",
",",
"tokens",
",",
"segments",
")",
":",
"encoded",
"=",
"self",
".",
"encoder",
"(",
"tokens",
",",
"None",
",",
"segments",
")",
"res",
"=",
"self",
".",
"linear_layer",
"(",
"encoded",
")",
"return",
"res"
] | [
114,
4
] | [
120,
18
] | python | en | ['en', 'error', 'th'] | False |
Surface.count | (self) |
Sets the number of iso-surfaces between minimum and maximum
iso-values. By default this value is 2 meaning that only
minimum and maximum surfaces would be drawn.
The 'count' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
... |
Sets the number of iso-surfaces between minimum and maximum
iso-values. By default this value is 2 meaning that only
minimum and maximum surfaces would be drawn.
The 'count' property is a integer and may be specified as:
- An int (or float that will be cast to an int)
... | def count(self):
"""
Sets the number of iso-surfaces between minimum and maximum
iso-values. By default this value is 2 meaning that only
minimum and maximum surfaces would be drawn.
The 'count' property is a integer and may be specified as:
- An int (or float that... | [
"def",
"count",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"count\"",
"]"
] | [
15,
4
] | [
29,
28
] | python | en | ['en', 'error', 'th'] | False |
Surface.fill | (self) |
Sets the fill ratio of the iso-surface. The default fill value
of the surface is 1 meaning that they are entirely shaded. On
the other hand Applying a `fill` ratio less than one would
allow the creation of openings parallel to the edges.
The 'fill' property is a number and ... |
Sets the fill ratio of the iso-surface. The default fill value
of the surface is 1 meaning that they are entirely shaded. On
the other hand Applying a `fill` ratio less than one would
allow the creation of openings parallel to the edges.
The 'fill' property is a number and ... | def fill(self):
"""
Sets the fill ratio of the iso-surface. The default fill value
of the surface is 1 meaning that they are entirely shaded. On
the other hand Applying a `fill` ratio less than one would
allow the creation of openings parallel to the edges.
The 'fill... | [
"def",
"fill",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"fill\"",
"]"
] | [
38,
4
] | [
52,
27
] | python | en | ['en', 'error', 'th'] | False |
Surface.pattern | (self) |
Sets the surface pattern of the iso-surface 3-D sections. The
default pattern of the surface is `all` meaning that the rest
of surface elements would be shaded. The check options (either
1 or 2) could be used to draw half of the squares on the
surface. Using various combinations... |
Sets the surface pattern of the iso-surface 3-D sections. The
default pattern of the surface is `all` meaning that the rest
of surface elements would be shaded. The check options (either
1 or 2) could be used to draw half of the squares on the
surface. Using various combinations... | def pattern(self):
"""
Sets the surface pattern of the iso-surface 3-D sections. The
default pattern of the surface is `all` meaning that the rest
of surface elements would be shaded. The check options (either
1 or 2) could be used to draw half of the squares on the
surfa... | [
"def",
"pattern",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"pattern\"",
"]"
] | [
61,
4
] | [
81,
30
] | python | en | ['en', 'error', 'th'] | False |
Surface.show | (self) |
Hides/displays surfaces between minimum and maximum iso-values.
The 'show' property must be specified as a bool
(either True, or False)
Returns
-------
bool
|
Hides/displays surfaces between minimum and maximum iso-values.
The 'show' property must be specified as a bool
(either True, or False) | def show(self):
"""
Hides/displays surfaces between minimum and maximum iso-values.
The 'show' property must be specified as a bool
(either True, or False)
Returns
-------
bool
"""
return self["show"] | [
"def",
"show",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"show\"",
"]"
] | [
90,
4
] | [
101,
27
] | python | en | ['en', 'error', 'th'] | False |
Surface.__init__ | (
self, arg=None, count=None, fill=None, pattern=None, show=None, **kwargs
) |
Construct a new Surface object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.volume.Surface`
count
Sets the number of iso-surfaces between minimum... |
Construct a new Surface object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.volume.Surface`
count
Sets the number of iso-surfaces between minimum... | def __init__(
self, arg=None, count=None, fill=None, pattern=None, show=None, **kwargs
):
"""
Construct a new Surface object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:c... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"count",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"pattern",
"=",
"None",
",",
"show",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Surface",
",",
"self",
")",
"... | [
137,
4
] | [
229,
34
] | python | en | ['en', 'error', 'th'] | False |
Increasing.color | (self) |
Sets the color for increasing value.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%... |
Sets the color for increasing value.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%... | def color(self):
"""
Sets the color for increasing value.
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva s... | [
"def",
"color",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"color\"",
"]"
] | [
15,
4
] | [
65,
28
] | python | en | ['en', 'error', 'th'] | False |
Increasing.symbol | (self) |
Sets the symbol to display for increasing value
The 'symbol' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
|
Sets the symbol to display for increasing value
The 'symbol' property is a string and must be specified as:
- A string
- A number that will be converted to a string | def symbol(self):
"""
Sets the symbol to display for increasing value
The 'symbol' property is a string and must be specified as:
- A string
- A number that will be converted to a string
Returns
-------
str
"""
return self["symbol... | [
"def",
"symbol",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"symbol\"",
"]"
] | [
74,
4
] | [
86,
29
] | python | en | ['en', 'error', 'th'] | False |
Increasing.__init__ | (self, arg=None, color=None, symbol=None, **kwargs) |
Construct a new Increasing object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.indicator.delta.Increasing`
color
Sets the color for increasing va... |
Construct a new Increasing object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.indicator.delta.Increasing`
color
Sets the color for increasing va... | def __init__(self, arg=None, color=None, symbol=None, **kwargs):
"""
Construct a new Increasing object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.indicator.... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"color",
"=",
"None",
",",
"symbol",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Increasing",
",",
"self",
")",
".",
"__init__",
"(",
"\"increasing\"",
")",
"if",
"\"_... | [
103,
4
] | [
166,
34
] | python | en | ['en', 'error', 'th'] | False |
BasePoints.coord | (self) | torch.Tensor: Coordinates of each point with size (N, 3). | torch.Tensor: Coordinates of each point with size (N, 3). | def coord(self):
"""torch.Tensor: Coordinates of each point with size (N, 3)."""
return self.tensor[:, :3] | [
"def",
"coord",
"(",
"self",
")",
":",
"return",
"self",
".",
"tensor",
"[",
":",
",",
":",
"3",
"]"
] | [
44,
4
] | [
46,
33
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.height | (self) | torch.Tensor: A vector with height of each point. | torch.Tensor: A vector with height of each point. | def height(self):
"""torch.Tensor: A vector with height of each point."""
if self.attribute_dims is not None and \
'height' in self.attribute_dims.keys():
return self.tensor[:, self.attribute_dims['height']]
else:
return None | [
"def",
"height",
"(",
"self",
")",
":",
"if",
"self",
".",
"attribute_dims",
"is",
"not",
"None",
"and",
"'height'",
"in",
"self",
".",
"attribute_dims",
".",
"keys",
"(",
")",
":",
"return",
"self",
".",
"tensor",
"[",
":",
",",
"self",
".",
"attrib... | [
49,
4
] | [
55,
23
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.color | (self) | torch.Tensor: A vector with color of each point. | torch.Tensor: A vector with color of each point. | def color(self):
"""torch.Tensor: A vector with color of each point."""
if self.attribute_dims is not None and \
'color' in self.attribute_dims.keys():
return self.tensor[:, self.attribute_dims['color']]
else:
return None | [
"def",
"color",
"(",
"self",
")",
":",
"if",
"self",
".",
"attribute_dims",
"is",
"not",
"None",
"and",
"'color'",
"in",
"self",
".",
"attribute_dims",
".",
"keys",
"(",
")",
":",
"return",
"self",
".",
"tensor",
"[",
":",
",",
"self",
".",
"attribut... | [
58,
4
] | [
64,
23
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.shape | (self) | torch.Shape: Shape of points. | torch.Shape: Shape of points. | def shape(self):
"""torch.Shape: Shape of points."""
return self.tensor.shape | [
"def",
"shape",
"(",
"self",
")",
":",
"return",
"self",
".",
"tensor",
".",
"shape"
] | [
67,
4
] | [
69,
32
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.shuffle | (self) | Shuffle the points. | Shuffle the points. | def shuffle(self):
"""Shuffle the points."""
self.tensor = self.tensor[torch.randperm(
self.__len__(), device=self.tensor.device)] | [
"def",
"shuffle",
"(",
"self",
")",
":",
"self",
".",
"tensor",
"=",
"self",
".",
"tensor",
"[",
"torch",
".",
"randperm",
"(",
"self",
".",
"__len__",
"(",
")",
",",
"device",
"=",
"self",
".",
"tensor",
".",
"device",
")",
"]"
] | [
71,
4
] | [
74,
55
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.rotate | (self, rotation, axis=None) | Rotate points with the given rotation matrix or angle.
Args:
rotation (float, np.ndarray, torch.Tensor): Rotation matrix
or angle.
axis (int): Axis to rotate at. Defaults to None.
| Rotate points with the given rotation matrix or angle. | def rotate(self, rotation, axis=None):
"""Rotate points with the given rotation matrix or angle.
Args:
rotation (float, np.ndarray, torch.Tensor): Rotation matrix
or angle.
axis (int): Axis to rotate at. Defaults to None.
"""
if not isinstance(rot... | [
"def",
"rotate",
"(",
"self",
",",
"rotation",
",",
"axis",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"rotation",
",",
"torch",
".",
"Tensor",
")",
":",
"rotation",
"=",
"self",
".",
"tensor",
".",
"new_tensor",
"(",
"rotation",
")",
"as... | [
76,
4
] | [
114,
59
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.flip | (self, bev_direction='horizontal') | Flip the points in BEV along given BEV direction. | Flip the points in BEV along given BEV direction. | def flip(self, bev_direction='horizontal'):
"""Flip the points in BEV along given BEV direction."""
pass | [
"def",
"flip",
"(",
"self",
",",
"bev_direction",
"=",
"'horizontal'",
")",
":",
"pass"
] | [
117,
4
] | [
119,
12
] | python | en | ['en', 'da', 'en'] | True |
BasePoints.translate | (self, trans_vector) | Translate points with the given translation vector.
Args:
trans_vector (np.ndarray, torch.Tensor): Translation
vector of size 3 or nx3.
| Translate points with the given translation vector. | def translate(self, trans_vector):
"""Translate points with the given translation vector.
Args:
trans_vector (np.ndarray, torch.Tensor): Translation
vector of size 3 or nx3.
"""
if not isinstance(trans_vector, torch.Tensor):
trans_vector = self.te... | [
"def",
"translate",
"(",
"self",
",",
"trans_vector",
")",
":",
"if",
"not",
"isinstance",
"(",
"trans_vector",
",",
"torch",
".",
"Tensor",
")",
":",
"trans_vector",
"=",
"self",
".",
"tensor",
".",
"new_tensor",
"(",
"trans_vector",
")",
"trans_vector",
... | [
121,
4
] | [
140,
42
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.in_range_3d | (self, point_range) | Check whether the points are in the given range.
Args:
point_range (list | torch.Tensor): The range of point
(x_min, y_min, z_min, x_max, y_max, z_max)
Note:
In the original implementation of SECOND, checking whether
a box in the range checks whether... | Check whether the points are in the given range. | def in_range_3d(self, point_range):
"""Check whether the points are in the given range.
Args:
point_range (list | torch.Tensor): The range of point
(x_min, y_min, z_min, x_max, y_max, z_max)
Note:
In the original implementation of SECOND, checking whethe... | [
"def",
"in_range_3d",
"(",
"self",
",",
"point_range",
")",
":",
"in_range_flags",
"=",
"(",
"(",
"self",
".",
"tensor",
"[",
":",
",",
"0",
"]",
">",
"point_range",
"[",
"0",
"]",
")",
"&",
"(",
"self",
".",
"tensor",
"[",
":",
",",
"1",
"]",
... | [
142,
4
] | [
164,
29
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.in_range_bev | (self, point_range) | Check whether the points are in the given range.
Args:
point_range (list | torch.Tensor): The range of point
in order of (x_min, y_min, x_max, y_max).
Returns:
torch.Tensor: Indicating whether each point is inside \
the reference range.
| Check whether the points are in the given range. | def in_range_bev(self, point_range):
"""Check whether the points are in the given range.
Args:
point_range (list | torch.Tensor): The range of point
in order of (x_min, y_min, x_max, y_max).
Returns:
torch.Tensor: Indicating whether each point is inside ... | [
"def",
"in_range_bev",
"(",
"self",
",",
"point_range",
")",
":",
"pass"
] | [
167,
4
] | [
178,
12
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.convert_to | (self, dst, rt_mat=None) | Convert self to ``dst`` mode.
Args:
dst (:obj:`CoordMode`): The target Box mode.
rt_mat (np.ndarray | torch.Tensor): The rotation and translation
matrix between different coordinates. Defaults to None.
The conversion from `src` coordinates to `dst` coordi... | Convert self to ``dst`` mode. | def convert_to(self, dst, rt_mat=None):
"""Convert self to ``dst`` mode.
Args:
dst (:obj:`CoordMode`): The target Box mode.
rt_mat (np.ndarray | torch.Tensor): The rotation and translation
matrix between different coordinates. Defaults to None.
Th... | [
"def",
"convert_to",
"(",
"self",
",",
"dst",
",",
"rt_mat",
"=",
"None",
")",
":",
"pass"
] | [
181,
4
] | [
196,
12
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.scale | (self, scale_factor) | Scale the points with horizontal and vertical scaling factors.
Args:
scale_factors (float): Scale factors to scale the points.
| Scale the points with horizontal and vertical scaling factors. | def scale(self, scale_factor):
"""Scale the points with horizontal and vertical scaling factors.
Args:
scale_factors (float): Scale factors to scale the points.
"""
self.tensor[:, :3] *= scale_factor | [
"def",
"scale",
"(",
"self",
",",
"scale_factor",
")",
":",
"self",
".",
"tensor",
"[",
":",
",",
":",
"3",
"]",
"*=",
"scale_factor"
] | [
198,
4
] | [
204,
42
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.__getitem__ | (self, item) |
Note:
The following usage are allowed:
1. `new_points = points[3]`:
return a `Points` that contains only one point.
2. `new_points = points[2:10]`:
return a slice of points.
3. `new_points = points[vector]`:
where v... |
Note:
The following usage are allowed:
1. `new_points = points[3]`:
return a `Points` that contains only one point.
2. `new_points = points[2:10]`:
return a slice of points.
3. `new_points = points[vector]`:
where v... | def __getitem__(self, item):
"""
Note:
The following usage are allowed:
1. `new_points = points[3]`:
return a `Points` that contains only one point.
2. `new_points = points[2:10]`:
return a slice of points.
3. `new_points = ... | [
"def",
"__getitem__",
"(",
"self",
",",
"item",
")",
":",
"original_type",
"=",
"type",
"(",
"self",
")",
"if",
"isinstance",
"(",
"item",
",",
"int",
")",
":",
"return",
"original_type",
"(",
"self",
".",
"tensor",
"[",
"item",
"]",
".",
"view",
"("... | [
206,
4
] | [
270,
68
] | python | en | ['en', 'error', 'th'] | False |
BasePoints.__len__ | (self) | int: Number of points in the current object. | int: Number of points in the current object. | def __len__(self):
"""int: Number of points in the current object."""
return self.tensor.shape[0] | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"self",
".",
"tensor",
".",
"shape",
"[",
"0",
"]"
] | [
272,
4
] | [
274,
35
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.__repr__ | (self) | str: Return a strings that describes the object. | str: Return a strings that describes the object. | def __repr__(self):
"""str: Return a strings that describes the object."""
return self.__class__.__name__ + '(\n ' + str(self.tensor) + ')' | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
".",
"__name__",
"+",
"'(\\n '",
"+",
"str",
"(",
"self",
".",
"tensor",
")",
"+",
"')'"
] | [
276,
4
] | [
278,
75
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.cat | (cls, points_list) | Concatenate a list of Points into a single Points.
Args:
points_list (list[:obj:`BasePoints`]): List of points.
Returns:
:obj:`BasePoints`: The concatenated Points.
| Concatenate a list of Points into a single Points. | def cat(cls, points_list):
"""Concatenate a list of Points into a single Points.
Args:
points_list (list[:obj:`BasePoints`]): List of points.
Returns:
:obj:`BasePoints`: The concatenated Points.
"""
assert isinstance(points_list, (list, tuple))
i... | [
"def",
"cat",
"(",
"cls",
",",
"points_list",
")",
":",
"assert",
"isinstance",
"(",
"points_list",
",",
"(",
"list",
",",
"tuple",
")",
")",
"if",
"len",
"(",
"points_list",
")",
"==",
"0",
":",
"return",
"cls",
"(",
"torch",
".",
"empty",
"(",
"0... | [
281,
4
] | [
301,
25
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.to | (self, device) | Convert current points to a specific device.
Args:
device (str | :obj:`torch.device`): The name of the device.
Returns:
:obj:`BasePoints`: A new boxes object on the \
specific device.
| Convert current points to a specific device. | def to(self, device):
"""Convert current points to a specific device.
Args:
device (str | :obj:`torch.device`): The name of the device.
Returns:
:obj:`BasePoints`: A new boxes object on the \
specific device.
"""
original_type = type(self... | [
"def",
"to",
"(",
"self",
",",
"device",
")",
":",
"original_type",
"=",
"type",
"(",
"self",
")",
"return",
"original_type",
"(",
"self",
".",
"tensor",
".",
"to",
"(",
"device",
")",
",",
"points_dim",
"=",
"self",
".",
"points_dim",
",",
"attribute_... | [
303,
4
] | [
317,
47
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.clone | (self) | Clone the Points.
Returns:
:obj:`BasePoints`: Box object with the same properties \
as self.
| Clone the Points. | def clone(self):
"""Clone the Points.
Returns:
:obj:`BasePoints`: Box object with the same properties \
as self.
"""
original_type = type(self)
return original_type(
self.tensor.clone(),
points_dim=self.points_dim,
... | [
"def",
"clone",
"(",
"self",
")",
":",
"original_type",
"=",
"type",
"(",
"self",
")",
"return",
"original_type",
"(",
"self",
".",
"tensor",
".",
"clone",
"(",
")",
",",
"points_dim",
"=",
"self",
".",
"points_dim",
",",
"attribute_dims",
"=",
"self",
... | [
319,
4
] | [
330,
47
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.device | (self) | str: The device of the points are on. | str: The device of the points are on. | def device(self):
"""str: The device of the points are on."""
return self.tensor.device | [
"def",
"device",
"(",
"self",
")",
":",
"return",
"self",
".",
"tensor",
".",
"device"
] | [
333,
4
] | [
335,
33
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.__iter__ | (self) | Yield a point as a Tensor of shape (4,) at a time.
Returns:
torch.Tensor: A point of shape (4,).
| Yield a point as a Tensor of shape (4,) at a time. | def __iter__(self):
"""Yield a point as a Tensor of shape (4,) at a time.
Returns:
torch.Tensor: A point of shape (4,).
"""
yield from self.tensor | [
"def",
"__iter__",
"(",
"self",
")",
":",
"yield",
"from",
"self",
".",
"tensor"
] | [
337,
4
] | [
343,
30
] | python | en | ['en', 'en', 'en'] | True |
BasePoints.new_point | (self, data) | Create a new point object with data.
The new point and its tensor has the similar properties \
as self and self.tensor, respectively.
Args:
data (torch.Tensor | numpy.array | list): Data to be copied.
Returns:
:obj:`BasePoints`: A new point object with ``da... | Create a new point object with data. | def new_point(self, data):
"""Create a new point object with data.
The new point and its tensor has the similar properties \
as self and self.tensor, respectively.
Args:
data (torch.Tensor | numpy.array | list): Data to be copied.
Returns:
:obj:`Bas... | [
"def",
"new_point",
"(",
"self",
",",
"data",
")",
":",
"new_tensor",
"=",
"self",
".",
"tensor",
".",
"new_tensor",
"(",
"data",
")",
"if",
"not",
"isinstance",
"(",
"data",
",",
"torch",
".",
"Tensor",
")",
"else",
"data",
".",
"to",
"(",
"self",
... | [
345,
4
] | [
364,
47
] | python | en | ['en', 'en', 'en'] | True |
Stream.maxpoints | (self) |
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000]... |
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000] | def maxpoints(self):
"""
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or ... | [
"def",
"maxpoints",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"maxpoints\"",
"]"
] | [
15,
4
] | [
28,
32
] | python | en | ['en', 'error', 'th'] | False |
Stream.token | (self) |
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string
Returns
-------
str
|
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string | def token(self):
"""
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string
Returns
-------
... | [
"def",
"token",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"token\"",
"]"
] | [
37,
4
] | [
50,
28
] | python | en | ['en', 'error', 'th'] | False |
Stream.__init__ | (self, arg=None, maxpoints=None, token=None, **kwargs) |
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.splom.Stream`
maxpoints
Sets the maximum number of points to keep on the plots
... |
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.splom.Stream`
maxpoints
Sets the maximum number of points to keep on the plots
... | def __init__(self, arg=None, maxpoints=None, token=None, **kwargs):
"""
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of :class:`plotly.graph_objs.splom.Stream`
m... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"maxpoints",
"=",
"None",
",",
"token",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Stream",
",",
"self",
")",
".",
"__init__",
"(",
"\"stream\"",
")",
"if",
"\"_paren... | [
72,
4
] | [
139,
34
] | python | en | ['en', 'error', 'th'] | False |
HredModel.reorder_encoder_states | (self, encoder_states, indices) |
Reorder encoder states according to a new set of indices.
|
Reorder encoder states according to a new set of indices.
| def reorder_encoder_states(self, encoder_states, indices):
"""
Reorder encoder states according to a new set of indices.
"""
enc_out, hidden, attn_mask, context_vec = encoder_states
# make sure we swap the hidden state around, apropos multigpu settings
hidden = _transpose... | [
"def",
"reorder_encoder_states",
"(",
"self",
",",
"encoder_states",
",",
"indices",
")",
":",
"enc_out",
",",
"hidden",
",",
"attn_mask",
",",
"context_vec",
"=",
"encoder_states",
"# make sure we swap the hidden state around, apropos multigpu settings",
"hidden",
"=",
"... | [
81,
4
] | [
109,
54
] | python | en | ['en', 'error', 'th'] | False |
HredEncoder.__init__ | (
self,
num_features,
embeddingsize,
hiddensize,
device,
padding_idx=0,
rnn_class="lstm",
numlayers=2,
dropout=0.1,
bidirectional=False,
shared_lt=None,
shared_rnn=None,
input_dropout=0,
unknown_idx=None,
... |
Initialize recurrent encoder and context lstm.
|
Initialize recurrent encoder and context lstm.
| def __init__(
self,
num_features,
embeddingsize,
hiddensize,
device,
padding_idx=0,
rnn_class="lstm",
numlayers=2,
dropout=0.1,
bidirectional=False,
shared_lt=None,
shared_rnn=None,
input_dropout=0,
unknown_i... | [
"def",
"__init__",
"(",
"self",
",",
"num_features",
",",
"embeddingsize",
",",
"hiddensize",
",",
"device",
",",
"padding_idx",
"=",
"0",
",",
"rnn_class",
"=",
"\"lstm\"",
",",
"numlayers",
"=",
"2",
",",
"dropout",
"=",
"0.1",
",",
"bidirectional",
"=",... | [
129,
4
] | [
167,
20
] | python | en | ['en', 'error', 'th'] | False |
HredEncoder.sequence_to_padding | (self, x, lengths) |
Return padded and reshaped sequence (x) according to tensor lengths
Example:
x = tensor([[1, 2], [2, 3], [4, 0], [5, 6], [7, 8], [9, 10]])
lengths = tensor([1, 2, 2, 1])
Would output:
tensor([[[1, 2], [0, 0]],
[[2, 3], [4, 0]],
... |
Return padded and reshaped sequence (x) according to tensor lengths
Example:
x = tensor([[1, 2], [2, 3], [4, 0], [5, 6], [7, 8], [9, 10]])
lengths = tensor([1, 2, 2, 1])
Would output:
tensor([[[1, 2], [0, 0]],
[[2, 3], [4, 0]],
... | def sequence_to_padding(self, x, lengths):
"""
Return padded and reshaped sequence (x) according to tensor lengths
Example:
x = tensor([[1, 2], [2, 3], [4, 0], [5, 6], [7, 8], [9, 10]])
lengths = tensor([1, 2, 2, 1])
Would output:
tensor([[[1, 2], [0, ... | [
"def",
"sequence_to_padding",
"(",
"self",
",",
"x",
",",
"lengths",
")",
":",
"ret_tensor",
"=",
"torch",
".",
"zeros",
"(",
"(",
"lengths",
".",
"shape",
"[",
"0",
"]",
",",
"torch",
".",
"max",
"(",
"lengths",
")",
".",
"int",
"(",
")",
")",
"... | [
211,
4
] | [
230,
25
] | python | en | ['en', 'error', 'th'] | False |
HredDecoder.__init__ | (
self,
num_features,
embeddingsize,
hiddensize,
padding_idx=0,
rnn_class="lstm",
numlayers=2,
dropout=0.1,
bidir_input=False,
attn_length=-1,
sparse=False,
) |
Initialize recurrent decoder.
|
Initialize recurrent decoder.
| def __init__(
self,
num_features,
embeddingsize,
hiddensize,
padding_idx=0,
rnn_class="lstm",
numlayers=2,
dropout=0.1,
bidir_input=False,
attn_length=-1,
sparse=False,
):
"""
Initialize recurrent decoder.
... | [
"def",
"__init__",
"(",
"self",
",",
"num_features",
",",
"embeddingsize",
",",
"hiddensize",
",",
"padding_idx",
"=",
"0",
",",
"rnn_class",
"=",
"\"lstm\"",
",",
"numlayers",
"=",
"2",
",",
"dropout",
"=",
"0.1",
",",
"bidir_input",
"=",
"False",
",",
... | [
238,
4
] | [
269,
9
] | python | en | ['en', 'error', 'th'] | False |
HredDecoder.forward | (self, xs, encoder_output, incremental_state=None) |
Decode from input tokens.
:param xs: (bsz x seqlen) LongTensor of input token indices
:param encoder_output: output from HredEncoder. Tuple containing
(enc_out, enc_hidden, attn_mask, context_hidden) tuple.
:param incremental_state: most recent hidden state to the decoder.
... |
Decode from input tokens. | def forward(self, xs, encoder_output, incremental_state=None):
"""
Decode from input tokens.
:param xs: (bsz x seqlen) LongTensor of input token indices
:param encoder_output: output from HredEncoder. Tuple containing
(enc_out, enc_hidden, attn_mask, context_hidden) tuple.
... | [
"def",
"forward",
"(",
"self",
",",
"xs",
",",
"encoder_output",
",",
"incremental_state",
"=",
"None",
")",
":",
"(",
"enc_state",
",",
"(",
"hidden_state",
",",
"cell_state",
")",
",",
"attn_mask",
",",
"context_hidden",
",",
")",
"=",
"encoder_output",
... | [
271,
4
] | [
304,
58
] | python | en | ['en', 'error', 'th'] | False |
load_fasttext_embeddings | (dic, embedding_dim, datapath) |
Load weights from fasttext_cc and put them in embeddings.weights.
|
Load weights from fasttext_cc and put them in embeddings.weights.
| def load_fasttext_embeddings(dic, embedding_dim, datapath):
"""
Load weights from fasttext_cc and put them in embeddings.weights.
"""
print('Initializing embeddings from fasttext_cc')
from parlai.zoo.fasttext_cc_vectors.build import download
pretrained = download(datapath)
print(
'D... | [
"def",
"load_fasttext_embeddings",
"(",
"dic",
",",
"embedding_dim",
",",
"datapath",
")",
":",
"print",
"(",
"'Initializing embeddings from fasttext_cc'",
")",
"from",
"parlai",
".",
"zoo",
".",
"fasttext_cc_vectors",
".",
"build",
"import",
"download",
"pretrained",... | [
571,
0
] | [
592,
14
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.add_cmdline_args | (
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) |
Add command line arguments.
|
Add command line arguments.
| def add_cmdline_args(
cls, parser: ParlaiParser, partial_opt: Optional[Opt] = None
) -> ParlaiParser:
"""
Add command line arguments.
"""
Transformer.add_common_cmdline_args(parser)
agent = parser.add_argument_group('TransresnetModel arguments')
agent.add_argu... | [
"def",
"add_cmdline_args",
"(",
"cls",
",",
"parser",
":",
"ParlaiParser",
",",
"partial_opt",
":",
"Optional",
"[",
"Opt",
"]",
"=",
"None",
")",
"->",
"ParlaiParser",
":",
"Transformer",
".",
"add_common_cmdline_args",
"(",
"parser",
")",
"agent",
"=",
"pa... | [
26,
4
] | [
104,
21
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel._build_personality_dictionary | (self, personalities_list) |
Build the personality dictionary mapping personality to id.
:param personalities_list:
list of personalities
|
Build the personality dictionary mapping personality to id. | def _build_personality_dictionary(self, personalities_list):
"""
Build the personality dictionary mapping personality to id.
:param personalities_list:
list of personalities
"""
self.personalities_list = personalities_list
self.personality_to_id = {p: i for i... | [
"def",
"_build_personality_dictionary",
"(",
"self",
",",
"personalities_list",
")",
":",
"self",
".",
"personalities_list",
"=",
"personalities_list",
"self",
".",
"personality_to_id",
"=",
"{",
"p",
":",
"i",
"for",
"i",
",",
"p",
"in",
"enumerate",
"(",
"pe... | [
137,
4
] | [
146,
65
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel._build_text_encoder | (self, n_layers_text) |
Build the text (candidate) encoder.
:param n_layers_text:
how many layers the transformer will have
|
Build the text (candidate) encoder. | def _build_text_encoder(self, n_layers_text):
"""
Build the text (candidate) encoder.
:param n_layers_text:
how many layers the transformer will have
"""
self.embeddings = nn.Embedding(len(self.dictionary), self.opt['embedding_size'])
if (
self.op... | [
"def",
"_build_text_encoder",
"(",
"self",
",",
"n_layers_text",
")",
":",
"self",
".",
"embeddings",
"=",
"nn",
".",
"Embedding",
"(",
"len",
"(",
"self",
".",
"dictionary",
")",
",",
"self",
".",
"opt",
"[",
"'embedding_size'",
"]",
")",
"if",
"(",
"... | [
148,
4
] | [
189,
9
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel._build_image_encoder | (self, n_layers_img) |
Build the image encoder mapping raw image features to the appropriate space.
:param n_layers_img:
number of feed-forward layers for the image encoder
|
Build the image encoder mapping raw image features to the appropriate space. | def _build_image_encoder(self, n_layers_img):
"""
Build the image encoder mapping raw image features to the appropriate space.
:param n_layers_img:
number of feed-forward layers for the image encoder
"""
image_layers = [
nn.BatchNorm1d(self.opt['image_fea... | [
"def",
"_build_image_encoder",
"(",
"self",
",",
"n_layers_img",
")",
":",
"image_layers",
"=",
"[",
"nn",
".",
"BatchNorm1d",
"(",
"self",
".",
"opt",
"[",
"'image_features_dim'",
"]",
")",
",",
"nn",
".",
"Dropout",
"(",
"p",
"=",
"self",
".",
"opt",
... | [
191,
4
] | [
209,
57
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.forward | (
self, image_features, personalities, captions, personalities_tensor=None
) |
Model forward pass.
:param image_features:
list of tensors of image features, one per example
:param personalities:
list of personalities, one per example
:param captions:
list of captions, one per example
:param personalities_tensor:
... |
Model forward pass. | def forward(
self, image_features, personalities, captions, personalities_tensor=None
):
"""
Model forward pass.
:param image_features:
list of tensors of image features, one per example
:param personalities:
list of personalities, one per example
... | [
"def",
"forward",
"(",
"self",
",",
"image_features",
",",
"personalities",
",",
"captions",
",",
"personalities_tensor",
"=",
"None",
")",
":",
"captions_encoded",
"=",
"None",
"context_encoded",
"=",
"None",
"img_encoded",
"=",
"None",
"# encode captions",
"if",... | [
219,
4
] | [
257,
48
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.forward_personality | (self, personalities, personalities_tensor) |
Encode personalities.
:param personalities:
list of personalities, one per example
:param personalities_tensor:
(optional) list of personality representations, usually a one-hot
vector if specified
:return:
encoded representation of the ... |
Encode personalities. | def forward_personality(self, personalities, personalities_tensor):
"""
Encode personalities.
:param personalities:
list of personalities, one per example
:param personalities_tensor:
(optional) list of personality representations, usually a one-hot
v... | [
"def",
"forward_personality",
"(",
"self",
",",
"personalities",
",",
"personalities_tensor",
")",
":",
"pers_encoded",
"=",
"None",
"if",
"personalities",
"is",
"not",
"None",
":",
"if",
"personalities_tensor",
"is",
"not",
"None",
":",
"pers_feature",
"=",
"pe... | [
259,
4
] | [
288,
27
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.forward_image | (self, image_features) |
Encode image features.
:param image_features:
list of image features
:return:
encoded representation of the image features
|
Encode image features. | def forward_image(self, image_features):
"""
Encode image features.
:param image_features:
list of image features
:return:
encoded representation of the image features
"""
img_encoded = None
if image_features is not None:
stac... | [
"def",
"forward_image",
"(",
"self",
",",
"image_features",
")",
":",
"img_encoded",
"=",
"None",
"if",
"image_features",
"is",
"not",
"None",
":",
"stacked",
"=",
"torch",
".",
"stack",
"(",
"image_features",
")",
"if",
"self",
".",
"use_cuda",
":",
"stac... | [
290,
4
] | [
307,
26
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.train_batch | (self, image_features, personalities, captions) |
Batch train on a set of examples.
Uses captions from other examples as negatives during training
:param image_features:
list of tensors of image features
:param personalities:
list of personalities
:param captions:
list of captions
... |
Batch train on a set of examples. | def train_batch(self, image_features, personalities, captions):
"""
Batch train on a set of examples.
Uses captions from other examples as negatives during training
:param image_features:
list of tensors of image features
:param personalities:
list of pe... | [
"def",
"train_batch",
"(",
"self",
",",
"image_features",
",",
"personalities",
",",
"captions",
")",
":",
"self",
".",
"zero_grad",
"(",
")",
"self",
".",
"train",
"(",
")",
"context_encoded",
",",
"captions_encoded",
"=",
"self",
".",
"forward",
"(",
"im... | [
309,
4
] | [
341,
46
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.eval_batch | (self, image_features, personalities, captions) |
Evaluate performance of model on one batch.
Batch is split into chunks of 100 to evaluate hits@1/100
:param image_features:
list of tensors of image features
:param personalities:
list of personalities
:param captions:
list of captions
... |
Evaluate performance of model on one batch. | def eval_batch(self, image_features, personalities, captions):
"""
Evaluate performance of model on one batch.
Batch is split into chunks of 100 to evaluate hits@1/100
:param image_features:
list of tensors of image features
:param personalities:
list of... | [
"def",
"eval_batch",
"(",
"self",
",",
"image_features",
",",
"personalities",
",",
"captions",
")",
":",
"if",
"personalities",
"is",
"None",
":",
"personalities",
"=",
"[",
"''",
"]",
"*",
"len",
"(",
"image_features",
")",
"if",
"len",
"(",
"image_featu... | [
343,
4
] | [
371,
46
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.choose_best_caption | (
self, image_features, personalities, candidates, candidates_encoded=None, k=1
) |
Choose the best caption for each example.
:param image_features:
list of tensors of image features
:param personalities:
list of personalities
:param candidates:
list of candidates, one set per example
:param candidates_encoded:
o... |
Choose the best caption for each example. | def choose_best_caption(
self, image_features, personalities, candidates, candidates_encoded=None, k=1
):
"""
Choose the best caption for each example.
:param image_features:
list of tensors of image features
:param personalities:
list of personalitie... | [
"def",
"choose_best_caption",
"(",
"self",
",",
"image_features",
",",
"personalities",
",",
"candidates",
",",
"candidates_encoded",
"=",
"None",
",",
"k",
"=",
"1",
")",
":",
"self",
".",
"eval",
"(",
")",
"context_encoded",
",",
"_",
"=",
"self",
".",
... | [
373,
4
] | [
424,
21
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.eval_batch_of_100 | (self, context_encoded, captions_encoded) |
Evaluate a batch of 100 examples.
The captions of the other examples are used as negatives.
:param context_encoded:
the encoded context
:param captions_encoded:
the encoded captions
:return:
the total loss, the total number of correct examp... |
Evaluate a batch of 100 examples. | def eval_batch_of_100(self, context_encoded, captions_encoded):
"""
Evaluate a batch of 100 examples.
The captions of the other examples are used as negatives.
:param context_encoded:
the encoded context
:param captions_encoded:
the encoded captions
... | [
"def",
"eval_batch_of_100",
"(",
"self",
",",
"context_encoded",
",",
"captions_encoded",
")",
":",
"total_loss",
"=",
"0",
"total_ok",
"=",
"0",
"num_examples",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"context_encoded",
")",
",",
... | [
426,
4
] | [
453,
49
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.evaluate_one_batch | (self, context_encoded, captions_encoded, during_train=False) |
Compute loss - and number of correct examples - for one batch.
:param context_encoded:
the encoded context
:param captions_encoded:
the encoded captions
:param during_train:
true if training, else False
:return:
the batch loss an... |
Compute loss - and number of correct examples - for one batch. | def evaluate_one_batch(self, context_encoded, captions_encoded, during_train=False):
"""
Compute loss - and number of correct examples - for one batch.
:param context_encoded:
the encoded context
:param captions_encoded:
the encoded captions
:param during... | [
"def",
"evaluate_one_batch",
"(",
"self",
",",
"context_encoded",
",",
"captions_encoded",
",",
"during_train",
"=",
"False",
")",
":",
"if",
"not",
"during_train",
":",
"self",
".",
"zero_grad",
"(",
")",
"self",
".",
"eval",
"(",
")",
"dot_products",
"=",
... | [
455,
4
] | [
479,
32
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.freeze_text_encoder | (self) |
Freeze the text (candidate) encoder.
|
Freeze the text (candidate) encoder.
| def freeze_text_encoder(self):
"""
Freeze the text (candidate) encoder.
"""
self.text_encoder_frozen = True | [
"def",
"freeze_text_encoder",
"(",
"self",
")",
":",
"self",
".",
"text_encoder_frozen",
"=",
"True"
] | [
481,
4
] | [
485,
39
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.unfreeze_text_encoder | (self) |
Unfreeze the text (candidate) encoder.
|
Unfreeze the text (candidate) encoder.
| def unfreeze_text_encoder(self):
"""
Unfreeze the text (candidate) encoder.
"""
self.text_encoder_frozen = False | [
"def",
"unfreeze_text_encoder",
"(",
"self",
")",
":",
"self",
".",
"text_encoder_frozen",
"=",
"False"
] | [
487,
4
] | [
491,
40
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.sum_encodings | (self, addends) |
Add up a list of encodings, some of which may be `None`.
:param addends:
tensors to add
:return:
sum of non-`None` addends
|
Add up a list of encodings, some of which may be `None`. | def sum_encodings(self, addends):
"""
Add up a list of encodings, some of which may be `None`.
:param addends:
tensors to add
:return:
sum of non-`None` addends
"""
addends = [a for a in addends if a is not None]
return sum(addends) if le... | [
"def",
"sum_encodings",
"(",
"self",
",",
"addends",
")",
":",
"addends",
"=",
"[",
"a",
"for",
"a",
"in",
"addends",
"if",
"a",
"is",
"not",
"None",
"]",
"return",
"sum",
"(",
"addends",
")",
"if",
"len",
"(",
"addends",
")",
">",
"0",
"else",
"... | [
493,
4
] | [
504,
57
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.personalities_to_index | (self, personalities) |
Map personalities to their index in the personality dictionary.
:param personalities:
list of personalities
:return:
list of personality ids
|
Map personalities to their index in the personality dictionary. | def personalities_to_index(self, personalities):
"""
Map personalities to their index in the personality dictionary.
:param personalities:
list of personalities
:return:
list of personality ids
"""
res = []
for p in personalities:
... | [
"def",
"personalities_to_index",
"(",
"self",
",",
"personalities",
")",
":",
"res",
"=",
"[",
"]",
"for",
"p",
"in",
"personalities",
":",
"if",
"p",
"in",
"self",
".",
"personality_to_id",
":",
"res",
".",
"append",
"(",
"self",
".",
"personality_to_id",... | [
506,
4
] | [
522,
18
] | python | en | ['en', 'error', 'th'] | False |
TransresnetModel.captions_to_tensor | (self, captions) |
Tokenize a list of sentences into a 2D float tensor.
:param captions:
list of sentences to tokenize
:return:
a (batchsize X truncate_length) tensor representation of the captions,
and a similarly sized mask tensor
|
Tokenize a list of sentences into a 2D float tensor. | def captions_to_tensor(self, captions):
"""
Tokenize a list of sentences into a 2D float tensor.
:param captions:
list of sentences to tokenize
:return:
a (batchsize X truncate_length) tensor representation of the captions,
and a similarly sized mask... | [
"def",
"captions_to_tensor",
"(",
"self",
",",
"captions",
")",
":",
"max_length",
"=",
"self",
".",
"truncate_length",
"indexes",
"=",
"[",
"]",
"for",
"c",
"in",
"captions",
":",
"vec",
"=",
"self",
".",
"dictionary",
".",
"txt2vec",
"(",
"c",
")",
"... | [
524,
4
] | [
553,
24
] | python | en | ['en', 'error', 'th'] | False |
LinearWrapper.forward | (self, input) |
Forward pass.
|
Forward pass.
| def forward(self, input):
"""
Forward pass.
"""
return self.lin(self.dp(input)) | [
"def",
"forward",
"(",
"self",
",",
"input",
")",
":",
"return",
"self",
".",
"lin",
"(",
"self",
".",
"dp",
"(",
"input",
")",
")"
] | [
605,
4
] | [
609,
39
] | python | en | ['en', 'error', 'th'] | False |
InteractiveWorld.parley | (self) |
Loop between wizard and apprentice.
Adds knowledge to the wizard observations. Assumes that the model agent is the
wizard model.
|
Loop between wizard and apprentice. | def parley(self):
"""
Loop between wizard and apprentice.
Adds knowledge to the wizard observations. Assumes that the model agent is the
wizard model.
"""
if self.cnt == 0:
self.topic = self._get_new_topic()
self.acts = [None, None]
i... | [
"def",
"parley",
"(",
"self",
")",
":",
"if",
"self",
".",
"cnt",
"==",
"0",
":",
"self",
".",
"topic",
"=",
"self",
".",
"_get_new_topic",
"(",
")",
"self",
".",
"acts",
"=",
"[",
"None",
",",
"None",
"]",
"if",
"self",
".",
"topic",
"!=",
"NO... | [
135,
4
] | [
187,
36
] | python | en | ['en', 'error', 'th'] | False |
smooth_l1_loss | (pred, target, beta=1.0) | Smooth L1 loss.
Args:
pred (torch.Tensor): The prediction.
target (torch.Tensor): The learning target of the prediction.
beta (float, optional): The threshold in the piecewise function.
Defaults to 1.0.
Returns:
torch.Tensor: Calculated loss
| Smooth L1 loss. | def smooth_l1_loss(pred, target, beta=1.0):
"""Smooth L1 loss.
Args:
pred (torch.Tensor): The prediction.
target (torch.Tensor): The learning target of the prediction.
beta (float, optional): The threshold in the piecewise function.
Defaults to 1.0.
Returns:
tor... | [
"def",
"smooth_l1_loss",
"(",
"pred",
",",
"target",
",",
"beta",
"=",
"1.0",
")",
":",
"assert",
"beta",
">",
"0",
"assert",
"pred",
".",
"size",
"(",
")",
"==",
"target",
".",
"size",
"(",
")",
"and",
"target",
".",
"numel",
"(",
")",
">",
"0",... | [
8,
0
] | [
25,
15
] | python | en | ['es', 'fil', 'en'] | False |
l1_loss | (pred, target) | L1 loss.
Args:
pred (torch.Tensor): The prediction.
target (torch.Tensor): The learning target of the prediction.
Returns:
torch.Tensor: Calculated loss
| L1 loss. | def l1_loss(pred, target):
"""L1 loss.
Args:
pred (torch.Tensor): The prediction.
target (torch.Tensor): The learning target of the prediction.
Returns:
torch.Tensor: Calculated loss
"""
assert pred.size() == target.size() and target.numel() > 0
loss = torch.abs(pred - ... | [
"def",
"l1_loss",
"(",
"pred",
",",
"target",
")",
":",
"assert",
"pred",
".",
"size",
"(",
")",
"==",
"target",
".",
"size",
"(",
")",
"and",
"target",
".",
"numel",
"(",
")",
">",
"0",
"loss",
"=",
"torch",
".",
"abs",
"(",
"pred",
"-",
"targ... | [
29,
0
] | [
41,
15
] | python | ca | ['es', 'ca', 'it'] | False |
Stream.maxpoints | (self) |
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000]... |
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or float in the interval [0, 10000] | def maxpoints(self):
"""
Sets the maximum number of points to keep on the plots from an
incoming stream. If `maxpoints` is set to 50, only the newest
50 points will be displayed on the plot.
The 'maxpoints' property is a number and may be specified as:
- An int or ... | [
"def",
"maxpoints",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"maxpoints\"",
"]"
] | [
15,
4
] | [
28,
32
] | python | en | ['en', 'error', 'th'] | False |
Stream.token | (self) |
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string
Returns
-------
str
|
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string | def token(self):
"""
The stream id number links a data trace on a plot with a
stream. See https://chart-studio.plotly.com/settings for more
details.
The 'token' property is a string and must be specified as:
- A non-empty string
Returns
-------
... | [
"def",
"token",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"token\"",
"]"
] | [
37,
4
] | [
50,
28
] | python | en | ['en', 'error', 'th'] | False |
Stream.__init__ | (self, arg=None, maxpoints=None, token=None, **kwargs) |
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.waterfall.Stream`
maxpoints
Sets the maximum number of points to keep ... |
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.waterfall.Stream`
maxpoints
Sets the maximum number of points to keep ... | def __init__(self, arg=None, maxpoints=None, token=None, **kwargs):
"""
Construct a new Stream object
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
:class:`plotly.graph_objs.waterfall.S... | [
"def",
"__init__",
"(",
"self",
",",
"arg",
"=",
"None",
",",
"maxpoints",
"=",
"None",
",",
"token",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Stream",
",",
"self",
")",
".",
"__init__",
"(",
"\"stream\"",
")",
"if",
"\"_paren... | [
72,
4
] | [
140,
34
] | python | en | ['en', 'error', 'th'] | False |
air_flux | (air_flow: float, co2_source: float, co2_target: float) |
Equation 8.46
Args:
co2_source, co2_target: CO2-concentration at location (mg m^-3)
air_flow: the air flux from location 1 to location 2 (m^3 m^-2 s^-1)
return: CO2 flux accompanying an air flux from location 1 to location 2 [mg m^-2 s^-1]
|
Equation 8.46
Args:
co2_source, co2_target: CO2-concentration at location (mg m^-3)
air_flow: the air flux from location 1 to location 2 (m^3 m^-2 s^-1)
return: CO2 flux accompanying an air flux from location 1 to location 2 [mg m^-2 s^-1]
| def air_flux(air_flow: float, co2_source: float, co2_target: float) -> float:
"""
Equation 8.46
Args:
co2_source, co2_target: CO2-concentration at location (mg m^-3)
air_flow: the air flux from location 1 to location 2 (m^3 m^-2 s^-1)
return: CO2 flux accompanying an air flux from locat... | [
"def",
"air_flux",
"(",
"air_flow",
":",
"float",
",",
"co2_source",
":",
"float",
",",
"co2_target",
":",
"float",
")",
"->",
"float",
":",
"return",
"air_flow",
"*",
"(",
"co2_source",
"-",
"co2_target",
")"
] | [
24,
0
] | [
32,
47
] | python | en | ['en', 'error', 'th'] | False |
ConnectionRecord.__init__ | (
self,
*,
connection_id: str = None,
my_did: str = None,
their_did: str = None,
their_label: str = None,
their_role: str = None,
initiator: str = None,
invitation_key: str = None,
request_id: str = None,
state: str = None,
... | Initialize a new ConnectionRecord. | Initialize a new ConnectionRecord. | def __init__(
self,
*,
connection_id: str = None,
my_did: str = None,
their_did: str = None,
their_label: str = None,
their_role: str = None,
initiator: str = None,
invitation_key: str = None,
request_id: str = None,
state: str = No... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"connection_id",
":",
"str",
"=",
"None",
",",
"my_did",
":",
"str",
"=",
"None",
",",
"their_did",
":",
"str",
"=",
"None",
",",
"their_label",
":",
"str",
"=",
"None",
",",
"their_role",
":",
"str",
... | [
64,
4
] | [
98,
26
] | python | en | ['en', 'en', 'en'] | True |
ConnectionRecord.connection_id | (self) | Accessor for the ID associated with this connection. | Accessor for the ID associated with this connection. | def connection_id(self) -> str:
"""Accessor for the ID associated with this connection."""
return self._id | [
"def",
"connection_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_id"
] | [
101,
4
] | [
103,
23
] | python | en | ['en', 'en', 'en'] | True |
ConnectionRecord.record_value | (self) | Accessor to for the JSON record value properties for this connection. | Accessor to for the JSON record value properties for this connection. | def record_value(self) -> dict:
"""Accessor to for the JSON record value properties for this connection."""
return {
prop: getattr(self, prop)
for prop in (
"initiator",
"their_role",
"inbound_connection_id",
"routin... | [
"def",
"record_value",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"prop",
":",
"getattr",
"(",
"self",
",",
"prop",
")",
"for",
"prop",
"in",
"(",
"\"initiator\"",
",",
"\"their_role\"",
",",
"\"inbound_connection_id\"",
",",
"\"routing_state\"",
",... | [
106,
4
] | [
122,
9
] | python | en | ['en', 'en', 'en'] | True |
ConnectionRecord.retrieve_by_did | (
cls,
context: InjectionContext,
their_did: str = None,
my_did: str = None,
initiator: str = None,
) | Retrieve a connection record by target DID.
Args:
context: The injection context to use
their_did: The target DID to filter by
my_did: One of our DIDs to filter by
initiator: Filter connections by the initiator value
| Retrieve a connection record by target DID. | async def retrieve_by_did(
cls,
context: InjectionContext,
their_did: str = None,
my_did: str = None,
initiator: str = None,
) -> "ConnectionRecord":
"""Retrieve a connection record by target DID.
Args:
context: The injection context to use
... | [
"async",
"def",
"retrieve_by_did",
"(",
"cls",
",",
"context",
":",
"InjectionContext",
",",
"their_did",
":",
"str",
"=",
"None",
",",
"my_did",
":",
"str",
"=",
"None",
",",
"initiator",
":",
"str",
"=",
"None",
",",
")",
"->",
"\"ConnectionRecord\"",
... | [
125,
4
] | [
148,
81
] | python | en | ['en', 'en', 'en'] | True |
ConnectionRecord.retrieve_by_invitation_key | (
cls, context: InjectionContext, invitation_key: str, initiator: str = None
) | Retrieve a connection record by invitation key.
Args:
context: The injection context to use
invitation_key: The key on the originating invitation
initiator: Filter by the initiator value
| Retrieve a connection record by invitation key. | async def retrieve_by_invitation_key(
cls, context: InjectionContext, invitation_key: str, initiator: str = None
) -> "ConnectionRecord":
"""Retrieve a connection record by invitation key.
Args:
context: The injection context to use
invitation_key: The key on the ori... | [
"async",
"def",
"retrieve_by_invitation_key",
"(",
"cls",
",",
"context",
":",
"InjectionContext",
",",
"invitation_key",
":",
"str",
",",
"initiator",
":",
"str",
"=",
"None",
")",
"->",
"\"ConnectionRecord\"",
":",
"tag_filter",
"=",
"{",
"\"invitation_key\"",
... | [
151,
4
] | [
165,
81
] | python | en | ['en', 'en', 'en'] | True |
ConnectionRecord.retrieve_by_request_id | (
cls, context: InjectionContext, request_id: str
) | Retrieve a connection record from our previous request ID.
Args:
context: The injection context to use
request_id: The ID of the originating connection request
| Retrieve a connection record from our previous request ID. | async def retrieve_by_request_id(
cls, context: InjectionContext, request_id: str
) -> "ConnectionRecord":
"""Retrieve a connection record from our previous request ID.
Args:
context: The injection context to use
request_id: The ID of the originating connection reque... | [
"async",
"def",
"retrieve_by_request_id",
"(",
"cls",
",",
"context",
":",
"InjectionContext",
",",
"request_id",
":",
"str",
")",
"->",
"\"ConnectionRecord\"",
":",
"tag_filter",
"=",
"{",
"\"request_id\"",
":",
"request_id",
"}",
"return",
"await",
"cls",
".",... | [
168,
4
] | [
178,
68
] | python | en | ['en', 'en', 'en'] | True |
ConnectionRecord.attach_invitation | (
self, context: InjectionContext, invitation: ConnectionInvitation
) | Persist the related connection invitation to storage.
Args:
context: The injection context to use
invitation: The invitation to relate to this connection record
| Persist the related connection invitation to storage. | async def attach_invitation(
self, context: InjectionContext, invitation: ConnectionInvitation
):
"""Persist the related connection invitation to storage.
Args:
context: The injection context to use
invitation: The invitation to relate to this connection record
... | [
"async",
"def",
"attach_invitation",
"(",
"self",
",",
"context",
":",
"InjectionContext",
",",
"invitation",
":",
"ConnectionInvitation",
")",
":",
"assert",
"self",
".",
"connection_id",
"record",
"=",
"StorageRecord",
"(",
"self",
".",
"RECORD_TYPE_INVITATION",
... | [
180,
4
] | [
196,
40
] | python | en | ['en', 'en', 'en'] | True |
ConnectionRecord.retrieve_invitation | (
self, context: InjectionContext
) | Retrieve the related connection invitation.
Args:
context: The injection context to use
| Retrieve the related connection invitation. | async def retrieve_invitation(
self, context: InjectionContext
) -> ConnectionInvitation:
"""Retrieve the related connection invitation.
Args:
context: The injection context to use
"""
assert self.connection_id
storage: BaseStorage = await context.inject(... | [
"async",
"def",
"retrieve_invitation",
"(",
"self",
",",
"context",
":",
"InjectionContext",
")",
"->",
"ConnectionInvitation",
":",
"assert",
"self",
".",
"connection_id",
"storage",
":",
"BaseStorage",
"=",
"await",
"context",
".",
"inject",
"(",
"BaseStorage",
... | [
198,
4
] | [
211,
59
] | python | en | ['en', 'en', 'en'] | True |
ConnectionRecord.attach_request | (
self, context: InjectionContext, request: ConnectionRequest
) | Persist the related connection request to storage.
Args:
context: The injection context to use
request: The request to relate to this connection record
| Persist the related connection request to storage. | async def attach_request(
self, context: InjectionContext, request: ConnectionRequest
):
"""Persist the related connection request to storage.
Args:
context: The injection context to use
request: The request to relate to this connection record
"""
ass... | [
"async",
"def",
"attach_request",
"(",
"self",
",",
"context",
":",
"InjectionContext",
",",
"request",
":",
"ConnectionRequest",
")",
":",
"assert",
"self",
".",
"connection_id",
"record",
"=",
"StorageRecord",
"(",
"self",
".",
"RECORD_TYPE_REQUEST",
",",
"req... | [
213,
4
] | [
229,
40
] | 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.