class_docstr: S2Anet head
  Args:
      stacked_convs (int): number of stacked_convs
      feat_in (int): input channels of feat
      feat_out (int): output channels of feat
      num_classes (int): num_classes
      anchor_strides (list): stride of anchors
      anchor_scales (list): scale of anchors
      anchor_ratios (list): ratios of anchors
      target_means (list): target_means
      target_stds (list): target_stds
      align_conv_type (str): align_conv_type ['Conv', 'AlignConv']
      align_conv_size (int): kernel size of align_conv
      use_sigmoid_cls (bool): use sigmoid_cls or not
      reg_loss_weight (list): loss weight for regression
class_docstr_tok: ["S2Anet","head","Args",":","stacked_convs","(","int",")",":","number","of","stacked_convs","feat_in","(","int",")",":","input","channels","of","feat","feat_out","(","int",")",":","output","channels","of","feat","num_classes","(","int",")",":","num_classes","anchor_strides","(","list",")",":","stride","of","anchors","anchor_scales","(","list",")",":","scale","of","anchors","anchor_ratios","(","list",")",":","ratios","of","anchors","target_means","(","list",")",":","target_means","target_stds","(","list",")",":","target_stds","align_conv_type","(","str",")",":","align_conv_type","[","'Conv","'",",","'AlignConv","'","]","align_conv_size","(","int",")",":","kernel","size","of","align_conv","use_sigmoid_cls","(","bool",")",":","use","sigmoid_cls","or","not","reg_loss_weight","(","list",")",":","loss","weight","for","regression"]
code: def get_fam_loss(
      self, fam_target, s2anet_head_out, reg_loss_type="l1"
  ):
      (
          labels,
          label_weights,
          bbox_targets,
          bbox_weights,
          bbox_gt_bboxes,
          pos_inds,
          neg_inds,
      ) = fam_target
      (
          fam_cls_branch_list,
          fam_reg_branch_list,
          odm_cls_branch_list,
          odm_reg_branch_list,
          num_anchors_list,
      ) = s2anet_head_out
  
      fam_cls_losses = []
      fam_bbox_losses = []
      st_idx = 0
      num_total_samples = (
          len(pos_inds) + len(neg_inds)
          if self.sampling
          else len(pos_inds)
      )
      num_total_samples = max(1, num_total_samples)
  
      for idx, feat_anchor_num in enumerate(num_anchors_list):
          # step1:  get data
          feat_labels = labels[st_idx : st_idx + feat_anchor_num]
          feat_label_weights = label_weights[
              st_idx : st_idx + feat_anchor_num
          ]
  
          feat_bbox_targets = bbox_targets[
              st_idx : st_idx + feat_anchor_num, :
          ]
          feat_bbox_weights = bbox_weights[
              st_idx : st_idx + feat_anchor_num, :
          ]
  
          # step2: calc cls loss
          feat_labels = feat_labels.reshape(-1)
          feat_label_weights = feat_label_weights.reshape(-1)
  
          fam_cls_score = fam_cls_branch_list[idx]
          fam_cls_score = paddle.squeeze(fam_cls_score, axis=0)
          fam_cls_score1 = fam_cls_score
  
          feat_labels = paddle.to_tensor(feat_labels)
          feat_labels_one_hot = paddle.nn.functional.one_hot(
              feat_labels, self.cls_out_channels + 1
          )
          feat_labels_one_hot = feat_labels_one_hot[:, 1:]
          feat_labels_one_hot.stop_gradient = True
  
          num_total_samples = paddle.to_tensor(
              num_total_samples, dtype="float32", stop_gradient=True
          )
  
          fam_cls = F.sigmoid_focal_loss(
              fam_cls_score1,
              feat_labels_one_hot,
              normalizer=num_total_samples,
              reduction="none",
          )
  
          feat_label_weights = feat_label_weights.reshape(
              feat_label_weights.shape[0], 1
          )
          feat_label_weights = np.repeat(
              feat_label_weights, self.cls_out_channels, axis=1
          )
          feat_label_weights = paddle.to_tensor(
              feat_label_weights, stop_gradient=True
          )
  
          fam_cls = fam_cls * feat_label_weights
          fam_cls_total = paddle.sum(fam_cls)
          fam_cls_losses.append(fam_cls_total)
  
          # step3: regression loss
          feat_bbox_targets = paddle.to_tensor(
              feat_bbox_targets, dtype="float32", stop_gradient=True
          )
          feat_bbox_targets = paddle.reshape(feat_bbox_targets, [-1, 5])
  
          fam_bbox_pred = fam_reg_branch_list[idx]
          fam_bbox_pred = paddle.squeeze(fam_bbox_pred, axis=0)
          fam_bbox_pred = paddle.reshape(fam_bbox_pred, [-1, 5])
          fam_bbox = self.smooth_l1_loss(
              fam_bbox_pred, feat_bbox_targets
          )
          loss_weight = paddle.to_tensor(
              self.reg_loss_weight, dtype="float32", stop_gradient=True
          )
          fam_bbox = paddle.multiply(fam_bbox, loss_weight)
          feat_bbox_weights = paddle.to_tensor(
              feat_bbox_weights, stop_gradient=True
          )
  
          fam_bbox = fam_bbox * feat_bbox_weights
          fam_bbox_total = paddle.sum(fam_bbox) / num_total_samples
          fam_bbox_losses.append(fam_bbox_total)
          st_idx += feat_anchor_num
  
      fam_cls_loss = paddle.add_n(fam_cls_losses)
      fam_cls_loss_weight = paddle.to_tensor(
          self.cls_loss_weight[0], dtype="float32", stop_gradient=True
      )
      fam_cls_loss = fam_cls_loss * fam_cls_loss_weight
      fam_reg_loss = paddle.add_n(fam_bbox_losses)
      return fam_cls_loss, fam_reg_loss
  
imports: import paddle
  from paddle import ParamAttr
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn.initializer import Normal, Constant
  from ppdet.core.workspace import register
  from ppdet.modeling.proposal_generator.target_layer import RBoxAssigner
  from ppdet.modeling.proposal_generator.anchor_generator import S2ANetAnchorGenerator
  from ppdet.modeling.layers import AlignConv
  from ..cls_utils import _get_class_default_kwargs
  import numpy
label_desc: Use image node_id 7 for calling the S2ANetHead obj's underlying member method code with example usage: obj.get_fam_loss(fam_target, s2anet_head_out, reg_loss_type) and returns: fam_cls_loss,  fam_reg_loss