code: def clamp_by_pnorm(x, p, r):
      assert isinstance(p, float) or isinstance(p, int)
      norm = _get_norm_batch(x, p)
      if isinstance(r, torch.Tensor):
          assert norm.size() == r.size()
      else:
          assert isinstance(r, float)
      factor = torch.min(r / norm, torch.ones_like(norm))
      return batch_multiply(factor, x)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import torch
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 20 for calling a global function with example usage: clamp_by_pnorm(x, p, r) and returns: batch_multiply