code: def get_req_only_goals(
      goals_list: List[Dict], api_schemas: List[Dict]
  ) -> List[Dict]:
      """
      Given a list of goals and a list of api schemas that say if slots are required or
      optional, this function filters for the goals to be only the required ones.
  
      If we have no api schemas or a goal is malformed, we return the empty list. If a
      goal is malformed, we print a warning, since this whole req-only goals thing is
      experimental at best anyhow.
      """
      if len(api_schemas) == 0:
          return []
      result = []
      for goal in goals_list:
          req_goals = {}
          method = goal.get(STANDARD_API_NAME_SLOT, None)
          if method is None:
              return []
          required = []
          for schema in api_schemas:
              if schema.get(STANDARD_API_NAME_SLOT, "") == method:
                  required = schema.get(STANDARD_REQUIRED_KEY, {})
          print("-".join(required))
          for key in required:
              if key not in goal:
                  print(f"No required key `{key}` in goal `{goal}`")
                  return []
              req_goals[key] = goal[key]
          if len(req_goals) > 0:
              req_goals[
                  STANDARD_API_NAME_SLOT
              ] = method  # for consistency with all.
              result.append(req_goals)
      return result
  
imports: from parlai.core.message import Message
  from parlai.core.metrics import Metric, AverageMetric, normalize_answer, BleuMetric, SumMetric
  from parlai.core.tod.tod_core import STANDARD_API_NAME_SLOT, STANDARD_REQUIRED_KEY, STANDARD_OPTIONAL_KEY, STANDARD_API_SCHEMAS
  from typing import Dict, List, Optional, Tuple
  from parlai.core.tod.world_metrics_handlers import TodMetricsHandler, register_metrics_handler, _ApiCallGoalInteractionHelper, goals_hit_helper
label_desc: Use image node_id 1 for calling a global function with example usage: get_req_only_goals(goals_list, api_schemas) and returns: result, list, list, list