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 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
[
  {
    "function_name": "LoraModel.__init__",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "super().__init__",
        "functionality": "Initializes the parent torch.nn.Module.",
        "input": "self",
        "output": "None",
        "location_or_namespace": "torch.nn.Module"
      },
      {
        "function_call_name": "self._find_and_replace",
        "functionality": "Finds and replaces target modules with LoRA layers.",
        "input": "self",
        "output": "None",
        "location_or_namespace": "peft/lora.py"
      },
      {
        "function_call_name": "mark_only_lora_as_trainable",
        "functionality": "Sets the requires_grad flag for model parameters, freezing non-LoRA layers.",
        "input": "model (torch.nn.Module), bias (str)",
        "output": "None",
        "location_or_namespace": "peft/lora.py"
      }
    ]
  },
  {
    "function_name": "LoraModel._find_and_replace",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "getattr",
        "functionality": "Returns the value of a named attribute of an object.",
        "input": "object, name (str), default (any)",
        "output": "any",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "hasattr",
        "functionality": "Returns true if the object has the given named attribute and false if it does not.",
        "input": "object, name (str)",
        "output": "bool",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "re.fullmatch",
        "functionality": "Checks if the entire string matches the regular expression pattern.",
        "input": "pattern (str), string (str)",
        "output": "match object or None",
        "location_or_namespace": "re"
      },
      {
        "function_call_name": "self._get_submodules",
        "functionality": "Retrieves the parent module, target module, and target name for a given key.",
        "input": "self, key (str)",
        "output": "tuple (parent_module, target_module, target_name)",
        "location_or_namespace": "peft/lora.py"
      },
      {
        "function_call_name": "isinstance",
        "functionality": "Checks if an object is an instance of a class or of a subclass thereof.",
        "input": "object, classinfo",
        "output": "bool",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "Linear",
        "functionality": "Constructor for the custom LoRA linear layer.",
        "input": "in_features (int), out_features (int), bias (bool), **kwargs",
        "output": "Linear object",
        "location_or_namespace": "peft/lora.py"
      },
      {
        "function_call_name": "self._replace_module",
        "functionality": "Replaces a module in the model with a new module.",
        "input": "self, parent_module (torch.nn.Module), child_name (str), new_module (torch.nn.Module), old_module (torch.nn.Module)",
        "output": "None",
        "location_or_namespace": "peft/lora.py"
      }
    ]
  },
  {
    "function_name": "LoraModel._get_submodules",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "self.model.get_submodule",
        "functionality": "Returns the submodule given by the dot-separated path.",
        "input": "target (str)",
        "output": "torch.nn.Module",
        "location_or_namespace": "torch.nn.Module"
      }
    ]
  },
  {
    "function_name": "LoraModel._replace_module",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "setattr",
        "functionality": "Sets the value of an attribute of an object.",
        "input": "object, name (str), value (any)",
        "output": "None",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "getattr",
        "functionality": "Returns the value of a named attribute of an object.",
        "input": "object, name (str), default (any)",
        "output": "any",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "new_module.named_modules",
        "functionality": "Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself.",
        "input": "self",
        "output": "iterator",
        "location_or_namespace": "torch.nn.Module"
      },
      {
        "function_call_name": "module.to",
        "functionality": "Moves and/or casts the parameters and buffers.",
        "input": "device (torch.device)",
        "output": "self",
        "location_or_namespace": "torch.nn.Module"
      }
    ]
  },
  {
    "function_name": "LoraModel.get_peft_config_as_dict",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "asdict",
        "functionality": "Return a new dict which maps field names to their values for a dataclass instance.",
        "input": "obj",
        "output": "dict",
        "location_or_namespace": "dataclasses"
      },
      {
        "function_call_name": "isinstance",
        "functionality": "Checks if an object is an instance of a class or of a subclass thereof.",
        "input": "object, classinfo",
        "output": "bool",
        "location_or_namespace": "builtins"
      }
    ]
  },
  {
    "function_name": "LoraModel.enable_adapter_layers",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "self._set_adapter_layers",
        "functionality": "Internal helper to enable or disable adapter layers.",
        "input": "self, enabled (bool)",
        "output": "None",
        "location_or_namespace": "peft/lora.py"
      }
    ]
  },
  {
    "function_name": "LoraModel.disable_adapter_layers",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "self._set_adapter_layers",
        "functionality": "Internal helper to enable or disable adapter layers.",
        "input": "self, enabled (bool)",
        "output": "None",
        "location_or_namespace": "peft/lora.py"
      }
    ]
  },
  {
    "function_name": "mark_only_lora_as_trainable",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "model.named_parameters",
        "functionality": "Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.",
        "input": "self",
        "output": "iterator",
        "location_or_namespace": "torch.nn.Module"
      },
      {
        "function_call_name": "model.modules",
        "functionality": "Returns an iterator over all modules in the network.",
        "input": "self",
        "output": "iterator",
        "location_or_namespace": "torch.nn.Module"
      },
      {
        "function_call_name": "isinstance",
        "functionality": "Checks if an object is an instance of a class or of a subclass thereof.",
        "input": "object, classinfo",
        "output": "bool",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "hasattr",
        "functionality": "Returns true if the object has the given named attribute and false if it does not.",
        "input": "object, name (str)",
        "output": "bool",
        "location_or_namespace": "builtins"
      }
    ]
  },
  {
    "function_name": "LoraLayer.__init__",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "torch.nn.Dropout",
        "functionality": "Initializes a dropout layer.",
        "input": "p (float)",
        "output": "Dropout layer object",
        "location_or_namespace": "torch.nn"
      }
    ]
  },
  {
    "function_name": "Linear.__init__",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "torch.nn.Linear.__init__",
        "functionality": "Initializes the parent nn.Linear layer.",
        "input": "self, in_features (int), out_features (int), **kwargs",
        "output": "None",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "LoraLayer.__init__",
        "functionality": "Initializes the LoraLayer base class.",
        "input": "self, r (int), lora_alpha (int), lora_dropout (float), merge_weights (bool)",
        "output": "None",
        "location_or_namespace": "peft/lora.py"
      },
      {
        "function_call_name": "torch.nn.Linear",
        "functionality": "Initializes a standard linear layer.",
        "input": "in_features (int), out_features (int), bias (bool)",
        "output": "Linear layer object",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "setattr",
        "functionality": "Sets the value of an attribute of an object.",
        "input": "object, name (str), value (any)",
        "output": "None",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "self.reset_parameters",
        "functionality": "Initializes the weights of the LoRA and base layers.",
        "input": "self",
        "output": "None",
        "location_or_namespace": "peft/lora.py"
      }
    ]
  },
  {
    "function_name": "Linear.reset_parameters",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "torch.nn.Linear.reset_parameters",
        "functionality": "Resets the parameters of the base linear layer.",
        "input": "self",
        "output": "None",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "hasattr",
        "functionality": "Returns true if the object has the given named attribute and false if it does not.",
        "input": "object, name (str)",
        "output": "bool",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "getattr",
        "functionality": "Returns the value of a named attribute of an object.",
        "input": "object, name (str)",
        "output": "any",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "torch.nn.init.kaiming_uniform_",
        "functionality": "Fills the input Tensor with values according to the Kaiming uniform distribution.",
        "input": "tensor, a (float)",
        "output": "Tensor",
        "location_or_namespace": "torch.nn.init"
      },
      {
        "function_call_name": "torch.nn.init.zeros_",
        "functionality": "Fills the input Tensor with the scalar value 0.",
        "input": "tensor",
        "output": "Tensor",
        "location_or_namespace": "torch.nn.init"
      },
      {
        "function_call_name": "math.sqrt",
        "functionality": "Returns the square root of a number.",
        "input": "x (number)",
        "output": "float",
        "location_or_namespace": "math"
      }
    ]
  },
  {
    "function_name": "Linear.train",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "torch.nn.Linear.train",
        "functionality": "Sets the module in training mode.",
        "input": "self, mode (bool)",
        "output": "self",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "lora_route.train",
        "functionality": "Sets the routing layer in training mode.",
        "input": "mode (bool)",
        "output": "self",
        "location_or_namespace": "torch.nn.Module"
      },
      {
        "function_call_name": "getattr",
        "functionality": "Returns the value of a named attribute of an object.",
        "input": "object, name (str)",
        "output": "any",
        "location_or_namespace": "builtins"
      }
    ]
  },
  {
    "function_name": "Linear.eval",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "torch.nn.Linear.eval",
        "functionality": "Sets the module in evaluation mode.",
        "input": "self",
        "output": "self",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "lora_route.eval",
        "functionality": "Sets the routing layer in evaluation mode.",
        "input": "self",
        "output": "self",
        "location_or_namespace": "torch.nn.Module"
      },
      {
        "function_call_name": "getattr",
        "functionality": "Returns the value of a named attribute of an object.",
        "input": "object, name (str)",
        "output": "any",
        "location_or_namespace": "builtins"
      }
    ]
  },
  {
    "function_name": "Linear.cv_squared",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "torch.tensor",
        "functionality": "Constructs a tensor with data.",
        "input": "data, device, dtype",
        "output": "Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "x.float",
        "functionality": "Casts the tensor to float dtype.",
        "input": "self",
        "output": "Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "x.var",
        "functionality": "Calculates the variance of the tensor.",
        "input": "self",
        "output": "Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "x.mean",
        "functionality": "Calculates the mean of the tensor.",
        "input": "self",
        "output": "Tensor",
        "location_or_namespace": "torch.Tensor"
      }
    ]
  },
  {
    "function_name": "Linear.forward",
    "file_path": "peft/lora.py",
    "function_calls": [
      {
        "function_call_name": "torch.nn.functional.linear",
        "functionality": "Applies a linear transformation to the incoming data.",
        "input": "input, weight, bias",
        "output": "Tensor",
        "location_or_namespace": "torch.nn.functional"
      },
      {
        "function_call_name": "transpose",
        "functionality": "Transposes a matrix.",
        "input": "x (Tensor), fan_in_fan_out (bool)",
        "output": "Tensor",
        "location_or_namespace": "peft.utils"
      },
      {
        "function_call_name": "torch.nn.functional.softmax",
        "functionality": "Applies a softmax function.",
        "input": "input, dim, dtype",
        "output": "Tensor",
        "location_or_namespace": "torch.nn.functional"
      },
      {
        "function_call_name": "self.lora_route",
        "functionality": "Forward pass of the routing linear layer.",
        "input": "x (Tensor)",
        "output": "Tensor",
        "location_or_namespace": "torch.nn.Module"
      },
      {
        "function_call_name": "torch.unsqueeze",
        "functionality": "Returns a new tensor with a dimension of size one inserted at the specified position.",
        "input": "input, dim",
        "output": "Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "getattr",
        "functionality": "Returns the value of a named attribute of an object.",
        "input": "object, name (str)",
        "output": "any",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "self.lora_dropout",
        "functionality": "Forward pass of the dropout layer.",
        "input": "x (Tensor)",
        "output": "Tensor",
        "location_or_namespace": "torch.nn.Dropout"
      },
      {
        "function_call_name": "torch.zeros",
        "functionality": "Returns a tensor filled with the scalar value 0.",
        "input": "size, device",
        "output": "Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "task_types.view",
        "functionality": "Returns a new tensor with the same data as the self tensor but of a different shape.",
        "input": "shape",
        "output": "Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "self.cv_squared",
        "functionality": "Calculates the squared coefficient of variation.",
        "input": "self, x (Tensor)",
        "output": "Tensor",
        "location_or_namespace": "peft/lora.py"
      },
      {
        "function_call_name": "route_weight.sum",
        "functionality": "Calculates the sum of tensor elements over given dimensions.",
        "input": "dim",
        "output": "Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "torch.where",
        "functionality": "Return a tensor of elements selected from either x or y, depending on condition.",
        "input": "condition, x, y",
        "output": "Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "torch.concat",
        "functionality": "Concatenates the given sequence of seq tensors in the given dimension.",
        "input": "tensors, dim",
        "output": "Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "tensor.repeat",
        "functionality": "Repeats this tensor along the specified dimensions.",
        "input": "sizes",
        "output": "Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "tensor.flatten",
        "functionality": "Flattens a contiguous range of dims in a tensor.",
        "input": "self",
        "output": "Tensor",
        "location_or_namespace": "torch.Tensor"
      }
    ]
  }
]