nodes: 0, module; 1, function_definition; 2, function_name:sorted_members; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, if_statement; 11, expression_statement; 12, comment:"""
          Iterate over sorted members of shape in the same order in which
          the members are declared except yielding the required members before
          any optional members.
          """; 13, assignment; 14, assignment; 15, pattern_list; 16, call; 17, block; 18, attribute; 19, comment:# ResponseMetadata is the first member for all output shapes.; 20, block; 21, yield; 22, identifier:members; 23, call; 24, identifier:required_names; 25, call; 26, identifier:name; 27, identifier:shape; 28, attribute; 29, argument_list; 30, expression_statement; 31, identifier:self; 32, identifier:is_output_shape; 33, expression_statement; 34, call; 35, attribute; 36, argument_list; 37, attribute; 38, argument_list; 39, attribute; 40, identifier:items; 41, assignment; 42, yield; 43, identifier:sorted; 44, argument_list; 45, identifier:collections; 46, identifier:OrderedDict; 47, attribute; 48, identifier:get; 49, string:"required"; 50, tuple; 51, identifier:self; 52, identifier:members; 53, subscript; 54, call; 55, call; 56, call; 57, keyword_argument; 58, identifier:self; 59, identifier:metadata; 60, identifier:members; 61, identifier:name; 62, identifier:AbShapeMember; 63, argument_list; 64, identifier:AbShapeMember; 65, argument_list; 66, attribute; 67, argument_list; 68, identifier:key; 69, lambda; 70, keyword_argument; 71, keyword_argument; 72, keyword_argument; 73, keyword_argument; 74, keyword_argument; 75, keyword_argument; 76, identifier:members; 77, identifier:values; 78, lambda_parameters; 79, not_operator; 80, identifier:name; 81, identifier:name; 82, identifier:shape; 83, identifier:shape; 84, identifier:is_required; 85, comparison_operator:name in required_names; 86, identifier:name; 87, string:"ResponseMetadata"; 88, identifier:shape; 89, call; 90, identifier:is_required; 91, True; 92, identifier:m; 93, attribute; 94, identifier:name; 95, identifier:required_names; 96, attribute; 97, argument_list; 98, identifier:m; 99, identifier:is_required; 100, attribute; 101, identifier:get_shape_by_name; 102, string:"ResponseMetadata"; 103, identifier:self; 104, identifier:_shape_resolver
code: def sorted_members(self):
          """
          Iterate over sorted members of shape in the same order in which
          the members are declared except yielding the required members before
          any optional members.
          """
          members = collections.OrderedDict()
          required_names = self.metadata.get("required", ())
          for name, shape in self.members.items():
              members[name] = AbShapeMember(name=name, shape=shape, is_required=name in required_names)
  
          if self.is_output_shape:
              # ResponseMetadata is the first member for all output shapes.
              yield AbShapeMember(
                  name="ResponseMetadata",
                  shape=self._shape_resolver.get_shape_by_name("ResponseMetadata"),
                  is_required=True,
              )
  
          yield from sorted(members.values(), key=lambda m: not m.is_required)