code: def set_elems(self, subs, vals):
          
          if isinstance(vals, (int, float)):
              # if vals is a scalar, extend it to a list of appropriate length
              vals = [vals] * len(subs)
  
          for i in range(len(subs)):
              self.set_(subs[i], vals[i])
docs: set_elems(subs, vals) sets the array elements specified by the list
             of subscript values subs (each element of subs is a tuple of 
             subscripts identifying an array element) to the corresponding value
             in vals.