m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
4.8 KiB

6 months ago
  1. import sys
  2. from typing import (
  3. Any,
  4. Optional,
  5. Union,
  6. Sequence,
  7. Tuple,
  8. Callable,
  9. List,
  10. overload,
  11. TypeVar,
  12. Iterable,
  13. )
  14. from numpy import ndarray, generic, dtype, bool_, signedinteger, _OrderKACF, _OrderCF
  15. from numpy.typing import ArrayLike, DTypeLike, _ShapeLike
  16. if sys.version_info >= (3, 8):
  17. from typing import Literal
  18. else:
  19. from typing_extensions import Literal
  20. _T = TypeVar("_T")
  21. _ArrayType = TypeVar("_ArrayType", bound=ndarray)
  22. _CorrelateMode = Literal["valid", "same", "full"]
  23. @overload
  24. def zeros_like(
  25. a: _ArrayType,
  26. dtype: None = ...,
  27. order: _OrderKACF = ...,
  28. subok: Literal[True] = ...,
  29. shape: None = ...,
  30. ) -> _ArrayType: ...
  31. @overload
  32. def zeros_like(
  33. a: ArrayLike,
  34. dtype: DTypeLike = ...,
  35. order: _OrderKACF = ...,
  36. subok: bool = ...,
  37. shape: Optional[_ShapeLike] = ...,
  38. ) -> ndarray: ...
  39. def ones(
  40. shape: _ShapeLike,
  41. dtype: DTypeLike = ...,
  42. order: _OrderCF = ...,
  43. *,
  44. like: ArrayLike = ...,
  45. ) -> ndarray: ...
  46. @overload
  47. def ones_like(
  48. a: _ArrayType,
  49. dtype: None = ...,
  50. order: _OrderKACF = ...,
  51. subok: Literal[True] = ...,
  52. shape: None = ...,
  53. ) -> _ArrayType: ...
  54. @overload
  55. def ones_like(
  56. a: ArrayLike,
  57. dtype: DTypeLike = ...,
  58. order: _OrderKACF = ...,
  59. subok: bool = ...,
  60. shape: Optional[_ShapeLike] = ...,
  61. ) -> ndarray: ...
  62. @overload
  63. def empty_like(
  64. a: _ArrayType,
  65. dtype: None = ...,
  66. order: _OrderKACF = ...,
  67. subok: Literal[True] = ...,
  68. shape: None = ...,
  69. ) -> _ArrayType: ...
  70. @overload
  71. def empty_like(
  72. a: ArrayLike,
  73. dtype: DTypeLike = ...,
  74. order: _OrderKACF = ...,
  75. subok: bool = ...,
  76. shape: Optional[_ShapeLike] = ...,
  77. ) -> ndarray: ...
  78. def full(
  79. shape: _ShapeLike,
  80. fill_value: Any,
  81. dtype: DTypeLike = ...,
  82. order: _OrderCF = ...,
  83. *,
  84. like: ArrayLike = ...,
  85. ) -> ndarray: ...
  86. @overload
  87. def full_like(
  88. a: _ArrayType,
  89. fill_value: Any,
  90. dtype: None = ...,
  91. order: _OrderKACF = ...,
  92. subok: Literal[True] = ...,
  93. shape: None = ...,
  94. ) -> _ArrayType: ...
  95. @overload
  96. def full_like(
  97. a: ArrayLike,
  98. fill_value: Any,
  99. dtype: DTypeLike = ...,
  100. order: _OrderKACF = ...,
  101. subok: bool = ...,
  102. shape: Optional[_ShapeLike] = ...,
  103. ) -> ndarray: ...
  104. @overload
  105. def count_nonzero(
  106. a: ArrayLike,
  107. axis: None = ...,
  108. *,
  109. keepdims: Literal[False] = ...,
  110. ) -> int: ...
  111. @overload
  112. def count_nonzero(
  113. a: ArrayLike,
  114. axis: _ShapeLike = ...,
  115. *,
  116. keepdims: bool = ...,
  117. ) -> Any: ... # TODO: np.intp or ndarray[np.intp]
  118. def isfortran(a: Union[ndarray, generic]) -> bool: ...
  119. def argwhere(a: ArrayLike) -> ndarray: ...
  120. def flatnonzero(a: ArrayLike) -> ndarray: ...
  121. def correlate(
  122. a: ArrayLike,
  123. v: ArrayLike,
  124. mode: _CorrelateMode = ...,
  125. ) -> ndarray: ...
  126. def convolve(
  127. a: ArrayLike,
  128. v: ArrayLike,
  129. mode: _CorrelateMode = ...,
  130. ) -> ndarray: ...
  131. @overload
  132. def outer(
  133. a: ArrayLike,
  134. b: ArrayLike,
  135. out: None = ...,
  136. ) -> ndarray: ...
  137. @overload
  138. def outer(
  139. a: ArrayLike,
  140. b: ArrayLike,
  141. out: _ArrayType = ...,
  142. ) -> _ArrayType: ...
  143. def tensordot(
  144. a: ArrayLike,
  145. b: ArrayLike,
  146. axes: Union[int, Tuple[_ShapeLike, _ShapeLike]] = ...,
  147. ) -> ndarray: ...
  148. def roll(
  149. a: ArrayLike,
  150. shift: _ShapeLike,
  151. axis: Optional[_ShapeLike] = ...,
  152. ) -> ndarray: ...
  153. def rollaxis(a: ndarray, axis: int, start: int = ...) -> ndarray: ...
  154. def moveaxis(
  155. a: ndarray,
  156. source: _ShapeLike,
  157. destination: _ShapeLike,
  158. ) -> ndarray: ...
  159. def cross(
  160. a: ArrayLike,
  161. b: ArrayLike,
  162. axisa: int = ...,
  163. axisb: int = ...,
  164. axisc: int = ...,
  165. axis: Optional[int] = ...,
  166. ) -> ndarray: ...
  167. @overload
  168. def indices(
  169. dimensions: Sequence[int],
  170. dtype: DTypeLike = ...,
  171. sparse: Literal[False] = ...,
  172. ) -> ndarray: ...
  173. @overload
  174. def indices(
  175. dimensions: Sequence[int],
  176. dtype: DTypeLike = ...,
  177. sparse: Literal[True] = ...,
  178. ) -> Tuple[ndarray, ...]: ...
  179. def fromfunction(
  180. function: Callable[..., _T],
  181. shape: Sequence[int],
  182. *,
  183. dtype: DTypeLike = ...,
  184. like: ArrayLike = ...,
  185. **kwargs: Any,
  186. ) -> _T: ...
  187. def isscalar(element: Any) -> bool: ...
  188. def binary_repr(num: int, width: Optional[int] = ...) -> str: ...
  189. def base_repr(number: int, base: int = ..., padding: int = ...) -> str: ...
  190. def identity(
  191. n: int,
  192. dtype: DTypeLike = ...,
  193. *,
  194. like: ArrayLike = ...,
  195. ) -> ndarray: ...
  196. def allclose(
  197. a: ArrayLike,
  198. b: ArrayLike,
  199. rtol: float = ...,
  200. atol: float = ...,
  201. equal_nan: bool = ...,
  202. ) -> bool: ...
  203. def isclose(
  204. a: ArrayLike,
  205. b: ArrayLike,
  206. rtol: float = ...,
  207. atol: float = ...,
  208. equal_nan: bool = ...,
  209. ) -> Any: ...
  210. def array_equal(a1: ArrayLike, a2: ArrayLike, equal_nan: bool = ...) -> bool: ...
  211. def array_equiv(a1: ArrayLike, a2: ArrayLike) -> bool: ...