(
self,
*shape,
rng: List[torch.Generator] | torch.Generator | None = None,
**kwargs,
)
| 103 | return self._dummy.device |
| 104 | |
| 105 | def randn( |
| 106 | self, |
| 107 | *shape, |
| 108 | rng: List[torch.Generator] | torch.Generator | None = None, |
| 109 | **kwargs, |
| 110 | ) -> torch.Tensor: |
| 111 | if rng is None: |
| 112 | return torch.randn(*shape, **kwargs) |
| 113 | elif isinstance(rng, torch.Generator): |
| 114 | return torch.randn(*shape, generator=rng, **kwargs) |
| 115 | elif isinstance(rng, list): |
| 116 | assert len(rng) == shape[0] |
| 117 | return torch.stack( |
| 118 | [torch.randn(*shape[1:], generator=r, **kwargs) for r in rng] |
| 119 | ) |
| 120 | else: |
| 121 | raise ValueError(f"invalid rng: {rng}") |
| 122 | |
| 123 | def randn_like( |
| 124 | self, |
no outgoing calls
no test coverage detected