Create a new tensor or nested list of tensors that has the same shape as x. Each of the tensor is filled with iid samples from a standard normal distribution.
(x: T.Union[torch.Tensor, T.Sequence[torch.Tensor]])
| 117 | |
| 118 | |
| 119 | def randn_like(x: T.Union[torch.Tensor, T.Sequence[torch.Tensor]]): |
| 120 | """ |
| 121 | Create a new tensor or nested list of tensors that has the same shape as x. |
| 122 | Each of the tensor is filled with iid samples from a standard normal distribution. |
| 123 | """ |
| 124 | if isinstance(x, torch.Tensor): |
| 125 | return torch.randn_like(x) |
| 126 | elif isinstance(x, T.Sequence): |
| 127 | return [randn_like(xi) for xi in x] |
| 128 | else: |
| 129 | raise NotImplementedError |
| 130 | |
| 131 | |
| 132 | def get_constant_rnn_hidden_states( |
nothing calls this directly
no outgoing calls
no test coverage detected