Coverage for transformer_lens/utils.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.10.1, created at 2026-04-30 01:33 +0000

1"""utils. 

2 

3This module is deprecated, but imports from the new utilities to maintain backwards compatibility. 

4""" 

5 

6import warnings 

7 

8from transformer_lens.utilities import * # noqa: F401,F403 

9 

10warnings.warn( 

11 "The 'utils' module has been deprecated. Please use 'transformer_lens.utilities' instead. " 

12 "Importing from utils.py will be removed in TransformerLens 4.0.", 

13 DeprecationWarning, 

14 stacklevel=2, 

15) 

16 

17 

18__all__ = [ 

19 "download_file_from_hf", 

20 "clear_huggingface_cache", 

21 "keep_single_column", 

22 "get_dataset", 

23 "print_gpu_mem", 

24 "get_device", 

25 "get_corner", 

26 "to_numpy", 

27 "remove_batch_dim", 

28 "transpose", 

29 "is_square", 

30 "is_lower_triangular", 

31 "check_structure", 

32 "composition_scores", 

33 "get_offset_position_ids", 

34 "get_cumsum_along_dim", 

35 "repeat_along_head_dimension", 

36 "filter_dict_by_prefix", 

37 "lm_cross_entropy_loss", 

38 "lm_accuracy", 

39 "gelu_new", 

40 "gelu_fast", 

41 "solu", 

42 "calc_fan_in_and_fan_out", 

43 "init_xavier_uniform_", 

44 "init_xavier_normal_", 

45 "init_kaiming_uniform_", 

46 "init_kaiming_normal_", 

47 "is_library_available", 

48 "tokenize_and_concatenate", 

49 "get_tokenizer_with_bos", 

50 "get_input_with_manually_prepended_bos", 

51 "get_tokens_with_bos_removed", 

52 "get_attention_mask", 

53 "sample_logits", 

54 "SliceInput", 

55 "Slice", 

56 "get_act_name", 

57 "get_nested_attr", 

58 "set_nested_attr", 

59 "override_or_use_default_value", 

60 "LocallyOverridenDefaults", 

61 "USE_DEFAULT_VALUE", 

62 "test_prompt", 

63 "warn_if_mps", 

64]